diff options
author | Yabin Cui <yabinc@google.com> | 2016-10-24 13:38:38 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2016-10-31 10:40:03 -0700 |
commit | c5b4a3106a0845d1bd8fd2c1b1c724eeb719ec62 (patch) | |
tree | 8d045224b547f708cadcd4c7c23476b0a78e262e /simpleperf/record_file_reader.cpp | |
parent | d2fcab88ef855a9a415159b669f7ea7e00f5a575 (diff) | |
download | extras-c5b4a3106a0845d1bd8fd2c1b1c724eeb719ec62.tar.gz |
simpleperf: dump file feature section.
For `record --dump-symbols` option, change from dumping
DsoRecord and SymbolRecord to dumping file feature section.
It is to avoid reading symbols from elf files during recording,
which takes a lot of time. And we don't want to mix optional
data (the symbol tables) with necessary data (the profiling records).
Bug: http://b/32340274
Test: run simpleperf_unit_test.
Test: run simpleperf runtest.py.
Change-Id: I0a387de243afac93486fc885f223a58060ec07f4
Diffstat (limited to 'simpleperf/record_file_reader.cpp')
-rw-r--r-- | simpleperf/record_file_reader.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/simpleperf/record_file_reader.cpp b/simpleperf/record_file_reader.cpp index c300fc72..b58b0ce7 100644 --- a/simpleperf/record_file_reader.cpp +++ b/simpleperf/record_file_reader.cpp @@ -378,6 +378,60 @@ std::string RecordFileReader::ReadFeatureString(int feature) { return p; } +bool RecordFileReader::ReadFileFeature(size_t& read_pos, + std::string* file_path, + uint32_t* file_type, + uint64_t* min_vaddr, + std::vector<Symbol>* symbols) { + auto it = feature_section_descriptors_.find(FEAT_FILE); + if (it == feature_section_descriptors_.end()) { + return false; + } + if (read_pos >= it->second.size) { + return false; + } + if (read_pos == 0) { + if (fseek(record_fp_, it->second.offset, SEEK_SET) != 0) { + PLOG(ERROR) << "fseek() failed"; + return false; + } + } + uint32_t size; + if (!Read(&size, 4)) { + return false; + } + std::vector<char> buf(size); + if (!Read(buf.data(), size)) { + return false; + } + read_pos += 4 + size; + const char* p = buf.data(); + *file_path = p; + p += file_path->size() + 1; + memcpy(file_type, p, sizeof(uint32_t)); + p += sizeof(uint32_t); + memcpy(min_vaddr, p, sizeof(uint64_t)); + p += sizeof(uint64_t); + uint32_t symbol_count; + memcpy(&symbol_count, p, sizeof(uint32_t)); + p += sizeof(uint32_t); + symbols->clear(); + symbols->reserve(symbol_count); + for (uint32_t i = 0; i < symbol_count; ++i) { + uint64_t start_vaddr; + uint32_t len; + memcpy(&start_vaddr, p, sizeof(uint64_t)); + p += sizeof(uint64_t); + memcpy(&len, p, sizeof(uint32_t)); + p += sizeof(uint32_t); + std::string name = p; + p += name.size() + 1; + symbols->emplace_back(name, start_vaddr, len); + } + CHECK_EQ(size, static_cast<size_t>(p - buf.data())); + return true; +} + std::vector<std::unique_ptr<Record>> RecordFileReader::DataSection() { std::vector<std::unique_ptr<Record>> records; ReadDataSection([&](std::unique_ptr<Record> record) { |