Commit | Line | Data |
---|---|---|
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 |
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; | |
393b2ad8 | 38 | u64 time; |
1fe2c106 FW |
39 | }; |
40 | ||
41 | struct 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 |
50 | struct 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 |
59 | struct sample_event{ |
60 | struct perf_event_header header; | |
61 | u64 array[]; | |
62 | }; | |
63 | ||
64 | ||
1fe2c106 FW |
65 | typedef union event_union { |
66 | struct perf_event_header header; | |
67 | struct ip_event ip; | |
68 | struct mmap_event mmap; | |
69 | struct comm_event comm; | |
70 | struct fork_event fork; | |
71 | struct lost_event lost; | |
72 | struct read_event read; | |
fd39e055 | 73 | struct sample_event sample; |
1fe2c106 | 74 | } event_t; |
66e274f3 FW |
75 | |
76 | struct map { | |
439d473b ACM |
77 | union { |
78 | struct rb_node rb_node; | |
79 | struct list_head node; | |
80 | }; | |
66e274f3 FW |
81 | u64 start; |
82 | u64 end; | |
83 | u64 pgoff; | |
84 | u64 (*map_ip)(struct map *, u64); | |
ed52ce2e | 85 | u64 (*unmap_ip)(struct map *, u64); |
66e274f3 FW |
86 | struct dso *dso; |
87 | }; | |
88 | ||
89 | static inline u64 map__map_ip(struct map *map, u64 ip) | |
90 | { | |
91 | return ip - map->start + map->pgoff; | |
92 | } | |
93 | ||
ed52ce2e ACM |
94 | static inline u64 map__unmap_ip(struct map *map, u64 ip) |
95 | { | |
96 | return ip + map->start - map->pgoff; | |
97 | } | |
98 | ||
99 | static inline u64 identity__map_ip(struct map *map __used, u64 ip) | |
66e274f3 FW |
100 | { |
101 | return ip; | |
102 | } | |
103 | ||
e4204992 ACM |
104 | struct symbol; |
105 | ||
106 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); | |
107 | ||
afb7b4f0 ACM |
108 | void map__init(struct map *self, u64 start, u64 end, u64 pgoff, |
109 | struct dso *dso); | |
00a192b3 | 110 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen); |
66e274f3 FW |
111 | struct map *map__clone(struct map *self); |
112 | int map__overlap(struct map *l, struct map *r); | |
113 | size_t map__fprintf(struct map *self, FILE *fp); | |
66bd8424 | 114 | struct symbol *map__find_symbol(struct map *self, u64 ip, symbol_filter_t filter); |
66e274f3 | 115 | |
234fbbf5 ACM |
116 | int event__synthesize_thread(pid_t pid, int (*process)(event_t *event)); |
117 | void event__synthesize_threads(int (*process)(event_t *event)); | |
118 | ||
8b40f521 | 119 | #endif /* __PERF_RECORD_H */ |