From f3da1edd7d18db0c89c02c786cbd5eb76c0c1425 Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Wed, 25 Nov 2020 15:37:38 -0800 Subject: 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 --- simpleperf/environment.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'simpleperf/environment.cpp') 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 GetOnlineCpus() { } static std::vector GetLoadedModules() { + if (IsRoot() && !CheckKernelSymbolAddresses()) { + return {}; + } std::vector result; FILE* fp = fopen("/proc/modules", "re"); if (fp == nullptr) { -- cgit v1.2.3