OSDN Git Service

resolve merge conflicts of d38ce6ce to oc-dev-plus-aosp
[android-x86/system-extras.git] / simpleperf / record.h
index abfc163..d6ee2ce 100644 (file)
 #include "build_id.h"
 #include "perf_event.h"
 
-struct KernelMmap;
-struct ModuleMmap;
-struct ThreadComm;
-struct ThreadMmap;
-
 enum user_record_type {
   PERF_RECORD_USER_DEFINED_TYPE_START = 64,
   PERF_RECORD_ATTR = 64,
@@ -45,10 +40,12 @@ enum user_record_type {
 
   SIMPLE_PERF_RECORD_TYPE_START = 32768,
   SIMPLE_PERF_RECORD_KERNEL_SYMBOL,
+  // TODO: remove DsoRecord and SymbolRecord.
   SIMPLE_PERF_RECORD_DSO,
   SIMPLE_PERF_RECORD_SYMBOL,
   SIMPLE_PERF_RECORD_SPLIT,
   SIMPLE_PERF_RECORD_SPLIT_END,
+  SIMPLE_PERF_RECORD_EVENT_ID,
 };
 
 // perf_event_header uses u16 to store record size. However, that is not
@@ -250,6 +247,7 @@ struct Record {
 
   virtual uint64_t Timestamp() const;
   virtual uint32_t Cpu() const;
+  virtual uint64_t Id() const;
 
  protected:
   void UpdateBinary(const char* new_binary);
@@ -318,7 +316,7 @@ struct CommRecord : public Record {
   CommRecord(const perf_event_attr& attr, const char* p);
 
   CommRecord(const perf_event_attr& attr, uint32_t pid, uint32_t tid,
-             const std::string& comm, uint64_t event_id);
+             const std::string& comm, uint64_t event_id, uint64_t time);
 
  protected:
   void DumpData(size_t indent) const override;
@@ -384,9 +382,14 @@ struct SampleRecord : public Record {
   PerfSampleStackUserType stack_user_data;  // Valid if PERF_SAMPLE_STACK_USER.
 
   SampleRecord(const perf_event_attr& attr, const char* p);
+  SampleRecord(const perf_event_attr& attr, uint64_t id, uint64_t ip,
+               uint32_t pid, uint32_t tid, uint64_t time, uint32_t cpu,
+               uint64_t period, const std::vector<uint64_t>& ips);
+
   void ReplaceRegAndStackWithCallChain(const std::vector<uint64_t>& ips);
   uint64_t Timestamp() const override;
   uint32_t Cpu() const override;
+  uint64_t Id() const override;
 
   uint64_t GetValidStackSize() const {
     // If stack_user_data.dyn_size == 0, it may be because the kernel misses
@@ -424,7 +427,7 @@ struct KernelSymbolRecord : public Record {
 
   explicit KernelSymbolRecord(const char* p);
 
-  KernelSymbolRecord(const std::string& kallsyms);
+  explicit KernelSymbolRecord(const std::string& kallsyms);
 
  protected:
   void DumpData(size_t indent) const override;
@@ -466,7 +469,22 @@ struct TracingDataRecord : public Record {
 
   explicit TracingDataRecord(const char* p);
 
-  TracingDataRecord(const std::vector<char>& tracing_data);
+  explicit TracingDataRecord(const std::vector<char>& tracing_data);
+
+ protected:
+  void DumpData(size_t indent) const override;
+};
+
+struct EventIdRecord : public Record {
+  uint64_t count;
+  struct EventIdData {
+    uint64_t attr_id;
+    uint64_t event_id;
+  } const* data;
+
+  explicit EventIdRecord(const char* p);
+
+  explicit EventIdRecord(const std::vector<uint64_t>& data);
 
  protected:
   void DumpData(size_t indent) const override;
@@ -497,6 +515,11 @@ std::unique_ptr<Record> ReadRecordFromOwnedBuffer(const perf_event_attr& attr,
 std::vector<std::unique_ptr<Record>> ReadRecordsFromBuffer(
     const perf_event_attr& attr, const char* buf, size_t buf_size);
 
+// Read one record from the buffer pointed by [p]. But the record doesn't
+// own the buffer.
+std::unique_ptr<Record> ReadRecordFromBuffer(const perf_event_attr& attr,
+                                             const char* p);
+
 // RecordCache is a cache used when receiving records from the kernel.
 // It sorts received records based on type and timestamp, and pops records
 // in sorted order. Records from the kernel need to be sorted because