From 5ead6440ff99bc9f2caa0c737158e83594529b70 Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Mon, 22 Dec 2025 15:45:15 +0100 Subject: [PATCH] fix: filter out arm debugging symbols --- src/executor/wall_time/perf/perf_map.rs | 33 +++++++++++++------ ...__perf_map__tests__rust_divan_symbols.snap | 4 +-- ...rf_map__tests__the_algorithms_symbols.snap | 4 +-- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/executor/wall_time/perf/perf_map.rs b/src/executor/wall_time/perf/perf_map.rs index 2e9883ca..7d14e285 100644 --- a/src/executor/wall_time/perf/perf_map.rs +++ b/src/executor/wall_time/perf/perf_map.rs @@ -79,6 +79,27 @@ impl ModuleSymbols { })); } + // Filter out + // - ARM ELF "mapping symbols" (https://github.com/torvalds/linux/blob/9448598b22c50c8a5bb77a9103e2d49f134c9578/tools/perf/util/symbol-elf.c#L1591C1-L1598C4) + // - symbols that have en empty name + symbols.retain(|symbol| { + if symbol.name.is_empty() { + trace!("Filtering out symbol with empty name: {symbol:?}"); + return false; + } + + // Reject ARM ELF "mapping symbols" as does perf + let name = symbol.name.as_str(); + if let [b'$', b'a' | b'd' | b't' | b'x', rest @ ..] = name.as_bytes() { + if rest.is_empty() || rest.starts_with(b".") { + trace!("Filtering out ARM ELF mapping symbol: {symbol:?}"); + return false; + } + } + + true + }); + // Update zero-sized symbols to cover the range until the next symbol // This is what perf does // https://github.com/torvalds/linux/blob/e538109ac71d801d26776af5f3c54f548296c29c/tools/perf/util/symbol.c#L256 @@ -100,16 +121,8 @@ impl ModuleSymbols { } } - // Filter out any symbols that still have zero size or an empty name - symbols.retain(|symbol| { - let should_keep = symbol.size > 0 && !symbol.name.is_empty(); - - if !should_keep { - trace!("Filtering out symbol: {symbol:?}"); - } - - should_keep - }); + // Filter out any symbols are still zero-sized + symbols.retain(|symbol| symbol.size > 0); if symbols.is_empty() { return Err(anyhow::anyhow!("No symbols found")); diff --git a/src/executor/wall_time/perf/snapshots/codspeed__executor__wall_time__perf__perf_map__tests__rust_divan_symbols.snap b/src/executor/wall_time/perf/snapshots/codspeed__executor__wall_time__perf__perf_map__tests__rust_divan_symbols.snap index f626fc68..01ae397e 100644 --- a/src/executor/wall_time/perf/snapshots/codspeed__executor__wall_time__perf__perf_map__tests__rust_divan_symbols.snap +++ b/src/executor/wall_time/perf/snapshots/codspeed__executor__wall_time__perf__perf_map__tests__rust_divan_symbols.snap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:96076d39277b33ed3bbe060af13400acf3007a61c4b28fe5d93609122774a8dc -size 498482 +oid sha256:2a7fe3c34026d24978a593c5d9610680c5cf1881ddaf0445f7a3b608400f17fb +size 498487 diff --git a/src/executor/wall_time/perf/snapshots/codspeed__executor__wall_time__perf__perf_map__tests__the_algorithms_symbols.snap b/src/executor/wall_time/perf/snapshots/codspeed__executor__wall_time__perf__perf_map__tests__the_algorithms_symbols.snap index 79b9c208..adcde443 100644 --- a/src/executor/wall_time/perf/snapshots/codspeed__executor__wall_time__perf__perf_map__tests__the_algorithms_symbols.snap +++ b/src/executor/wall_time/perf/snapshots/codspeed__executor__wall_time__perf__perf_map__tests__the_algorithms_symbols.snap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4fba1f2413398a08fb12a54ecbefbf69c3a18cf5bf9d544386f2e1d794bf81f1 -size 557134 +oid sha256:56704ece3d27b5d3725bcf2a0eb8801f8c28dbf447f6e37996a5cd0596901606 +size 557139