summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_report.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-04-01 20:22:35 -0700
committerYabin Cui <yabinc@google.com>2016-04-05 16:52:47 -0700
commit2d6efe4b167da4e6b77f168b1820239ee65599e2 (patch)
tree631aced5c7cb30b3c93345c55e67fe329fdf1d1a /simpleperf/cmd_report.cpp
parent96e12e78722988e912664b7323341799fdd12b9b (diff)
downloadextras-2d6efe4b167da4e6b77f168b1820239ee65599e2.tar.gz
simpleperf: support reporting more than one event type.
When sampling kernel trace points, it is like to sample more than one even type. Like `simpleperf record -e kmem:mm_page_alloc,kmem:mm_page_free`. 1. change record command to dump event_id for all records. 2. change report command and record reader to support multiple event attrs. 3. hide record_cache inside EventSelectionSet. 4. add test to report multiple event types. Bug: 27403614 Change-Id: Ic22a5527d68e7a843e3cf95e85381f8ad6bcb196
Diffstat (limited to 'simpleperf/cmd_report.cpp')
-rw-r--r--simpleperf/cmd_report.cpp46
1 files changed, 26 insertions, 20 deletions
diff --git a/simpleperf/cmd_report.cpp b/simpleperf/cmd_report.cpp
index b9c3d6f7..db7f8a35 100644
--- a/simpleperf/cmd_report.cpp
+++ b/simpleperf/cmd_report.cpp
@@ -306,7 +306,7 @@ class ReportCommand : public Command {
std::string record_filename_;
ArchType record_file_arch_;
std::unique_ptr<RecordFileReader> record_file_reader_;
- perf_event_attr event_attr_;
+ std::vector<perf_event_attr> event_attrs_;
std::vector<std::unique_ptr<Displayable>> displayable_items_;
std::vector<Comparable*> comparable_items_;
ThreadTree thread_tree_;
@@ -515,15 +515,22 @@ bool ReportCommand::ParseOptions(const std::vector<std::string>& args) {
}
bool ReportCommand::ReadEventAttrFromRecordFile() {
- const std::vector<PerfFileFormat::FileAttr>& attrs = record_file_reader_->AttrSection();
- if (attrs.size() != 1) {
- LOG(ERROR) << "record file contains " << attrs.size() << " attrs";
- return false;
- }
- event_attr_ = attrs[0].attr;
- if (use_branch_address_ && (event_attr_.sample_type & PERF_SAMPLE_BRANCH_STACK) == 0) {
- LOG(ERROR) << record_filename_ << " is not recorded with branch stack sampling option.";
- return false;
+ const std::vector<PerfFileFormat::FileAttr>& file_attrs = record_file_reader_->AttrSection();
+ for (const auto& attr : file_attrs) {
+ event_attrs_.push_back(attr.attr);
+ }
+ if (use_branch_address_) {
+ bool has_branch_stack = true;
+ for (const auto& attr : event_attrs_) {
+ if ((attr.sample_type & PERF_SAMPLE_BRANCH_STACK) == 0) {
+ has_branch_stack = false;
+ break;
+ }
+ }
+ if (!has_branch_stack) {
+ LOG(ERROR) << record_filename_ << " is not recorded with branch stack sampling option.";
+ return false;
+ }
}
return true;
}
@@ -706,19 +713,18 @@ bool ReportCommand::PrintReport() {
}
void ReportCommand::PrintReportContext() {
- const EventType* event_type = FindEventTypeByConfig(event_attr_.type, event_attr_.config);
- std::string event_type_name;
- if (event_type != nullptr) {
- event_type_name = event_type->name;
- } else {
- event_type_name =
- android::base::StringPrintf("(type %u, config %llu)", event_attr_.type, event_attr_.config);
- }
if (!record_cmdline_.empty()) {
fprintf(report_fp_, "Cmdline: %s\n", record_cmdline_.c_str());
}
- fprintf(report_fp_, "Samples: %" PRIu64 " of event '%s'\n", sample_tree_->TotalSamples(),
- event_type_name.c_str());
+ for (const auto& attr : event_attrs_) {
+ const EventType* event_type = FindEventTypeByConfig(attr.type, attr.config);
+ std::string name;
+ if (event_type != nullptr) {
+ name = event_type->name;
+ }
+ fprintf(report_fp_, "Event: %s (type %u, config %llu)\n", name.c_str(), attr.type, attr.config);
+ }
+ fprintf(report_fp_, "Samples: %" PRIu64 "\n", sample_tree_->TotalSamples());
fprintf(report_fp_, "Event count: %" PRIu64 "\n\n", sample_tree_->TotalPeriod());
}