Skip to content

Commit

Permalink
Add end-to-end test for Gsym inlined function symbolization
Browse files Browse the repository at this point in the history
Now that all the pieces came together and we are able to report inlined
functions, this change adds a test checking that inlined function
symbolization works as expected for the Gsym file source.

Signed-off-by: Daniel Müller <[email protected]>
  • Loading branch information
d-e-s-o committed Sep 19, 2023
1 parent 6d654da commit 0c95099
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/blazesym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,49 @@ fn symbolize_elf_dwarf_gsym() {
test(src, true);
}

/// Make sure that we report (enabled) or don't report (disabled) inlined
/// functions with a Gsym source.
#[test]
fn symbolize_gsym_inlined() {
fn test(src: symbolize::Source, inlined_fns: bool) {
let symbolizer = Symbolizer::builder()
.enable_inlined_fns(inlined_fns)
.build();
let results = symbolizer
.symbolize(&src, &[0x200020a])
.unwrap()
.into_iter()
.collect::<Vec<_>>();
assert_eq!(results.len(), 1);

let (result, _addr_idx) = &results[0];
if inlined_fns {
assert_eq!(result.inlined.len(), 2);

let name = &result.inlined[0].name;
assert_eq!(*name, "factorial_inline_wrapper");
let frame = result.inlined[0].code_info.as_ref().unwrap();
assert_eq!(frame.file, "test-stable-addresses.c");
assert_eq!(frame.line, Some(32));

let name = &result.inlined[1].name;
assert_eq!(*name, "factorial_2nd_layer_inline_wrapper");
let frame = result.inlined[1].code_info.as_ref().unwrap();
assert_eq!(frame.file, "test-stable-addresses.c");
assert_eq!(frame.line, Some(26));
} else {
assert_eq!(result.inlined, Vec::new());
}
}

let path = Path::new(&env!("CARGO_MANIFEST_DIR"))
.join("data")
.join("test-stable-addresses.gsym");
let src = symbolize::Source::from(symbolize::GsymFile::new(path));
test(src.clone(), true);
test(src, false);
}

/// Check that we can symbolize the `abort_creds` function inside a
/// kernel image properly. Inside of
/// vmlinux-5.17.12-100.fc34.x86_64.dwarf, this function's address range
Expand Down

0 comments on commit 0c95099

Please sign in to comment.