Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1 | #ifndef __PERF_RECORD_H |
| 2 | #define __PERF_RECORD_H |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 3 | |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 4 | #include "../perf.h" |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 5 | #include "util.h" |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 6 | #include <linux/list.h> |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 7 | #include <linux/rbtree.h> |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 8 | |
Peter Zijlstra | 18408dd | 2009-08-13 11:47:55 +0200 | [diff] [blame] | 9 | /* |
| 10 | * PERF_SAMPLE_IP | PERF_SAMPLE_TID | * |
| 11 | */ |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 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; |
Arjan van de Ven | 393b2ad | 2009-09-12 07:52:47 +0200 | [diff] [blame] | 38 | u64 time; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | struct lost_event { |
| 42 | struct perf_event_header header; |
| 43 | u64 id; |
| 44 | u64 lost; |
| 45 | }; |
| 46 | |
Peter Zijlstra | 18408dd | 2009-08-13 11:47:55 +0200 | [diff] [blame] | 47 | /* |
| 48 | * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID |
| 49 | */ |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 50 | struct read_event { |
| 51 | struct perf_event_header header; |
Ingo Molnar | dc02bf7 | 2009-09-16 13:45:00 +0200 | [diff] [blame] | 52 | u32 pid, tid; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 53 | u64 value; |
| 54 | u64 time_enabled; |
| 55 | u64 time_running; |
| 56 | u64 id; |
| 57 | }; |
| 58 | |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 59 | struct sample_event{ |
| 60 | struct perf_event_header header; |
| 61 | u64 array[]; |
| 62 | }; |
| 63 | |
Arnaldo Carvalho de Melo | 8d06367 | 2009-11-04 18:50:43 -0200 | [diff] [blame^] | 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 | }; |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 71 | |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 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; |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 80 | struct sample_event sample; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 81 | } event_t; |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 82 | |
| 83 | struct map { |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 84 | union { |
| 85 | struct rb_node rb_node; |
| 86 | struct list_head node; |
| 87 | }; |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 88 | u64 start; |
| 89 | u64 end; |
| 90 | u64 pgoff; |
| 91 | u64 (*map_ip)(struct map *, u64); |
Arnaldo Carvalho de Melo | ed52ce2 | 2009-10-19 17:17:57 -0200 | [diff] [blame] | 92 | u64 (*unmap_ip)(struct map *, u64); |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 93 | struct dso *dso; |
| 94 | }; |
| 95 | |
| 96 | static inline u64 map__map_ip(struct map *map, u64 ip) |
| 97 | { |
| 98 | return ip - map->start + map->pgoff; |
| 99 | } |
| 100 | |
Arnaldo Carvalho de Melo | ed52ce2 | 2009-10-19 17:17:57 -0200 | [diff] [blame] | 101 | static inline u64 map__unmap_ip(struct map *map, u64 ip) |
| 102 | { |
| 103 | return ip + map->start - map->pgoff; |
| 104 | } |
| 105 | |
| 106 | static inline u64 identity__map_ip(struct map *map __used, u64 ip) |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 107 | { |
| 108 | return ip; |
| 109 | } |
| 110 | |
Arnaldo Carvalho de Melo | e420499 | 2009-10-20 14:25:40 -0200 | [diff] [blame] | 111 | struct symbol; |
| 112 | |
| 113 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); |
| 114 | |
Arnaldo Carvalho de Melo | afb7b4f | 2009-10-30 16:28:23 -0200 | [diff] [blame] | 115 | void map__init(struct map *self, u64 start, u64 end, u64 pgoff, |
| 116 | struct dso *dso); |
Arnaldo Carvalho de Melo | 00a192b | 2009-10-30 16:28:24 -0200 | [diff] [blame] | 117 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen); |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 118 | struct map *map__clone(struct map *self); |
| 119 | int map__overlap(struct map *l, struct map *r); |
| 120 | size_t map__fprintf(struct map *self, FILE *fp); |
Arnaldo Carvalho de Melo | 66bd842 | 2009-10-28 21:51:21 -0200 | [diff] [blame] | 121 | struct symbol *map__find_symbol(struct map *self, u64 ip, symbol_filter_t filter); |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 122 | |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 123 | int event__synthesize_thread(pid_t pid, int (*process)(event_t *event)); |
| 124 | void event__synthesize_threads(int (*process)(event_t *event)); |
| 125 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 126 | #endif /* __PERF_RECORD_H */ |