Skip to content

Commit a488351

Browse files
committed
feat: dump debug info of loaded modules
1 parent af0cb64 commit a488351

14 files changed

+371
-12
lines changed

.gitattributes

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
testdata/perf_map/cpp_my_benchmark.bin filter=lfs diff=lfs merge=lfs -text
2-
testdata/perf_map/go_fib.bin filter=lfs diff=lfs merge=lfs -text
3-
testdata/perf_map/divan_sleep_benches.bin filter=lfs diff=lfs merge=lfs -text
4-
testdata/perf_map/the_algorithms.bin filter=lfs diff=lfs merge=lfs -text
5-
src/run/runner/wall_time/perf/snapshots/codspeed__run__runner__wall_time__perf__perf_map__tests__ruff_symbols.snap filter=lfs diff=lfs merge=lfs -text
6-
testdata/perf_map/ty_walltime filter=lfs diff=lfs merge=lfs -text
1+
testdata/perf_map/* filter=lfs diff=lfs merge=lfs -text
2+
src/run/runner/wall_time/perf/snapshots/*.snap filter=lfs diff=lfs merge=lfs -text

Cargo.lock

Lines changed: 82 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ nix = { version = "0.29.0", features = ["fs", "time", "user"] }
5757
futures = "0.3.31"
5858
runner-shared = { path = "crates/runner-shared" }
5959
shellexpand = { version = "3.1.1", features = ["tilde"] }
60+
addr2line = "0.25"
61+
gimli = "0.32"
6062

6163
[target.'cfg(target_os = "linux")'.dependencies]
6264
procfs = "0.17.0"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
#[derive(Hash, PartialEq, Eq, Clone, Serialize, Deserialize)]
4+
pub struct DebugInfo {
5+
pub addr: u64,
6+
pub size: u64,
7+
pub name: String,
8+
pub file: String,
9+
pub line: Option<u32>,
10+
}
11+
12+
impl std::fmt::Debug for DebugInfo {
13+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14+
let location = format!("{}:{}", self.file, self.line.unwrap_or(0));
15+
let name = &self.name;
16+
write!(
17+
f,
18+
"DebugInfo {{ addr: {:x}, size: {:x}, name: {}, location: {} }}",
19+
self.addr, self.size, name, location
20+
)
21+
}
22+
}
23+
24+
#[derive(Debug, Clone, Serialize, Deserialize)]
25+
pub struct ModuleDebugInfo {
26+
/// The path to the object file on disk (e.g. `/usr/lib/libc.so.6`)
27+
pub object_path: String,
28+
29+
/// The minimum and maximum address covered by the debug infos. This is useful for
30+
/// quickly checking if an address might be covered by this module.
31+
pub addr_bounds: (u64, u64),
32+
33+
/// The load bias of the module. This is the difference between the address in the
34+
/// symbol table and the actual address in memory.
35+
pub load_bias: u64,
36+
37+
/// The debug info for this module, sorted by address.
38+
pub debug_infos: Vec<DebugInfo>,
39+
}

crates/runner-shared/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod debug_info;
12
pub mod fifo;
23
pub mod metadata;
34
pub mod unwind_data;

crates/runner-shared/src/metadata.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use anyhow::Context;
22
use serde::{Deserialize, Serialize};
33
use std::path::Path;
44

5+
use crate::debug_info::ModuleDebugInfo;
56
use crate::fifo::MarkerType;
67

78
#[derive(Serialize, Deserialize)]
@@ -20,6 +21,10 @@ pub struct PerfMetadata {
2021

2122
/// Marker for certain regions in the profiling data
2223
pub markers: Vec<MarkerType>,
24+
25+
/// Debug info for all modules across all processes, mapping PID to module debug info
26+
#[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")]
27+
pub debug_info_by_pid: std::collections::HashMap<i32, Vec<ModuleDebugInfo>>,
2328
}
2429

2530
impl PerfMetadata {

0 commit comments

Comments
 (0)