Skip to content

Commit

Permalink
Fix crashlog-symbolizer register decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
boozook committed Jun 25, 2024
1 parent db971fa commit ffdb995
Show file tree
Hide file tree
Showing 6 changed files with 1,201 additions and 50 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion support/addr2line/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-symbolize"
version = "0.1.3"
version = "0.2.0"
readme = "README.md"
description = "Tools for symbolise addresses from bin (pdex.elf) and Playdate's trace or crashlog."
keywords = ["playdate", "bin", "elf", "addr2line", "utility"]
Expand Down Expand Up @@ -36,6 +36,7 @@ symbolic = { version = "12.8", features = ["demangle"] }

regex.workspace = true
const-str = { version = "0.5", default-features = false, optional = true }
paste = "1.0"

tokio = { workspace = true, features = ["full", "rt-multi-thread"] }
async-stream = "0.3"
Expand Down
56 changes: 19 additions & 37 deletions support/addr2line/src/addr2line-crashlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ use futures_util::StreamExt;
use futures_util::TryStreamExt;

use pd::elf::map_result_fallback_os;
use pd::fmt::crashlog::CrashLog;
use pd::fmt::report::WriteReport as _;
use pd::*;


const ADDR_REG: &[&str] = &["lr", "pc", "mmfar", "bfar", "r0", "r1", "r2", "r3", "r12"];


#[tokio::main]
async fn main() -> anyhow::Result<()> {
let cfg = cli_ext::parse();
Expand All @@ -31,11 +32,11 @@ async fn main() -> anyhow::Result<()> {
let docs: Vec<_> = {
let addrs = &mut addrs;
stream.map(move |doc| -> Result<_, anyhow::Error> {
let count = doc.ptrs
.values()
.filter(|v| addrs.insert(**v))
.map_while(|v| tx.send(*v).map_err(|err| error!("{err}")).ok())
.count();
let count = ADDR_REG.into_iter()
.flat_map(|v| doc.ptrs.get(*v))
.filter(|v| addrs.insert(**v))
.map_while(|v| tx.send(*v).map_err(|err| error!("{err}")).ok())
.count();
let date = doc.date.as_deref().unwrap_or("n/a");
debug!("sent to resolve {count} addrs for doc by {date}");
Ok(doc)
Expand Down Expand Up @@ -65,36 +66,17 @@ async fn main() -> anyhow::Result<()> {

os_db.close().await?;

let docs: Vec<_> = docs.into_iter()
.map(|doc| {
let CrashLog { date,
build,
heap,
ptrs, } = doc;
let ptrs = ptrs.into_iter()
.map(|(k, v)| {
match resolved_addrs.get(&v) {
Some(rep) => (k, rep),
None => unreachable!("Key not found: {v:#08x?}"),
}
})
.collect();
CrashLog { date,
build,
heap,
ptrs }
})
.collect();

for doc in docs {
doc.default_print(
std::io::stdout(),
true,
0,
cfg.base.flags.functions,
cfg.base.flags.basenames,
cfg.base.flags.ranges,
cfg.base.flags.demangle,

for doc in &docs {
doc.pretty_print(
std::io::stdout(),
&resolved_addrs,
true,
0,
cfg.base.flags.functions,
cfg.base.flags.basenames,
cfg.base.flags.ranges,
cfg.base.flags.demangle,
)?;
}

Expand Down
Loading

0 comments on commit ffdb995

Please sign in to comment.