#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,
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
virtual uint64_t Timestamp() const;
virtual uint32_t Cpu() const;
+ virtual uint64_t Id() const;
protected:
void UpdateBinary(const char* new_binary);
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;
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
explicit KernelSymbolRecord(const char* p);
- KernelSymbolRecord(const std::string& kallsyms);
+ explicit KernelSymbolRecord(const std::string& kallsyms);
protected:
void DumpData(size_t indent) const override;
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;
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