Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions src/executor/wall_time/perf/debug_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ impl ModuleDebugInfoExt for ModuleDebugInfo {
let ctx = if object.section_by_name(".debug_info").is_some() {
Self::create_dwarf_context(&object).context("Failed to create DWARF context")?
} else {
let debug_path = find_debug_file(&object, path.as_ref()).with_context(|| {
format!(
let Some(debug_path) = find_debug_file(&object, path.as_ref()) else {
warn_missing_libc_debug_info(path.as_ref());
anyhow::bail!(
"No DWARF in {:?} and no separate debug file found",
path.as_ref()
)
})?;
);
};
Comment thread
not-matthias marked this conversation as resolved.
trace!(
"Using separate debug file {debug_path:?} for {:?}",
path.as_ref()
Expand Down Expand Up @@ -129,6 +130,25 @@ impl ModuleDebugInfoExt for ModuleDebugInfo {
}
}

fn is_libc_filename(file_name: &str) -> bool {
file_name.starts_with("libc.so") || file_name.starts_with("libc-")
}

fn warn_missing_libc_debug_info(path: &Path) {
let Some(file_name) = path.file_name().and_then(|n| n.to_str()) else {
return;
};
if !is_libc_filename(file_name) {
return;
}

warn!(
"Debug info for {} not found. Install libc6-dbg (Debian/Ubuntu) or \
glibc-debuginfo (Fedora/RHEL) to fix missing symbols in the flamegraph",
path.display()
);
}

/// Compute debug info once per unique ELF path from deduplicated symbols.
/// Returns a map of path -> ModuleDebugInfo with `load_bias: 0` (load bias is per-pid).
pub fn debug_info_by_path(
Expand Down Expand Up @@ -260,6 +280,16 @@ mod tests {
);
}

#[rstest::rstest]
#[case::libc_so_6("libc.so.6", true)]
#[case::libc_so("libc.so", true)]
#[case::libc_versioned("libc-2.31.so", true)]
#[case::libm("libm.so.6", false)]
#[case::random("my_binary", false)]
fn test_is_libc_filename(#[case] name: &str, #[case] expected: bool) {
assert_eq!(super::is_libc_filename(name), expected);
}

#[test]
fn test_ruff_debug_info() {
const MODULE_PATH: &str = "testdata/perf_map/ty_walltime";
Expand Down
Loading