Skip to content

Commit 4fec70b

Browse files
committed
feat: warn when libc debug info is not found
When libc-dbg is not installed, libc frames in perf flamegraphs appear as bare hex addresses, making comparisons unusable. This adds a warning during walltime profile processing when libc is loaded but has no DWARF debug info, suggesting users install libc6-dbg.
1 parent 218b80c commit 4fec70b

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/executor/wall_time/perf/save_artifacts.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,36 @@ fn save_symbols(
124124
mappings_by_pid
125125
}
126126

127+
fn is_libc_path(path: &Path) -> bool {
128+
let Some(filename) = path.file_name().and_then(|n| n.to_str()) else {
129+
return false;
130+
};
131+
// Match libc.so.6, libc-2.31.so, etc. but not unrelated libs like libc-client.so
132+
filename.starts_with("libc.so")
133+
|| (filename.starts_with("libc-")
134+
&& filename.as_bytes().get(5).is_some_and(u8::is_ascii_digit))
135+
}
136+
137+
fn warn_missing_libc_debug_info(
138+
loaded_modules_by_path: &HashMap<PathBuf, LoadedModule>,
139+
debug_info_by_elf_path: &HashMap<PathBuf, ModuleDebugInfo>,
140+
) {
141+
for (path, loaded_module) in loaded_modules_by_path {
142+
if !is_libc_path(path) || loaded_module.module_symbols.is_none() {
143+
continue;
144+
}
145+
if debug_info_by_elf_path.contains_key(path) {
146+
continue;
147+
}
148+
warn!(
149+
"libc debug info not found for {}. Flamegraphs may contain \
150+
unsymbolicated libc frames. Install debug symbols \
151+
(e.g., `apt install libc6-dbg`) to fix this.",
152+
path.display()
153+
);
154+
}
155+
}
156+
127157
/// Compute debug info from symbols and build per-pid debug info mappings.
128158
fn save_debug_info(
129159
loaded_modules_by_path: &HashMap<PathBuf, LoadedModule>,
@@ -136,6 +166,8 @@ fn save_debug_info(
136166

137167
let debug_info_by_elf_path = debug_info_by_path(loaded_modules_by_path);
138168

169+
warn_missing_libc_debug_info(loaded_modules_by_path, &debug_info_by_elf_path);
170+
139171
for path in debug_info_by_elf_path.keys() {
140172
get_or_insert_key(path_to_key, path);
141173
}

0 commit comments

Comments
 (0)