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 | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame^] | 6 | #include <linux/rbtree.h> |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 7 | |
Frederic Weisbecker | 0f25bfc | 2009-08-16 19:56:54 +0200 | [diff] [blame] | 8 | enum { |
| 9 | SHOW_KERNEL = 1, |
| 10 | SHOW_USER = 2, |
| 11 | SHOW_HV = 4, |
| 12 | }; |
| 13 | |
Peter Zijlstra | 18408dd | 2009-08-13 11:47:55 +0200 | [diff] [blame] | 14 | /* |
| 15 | * PERF_SAMPLE_IP | PERF_SAMPLE_TID | * |
| 16 | */ |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 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; |
Arjan van de Ven | 393b2ad | 2009-09-12 07:52:47 +0200 | [diff] [blame] | 43 | u64 time; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | struct lost_event { |
| 47 | struct perf_event_header header; |
| 48 | u64 id; |
| 49 | u64 lost; |
| 50 | }; |
| 51 | |
Peter Zijlstra | 18408dd | 2009-08-13 11:47:55 +0200 | [diff] [blame] | 52 | /* |
| 53 | * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID |
| 54 | */ |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 55 | struct read_event { |
| 56 | struct perf_event_header header; |
Ingo Molnar | dc02bf7 | 2009-09-16 13:45:00 +0200 | [diff] [blame] | 57 | u32 pid, tid; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 58 | u64 value; |
| 59 | u64 time_enabled; |
| 60 | u64 time_running; |
| 61 | u64 id; |
| 62 | }; |
| 63 | |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 64 | struct sample_event{ |
| 65 | struct perf_event_header header; |
| 66 | u64 array[]; |
| 67 | }; |
| 68 | |
| 69 | |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 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; |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 78 | struct sample_event sample; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 79 | } event_t; |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 80 | |
| 81 | struct map { |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame^] | 82 | struct rb_node rb_node; |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 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 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 105 | #endif /* __PERF_RECORD_H */ |