Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ crossbeam-channel = "0.5.6"
crossterm = "0.29.0"
csv = "1.1.3"
ctrlc = "3.1.5"
datamap = "0.1.0"
env_logger = "0.11.10"
gimli = "0.33.0"
goblin = "0.10"
Expand Down
2 changes: 1 addition & 1 deletion cmd/diagnose/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn diagnose(
}
}

if core.is_dump() {
if core.is_memory_core() {
section("This Is A Core Dump");
println!("You're running this on a dump; that's all we can do.");
println!("Connect to a live system for more output.");
Expand Down
17 changes: 9 additions & 8 deletions cmd/dump/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ use clap::{ArgGroup, Parser};
use humility::core::Core;
use humility::hubris::*;
use humility::log::{Logger, info};
use humility::mem::InMemoryCore;
use humility_arch_arm::ARMRegister;
use humility_cli::{ExecutionContext, humility_cmd};
use humility_dump_agent::{
DumpAgent, DumpAgentCore, DumpAgentExt, DumpArea, DumpBreakdown,
HiffyDumpAgent, UdpDumpAgent, task_areas,
DumpAgent, DumpAgentExt, DumpArea, DumpBreakdown, HiffyDumpAgent,
UdpDumpAgent, task_areas,
};
use humpty::DumpTask;
use indicatif::{HumanBytes, HumanDuration, ProgressBar, ProgressStyle};
Expand Down Expand Up @@ -341,7 +342,7 @@ fn get_dump_agent<'a>(
fn read_dump<'a>(
agent: &mut Box<dyn DumpAgent + 'a>,
area: Option<DumpArea>,
out: &mut DumpAgentCore,
out: &mut humility::mem::InMemoryCore,
subargs: &DumpArgs,
log: &Logger,
) -> Result<Option<DumpTask>> {
Expand Down Expand Up @@ -415,7 +416,7 @@ fn simulate_dump_via_agent(
subargs: &DumpArgs,
log: &Logger,
) -> Result<()> {
let mut out = DumpAgentCore::new(HubrisFlashMap::new(hubris)?);
let mut out = InMemoryCore::from_archive(hubris)?;
let started = Some(Instant::now());
let mut area = subargs.extract.map(DumpArea::ByIndex);

Expand Down Expand Up @@ -537,7 +538,7 @@ fn simulate_dump_via_agent(

ncompressed += compressed;

out.add_ram_region(addr, compare);
out.add_ram_region(addr, compare)?;

remain -= nbytes;
nread += nbytes;
Expand Down Expand Up @@ -650,7 +651,7 @@ fn extract_or_read_via_agent(
subargs: &DumpArgs,
log: &Logger,
) -> Result<()> {
let mut out = DumpAgentCore::new(HubrisFlashMap::new(hubris)?);
let mut out = InMemoryCore::from_archive(hubris)?;
let started = Some(Instant::now());

let mut agent = get_dump_agent(hubris, core, subargs, log)?;
Expand Down Expand Up @@ -726,7 +727,7 @@ fn dump_task_via_agent(
subargs: &DumpArgs,
log: &Logger,
) -> Result<()> {
let mut out = DumpAgentCore::new(HubrisFlashMap::new(hubris)?);
let mut out = InMemoryCore::from_archive(hubris)?;
let started = Some(Instant::now());

let mut agent = get_dump_agent(hubris, core, subargs, log)?;
Expand Down Expand Up @@ -835,7 +836,7 @@ fn dump_all(
.unwrap();
info!(log, "dumping {task_name} (area {area})");

let mut out = DumpAgentCore::new(HubrisFlashMap::new(hubris)?);
let mut out = InMemoryCore::from_archive(hubris)?;
let started = Some(Instant::now());
let task = read_dump(
&mut agent,
Expand Down
64 changes: 5 additions & 59 deletions cmd/hydrate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
use anyhow::{Context, Result, bail};
use clap::{ArgGroup, Parser};
use humility::{
hubris::HubrisFlashMap,
log::{info, warn},
mem::InMemoryCore,
};
use humility_arch_arm::ARMRegister;
use humility_cli::{ExecutionContext, humility_cmd};
use std::{collections::BTreeMap, io::Read, path::PathBuf};

Expand All @@ -41,62 +40,6 @@ pub struct HydrateArgs {
file: PathBuf,
}

struct DryCore {
flash: HubrisFlashMap,
mem: BTreeMap<u32, Vec<u8>>,
}

// Helper macro to stub out functions
macro_rules! unsupported{
($fn_name:ident($($arg_name:ident: $arg_type:ty),*)) => {
unsupported!($fn_name($($arg_name: $arg_type),*) -> Result<()>);
};
($fn_name:ident($($arg_name:ident: $arg_type:ty),*) -> $out:ty) => {
fn $fn_name(&mut self, $($arg_name: $arg_type),*) -> $out {
bail!(concat!(
"DryCore does not support ",
stringify!($fn_name)))
}
};
}

impl humility::core::Core for DryCore {
unsupported!(run());
unsupported!(halt());
unsupported!(write_8(_addr: u32, _data: &[u8]));
unsupported!(op_done());
unsupported!(op_start());
unsupported!(read_reg(_reg: ARMRegister) -> Result<u32>);
unsupported!(write_word_32(_addr: u32, _data: u32));

fn is_archive(&self) -> bool {
false
}
fn is_dump(&self) -> bool {
true // I guess?
}
fn is_net(&self) -> bool {
false
}

fn read_8(&mut self, addr: u32, data: &mut [u8]) -> Result<()> {
if self.flash.read(addr, data).is_some() {
return Ok(());
}

let Some((base, mem)) = self.mem.range(0..=addr).next_back() else {
bail!("addr {addr:#08x} is below memory range");
};
let offset = (addr - base) as usize;
let end = offset + data.len();
if end > mem.len() {
bail!("region is not large enough; {end:#x} > {:#x}", mem.len());
}
data.copy_from_slice(&mem[offset..end]);
Ok(())
}
}

fn run(subargs: HydrateArgs, context: &mut ExecutionContext) -> Result<()> {
let f = std::fs::File::open(&subargs.file)?;
let mut z = zip::ZipArchive::new(f)?;
Expand Down Expand Up @@ -173,7 +116,10 @@ fn run(subargs: HydrateArgs, context: &mut ExecutionContext) -> Result<()> {
dump ID wants {archive_id:02x?}"
);
}
let mut core = DryCore { mem, flash: HubrisFlashMap::new(archive)? };
let mut core = InMemoryCore::from_archive(archive)?;
for (addr, data) in mem {
core.add_ram_region(addr, data)?;
}

let t = Some(humpty::DumpTask {
magic: humpty::DUMP_TASK_MAGIC,
Expand Down
4 changes: 2 additions & 2 deletions cmd/registers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fn registers(
let core = &mut *context.cli.attach_live_or_dump(hubris.as_ref(), None)?;
let mut regs = BTreeMap::new();

if subargs.fp && !core.is_dump() {
if subargs.fp && !core.is_memory_core() {
let mvfr = MVFR0::read(core)?;

if mvfr.simd_registers() != 1 {
Expand Down Expand Up @@ -346,7 +346,7 @@ fn registers(
// kernel stacks; in classic Humility fashion, phrase
// our hunch in the form of a question.
//
if core.is_dump() && task == HubrisTask::Kernel {
if core.is_memory_core() && task == HubrisTask::Kernel {
info!(
log,
"kernel stack missing; \
Expand Down
4 changes: 2 additions & 2 deletions cmd/sensors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ fn sensors(subargs: SensorsArgs, context: &mut ExecutionContext) -> Result<()> {
let core = &mut *context.cli.attach_live_or_dump_booted(hubris)?;
let mut reader: Box<dyn SensorReader> = match subargs.backend {
Some(Backend::Hiffy) => {
if core.is_dump() {
if core.is_memory_core() {
bail!("cannot use hiffy backend on dump");
}
let context = HiffyContext::new(hubris, core, timeout, log)?;
Expand All @@ -634,7 +634,7 @@ fn sensors(subargs: SensorsArgs, context: &mut ExecutionContext) -> Result<()> {
Some(Backend::Readmem) => {
Box::new(RamSensorReader::new(hubris, &sensors)?)
}
None if core.is_dump() => {
None if core.is_memory_core() => {
Box::new(RamSensorReader::new(hubris, &sensors)?)
}
None => match HiffyContext::new(hubris, core, timeout, log) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/spd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ fn spd(subargs: SpdArgs, context: &mut ExecutionContext) -> Result<()> {
}

Ok(())
} else if core.is_dump() {
} else if core.is_memory_core() {
bail!("cannot specify bus/controller on a dump");
} else {
// At this point, the user wants to poll DDR SPDs directly over I2C. We
Expand Down
2 changes: 1 addition & 1 deletion humility-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fn main() -> std::process::ExitCode {
} else if let Ok(e) = env::var("HUMILITY_TARGET") {
cli.target = Some(e);
} else if let Ok(e) = env::var("HUMILITY_DUMP") {
cli.dump = Some(e);
cli.dump = Some(std::path::PathBuf::from(e));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4536 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4536 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
humility counters failed: no IPC counters found
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4536 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4536 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
humility counters failed: no IPC counters found
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4536 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4536 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
humility counters failed: no IPC counters found
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4704 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4704 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
humility counters failed: no IPC counters found
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4704 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4704 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4536 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4536 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4536 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4536 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
humility counters failed: no IPC counters found
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4536 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4536 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
humility counters failed: no IPC counters found
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4704 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4704 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4704 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4704 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4536 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4536 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4536 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4536 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
humility counters failed: no IPC counters found
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4536 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4536 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
humility counters failed: no IPC counters found
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4704 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4704 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
humility: attached to dump
humility: WARNING: failed to load task table: read of 4704 bytes from invalid address: 0x24000490
humility: WARNING: failed to load task table: read of 4704 bytes failed: could not find addr 0x24000490 in memory
humility: WARNING: no generations/restart counts will be displayed.
humility: note: this may be a single-task dump.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
humility: attached to dump
humility host failed: read of 24964 bytes from invalid address: 0x24021ff4
humility host failed: read of 24964 bytes failed: could not find addr 0x24021ff4 in memory
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
humility: attached to dump
humility host failed: read of 4096 bytes from invalid address: 0x2402510d
humility host failed: read of 4096 bytes failed: could not find addr 0x2402510d in memory
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
humility: attached to dump
humility host failed: read of 4096 bytes from invalid address: 0x2401d10d
humility host failed: read of 4096 bytes failed: could not find addr 0x2401d10d in memory
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
humility: attached to dump
humility host failed: read of 4096 bytes from invalid address: 0x24025b99
humility host failed: read of 4096 bytes failed: could not find addr 0x24025b99 in memory
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
humility: attached to dump
humility host failed: read of 24964 bytes from invalid address: 0x24021c1c
humility host failed: read of 24964 bytes failed: could not find addr 0x24021c1c in memory
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
humility: attached to dump
humility spd failed: read of 8264 bytes from invalid address: 0x24004380
humility spd failed: read of 8264 bytes failed: could not find addr 0x24004380 in memory
2 changes: 1 addition & 1 deletion humility-bin/tests/cmd/spd/spd.extern-regions.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
humility: attached to dump
humility spd failed: read of 8192 bytes from invalid address: 0x24004380
humility spd failed: read of 8192 bytes failed: could not find addr 0x24004380 in memory
2 changes: 1 addition & 1 deletion humility-bin/tests/cmd/spd/spd.task.net.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
humility: attached to dump
humility spd failed: read of 8192 bytes from invalid address: 0x24004798
humility spd failed: read of 8192 bytes failed: could not find addr 0x24004798 in memory
2 changes: 1 addition & 1 deletion humility-bin/tests/cmd/spd/spd.task.power.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
humility: attached to dump
humility spd failed: read of 8192 bytes from invalid address: 0x24004380
humility spd failed: read of 8192 bytes failed: could not find addr 0x24004380 in memory
2 changes: 1 addition & 1 deletion humility-bin/tests/cmd/spd/spd.u16-ringbuf.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
humility: attached to dump
humility spd failed: read of 8264 bytes from invalid address: 0x24004380
humility spd failed: read of 8264 bytes failed: could not find addr 0x24004380 in memory
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
system time = 6193
ID TASK GEN PRI STATE
19 control_plane_agent 1 6 FAULT: stack overflow; sp=0x2402ff90 (was: ready)
could not read registers: read of 32 bytes from invalid address: 0x2402ff90
could not read registers: read of 32 bytes failed: could not find addr 0x2402ff90 in memory
guessing at stack trace using saved frame pointer
|
+---> 0x24030090 0x08027790 drv_lpc55_update_api::_::<impl serde::de::Deserialize for drv_lpc55_update_api::RotBootInfo>::deserialize
Expand Down
Loading
Loading