]> Pileus Git - ~andy/linux/blob - tools/perf/util/event.h
3ae3c964c901d5a2ead2b69d376a48ecdc3f1fde
[~andy/linux] / 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 #include <linux/rbtree.h>
8
9 /*
10  * PERF_SAMPLE_IP | PERF_SAMPLE_TID | *
11  */
12 struct ip_event {
13         struct perf_event_header header;
14         u64 ip;
15         u32 pid, tid;
16         unsigned char __more_data[];
17 };
18
19 struct 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
28 struct comm_event {
29         struct perf_event_header header;
30         u32 pid, tid;
31         char comm[16];
32 };
33
34 struct fork_event {
35         struct perf_event_header header;
36         u32 pid, ppid;
37         u32 tid, ptid;
38         u64 time;
39 };
40
41 struct lost_event {
42         struct perf_event_header header;
43         u64 id;
44         u64 lost;
45 };
46
47 /*
48  * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
49  */
50 struct read_event {
51         struct perf_event_header header;
52         u32 pid, tid;
53         u64 value;
54         u64 time_enabled;
55         u64 time_running;
56         u64 id;
57 };
58
59 struct sample_event{
60         struct perf_event_header        header;
61         u64 array[];
62 };
63
64 #define BUILD_ID_SIZE 20
65
66 struct build_id_event {
67         struct perf_event_header header;
68         u8                       build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))];
69         char                     filename[];
70 };
71
72 typedef 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;
80         struct sample_event             sample;
81 } event_t;
82
83 enum map_type {
84         MAP__FUNCTION = 0,
85
86         MAP__NR_TYPES,
87 };
88
89 struct map {
90         union {
91                 struct rb_node  rb_node;
92                 struct list_head node;
93         };
94         u64                     start;
95         u64                     end;
96         enum map_type           type;
97         u64                     pgoff;
98         u64                     (*map_ip)(struct map *, u64);
99         u64                     (*unmap_ip)(struct map *, u64);
100         struct dso              *dso;
101 };
102
103 static inline u64 map__map_ip(struct map *map, u64 ip)
104 {
105         return ip - map->start + map->pgoff;
106 }
107
108 static inline u64 map__unmap_ip(struct map *map, u64 ip)
109 {
110         return ip + map->start - map->pgoff;
111 }
112
113 static inline u64 identity__map_ip(struct map *map __used, u64 ip)
114 {
115         return ip;
116 }
117
118 struct symbol;
119
120 typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
121
122 void map__init(struct map *self, enum map_type type,
123                u64 start, u64 end, u64 pgoff, struct dso *dso);
124 struct map *map__new(struct mmap_event *event, enum map_type,
125                      char *cwd, int cwdlen);
126 void map__delete(struct map *self);
127 struct map *map__clone(struct map *self);
128 int map__overlap(struct map *l, struct map *r);
129 size_t map__fprintf(struct map *self, FILE *fp);
130 struct symbol *map__find_symbol(struct map *self, u64 addr,
131                                 symbol_filter_t filter);
132 void map__fixup_start(struct map *self);
133 void map__fixup_end(struct map *self);
134
135 int event__synthesize_thread(pid_t pid, int (*process)(event_t *event));
136 void event__synthesize_threads(int (*process)(event_t *event));
137
138 #endif /* __PERF_RECORD_H */