Skip to content

Commit

Permalink
deps: update blazesym submodule to v0.2.0-alpha.5
Browse files Browse the repository at this point in the history
Update the blazesym submodule to version 0.2.0-alpha.5. Also change the
dependency to using the default features, which includes DWARF support
and transparent symbol demangling.
The profile example is overhauled to use the changed APIs and improve
the code to be less redundant.

Signed-off-by: Daniel Müller <[email protected]>
  • Loading branch information
d-e-s-o committed Aug 10, 2023
1 parent d3fcabb commit c174771
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 51 deletions.
2 changes: 1 addition & 1 deletion blazesym
Submodule blazesym updated 72 files
+1 −1 .cargo/config
+9 −0 .cargo/runner.sh
+26 −0 .github/workflows/build.yml
+49 −8 .github/workflows/test.yml
+48 −0 CHANGELOG.md
+40 −18 Cargo.toml
+19 −6 README.md
+27 −4 benches/inspect.rs
+18 −2 benches/main.rs
+4 −4 benches/normalize.rs
+64 −18 benches/symbolize.rs
+127 −54 build.rs
+1 −0 cli/.cargo
+24 −0 cli/Cargo.toml
+60 −0 cli/README.md
+18 −0 cli/build.rs
+86 −0 cli/src/args.rs
+101 −0 cli/src/main.rs
+33 −0 cli/var/shell-complete.rs
+9 −0 codecov.yml
+ data/dwarf-example
+1 −1 data/test-stable-addresses.c
+38 −14 examples/addr2ln.rs
+37 −19 examples/addr2ln_pid.rs
+84 −0 examples/backtrace.rs
+133 −33 include/blazesym.h
+29 −3 src/c_api/inspect.rs
+228 −43 src/c_api/normalize.rs
+201 −36 src/c_api/symbolize.rs
+0 −64 src/dwarf/constants.rs
+0 −896 src/dwarf/debug_info.rs
+318 −0 src/dwarf/function.rs
+54 −0 src/dwarf/lazy.rs
+163 −0 src/dwarf/lines.rs
+159 −0 src/dwarf/location.rs
+8 −5 src/dwarf/mod.rs
+0 −1,100 src/dwarf/parser.rs
+89 −0 src/dwarf/range.rs
+31 −0 src/dwarf/reader.rs
+179 −151 src/dwarf/resolver.rs
+161 −0 src/dwarf/unit.rs
+491 −0 src/dwarf/units.rs
+24 −24 src/elf/cache.rs
+2 −0 src/elf/mod.rs
+236 −168 src/elf/parser.rs
+47 −27 src/elf/resolver.rs
+9 −0 src/elf/types.rs
+680 −0 src/error.rs
+29 −3 src/gsym/linetab.rs
+35 −73 src/gsym/parser.rs
+174 −102 src/gsym/resolver.rs
+4 −7 src/gsym/types.rs
+13 −4 src/inspect/inspector.rs
+1 −0 src/inspect/mod.rs
+19 −35 src/kernel.rs
+56 −34 src/ksym.rs
+31 −9 src/lib.rs
+81 −18 src/maps.rs
+17 −7 src/mmap.rs
+214 −0 src/normalize/buildid.rs
+105 −9 src/normalize/meta.rs
+24 −8 src/normalize/mod.rs
+115 −413 src/normalize/normalizer.rs
+492 −0 src/normalize/user.rs
+28 −6 src/resolver.rs
+62 −33 src/symbolize/mod.rs
+114 −17 src/symbolize/source.rs
+286 −84 src/symbolize/symbolizer.rs
+93 −106 src/util.rs
+58 −39 src/zip.rs
+194 −27 tests/blazesym.rs
+96 −64 tests/c_api.rs
75 changes: 73 additions & 2 deletions examples/rust/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 examples/rust/profile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "GPL-2.0 OR BSD-3-Clause"
edition = "2021"

[dependencies]
blazesym = { path = "../../../blazesym", default-features = false, features = ["dont-generate-test-files"] }
blazesym = { path = "../../../blazesym" }
clap = { version = "4.0", features = ["derive"] }
libbpf-rs = "0.19"
libc = "*"
Expand Down
78 changes: 31 additions & 47 deletions examples/rust/profile/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::u64;

use std::boxed::Box;
use std::io::Error;
use std::mem;
use std::result::Result;
use std::path::PathBuf;
use std::time::Duration;

use blazesym::symbolize;
Expand Down Expand Up @@ -97,49 +94,36 @@ fn show_stack_trace(stack: &[u64], symbolizer: &symbolize::Symbolizer, pid: u32)
},
};

for i in 0..stack.len() {
if syms.len() <= i || syms[i].len() == 0 {
println!(" {} [<{:016x}>]", i, stack[i]);
continue;
}

if syms[i].len() == 1 {
let sym = &syms[i][0];
if !sym.path.as_os_str().is_empty() {
println!(
" {} [<{:016x}>] {}+0x{:x} {}:{}",
i,
stack[i],
sym.symbol,
stack[i] - sym.addr,
sym.path.display(),
sym.line
);
} else {
println!(
" {} [<{:016x}>] {}+0x{}",
i,
stack[i],
sym.symbol,
stack[i] - sym.addr
);
}
continue;
}

println!(" {} [<{:016x}>]", i, stack[i]);

for sym in &syms[i] {
if !sym.path.as_os_str().is_empty() {
println!(
" {}+0x{:x} {}:{}",
sym.symbol,
stack[i] - sym.addr,
sym.path.display(),
sym.line
);
} else {
println!(" {}+0x{}", sym.symbol, stack[i] - sym.addr);
for (i, (addr, syms)) in stack.iter().zip(syms).enumerate() {
let mut addr_fmt = format!(" {i:2} [<{addr:016x}>]");
if syms.is_empty() {
println!("{addr_fmt}")
} else {
for (i, sym) in syms.into_iter().enumerate() {
if i == 1 {
addr_fmt = addr_fmt.replace(|_c| true, " ");
}

let symbolize::Sym {
name, addr, offset, ..
} = sym;

let path = match (sym.dir, sym.file) {
(Some(dir), Some(file)) => Some(dir.join(file)),
(dir, file) => dir.or_else(|| file.map(PathBuf::from)),
};

let src_loc = if let (Some(path), Some(line)) = (path, sym.line) {
if let Some(col) = sym.column {
format!(" {}:{line}:{col}", path.display())
} else {
format!(" {}:{line}", path.display())
}
} else {
String::new()
};

println!("{addr_fmt} {name} @ {addr:#x}+{offset:#x}{src_loc}");
}
}
}
Expand Down

0 comments on commit c174771

Please sign in to comment.