summaryrefslogtreecommitdiff
path: root/simpleperf/environment.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2020-11-25 15:37:38 -0800
committerYabin Cui <yabinc@google.com>2020-11-25 15:55:31 -0800
commitf3da1edd7d18db0c89c02c786cbd5eb76c0c1425 (patch)
treeaf4f2e6635dd42f62af77d6bb06653b322b666c4 /simpleperf/environment.cpp
parentdacfcca550b5d72ffb08a6d1f0ac30fda8243aaf (diff)
downloadextras-f3da1edd7d18db0c89c02c786cbd5eb76c0c1425.tar.gz
simpleperf: fix symbolization for kernel modules.
Simpleperf makes a wrong assumption that the kernel always load .text section of a kernel module at the start of its module memory. This can map an ip addr of a module to a wrong symbol. To fix it: 1. In KernelModuleDso, calculate min_vaddr and memory_offset, which are used to do the conversion in IpToVaddrInFile(). 2. Change record_file_reader/writer to store min_vaddr and memory_offset of KernelModuleDso in the recording file. 3. To get module start addresses, Use CheckKernelSymbolAddress() in GetLoadedModules(). Bug: 174076407 Test: run simpleperf_unit_test. Test: run simpleperf manually to check symbols of kernel modules. Change-Id: I2498564f78dcc34761c5fe3ae9ffa6b88a98a048
Diffstat (limited to 'simpleperf/environment.cpp')
-rw-r--r--simpleperf/environment.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/simpleperf/environment.cpp b/simpleperf/environment.cpp
index f3333ca1..a154b4e7 100644
--- a/simpleperf/environment.cpp
+++ b/simpleperf/environment.cpp
@@ -95,6 +95,9 @@ std::vector<int> GetOnlineCpus() {
}
static std::vector<KernelMmap> GetLoadedModules() {
+ if (IsRoot() && !CheckKernelSymbolAddresses()) {
+ return {};
+ }
std::vector<KernelMmap> result;
FILE* fp = fopen("/proc/modules", "re");
if (fp == nullptr) {