Log error instead of panicking when defmt erroneously enabled.
If defmt output is enabled in the `cargo embed` config, but the binary
being debugged doesn't use defmt, then `cargo embed` panic()ed on unwrap
without printing any useful error message to the user.  Log this at
error level instead.
@@ -489,10 +489,8 @@ fn main_try() -> Result<()> {
.any(|elem| elem.format == DataFormat::Defmt);
let defmt_state = if defmt_enable {
let elf = fs::read(path).unwrap();
- let table = defmt_decoder::Table::parse(&elf)?;
-
+ if let Some(table) = defmt_decoder::Table::parse(&elf)? {
let locs = {
- let table = table.as_ref().unwrap();
let locs = table.get_locations(&elf)?;
if !table.is_empty() && locs.is_empty() {
@@ -501,11 +499,17 @@ fn main_try() -> Result<()> {
} else if table.indices().all(|idx| locs.contains_key(&(idx as u64))) {
Some(locs)
} else {
- log::warn!("Location info is incomplete; it will be omitted from the output.");
+ log::warn!(
+ "Location info is incomplete; it will be omitted from the output."
+ );
None
}
};
- Some((table.unwrap(), locs))
+ Some((table, locs))
+ } else {
+ log::error!("Defmt enabled in rtt channel config, but defmt table couldn't be loaded from binary.");
+ None
+ }
} else {
None
};
