Skip to content

Commit

Permalink
Update defmt_decoder (#2167)
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani authored and t-moe committed Feb 20, 2024
1 parent 9d10d33 commit 7a7bb10
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion probe-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ cargo_toml = { version = "0.17.2", optional = true }
clap = { version = "4.4", features = ["derive"], optional = true }
colored = { version = "2.1.0", optional = true }
crossterm = { version = "<= 0.27.0", optional = true }
defmt-decoder = { version = "0.3.9", features = ["unstable"], optional = true }
defmt-decoder = { version = "=0.3.10", features = ["unstable"], optional = true } # pinned because "unstable" has potential for breaking changes
directories = { version = "5", optional = true }
dunce = { version = "1.0.4" }
figment = { version = "0.10", features = [
Expand Down
15 changes: 10 additions & 5 deletions probe-rs/src/bin/probe-rs/util/rtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ impl RttActiveChannel {
None,
)
};
let s =
formatter.format_to_string(frame, file.as_deref(), line, module);
let s = formatter.format_frame(frame, file.as_deref(), line, module);
writeln!(formatted_data, "{s}").expect("Writing to String cannot fail");
continue;
}
Expand Down Expand Up @@ -383,11 +382,16 @@ pub struct RttActiveTarget {
pub defmt_state: Option<DefmtState>,
}

#[derive(Debug)]
pub struct DefmtState {
table: defmt_decoder::Table,
locs: Option<defmt_decoder::Locations>,
formatter: defmt_decoder::log::Formatter,
formatter: defmt_decoder::log::format::Formatter,
}

impl fmt::Debug for DefmtState {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DefmtState").finish()
}
}

impl RttActiveTarget {
Expand Down Expand Up @@ -471,7 +475,8 @@ impl RttActiveTarget {
(false, true) => "{t} {L} {s}",
(false, false) => "{L} {s}",
});
let formatter = defmt_decoder::log::Formatter::new(format);
let format = defmt_decoder::log::format::FormatterConfig::custom(format);
let formatter = defmt_decoder::log::format::Formatter::new(format);

let locs = {
let locs = table.get_locations(&elf)?;
Expand Down

0 comments on commit 7a7bb10

Please sign in to comment.