summaryrefslogtreecommitdiff
path: root/simpleperf/record_file_reader.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2018-07-11 13:04:16 -0700
committerYabin Cui <yabinc@google.com>2018-07-11 15:03:58 -0700
commitd2d824c76435e344dc2d225ca8f1f565bbc809e8 (patch)
tree11839eabad305479df8527edec3852a1cfcdc3d6 /simpleperf/record_file_reader.cpp
parent975117333acc9eebf287904427f92de7ea057ceb (diff)
downloadextras-d2d824c76435e344dc2d225ca8f1f565bbc809e8.tar.gz
simpleperf: fix an abort caused by ip zero in kernel callchain.
When the kernel fails to unwind a kernel callchain, it may generate zero ip address. RecordFileReader::ReadRecord() removes zero ips in kernel callchain by adjusting r->callchain_data.ip_nr. However, it will make a check in SampleRecord::BuildBinaryWithNewCallChain() abort. This patch fixes it by moving the logic of erasing zero ip addresses to SampleRecord::AdjustCallChainGeneratedByKernel(), which replaces zero ip address with a context value, which will not be shown to user. Also change SampleRecord::ExcludeKernelCallChain() to support consecutive context values in callchain, which may be generated by SampleRecord::AdjustCallChainGeneratedByKernel(). Bug: none Test: run simpleperf_unit_test Change-Id: I85e5bfc4bf2bfddfbd2925748fa89d6e28d69ffc
Diffstat (limited to 'simpleperf/record_file_reader.cpp')
-rw-r--r--simpleperf/record_file_reader.cpp14
1 files changed, 0 insertions, 14 deletions
diff --git a/simpleperf/record_file_reader.cpp b/simpleperf/record_file_reader.cpp
index 46b72665..1703c0a7 100644
--- a/simpleperf/record_file_reader.cpp
+++ b/simpleperf/record_file_reader.cpp
@@ -234,20 +234,6 @@ bool RecordFileReader::ReadRecord(std::unique_ptr<Record>& record) {
}
if (record->type() == SIMPLE_PERF_RECORD_EVENT_ID) {
ProcessEventIdRecord(*static_cast<EventIdRecord*>(record.get()));
- } else if (record->type() == PERF_RECORD_SAMPLE) {
- SampleRecord* r = static_cast<SampleRecord*>(record.get());
- // Although we have removed ip == 0 callchains when recording dwarf based callgraph,
- // stack frame based callgraph can also generate ip == 0 callchains. Remove them here
- // to avoid caller's effort.
- if (r->sample_type & PERF_SAMPLE_CALLCHAIN) {
- size_t i;
- for (i = 0; i < r->callchain_data.ip_nr; ++i) {
- if (r->callchain_data.ips[i] == 0) {
- break;
- }
- }
- r->callchain_data.ip_nr = i;
- }
}
}
return true;