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

Function setup_debuglink_tmpdir

src/executor/helpers/debug_file.rs:102–121  ·  view source on GitHub ↗
(
    binary: &Path,
    debug_file: &Path,
)

Source from the content-addressed store, hash-verified

100/// the pair.
101#[cfg(all(test, target_os = "linux"))]
102pub(crate) fn setup_debuglink_tmpdir(
103 binary: &Path,
104 debug_file: &Path,
105) -> (tempfile::TempDir, PathBuf, PathBuf) {
106 let src = std::fs::read(binary).unwrap();
107 let object = object::File::parse(&*src).unwrap();
108 let (debuglink, _crc) = object
109 .gnu_debuglink()
110 .unwrap()
111 .expect("binary has no .gnu_debuglink");
112 let debuglink = std::str::from_utf8(debuglink).unwrap();
113
114 let dir = tempfile::tempdir().unwrap();
115 let staged_binary = dir.path().join("binary");
116 let staged_debug = dir.path().join(debuglink);
117 std::fs::copy(binary, &staged_binary).unwrap();
118 std::fs::copy(debug_file, &staged_debug).unwrap();
119
120 (dir, staged_binary, staged_debug)
121}
122
123#[cfg(all(test, target_os = "linux"))]
124mod tests {

Calls 2

pathMethod · 0.80
readFunction · 0.50