mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Prettify the output furter
This commit is contained in:
parent
726b400463
commit
fb9159d2cf
|
@ -36,21 +36,27 @@ fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
let ctx = addr2line::Context::new(&object)?;
|
let ctx = addr2line::Context::new(&object)?;
|
||||||
|
|
||||||
for address in cli.dump.split('-') {
|
for (i, address) in cli.dump.split('-').enumerate() {
|
||||||
let mut address = u64::from_str_radix(address, 16)?;
|
let mut address = u64::from_str_radix(address, 16)?;
|
||||||
if address <= 0xFFFF {
|
if address <= 0xFFFF {
|
||||||
address += 0x0800_0000;
|
address += 0x0800_0000;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_address(&ctx, address)?;
|
print_address(&ctx, i, address)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_address(ctx: &addr2line::Context<impl gimli::Reader>, address: u64) -> anyhow::Result<()> {
|
fn print_address(
|
||||||
|
ctx: &addr2line::Context<impl gimli::Reader>,
|
||||||
|
index: usize,
|
||||||
|
address: u64,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
let mut frames = ctx.find_frames(address).skip_all_loads()?;
|
let mut frames = ctx.find_frames(address).skip_all_loads()?;
|
||||||
|
|
||||||
|
let mut is_first = true;
|
||||||
|
|
||||||
while let Some(frame) = frames.next()? {
|
while let Some(frame) = frames.next()? {
|
||||||
let function_name = if let Some(func) = frame.function {
|
let function_name = if let Some(func) = frame.function {
|
||||||
func.demangle()?.into_owned()
|
func.demangle()?.into_owned()
|
||||||
|
@ -66,12 +72,19 @@ fn print_address(ctx: &addr2line::Context<impl gimli::Reader>, address: u64) ->
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
if is_first {
|
||||||
|
println!("{index}:\t{}", function_name.bold());
|
||||||
|
} else {
|
||||||
|
println!("\t(inlined by) {function_name}");
|
||||||
|
}
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"{}\n\t{}:{}",
|
"\t{}:{}",
|
||||||
function_name.white(),
|
|
||||||
location.filename.green(),
|
location.filename.green(),
|
||||||
location.line.to_string().green()
|
location.line.to_string().green()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
is_first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue