c31a5da6458b38f205b9e0acdb360f1e95447152
[safe/jmp/linux-2.6] / tools / perf / util / event.h
1 #ifndef __PERF_RECORD_H
2 #define __PERF_RECORD_H
3
4 #include "../perf.h"
5 #include "util.h"
6 #include <linux/list.h>
7
8 enum {
9         SHOW_KERNEL     = 1,
10         SHOW_USER       = 2,
11         SHOW_HV         = 4,
12 };
13
14 /*
15  * PERF_SAMPLE_IP | PERF_SAMPLE_TID | *
16  */
17 struct ip_event {
18         struct perf_event_header header;
19         u64 ip;
20         u32 pid, tid;
21         unsigned char __more_data[];
22 };
23
24 struct mmap_event {
25         struct perf_event_header header;
26         u32 pid, tid;
27         u64 start;
28         u64 len;
29         u64 pgoff;
30         char filename[PATH_MAX];
31 };
32
33 struct comm_event {
34         struct perf_event_header header;
35         u32 pid, tid;
36         char comm[16];
37 };
38
39 struct fork_event {
40         struct perf_event_header header;
41         u32 pid, ppid;
42         u32 tid, ptid;
43         u64 time;
44 };
45
46 struct lost_event {
47         struct perf_event_header header;
48         u64 id;
49         u64 lost;
50 };
51
52 /*
53  * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
54  */
55 struct read_event {
56         struct perf_event_header header;
57         u32 pid, tid;
58         u64 value;
59         u64 time_enabled;
60         u64 time_running;
61         u64 id;
62 };
63
64 struct sample_event{
65         struct perf_event_header        header;
66         u64 array[];
67 };
68
69
70 typedef union event_union {
71         struct perf_event_header        header;
72         struct ip_event                 ip;
73         struct mmap_event               mmap;
74         struct comm_event               comm;
75         struct fork_event               fork;
76         struct lost_event               lost;
77         struct read_event               read;
78         struct sample_event             sample;
79 } event_t;
80
81 struct map {
82         struct list_head        node;
83         u64                     start;
84         u64                     end;
85         u64                     pgoff;
86         u64                     (*map_ip)(struct map *, u64);
87         struct dso              *dso;
88 };
89
90 static inline u64 map__map_ip(struct map *map, u64 ip)
91 {
92         return ip - map->start + map->pgoff;
93 }
94
95 static inline u64 vdso__map_ip(struct map *map __used, u64 ip)
96 {
97         return ip;
98 }
99
100 struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen);
101 struct map *map__clone(struct map *self);
102 int map__overlap(struct map *l, struct map *r);
103 size_t map__fprintf(struct map *self, FILE *fp);
104
105 #endif /* __PERF_RECORD_H */