Skip to content

Commit e8cfad8

Browse files
committed
feat: warn when libc debug info is not found
When a stripped libc is loaded without a matching debug file (no .debug_info section and no match via build-id or .gnu_debuglink), emit a warning pointing users at libc6-dbg / glibc-debuginfo so they know why libc frames show as unknown symbols. Refs COD-2536
1 parent 9b26b2b commit e8cfad8

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

src/executor/wall_time/perf/debug_info.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ impl ModuleDebugInfoExt for ModuleDebugInfo {
6060
let ctx = if object.section_by_name(".debug_info").is_some() {
6161
Self::create_dwarf_context(&object).context("Failed to create DWARF context")?
6262
} else {
63-
let debug_path = find_debug_file(&object, path.as_ref()).with_context(|| {
64-
format!(
63+
let Some(debug_path) = find_debug_file(&object, path.as_ref()) else {
64+
warn_missing_external_debug_info(path.as_ref());
65+
anyhow::bail!(
6566
"No DWARF in {:?} and no separate debug file found",
6667
path.as_ref()
67-
)
68-
})?;
68+
);
69+
};
6970
trace!(
7071
"Using separate debug file {debug_path:?} for {:?}",
7172
path.as_ref()
@@ -129,6 +130,23 @@ impl ModuleDebugInfoExt for ModuleDebugInfo {
129130
}
130131
}
131132

133+
fn warn_missing_external_debug_info(path: &Path) -> Option<()> {
134+
let file_name = path.file_name()?.to_str()?;
135+
if !file_name.ends_with(".so") {
136+
return None;
137+
}
138+
139+
if file_name.starts_with("libc.so") || file_name.starts_with("libc-") {
140+
warn!(
141+
"Debug info for {} not found. Install libc6-dbg (Debian/Ubuntu) or \
142+
glibc-debuginfo (Fedora/RHEL) to avoid fix missing symbols in the flamegraph",
143+
path.display()
144+
);
145+
}
146+
147+
Some(())
148+
}
149+
132150
/// Compute debug info once per unique ELF path from deduplicated symbols.
133151
/// Returns a map of path -> ModuleDebugInfo with `load_bias: 0` (load bias is per-pid).
134152
pub fn debug_info_by_path(

0 commit comments

Comments
 (0)