Skip to content

Commit 3373f01

Browse files
fix: stop filtering out zero sized symbol
1 parent fde0294 commit 3373f01

7 files changed

+36
-14
lines changed

src/executor/wall_time/perf/perf_map.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,30 @@ impl ModuleSymbols {
7979
}));
8080
}
8181

82-
symbols.retain(|symbol| symbol.addr > 0 && symbol.size > 0);
82+
// Update zero-sized symbols to cover the range until the next symbol
83+
// This is what perf does
84+
// https://github.com/torvalds/linux/blob/e538109ac71d801d26776af5f3c54f548296c29c/tools/perf/util/symbol.c#L256
85+
// A common source for these is inline assembly functions.
86+
symbols.sort_by_key(|symbol| symbol.addr);
87+
for i in 0..symbols.len() {
88+
if symbols[i].size == 0 {
89+
if i + 1 < symbols.len() {
90+
// Set size to the distance to the next symbol
91+
symbols[i].size = symbols[i + 1].addr.saturating_sub(symbols[i].addr);
92+
} else {
93+
// Last symbol: round up to next 4KB page boundary and add 4KiB
94+
// This matches perf's behavior: roundup(curr->start, 4096) + 4096
95+
const PAGE_SIZE: u64 = 4096;
96+
let addr = symbols[i].addr;
97+
let end_addr = addr.next_multiple_of(PAGE_SIZE) + PAGE_SIZE;
98+
symbols[i].size = end_addr.saturating_sub(addr);
99+
}
100+
}
101+
}
102+
103+
// Filter out any symbols that still have zero size
104+
symbols.retain(|symbol| symbol.size > 0);
105+
83106
if symbols.is_empty() {
84107
return Err(anyhow::anyhow!("No symbols found"));
85108
}
@@ -143,7 +166,6 @@ impl ProcessSymbols {
143166
return;
144167
}
145168

146-
debug!("Loading module symbols at {start_addr:x}-{end_addr:x} (offset: {file_offset:x})");
147169
let path = module_path.as_ref().to_path_buf();
148170
match ModuleSymbols::new(module_path, start_addr, end_addr, file_offset) {
149171
Ok(symbol) => {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:18b3bab246f006ab09dcb364d019b5714777c93a2be302691fdd3120754e2691
3-
size 148095
2+
oid sha256:9af51e449587563ee665bc0c365c1e92b8fdbbd3182d70d026bc9f91890f06d8
3+
size 148236
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:83693652a98c569eec832a5fb6432ade575bf9c150c9621ca37eb47deba40b05
3-
size 490512
2+
oid sha256:a80d0a7b245514f01b8719ce71a5776e95c395b1986c5c78cfae948abee23a39
3+
size 490624
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:c7cc3eab372717be111d0595a1fa6a9c2062d85d4a1f8e8a8e8606f2ecd22cc1
3-
size 5995725
2+
oid sha256:be6c5d4b5981911d0ccc635cf0b0e1163ff5879e72b7c3076cac04423856fc68
3+
size 5996146
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:a0c804c19a74c27d25aa0633edb62649ab66ecf1becf282737ae606876d1e24d
3-
size 519684
2+
oid sha256:cecbdde3c24b806a75f9e8a438f82419f33f9fcc86b9966352685a35784abec6
3+
size 520675
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:09c5bee1afe80d0715360d1532eb631336e46d964a2cfabe5b58772e0d18d538
3-
size 567245
2+
oid sha256:da29e6ceb514be0437b501e406016656d2ddbc9f1cd0619ea29df64e7bc69e54
3+
size 568064
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:0717a77c9706bebec98155ac1853adccd44ff99036a5d1b3b5c8f556120a407c
3-
size 102925
2+
oid sha256:f03bda66a87fef7b32e3aa6ce67c36527cc01b26731e98dff292ac6f889a9431
3+
size 104083

0 commit comments

Comments
 (0)