MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / find_debug_file_by_debuglink

Function find_debug_file_by_debuglink

src/executor/helpers/debug_file.rs:64–96  ·  view source on GitHub ↗
(
    object: &object::File,
    binary_path: &Path,
    debug_dir: Option<&Path>,
)

Source from the content-addressed store, hash-verified

62}
63
64fn find_debug_file_by_debuglink(
65 object: &object::File,
66 binary_path: &Path,
67 debug_dir: Option<&Path>,
68) -> Option<PathBuf> {
69 let (debuglink, expected_crc) = object.gnu_debuglink().ok()??;
70 let debuglink = std::str::from_utf8(debuglink).ok()?;
71 let dir = binary_path.parent()?;
72
73 let mut candidates = vec![dir.join(debuglink), dir.join(".debug").join(debuglink)];
74 if let Some(debug_dir) = debug_dir {
75 candidates.push(
76 debug_dir
77 .join(dir.strip_prefix("/").unwrap_or(dir))
78 .join(debuglink),
79 );
80 }
81
82 candidates.into_iter().find(|p| {
83 let Ok(content) = std::fs::read(p) else {
84 return false;
85 };
86 let actual_crc = crc32fast::hash(&content);
87 if actual_crc != expected_crc {
88 trace!(
89 "CRC mismatch for {}: expected {expected_crc:#x}, got {actual_crc:#x}",
90 p.display()
91 );
92 return false;
93 }
94 true
95 })
96}
97
98/// Copy `binary` and `debug_file` in a fresh tempdir, renaming the debug file to
99/// match the binary's `.gnu_debuglink` basename so `find_debug_file` resolves

Callers 2

find_debug_fileFunction · 0.85
find_debug_file_inFunction · 0.85

Calls 1

readFunction · 0.50

Tested by

no test coverage detected