blob: 669409d35710c7c970281d38b0e8224e0c3c25c6 [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>
5
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +02006#include "../perf.h"
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -02007#include "map.h"
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +02008
Peter Zijlstra18408dd2009-08-13 11:47:55 +02009/*
10 * PERF_SAMPLE_IP | PERF_SAMPLE_TID | *
11 */
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +020012struct ip_event {
13 struct perf_event_header header;
14 u64 ip;
15 u32 pid, tid;
16 unsigned char __more_data[];
17};
18
19struct mmap_event {
20 struct perf_event_header header;
21 u32 pid, tid;
22 u64 start;
23 u64 len;
24 u64 pgoff;
25 char filename[PATH_MAX];
26};
27
28struct comm_event {
29 struct perf_event_header header;
30 u32 pid, tid;
31 char comm[16];
32};
33
34struct fork_event {
35 struct perf_event_header header;
36 u32 pid, ppid;
37 u32 tid, ptid;
Arjan van de Ven393b2ad2009-09-12 07:52:47 +020038 u64 time;
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +020039};
40
41struct lost_event {
42 struct perf_event_header header;
43 u64 id;
44 u64 lost;
45};
46
Peter Zijlstra18408dd2009-08-13 11:47:55 +020047/*
48 * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
49 */
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +020050struct read_event {
51 struct perf_event_header header;
Ingo Molnardc02bf72009-09-16 13:45:00 +020052 u32 pid, tid;
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +020053 u64 value;
54 u64 time_enabled;
55 u64 time_running;
56 u64 id;
57};
58
Frederic Weisbeckera2854122011-05-21 19:33:04 +020059
60#define PERF_SAMPLE_MASK \
61 (PERF_SAMPLE_IP | PERF_SAMPLE_TID | \
62 PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \
63 PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \
64 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
65
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +090066struct sample_event {
Arjan van de Venfd39e052009-09-12 07:53:00 +020067 struct perf_event_header header;
68 u64 array[];
69};
70
Arnaldo Carvalho de Melo8d50e5b2011-01-29 13:02:00 -020071struct perf_sample {
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +090072 u64 ip;
73 u32 pid, tid;
74 u64 time;
75 u64 addr;
76 u64 id;
77 u64 stream_id;
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +090078 u64 period;
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030079 u32 cpu;
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +090080 u32 raw_size;
81 void *raw_data;
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030082 struct ip_callchain *callchain;
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +090083};
84
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020085#define BUILD_ID_SIZE 20
86
87struct build_id_event {
88 struct perf_event_header header;
Zhang, Yanmina1645ce2010-04-19 13:32:50 +080089 pid_t pid;
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020090 u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))];
91 char filename[];
92};
Arjan van de Venfd39e052009-09-12 07:53:00 +020093
Frederic Weisbecker98402802010-05-02 22:05:29 +020094enum perf_user_event_type { /* above any possible kernel type */
Thomas Gleixner9aefcab2010-12-07 12:48:47 +000095 PERF_RECORD_USER_TYPE_START = 64,
Tom Zanussi2c46dbb2010-04-01 23:59:19 -050096 PERF_RECORD_HEADER_ATTR = 64,
Tom Zanussicd19a032010-04-01 23:59:20 -050097 PERF_RECORD_HEADER_EVENT_TYPE = 65,
Tom Zanussi92155452010-04-01 23:59:21 -050098 PERF_RECORD_HEADER_TRACING_DATA = 66,
Tom Zanussic7929e42010-04-01 23:59:22 -050099 PERF_RECORD_HEADER_BUILD_ID = 67,
Frederic Weisbecker98402802010-05-02 22:05:29 +0200100 PERF_RECORD_FINISHED_ROUND = 68,
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500101 PERF_RECORD_HEADER_MAX
102};
103
104struct attr_event {
105 struct perf_event_header header;
106 struct perf_event_attr attr;
107 u64 id[];
Tom Zanussi8dc58102010-04-01 23:59:15 -0500108};
109
Tom Zanussicd19a032010-04-01 23:59:20 -0500110#define MAX_EVENT_NAME 64
111
112struct perf_trace_event_type {
113 u64 event_id;
114 char name[MAX_EVENT_NAME];
115};
116
117struct event_type_event {
118 struct perf_event_header header;
119 struct perf_trace_event_type event_type;
120};
121
Tom Zanussi92155452010-04-01 23:59:21 -0500122struct tracing_data_event {
123 struct perf_event_header header;
124 u32 size;
125};
126
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200127union perf_event {
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +0200128 struct perf_event_header header;
129 struct ip_event ip;
130 struct mmap_event mmap;
131 struct comm_event comm;
132 struct fork_event fork;
133 struct lost_event lost;
134 struct read_event read;
Arjan van de Venfd39e052009-09-12 07:53:00 +0200135 struct sample_event sample;
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500136 struct attr_event attr;
Tom Zanussicd19a032010-04-01 23:59:20 -0500137 struct event_type_event event_type;
Tom Zanussi92155452010-04-01 23:59:21 -0500138 struct tracing_data_event tracing_data;
Tom Zanussic7929e42010-04-01 23:59:22 -0500139 struct build_id_event build_id;
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200140};
Frederic Weisbecker66e274f2009-08-12 11:07:25 +0200141
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200142void perf_event__print_totals(void);
Arnaldo Carvalho de Melo62daacb2009-11-27 16:29:22 -0200143
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200144struct perf_event_ops;
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -0200145struct perf_session;
Arnaldo Carvalho de Melo401b8e12011-02-10 12:52:47 -0200146struct thread_map;
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -0200147
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200148typedef int (*perf_event__handler_t)(struct perf_event_ops *ops,
149 union perf_event *event,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200150 struct perf_sample *sample,
Arnaldo Carvalho de Melo640c03c2010-12-02 14:10:21 -0200151 struct perf_session *session);
Arnaldo Carvalho de Melocf553112010-01-07 19:59:40 -0200152
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200153int perf_event__synthesize_thread_map(struct perf_event_ops *ops,
154 struct thread_map *threads,
Arnaldo Carvalho de Melo7c940c12011-02-11 11:45:54 -0200155 perf_event__handler_t process,
156 struct perf_session *session);
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200157int perf_event__synthesize_threads(struct perf_event_ops *ops,
158 perf_event__handler_t process,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200159 struct perf_session *session);
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200160int perf_event__synthesize_kernel_mmap(struct perf_event_ops *ops,
161 perf_event__handler_t process,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200162 struct perf_session *session,
163 struct machine *machine,
164 const char *symbol_name);
165
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200166int perf_event__synthesize_modules(struct perf_event_ops *ops,
167 perf_event__handler_t process,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200168 struct perf_session *session,
169 struct machine *machine);
170
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200171int perf_event__process_comm(struct perf_event_ops *ops,
172 union perf_event *event,
173 struct perf_sample *sample,
Arnaldo Carvalho de Melod8f66242009-12-13 19:50:24 -0200174 struct perf_session *session);
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200175int perf_event__process_lost(struct perf_event_ops *ops,
176 union perf_event *event,
177 struct perf_sample *sample,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200178 struct perf_session *session);
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200179int perf_event__process_mmap(struct perf_event_ops *ops,
180 union perf_event *event,
181 struct perf_sample *sample,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200182 struct perf_session *session);
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200183int perf_event__process_task(struct perf_event_ops *ops,
184 union perf_event *event,
185 struct perf_sample *sample,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200186 struct perf_session *session);
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200187int perf_event__process(struct perf_event_ops *ops,
188 union perf_event *event,
189 struct perf_sample *sample,
Arnaldo Carvalho de Melo640c03c2010-12-02 14:10:21 -0200190 struct perf_session *session);
Arnaldo Carvalho de Melo62daacb2009-11-27 16:29:22 -0200191
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -0200192struct addr_location;
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200193int perf_event__preprocess_sample(const union perf_event *self,
194 struct perf_session *session,
195 struct addr_location *al,
196 struct perf_sample *sample,
197 symbol_filter_t filter);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -0200198
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200199const char *perf_event__name(unsigned int id);
Arnaldo Carvalho de Meloc8446b92010-05-14 10:36:42 -0300200
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200201int perf_event__parse_sample(const union perf_event *event, u64 type,
Frederic Weisbeckera2854122011-05-21 19:33:04 +0200202 int sample_size, bool sample_id_all,
David Ahern936be502011-09-06 09:12:26 -0600203 struct perf_sample *sample, bool swapped);
Arnaldo Carvalho de Melod0dd74e2011-01-21 13:46:41 -0200204
John Kacur8b40f522009-09-24 18:02:18 +0200205#endif /* __PERF_RECORD_H */