Skip to content

Commit

Permalink
cli: Add support for symbolizing kernel addresses
Browse files Browse the repository at this point in the history
Add support for symbolization of kernel addresses to the program. Right
now we do not expose any additional options and just rely on the
"default" kernel symbolization source.

  $ cargo run -p blazecli -- symbolize kernel 0x0000000000019008 0xffffffffc005e378
  > 0x00000000019008: espfix_stack @ 0x19008+0x0
  > 0xffffffffc005e378: bpf_prog_6deef7357e7b4530_sd_fw_ingress @ 0xffffffffc005e2dc+0x9c

Signed-off-by: Daniel Müller <[email protected]>
  • Loading branch information
d-e-s-o authored and danielocfb committed Oct 17, 2024
1 parent 32bd801 commit f03c5f4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Unreleased
----------
- Added support for symbolization of kernel addresses


0.1.6
-----
- Added `--procmap-query` option to `normalize user` sub-command
Expand Down
8 changes: 8 additions & 0 deletions cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ pub mod symbolize {
Elf(Elf),
Gsym(Gsym),
Process(Process),
Kernel(Kernel),
}

#[derive(Debug, Arguments)]
Expand Down Expand Up @@ -246,4 +247,11 @@ pub mod symbolize {
#[clap(long)]
pub no_map_files: bool,
}

#[derive(Debug, Arguments)]
pub struct Kernel {
/// The addresses to symbolize.
#[arg(value_parser = parse_addr)]
pub addrs: Vec<Addr>,
}
}
7 changes: 7 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ fn symbolize(symbolize: args::symbolize::Symbolize) -> Result<()> {
let input = symbolize::Input::AbsAddr(addrs);
(src, input, addrs)
}
args::symbolize::Symbolize::Kernel(args::symbolize::Kernel { ref addrs }) => {
let kernel = symbolize::Kernel::default();
let src = symbolize::Source::from(kernel);
let addrs = addrs.as_slice();
let input = symbolize::Input::AbsAddr(addrs);
(src, input, addrs)
}
};

let symbolizer = builder.build();
Expand Down

0 comments on commit f03c5f4

Please sign in to comment.