diff options
author | Yabin Cui <yabinc@google.com> | 2018-03-26 17:34:00 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2018-03-28 17:16:27 -0700 |
commit | 516a87cd05e6f7dcf2c45fd8ba6d1d0e1e1e7bdd (patch) | |
tree | 642ab8433692d1862900ac93c7a24fc131ef4822 /simpleperf/record_file_reader.cpp | |
parent | 81ed0ea0e64d536287e823431f4999f183cc3cf1 (diff) | |
download | extras-516a87cd05e6f7dcf2c45fd8ba6d1d0e1e1e7bdd.tar.gz |
simpleperf: support showing symbols for interpreted java code.
To convert from a dex_pc (returned by libunwindstack) to a symbol name,
we need below things:
1. The mapping info of the vdex file containing the dex_pc.
2. The offsets of dex files in the vdex file.
So make below changes:
1. Record none executable maps when profiling java code.
2. Refactor dso code to add a new type for dex file, using DexFileDso
to store dex file offsets in a vdex file, and load symbols from that
vdex file.
3. Add read_dex_file.cpp to read java symbols using libdexfile.
4. Change the format of file section in record_file_format.h, to store
dex file offsets in vdex files.
Bug: http://b/73126888
Bug: http://b/77236599
Test: Run simpleperf to profile several apps manually, can see
Test: callstacks of both java code and native code.
Test: Run simpleperf_unit_test.
Change-Id: I08005a03beb3df1a70db034bc463f555934856ba
Diffstat (limited to 'simpleperf/record_file_reader.cpp')
-rw-r--r-- | simpleperf/record_file_reader.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/simpleperf/record_file_reader.cpp b/simpleperf/record_file_reader.cpp index 38a4b2d6..9b68c654 100644 --- a/simpleperf/record_file_reader.cpp +++ b/simpleperf/record_file_reader.cpp @@ -443,7 +443,8 @@ bool RecordFileReader::ReadFileFeature(size_t& read_pos, std::string* file_path, uint32_t* file_type, uint64_t* min_vaddr, - std::vector<Symbol>* symbols) { + std::vector<Symbol>* symbols, + std::vector<uint64_t>* dex_file_offsets) { auto it = feature_section_descriptors_.find(FEAT_FILE); if (it == feature_section_descriptors_.end()) { return false; @@ -484,6 +485,13 @@ bool RecordFileReader::ReadFileFeature(size_t& read_pos, p += name.size() + 1; symbols->emplace_back(name, start_vaddr, len); } + dex_file_offsets->clear(); + if (*file_type == static_cast<uint32_t>(DSO_DEX_FILE)) { + uint32_t offset_count; + MoveFromBinaryFormat(offset_count, p); + dex_file_offsets->resize(offset_count); + MoveFromBinaryFormat(dex_file_offsets->data(), offset_count, p); + } CHECK_EQ(size, static_cast<size_t>(p - buf.data())); return true; } @@ -518,10 +526,11 @@ void RecordFileReader::LoadBuildIdAndFileFeatures(ThreadTree& thread_tree) { uint32_t file_type; uint64_t min_vaddr; std::vector<Symbol> symbols; + std::vector<uint64_t> dex_file_offsets; size_t read_pos = 0; while (ReadFileFeature( - read_pos, &file_path, &file_type, &min_vaddr, &symbols)) { - thread_tree.AddDsoInfo(file_path, file_type, min_vaddr, &symbols); + read_pos, &file_path, &file_type, &min_vaddr, &symbols, &dex_file_offsets)) { + thread_tree.AddDsoInfo(file_path, file_type, min_vaddr, &symbols, dex_file_offsets); } } } |