summaryrefslogtreecommitdiff
path: root/simpleperf/dso.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2020-07-01 10:09:16 -0700
committerYabin Cui <yabinc@google.com>2020-07-01 10:16:26 -0700
commit90c3b30e1e310b128ddaf69014bf6601e6c8e26c (patch)
treede901ca5e40ac6094dd636ee90031a2677d73720 /simpleperf/dso.cpp
parent1f7cc3b43946e938bccc8b12f03f2edb8c97f1ba (diff)
downloadextras-90c3b30e1e310b128ddaf69014bf6601e6c8e26c.tar.gz
simpleperf: Move ReadMinExecutableVaddr into ElfFile class.
Bug: 160187327 Test: run simpleperf_unit_test. Change-Id: I913baff454ba01be9689712a61a970ffe04416fe
Diffstat (limited to 'simpleperf/dso.cpp')
-rw-r--r--simpleperf/dso.cpp29
1 files changed, 7 insertions, 22 deletions
diff --git a/simpleperf/dso.cpp b/simpleperf/dso.cpp
index d8096ca6..975a391a 100644
--- a/simpleperf/dso.cpp
+++ b/simpleperf/dso.cpp
@@ -484,29 +484,14 @@ class ElfDso : public Dso {
if (min_vaddr_ == uninitialized_value) {
min_vaddr_ = 0;
BuildId build_id = GetExpectedBuildId();
- uint64_t addr;
- uint64_t offset;
- ElfStatus result;
- auto tuple = SplitUrlInApk(debug_file_path_);
- if (std::get<0>(tuple)) {
- EmbeddedElf* elf = ApkInspector::FindElfInApkByName(std::get<1>(tuple),
- std::get<2>(tuple));
- if (elf == nullptr) {
- result = ElfStatus::FILE_NOT_FOUND;
- } else {
- result = ReadMinExecutableVirtualAddressFromEmbeddedElfFile(
- elf->filepath(), elf->entry_offset(), elf->entry_size(), build_id, &addr, &offset);
- }
- } else {
- result = ReadMinExecutableVirtualAddressFromElfFile(debug_file_path_, build_id, &addr,
- &offset);
- }
- if (result != ElfStatus::NO_ERROR) {
- LOG(WARNING) << "failed to read min virtual address of "
- << GetDebugFilePath() << ": " << result;
+
+ ElfStatus status;
+ auto elf = ElfFile::Open(debug_file_path_, &build_id, &status);
+ if (elf) {
+ min_vaddr_ = elf->ReadMinExecutableVaddr(&file_offset_of_min_vaddr_);
} else {
- min_vaddr_ = addr;
- file_offset_of_min_vaddr_ = offset;
+ LOG(WARNING) << "failed to read min virtual address of " << debug_file_path_ << ": "
+ << status;
}
}
*min_vaddr = min_vaddr_;