diff options
author | Yabin Cui <yabinc@google.com> | 2016-07-12 01:36:00 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-07-12 01:36:00 +0000 |
commit | 78f176baafaffbe5192b7565c4e7d68ce998e731 (patch) | |
tree | e8497f73c5541ba6cf04a230b99b915a1c29bc0f | |
parent | 2d6e0d6511db416b116ec46f747a84f29489fbec (diff) | |
parent | c855ecc6becfe5d1c2445094aa525856e4538f7c (diff) | |
download | extras-78f176baafaffbe5192b7565c4e7d68ce998e731.tar.gz |
Merge "simpleperf: add min_vaddr in DsoRecord."
-rw-r--r-- | simpleperf/cmd_record.cpp | 3 | ||||
-rw-r--r-- | simpleperf/cmd_report_test.cpp | 3 | ||||
-rw-r--r-- | simpleperf/dso.h | 1 | ||||
-rw-r--r-- | simpleperf/get_test_data.h | 4 | ||||
-rw-r--r-- | simpleperf/record.cpp | 8 | ||||
-rw-r--r-- | simpleperf/record.h | 3 | ||||
-rw-r--r-- | simpleperf/testdata/perf_with_symbols.data | bin | 255824 -> 255672 bytes | |||
-rw-r--r-- | simpleperf/testdata/perf_with_symbols_for_nonzero_minvaddr_dso.data | bin | 0 -> 251072 bytes | |||
-rw-r--r-- | simpleperf/thread_tree.cpp | 1 |
9 files changed, 19 insertions, 4 deletions
diff --git a/simpleperf/cmd_record.cpp b/simpleperf/cmd_record.cpp index 0e6b64e5..a7988173 100644 --- a/simpleperf/cmd_record.cpp +++ b/simpleperf/cmd_record.cpp @@ -814,7 +814,8 @@ bool RecordCommand::DumpSymbolForRecord(const SampleRecord& r, if (!map->dso->HasDumped()) { map->dso->SetDumped(); DsoRecord dso_record = - DsoRecord::Create(map->dso->type(), map->dso->id(), map->dso->Path()); + DsoRecord::Create(map->dso->type(), map->dso->id(), map->dso->Path(), + map->dso->MinVirtualAddress()); if (!record_file_writer_->WriteRecord(dso_record)) { return false; } diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp index e6c152e9..12811376 100644 --- a/simpleperf/cmd_report_test.cpp +++ b/simpleperf/cmd_report_test.cpp @@ -309,6 +309,9 @@ TEST_F(ReportCommandTest, report_dumped_symbols) { Report(PERF_DATA_WITH_SYMBOLS); ASSERT_TRUE(success); ASSERT_NE(content.find("main"), std::string::npos); + Report(PERF_DATA_WITH_SYMBOLS_FOR_NONZERO_MINVADDR_DSO); + ASSERT_TRUE(success); + ASSERT_NE(content.find("main"), std::string::npos); } TEST_F(ReportCommandTest, report_sort_vaddr_in_file) { diff --git a/simpleperf/dso.h b/simpleperf/dso.h index 5f3915e9..a3525701 100644 --- a/simpleperf/dso.h +++ b/simpleperf/dso.h @@ -93,6 +93,7 @@ struct Dso { // Return the minimum virtual address in program header. uint64_t MinVirtualAddress(); + void SetMinVirtualAddress(uint64_t min_vaddr) { min_vaddr_ = min_vaddr; } const Symbol* FindSymbol(uint64_t vaddr_in_dso); void InsertSymbol(const Symbol& symbol); diff --git a/simpleperf/get_test_data.h b/simpleperf/get_test_data.h index 5106d95f..686c245d 100644 --- a/simpleperf/get_test_data.h +++ b/simpleperf/get_test_data.h @@ -73,6 +73,10 @@ static const std::string PERF_DATA_WITH_KERNEL_SYMBOL = "perf_with_kernel_symbol // perf_with_symbols.data is generated by `sudo simpleperf record --dump-symbols` a process calling func2(int,int). static const std::string PERF_DATA_WITH_SYMBOLS = "perf_with_symbols.data"; +// perf_with_symbols.data is generated by `sudo simpleperf record --dump-symbols` a process using +// a binary having non zero min virtual address. +static const std::string PERF_DATA_WITH_SYMBOLS_FOR_NONZERO_MINVADDR_DSO = + "perf_with_symbols_for_nonzero_minvaddr_dso.data"; // perf_kmem_slab_callgraph.data is generated by `simpleperf kmem record --slab --call-graph fp -f 100 sleep 0.0001`. static const std::string PERF_DATA_WITH_KMEM_SLAB_CALLGRAPH_RECORD = "perf_with_kmem_slab_callgraph.data"; diff --git a/simpleperf/record.cpp b/simpleperf/record.cpp index 882dfc35..30a5aa1a 100644 --- a/simpleperf/record.cpp +++ b/simpleperf/record.cpp @@ -716,6 +716,7 @@ DsoRecord::DsoRecord(const char* p) : Record(p) { p += header_size(); MoveFromBinaryFormat(dso_type, p); MoveFromBinaryFormat(dso_id, p); + MoveFromBinaryFormat(min_vaddr, p); dso_name = p; p += Align(dso_name.size() + 1, 8); CHECK_EQ(p, end); @@ -727,6 +728,7 @@ std::vector<char> DsoRecord::BinaryFormat() const { MoveToBinaryFormat(header, p); MoveToBinaryFormat(dso_type, p); MoveToBinaryFormat(dso_id, p); + MoveToBinaryFormat(min_vaddr, p); strcpy(p, dso_name.c_str()); return buf; } @@ -735,17 +737,19 @@ void DsoRecord::DumpData(size_t indent) const { PrintIndented(indent, "dso_type: %s(%" PRIu64 ")\n", DsoTypeToString(static_cast<DsoType>(dso_type)), dso_type); PrintIndented(indent, "dso_id: %" PRIu64 "\n", dso_id); + PrintIndented(indent, "min_vaddr: 0x%" PRIx64 "\n", min_vaddr); PrintIndented(indent, "dso_name: %s\n", dso_name.c_str()); } DsoRecord DsoRecord::Create(uint64_t dso_type, uint64_t dso_id, - const std::string& dso_name) { + const std::string& dso_name, uint64_t min_vaddr) { DsoRecord record; record.SetTypeAndMisc(SIMPLE_PERF_RECORD_DSO, 0); record.dso_type = dso_type; record.dso_id = dso_id; + record.min_vaddr = min_vaddr; record.dso_name = dso_name; - record.SetSize(record.header_size() + 2 * sizeof(uint64_t) + + record.SetSize(record.header_size() + 3 * sizeof(uint64_t) + Align(record.dso_name.size() + 1, 8)); return record; } diff --git a/simpleperf/record.h b/simpleperf/record.h index c1d7593d..8929ee5a 100644 --- a/simpleperf/record.h +++ b/simpleperf/record.h @@ -417,6 +417,7 @@ struct KernelSymbolRecord : public Record { struct DsoRecord : public Record { uint64_t dso_type; uint64_t dso_id; + uint64_t min_vaddr; std::string dso_name; DsoRecord() {} @@ -425,7 +426,7 @@ struct DsoRecord : public Record { std::vector<char> BinaryFormat() const override; static DsoRecord Create(uint64_t dso_type, uint64_t dso_id, - const std::string& dso_name); + const std::string& dso_name, uint64_t min_vaddr); protected: void DumpData(size_t indent) const override; diff --git a/simpleperf/testdata/perf_with_symbols.data b/simpleperf/testdata/perf_with_symbols.data Binary files differindex 4c0dfe66..8571a964 100644 --- a/simpleperf/testdata/perf_with_symbols.data +++ b/simpleperf/testdata/perf_with_symbols.data diff --git a/simpleperf/testdata/perf_with_symbols_for_nonzero_minvaddr_dso.data b/simpleperf/testdata/perf_with_symbols_for_nonzero_minvaddr_dso.data Binary files differnew file mode 100644 index 00000000..cf45d3aa --- /dev/null +++ b/simpleperf/testdata/perf_with_symbols_for_nonzero_minvaddr_dso.data diff --git a/simpleperf/thread_tree.cpp b/simpleperf/thread_tree.cpp index d81e8f48..f3291e5d 100644 --- a/simpleperf/thread_tree.cpp +++ b/simpleperf/thread_tree.cpp @@ -280,6 +280,7 @@ void ThreadTree::Update(const Record& record) { } else { dso = FindUserDsoOrNew(r.dso_name); } + dso->SetMinVirtualAddress(r.min_vaddr); dso_id_to_dso_map_[r.dso_id] = dso; } else if (record.type() == SIMPLE_PERF_RECORD_SYMBOL) { auto& r = *static_cast<const SymbolRecord*>(&record); |