diff options
author | Yabin Cui <yabinc@google.com> | 2017-11-01 15:58:55 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2017-11-02 11:20:18 -0700 |
commit | 3d4aa26ae99db7576f352771d704bd9da9a55bcd (patch) | |
tree | 161cf9ed264aed0daa3d3a7217954d56db9078a9 /simpleperf/record_test.cpp | |
parent | 29c0043b5334432afc01584f435585c2d2da49fe (diff) | |
download | extras-3d4aa26ae99db7576f352771d704bd9da9a55bcd.tar.gz |
simpleperf: fix callchains generated by the kernel.
The kernel stores return addrs in the callchain, but we
want the addrs of call instructions along the callchain.
So adjust callchains generated by the kernel.
Also avoid using const_cast<> in record.cpp by constructing
Record classes with non const buffers.
Bug: None.
Test: `python report_html.py --add_disassembly`.
Test: run simpleperf_unit_test.
Change-Id: I8c5f369e333ec9bc96cf5b5166ac670c3e3b5c62
Diffstat (limited to 'simpleperf/record_test.cpp')
-rw-r--r-- | simpleperf/record_test.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/simpleperf/record_test.cpp b/simpleperf/record_test.cpp index 5004ae95..5430f7be 100644 --- a/simpleperf/record_test.cpp +++ b/simpleperf/record_test.cpp @@ -30,10 +30,9 @@ class RecordTest : public ::testing::Test { event_attr.sample_id_all = 1; } - void CheckRecordMatchBinary(const Record& record) { - const char* p = record.Binary(); + void CheckRecordMatchBinary(Record& record) { std::vector<std::unique_ptr<Record>> records = - ReadRecordsFromBuffer(event_attr, p, record.size()); + ReadRecordsFromBuffer(event_attr, record.BinaryForTestingOnly(), record.size()); ASSERT_EQ(1u, records.size()); CheckRecordEqual(record, *records[0]); } @@ -151,7 +150,7 @@ TEST_F(RecordTest, SampleRecord_exclude_kernel_callchain) { SampleRecord r1(event_attr, 0, 1, 0, 0, 0, 0, 0, {PERF_CONTEXT_USER, 2}); ASSERT_EQ(1u, r1.ExcludeKernelCallChain()); ASSERT_EQ(2u, r1.ip_data.ip); - SampleRecord r2(event_attr, r1.Binary()); + SampleRecord r2(event_attr, r1.BinaryForTestingOnly()); ASSERT_EQ(1u, r.ip_data.ip); ASSERT_EQ(2u, r2.callchain_data.ip_nr); ASSERT_EQ(PERF_CONTEXT_USER, r2.callchain_data.ips[0]); @@ -160,7 +159,7 @@ TEST_F(RecordTest, SampleRecord_exclude_kernel_callchain) { SampleRecord r3(event_attr, 0, 1, 0, 0, 0, 0, 0, {1, PERF_CONTEXT_USER, 2}); ASSERT_EQ(1u, r3.ExcludeKernelCallChain()); ASSERT_EQ(2u, r3.ip_data.ip); - SampleRecord r4(event_attr, r3.Binary()); + SampleRecord r4(event_attr, r3.BinaryForTestingOnly()); ASSERT_EQ(2u, r4.ip_data.ip); ASSERT_EQ(3u, r4.callchain_data.ip_nr); ASSERT_EQ(PERF_CONTEXT_USER, r4.callchain_data.ips[0]); |