Search for a separate debug info file, in GDB's order (see [Separate Debug Files]): build-id path first, then `.gnu_debuglink` with CRC32 validation. Build-id wins because it hashes the binary contents, so a match cannot be a false positive, while `.gnu_debuglink` only matches by filename. The searched roots are where Debian/Ubuntu `*-dbg`/`*-dbgsym` packages and NixOS `environment.enableDebugInf
(object: &object::File, binary_path: &Path)
| 12 | /// |
| 13 | /// [Separate Debug Files]: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Separate-Debug-Files.html |
| 14 | pub fn find_debug_file(object: &object::File, binary_path: &Path) -> Option<PathBuf> { |
| 15 | let via_known_roots = ["/usr/lib/debug", "/run/current-system/sw/lib/debug"] |
| 16 | .iter() |
| 17 | .map(Path::new) |
| 18 | .filter(|dir| dir.exists()) |
| 19 | .find_map(|dir| find_debug_file_in(object, binary_path, dir)); |
| 20 | |
| 21 | // `.gnu_debuglink` beside the binary (and its `.debug` subdirectory) is part of |
| 22 | // GDB's search order regardless of whether a global debug-directory root exists |
| 23 | // (see module docs), so it must not be skipped on systems without one, e.g. most |
| 24 | // CI runners. |
| 25 | via_known_roots.or_else(|| find_debug_file_by_debuglink(object, binary_path, None)) |
| 26 | } |
| 27 | |
| 28 | fn find_debug_file_in( |
| 29 | object: &object::File, |
no test coverage detected