operf_event.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef OPERF_EVENT_H_
00015 #define OPERF_EVENT_H_
00016
00017 #include <limits.h>
00018 #include <linux/perf_event.h>
00019 #include <vector>
00020 #include "op_types.h"
00021
00022
00023 #define OP_MAX_EVT_NAME_LEN 64
00024 #define OP_MAX_UM_NAME_LEN 64
00025 #define OP_MAX_NUM_EVENTS 512
00026
00027 struct ip_event {
00028 struct perf_event_header header;
00029 u64 ip;
00030 u32 pid, tid;
00031 unsigned char __more_data[];
00032 };
00033
00034 struct mmap_event {
00035 struct perf_event_header header;
00036 u32 pid, tid;
00037 u64 start;
00038 u64 len;
00039 u64 pgoff;
00040 char filename[PATH_MAX];
00041 };
00042
00043 struct comm_event {
00044 struct perf_event_header header;
00045 u32 pid, tid;
00046 char comm[16];
00047 };
00048
00049 struct fork_event {
00050 struct perf_event_header header;
00051 u32 pid, ppid;
00052 u32 tid, ptid;
00053 u64 time;
00054 };
00055
00056 struct lost_event {
00057 struct perf_event_header header;
00058 u64 id;
00059 u64 lost;
00060 };
00061
00062 struct read_event {
00063 struct perf_event_header header;
00064 u32 pid, tid;
00065 u64 value;
00066 u64 time_enabled;
00067 u64 time_running;
00068 u64 id;
00069 };
00070
00071 struct sample_event {
00072 struct perf_event_header header;
00073 u64 array[];
00074 };
00075
00076 typedef union event_union {
00077 struct perf_event_header header;
00078 struct ip_event ip;
00079 struct mmap_event mmap;
00080 struct comm_event comm;
00081 struct fork_event fork;
00082 struct lost_event lost;
00083 struct read_event read;
00084 struct sample_event sample;
00085 } event_t;
00086
00087 struct mmap_data {
00088 void *base;
00089 u64 mask;
00090 u64 prev;
00091 };
00092
00093 struct ip_callchain {
00094 u64 nr;
00095 u64 ips[0];
00096 };
00097 struct sample_data {
00098 u64 ip;
00099 u32 pid, tid;
00100 u64 time;
00101 u64 addr;
00102 u64 id;
00103 u32 cpu;
00104 u64 period;
00105 u32 raw_size;
00106 void *raw_data;
00107 struct ip_callchain * callchain;
00108 };
00109
00110
00111 typedef struct operf_event {
00112 char name[OP_MAX_EVT_NAME_LEN];
00113
00114 u64 evt_code;
00115
00116
00117
00118
00119
00120 u64 op_evt_code;
00121
00122 unsigned long evt_um;
00123 char um_name[OP_MAX_UM_NAME_LEN];
00124 unsigned long count;
00125 u32 counter;
00126 bool no_kernel;
00127 bool no_user;
00128 bool no_hv;
00129 } operf_event_t;
00130
00131 struct mmap_info {
00132 u64 offset, file_data_size, file_data_offset, head;
00133 char * buf;
00134 int traceFD;
00135 };
00136
00137
00138 struct op_file_section {
00139 u64 size;
00140 u64 offset;
00141 };
00142
00143 struct op_file_attr {
00144 struct perf_event_attr attr;
00145 struct op_file_section ids;
00146 };
00147
00148 struct op_header_evt_info {
00149 struct perf_event_attr attr;
00150 std::vector<u64> ids;
00151 off_t id_offset;
00152 };
00153
00154 struct OP_file_header {
00155 u64 magic;
00156 u64 size;
00157 u64 attr_size;
00158 struct op_file_section attrs;
00159 struct op_file_section data;
00160 };
00161
00162 struct OP_header {
00163 struct op_header_evt_info h_attrs[OP_MAX_NUM_EVENTS];
00164 off_t attr_offset;
00165 off_t data_offset;
00166 u64 data_size;
00167 };
00168
00169
00170 #endif