perf timechart: Fix header handling
[linux-2.6-block.git] / tools / perf / util / event.h
CommitLineData
cdd6c482
IM
1#ifndef __PERF_RECORD_H
2#define __PERF_RECORD_H
8b40f521 3
1fe2c106 4#include "../perf.h"
66e274f3 5#include "util.h"
439d473b 6#include <linux/list.h>
1b46cddf 7#include <linux/rbtree.h>
1fe2c106 8
18408ddc
PZ
9/*
10 * PERF_SAMPLE_IP | PERF_SAMPLE_TID | *
11 */
1fe2c106
FW
12struct 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;
393b2ad8 38 u64 time;
1fe2c106
FW
39};
40
41struct lost_event {
42 struct perf_event_header header;
43 u64 id;
44 u64 lost;
45};
46
18408ddc
PZ
47/*
48 * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
49 */
1fe2c106
FW
50struct read_event {
51 struct perf_event_header header;
dc02bf71 52 u32 pid, tid;
1fe2c106
FW
53 u64 value;
54 u64 time_enabled;
55 u64 time_running;
56 u64 id;
57};
58
fd39e055
AV
59struct sample_event{
60 struct perf_event_header header;
61 u64 array[];
62};
63
8d06367f
ACM
64#define BUILD_ID_SIZE 20
65
66struct build_id_event {
67 struct perf_event_header header;
68 u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))];
69 char filename[];
70};
fd39e055 71
1fe2c106
FW
72typedef union event_union {
73 struct perf_event_header header;
74 struct ip_event ip;
75 struct mmap_event mmap;
76 struct comm_event comm;
77 struct fork_event fork;
78 struct lost_event lost;
79 struct read_event read;
fd39e055 80 struct sample_event sample;
1fe2c106 81} event_t;
66e274f3 82
62daacb5
ACM
83struct events_stats {
84 unsigned long total;
85 unsigned long lost;
86};
87
88void event__print_totals(void);
89
3610583c 90enum map_type {
6a4694a4
ACM
91 MAP__FUNCTION = 0,
92
93 MAP__NR_TYPES,
3610583c
ACM
94};
95
66e274f3 96struct map {
439d473b
ACM
97 union {
98 struct rb_node rb_node;
99 struct list_head node;
100 };
66e274f3
FW
101 u64 start;
102 u64 end;
3610583c 103 enum map_type type;
66e274f3
FW
104 u64 pgoff;
105 u64 (*map_ip)(struct map *, u64);
ed52ce2e 106 u64 (*unmap_ip)(struct map *, u64);
66e274f3
FW
107 struct dso *dso;
108};
109
110static inline u64 map__map_ip(struct map *map, u64 ip)
111{
112 return ip - map->start + map->pgoff;
113}
114
ed52ce2e
ACM
115static inline u64 map__unmap_ip(struct map *map, u64 ip)
116{
117 return ip + map->start - map->pgoff;
118}
119
120static inline u64 identity__map_ip(struct map *map __used, u64 ip)
66e274f3
FW
121{
122 return ip;
123}
124
e4204992
ACM
125struct symbol;
126
127typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
128
3610583c
ACM
129void map__init(struct map *self, enum map_type type,
130 u64 start, u64 end, u64 pgoff, struct dso *dso);
131struct map *map__new(struct mmap_event *event, enum map_type,
132 char *cwd, int cwdlen);
c338aee8 133void map__delete(struct map *self);
66e274f3
FW
134struct map *map__clone(struct map *self);
135int map__overlap(struct map *l, struct map *r);
136size_t map__fprintf(struct map *self, FILE *fp);
6a4694a4
ACM
137struct symbol *map__find_symbol(struct map *self, u64 addr,
138 symbol_filter_t filter);
139void map__fixup_start(struct map *self);
140void map__fixup_end(struct map *self);
66e274f3 141
234fbbf5
ACM
142int event__synthesize_thread(pid_t pid, int (*process)(event_t *event));
143void event__synthesize_threads(int (*process)(event_t *event));
144
62daacb5
ACM
145extern char *event__cwd;
146extern int event__cwdlen;
147extern struct events_stats event__stats;
148extern unsigned long event__total[PERF_RECORD_MAX];
149
150int event__process_comm(event_t *self);
151int event__process_lost(event_t *self);
152int event__process_mmap(event_t *self);
153int event__process_task(event_t *self);
154
1ed091c4
ACM
155struct addr_location;
156int event__preprocess_sample(const event_t *self, struct addr_location *al,
157 symbol_filter_t filter);
158
8b40f521 159#endif /* __PERF_RECORD_H */