simpleperf: ignore arm mapping symbols in /proc/kallsyms.
ARM mapping symbols are misleading in reporting. We have ignored
them when reading symbols from ELF files. But they can also
appear in /proc/kallsyms for kernel modules.
Bug: none
Test: run simpleperf_unit_test
Change-Id: I3dc021bf5a64f9154940a22f3a46d9d42ec7a4ac
diff --git a/simpleperf/kallsyms.cpp b/simpleperf/kallsyms.cpp
index f9a9358..9cec784 100644
--- a/simpleperf/kallsyms.cpp
+++ b/simpleperf/kallsyms.cpp
@@ -24,6 +24,7 @@
#include <android-base/properties.h>
#include "environment.h"
+#include "read_elf.h"
#include "utils.h"
namespace simpleperf {
@@ -263,6 +264,10 @@
p = data_end;
}
if (ret >= 3) {
+ if (IsArmMappingSymbol(name)) {
+ continue;
+ }
+
symbol.name = name;
size_t module_len = strlen(module);
if (module_len > 2 && module[0] == '[' && module[module_len - 1] == ']') {
diff --git a/simpleperf/kallsyms_test.cpp b/simpleperf/kallsyms_test.cpp
index d45aeaa..cacd163 100644
--- a/simpleperf/kallsyms_test.cpp
+++ b/simpleperf/kallsyms_test.cpp
@@ -64,6 +64,25 @@
data, std::bind(&KernelSymbolsMatch, std::placeholders::_1, expected_symbol)));
}
+TEST(kallsyms, ProcessKernelSymbols_ignore_arm_mapping_symbols) {
+ std::string data =
+ "aaaaaaaaaaaaaaaa t $x.9 [coresight_etm4x]\n"
+ "bbbbbbbbbbbbbbbb t etm4_pm_clear [coresight_etm4x]\n";
+ bool has_normal_symbol = false;
+ bool has_arm_mapping_symbol = false;
+ auto callback = [&](const KernelSymbol& sym) {
+ if (strcmp(sym.name, "etm4_pm_clear") == 0) {
+ has_normal_symbol = true;
+ } else {
+ has_arm_mapping_symbol = true;
+ }
+ return false;
+ };
+ ProcessKernelSymbols(data, callback);
+ ASSERT_TRUE(has_normal_symbol);
+ ASSERT_FALSE(has_arm_mapping_symbol);
+}
+
#if defined(__ANDROID__)
TEST(kallsyms, GetKernelStartAddress) {
TEST_REQUIRE_ROOT();