blob: 21b99e741a87c016ab383d683492dfd2aa2017b9 [file] [log] [blame]
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001#ifndef __PERF_RECORD_H
2#define __PERF_RECORD_H
John Kacur8b40f522009-09-24 18:02:18 +02003
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -02004#include <limits.h>
Arnaldo Carvalho de Melo482ad892011-12-02 11:06:37 -02005#include <stdio.h>
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -02006
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +02007#include "../perf.h"
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -02008#include "map.h"
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +02009
Peter Zijlstra18408dd2009-08-13 11:47:55 +020010/*
11 * PERF_SAMPLE_IP | PERF_SAMPLE_TID | *
12 */
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +020013struct ip_event {
14 struct perf_event_header header;
15 u64 ip;
16 u32 pid, tid;
17 unsigned char __more_data[];
18};
19
20struct mmap_event {
21 struct perf_event_header header;
22 u32 pid, tid;
23 u64 start;
24 u64 len;
25 u64 pgoff;
26 char filename[PATH_MAX];
27};
28
29struct comm_event {
30 struct perf_event_header header;
31 u32 pid, tid;
32 char comm[16];
33};
34
35struct fork_event {
36 struct perf_event_header header;
37 u32 pid, ppid;
38 u32 tid, ptid;
Arjan van de Ven393b2ad2009-09-12 07:52:47 +020039 u64 time;
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +020040};
41
42struct lost_event {
43 struct perf_event_header header;
44 u64 id;
45 u64 lost;
46};
47
Peter Zijlstra18408dd2009-08-13 11:47:55 +020048/*
49 * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
50 */
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +020051struct read_event {
52 struct perf_event_header header;
Ingo Molnardc02bf72009-09-16 13:45:00 +020053 u32 pid, tid;
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +020054 u64 value;
55 u64 time_enabled;
56 u64 time_running;
57 u64 id;
58};
59
Frederic Weisbeckera2854122011-05-21 19:33:04 +020060
61#define PERF_SAMPLE_MASK \
62 (PERF_SAMPLE_IP | PERF_SAMPLE_TID | \
63 PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \
64 PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \
65 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
66
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +090067struct sample_event {
Arjan van de Venfd39e052009-09-12 07:53:00 +020068 struct perf_event_header header;
69 u64 array[];
70};
71
Jiri Olsa0f6a3012012-08-07 15:20:45 +020072struct regs_dump {
73 u64 *regs;
74};
75
76struct stack_dump {
77 u16 offset;
78 u64 size;
79 char *data;
80};
81
Arnaldo Carvalho de Melo8d50e5b2011-01-29 13:02:00 -020082struct perf_sample {
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +090083 u64 ip;
84 u32 pid, tid;
85 u64 time;
86 u64 addr;
87 u64 id;
88 u64 stream_id;
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +090089 u64 period;
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030090 u32 cpu;
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +090091 u32 raw_size;
92 void *raw_data;
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030093 struct ip_callchain *callchain;
Roberto Agostino Vitillob5387522012-02-09 23:21:01 +010094 struct branch_stack *branch_stack;
Jiri Olsa0f6a3012012-08-07 15:20:45 +020095 struct regs_dump user_regs;
96 struct stack_dump user_stack;
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +090097};
98
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020099#define BUILD_ID_SIZE 20
100
101struct build_id_event {
102 struct perf_event_header header;
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800103 pid_t pid;
Irina Tirdea9ac3e482012-09-11 01:15:01 +0300104 u8 build_id[PERF_ALIGN(BUILD_ID_SIZE, sizeof(u64))];
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -0200105 char filename[];
106};
Arjan van de Venfd39e052009-09-12 07:53:00 +0200107
Frederic Weisbecker98402802010-05-02 22:05:29 +0200108enum perf_user_event_type { /* above any possible kernel type */
Thomas Gleixner9aefcab2010-12-07 12:48:47 +0000109 PERF_RECORD_USER_TYPE_START = 64,
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500110 PERF_RECORD_HEADER_ATTR = 64,
Tom Zanussicd19a032010-04-01 23:59:20 -0500111 PERF_RECORD_HEADER_EVENT_TYPE = 65,
Tom Zanussi92155452010-04-01 23:59:21 -0500112 PERF_RECORD_HEADER_TRACING_DATA = 66,
Tom Zanussic7929e42010-04-01 23:59:22 -0500113 PERF_RECORD_HEADER_BUILD_ID = 67,
Frederic Weisbecker98402802010-05-02 22:05:29 +0200114 PERF_RECORD_FINISHED_ROUND = 68,
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500115 PERF_RECORD_HEADER_MAX
116};
117
118struct attr_event {
119 struct perf_event_header header;
120 struct perf_event_attr attr;
121 u64 id[];
Tom Zanussi8dc58102010-04-01 23:59:15 -0500122};
123
Tom Zanussicd19a032010-04-01 23:59:20 -0500124#define MAX_EVENT_NAME 64
125
126struct perf_trace_event_type {
127 u64 event_id;
128 char name[MAX_EVENT_NAME];
129};
130
131struct event_type_event {
132 struct perf_event_header header;
133 struct perf_trace_event_type event_type;
134};
135
Tom Zanussi92155452010-04-01 23:59:21 -0500136struct tracing_data_event {
137 struct perf_event_header header;
138 u32 size;
139};
140
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200141union perf_event {
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +0200142 struct perf_event_header header;
143 struct ip_event ip;
144 struct mmap_event mmap;
145 struct comm_event comm;
146 struct fork_event fork;
147 struct lost_event lost;
148 struct read_event read;
Arjan van de Venfd39e052009-09-12 07:53:00 +0200149 struct sample_event sample;
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500150 struct attr_event attr;
Tom Zanussicd19a032010-04-01 23:59:20 -0500151 struct event_type_event event_type;
Tom Zanussi92155452010-04-01 23:59:21 -0500152 struct tracing_data_event tracing_data;
Tom Zanussic7929e42010-04-01 23:59:22 -0500153 struct build_id_event build_id;
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200154};
Frederic Weisbecker66e274f2009-08-12 11:07:25 +0200155
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200156void perf_event__print_totals(void);
Arnaldo Carvalho de Melo62daacb2009-11-27 16:29:22 -0200157
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200158struct perf_tool;
Arnaldo Carvalho de Melo401b8e12011-02-10 12:52:47 -0200159struct thread_map;
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -0200160
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200161typedef int (*perf_event__handler_t)(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200162 union perf_event *event,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200163 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200164 struct machine *machine);
Arnaldo Carvalho de Melocf553112010-01-07 19:59:40 -0200165
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200166int perf_event__synthesize_thread_map(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200167 struct thread_map *threads,
Arnaldo Carvalho de Melo7c940c12011-02-11 11:45:54 -0200168 perf_event__handler_t process,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200169 struct machine *machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200170int perf_event__synthesize_threads(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200171 perf_event__handler_t process,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200172 struct machine *machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200173int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200174 perf_event__handler_t process,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200175 struct machine *machine,
176 const char *symbol_name);
177
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200178int perf_event__synthesize_modules(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200179 perf_event__handler_t process,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200180 struct machine *machine);
181
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200182int perf_event__process_comm(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200183 union perf_event *event,
184 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200185 struct machine *machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200186int perf_event__process_lost(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200187 union perf_event *event,
188 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200189 struct machine *machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200190int perf_event__process_mmap(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200191 union perf_event *event,
192 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200193 struct machine *machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200194int perf_event__process_task(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200195 union perf_event *event,
196 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200197 struct machine *machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200198int perf_event__process(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200199 union perf_event *event,
200 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200201 struct machine *machine);
Arnaldo Carvalho de Melo62daacb2009-11-27 16:29:22 -0200202
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -0200203struct addr_location;
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200204int perf_event__preprocess_sample(const union perf_event *self,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200205 struct machine *machine,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200206 struct addr_location *al,
207 struct perf_sample *sample,
208 symbol_filter_t filter);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -0200209
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200210const char *perf_event__name(unsigned int id);
Arnaldo Carvalho de Meloc8446b92010-05-14 10:36:42 -0300211
Andrew Vagin74eec262011-11-28 12:03:31 +0300212int perf_event__synthesize_sample(union perf_event *event, u64 type,
213 const struct perf_sample *sample,
214 bool swapped);
Arnaldo Carvalho de Melod0dd74e2011-01-21 13:46:41 -0200215
Arnaldo Carvalho de Melo482ad892011-12-02 11:06:37 -0200216size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp);
217size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp);
218size_t perf_event__fprintf_task(union perf_event *event, FILE *fp);
219size_t perf_event__fprintf(union perf_event *event, FILE *fp);
220
John Kacur8b40f522009-09-24 18:02:18 +0200221#endif /* __PERF_RECORD_H */