diff options
author | Yabin Cui <yabinc@google.com> | 2017-11-09 21:18:11 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-11-09 21:18:11 +0000 |
commit | 310c03406a502a847b961eb56a7492229b7940cb (patch) | |
tree | 875d4f572e91bf1d1facb5ffae0090c239aab16b | |
parent | 21a1e790919ef4bf3400d0220d7c9d1b161c6bac (diff) | |
parent | bf1dd36838f4244e0934ca3c193889ae74a7c116 (diff) | |
download | extras-310c03406a502a847b961eb56a7492229b7940cb.tar.gz |
Merge "simpleperf: fix parsing perf.data generated by --trace-offcpu option."
-rw-r--r-- | simpleperf/report_lib_interface.cpp | 9 | ||||
-rw-r--r-- | simpleperf/scripts/test.py | 1 |
2 files changed, 8 insertions, 2 deletions
diff --git a/simpleperf/report_lib_interface.cpp b/simpleperf/report_lib_interface.cpp index c7a606c9..e3af8a88 100644 --- a/simpleperf/report_lib_interface.cpp +++ b/simpleperf/report_lib_interface.cpp @@ -285,8 +285,13 @@ Event* ReportLib::GetEventOfCurrentSample() { event_attrs_.push_back(attr); } } - size_t attr_index = - record_file_reader_->GetAttrIndexOfRecord(current_record_.get()); + size_t attr_index; + if (trace_offcpu_) { + // For trace-offcpu, we don't want to show event sched:sched_switch. + attr_index = 0; + } else { + attr_index = record_file_reader_->GetAttrIndexOfRecord(current_record_.get()); + } current_event_.name = event_attrs_[attr_index].name.c_str(); update_flag_ |= UPDATE_FLAG_OF_EVENT; } diff --git a/simpleperf/scripts/test.py b/simpleperf/scripts/test.py index ab9a6b30..9924e99a 100644 --- a/simpleperf/scripts/test.py +++ b/simpleperf/scripts/test.py @@ -868,6 +868,7 @@ class TestReportLib(unittest.TestCase): if callchain.entries[i].symbol.symbol_name == sleep_function_name: sleep_function_period += sample.period break + self.assertEqual(self.report_lib.GetEventOfCurrentSample().name, 'cpu-cycles') sleep_percentage = float(sleep_function_period) / total_period self.assertGreater(sleep_percentage, 0.30) |