-
Notifications
You must be signed in to change notification settings - Fork 17
feat: warn when libc debug info is not found #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -124,6 +124,36 @@ fn save_symbols( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mappings_by_pid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn is_libc_path(path: &Path) -> bool { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let Some(filename) = path.file_name().and_then(|n| n.to_str()) else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Match libc.so.6, libc-2.31.so, etc. but not unrelated libs like libc-client.so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filename.starts_with("libc.so") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| || (filename.starts_with("libc-") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| && filename.as_bytes().get(5).is_some_and(u8::is_ascii_digit)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[cfg(test)] | |
| mod tests { | |
| use super::is_libc_path; | |
| use std::path::Path; | |
| #[test] | |
| fn is_libc_path_accepts_expected_libc_filenames() { | |
| let cases = [ | |
| "/lib/x86_64-linux-gnu/libc.so", | |
| "/lib/x86_64-linux-gnu/libc.so.6", | |
| "/usr/lib/libc-2.31.so", | |
| "libc-2.so", | |
| ]; | |
| for case in cases { | |
| assert!(is_libc_path(Path::new(case)), "expected match for {case}"); | |
| } | |
| } | |
| #[test] | |
| fn is_libc_path_rejects_non_libc_filenames() { | |
| let cases = [ | |
| "/usr/lib/libc-client.so", | |
| "/usr/lib/libcrypt.so", | |
| "/usr/lib/libc-.so", | |
| "/usr/lib/libc-a.so", | |
| "/usr/lib/not-libc.so.6", | |
| "/", | |
| "", | |
| ]; | |
| for case in cases { | |
| assert!(!is_libc_path(Path::new(case)), "unexpected match for {case}"); | |
| } | |
| } | |
| } |
Copilot
AI
Apr 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning suggests installing libc6-dbg via apt will fix missing DWARF, but debug_info_by_path() only attempts to read DWARF sections from the mapped ELF at path (it doesn't resolve .gnu_debuglink/build-id or /usr/lib/debug files). On Debian/Ubuntu, installing libc6-dbg typically provides a separate debug file, so this message may be misleading/unactionable (and apt is distro-specific). Consider either (a) implementing lookup of external debug files for libc (debuglink/build-id) or (b) adjusting the warning text to be OS/distro-agnostic and accurately describe what data is missing and where the tool looks for it.
| "libc debug info not found for {}. Flamegraphs may contain \ | |
| unsymbolicated libc frames. Install debug symbols \ | |
| (e.g., `apt install libc6-dbg`) to fix this.", | |
| "No DWARF debug info was found in the mapped libc ELF at {}. \ | |
| Flamegraphs may contain unsymbolicated libc frames. \ | |
| This tool currently reads debug info from the mapped ELF path only.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
filename.as_bytes().get(5)check relies on the hard-coded index immediately after the"libc-"prefix, which is a bit opaque. Consider rewriting usingstrip_prefix("libc-")+bytes().next()(or similar) to make the intent clearer and avoid manual indexing.