diff options
author | Yabin Cui <yabinc@google.com> | 2020-11-25 15:37:38 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2020-11-25 15:55:31 -0800 |
commit | f3da1edd7d18db0c89c02c786cbd5eb76c0c1425 (patch) | |
tree | af4f2e6635dd42f62af77d6bb06653b322b666c4 /simpleperf/dso.h | |
parent | dacfcca550b5d72ffb08a6d1f0ac30fda8243aaf (diff) | |
download | extras-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/dso.h')
-rw-r--r-- | simpleperf/dso.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/simpleperf/dso.h b/simpleperf/dso.h index ebfbc425..c5fda64f 100644 --- a/simpleperf/dso.h +++ b/simpleperf/dso.h @@ -134,6 +134,9 @@ class Dso { bool force_64bit = false); static std::unique_ptr<Dso> CreateElfDsoWithBuildId(const std::string& dso_path, BuildId& build_id); + static std::unique_ptr<Dso> CreateKernelModuleDso(const std::string& dso_path, + uint64_t memory_start, uint64_t memory_end, + Dso* kernel_dso); virtual ~Dso(); DsoType type() const { return type_; } @@ -173,7 +176,7 @@ class Dso { uint64_t map_pgoff); const Symbol* FindSymbol(uint64_t vaddr_in_dso); - + void LoadSymbols(); const std::vector<Symbol>& GetSymbols() { return symbols_; } void SetSymbols(std::vector<Symbol>* symbols); @@ -195,8 +198,7 @@ class Dso { Dso(DsoType type, const std::string& path, const std::string& debug_file_path); BuildId GetExpectedBuildId(); - void Load(); - virtual std::vector<Symbol> LoadSymbols() = 0; + virtual std::vector<Symbol> LoadSymbolsImpl() = 0; DsoType type_; // path of the shared library used by the profiled program |