diff options
author | Yabin Cui <yabinc@google.com> | 2016-06-01 17:29:06 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2016-06-03 15:24:03 -0700 |
commit | 4f41df6f68efc3b9b534014a8cfb6ee8ac4d5c91 (patch) | |
tree | 9cd04ed0e963ba2ce911087cf414df6cce35daf6 /simpleperf/record_file.h | |
parent | 471ec606874a7224e304482f5fa9cc7d207d26b8 (diff) | |
download | extras-4f41df6f68efc3b9b534014a8cfb6ee8ac4d5c91.tar.gz |
simpleperf: dump tracing data when needed.
When monitoring tracepoint events, dump tracing data to perf.data
can enable reporting on a different machine.
Bug: 27403614
Change-Id: Ie1af624717a245cacbeb44b4c1bcd499fc9ad8db
Diffstat (limited to 'simpleperf/record_file.h')
-rw-r--r-- | simpleperf/record_file.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/simpleperf/record_file.h b/simpleperf/record_file.h index 3005dee6..a0af30e4 100644 --- a/simpleperf/record_file.h +++ b/simpleperf/record_file.h @@ -100,15 +100,22 @@ class RecordFileReader { return header_; } - const std::vector<PerfFileFormat::FileAttr>& AttrSection() const { - return file_attrs_; + std::vector<AttrWithId> AttrSection() const { + std::vector<AttrWithId> result(file_attrs_.size()); + for (size_t i = 0; i < file_attrs_.size(); ++i) { + result[i].attr = &file_attrs_[i].attr; + result[i].ids = event_ids_for_file_attrs_[i]; + } + return result; } const std::map<int, PerfFileFormat::SectionDesc>& FeatureSectionDescriptors() const { return feature_section_descriptors_; } - - bool ReadIdsForAttr(const PerfFileFormat::FileAttr& attr, std::vector<uint64_t>* ids); + bool HasFeature(int feature) const { + return feature_section_descriptors_.find(feature) != feature_section_descriptors_.end(); + } + bool ReadFeatureSection(int feature, std::vector<char>* data); // If sorted is true, sort records before passing them to callback function. bool ReadDataSection(std::function<bool(std::unique_ptr<Record>)> callback, bool sorted = true); std::vector<std::string> ReadCmdlineFeature(); @@ -123,8 +130,8 @@ class RecordFileReader { RecordFileReader(const std::string& filename, FILE* fp); bool ReadHeader(); bool ReadAttrSection(); + bool ReadIdsForAttr(const PerfFileFormat::FileAttr& attr, std::vector<uint64_t>* ids); bool ReadFeatureSectionDescriptors(); - bool ReadFeatureSection(int feature, std::vector<char>* data); std::unique_ptr<Record> ReadRecord(); const std::string filename_; @@ -132,6 +139,7 @@ class RecordFileReader { PerfFileFormat::FileHeader header_; std::vector<PerfFileFormat::FileAttr> file_attrs_; + std::vector<std::vector<uint64_t>> event_ids_for_file_attrs_; std::unordered_map<uint64_t, perf_event_attr*> event_id_to_attr_map_; std::map<int, PerfFileFormat::SectionDesc> feature_section_descriptors_; |