diff options
author | Yabin Cui <yabinc@google.com> | 2018-05-21 17:37:00 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2018-05-22 11:28:47 -0700 |
commit | 2a53ff331b4ca0bb55f20115e95454c9afcc97c4 (patch) | |
tree | 904e80ffc98ab18011cbf0d7bf450916491fa76b /simpleperf/dso.cpp | |
parent | 9f3f98476cbfb1f35238689a57800be47b5be138 (diff) | |
download | extras-2a53ff331b4ca0bb55f20115e95454c9afcc97c4.tar.gz |
simpleperf: get symbols from dex files extracted from zip files.
ART may extract dex files into memory from zip files.
This CL supports getting symbols from extracted dex files in below steps:
1. Change map names in "/dev/ashmem/dalvik-xxx extracted in memory
from yyy.apk" format into yyy.apk!/xxx format.
2. Support dumping dex files in yyy.apk!/xxx format in JITDebugReader.
3. Support reading symbols from dex files in yyy.apk!/xxx format
in DexFileDso.
Also refactor FileHelper to return android::base::unique_fd,
refactor ArchiveHelper to wrap all operations to zip files.
Bug: 79118393
Test: run simpleperf_unit_test.
Test: run simpleperf on an app containing extracted dex files.
Change-Id: I65dbd98843f2d47272ea72935fd3d2b6d6e8ae40
Diffstat (limited to 'simpleperf/dso.cpp')
-rw-r--r-- | simpleperf/dso.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/simpleperf/dso.cpp b/simpleperf/dso.cpp index 04342744..f1804000 100644 --- a/simpleperf/dso.cpp +++ b/simpleperf/dso.cpp @@ -343,7 +343,20 @@ class DexFileDso : public Dso { std::vector<Symbol> LoadSymbols() override { std::vector<Symbol> symbols; std::vector<DexFileSymbol> dex_file_symbols; - if (!ReadSymbolsFromDexFile(debug_file_path_, dex_file_offsets_, &dex_file_symbols)) { + auto tuple = SplitUrlInApk(debug_file_path_); + bool status = false; + if (std::get<0>(tuple)) { + std::unique_ptr<ArchiveHelper> ahelper = ArchiveHelper::CreateInstance(std::get<1>(tuple)); + ZipEntry entry; + std::vector<uint8_t> data; + if (ahelper->FindEntry(std::get<2>(tuple), &entry) && ahelper->GetEntryData(entry, &data)) { + status = ReadSymbolsFromDexFileInMemory(data.data(), data.size(), dex_file_offsets_, + &dex_file_symbols); + } + } else { + status = ReadSymbolsFromDexFile(debug_file_path_, dex_file_offsets_, &dex_file_symbols); + } + if (!status) { android::base::LogSeverity level = symbols_.empty() ? android::base::WARNING : android::base::DEBUG; LOG(level) << "Failed to read symbols from " << debug_file_path_; |