Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1 | #ifndef __PERF_RECORD_H |
| 2 | #define __PERF_RECORD_H |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 3 | #include "../perf.h" |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 4 | #include "util.h" |
| 5 | #include <linux/list.h> |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 6 | |
Frederic Weisbecker | 0f25bfc | 2009-08-16 19:56:54 +0200 | [diff] [blame] | 7 | enum { |
| 8 | SHOW_KERNEL = 1, |
| 9 | SHOW_USER = 2, |
| 10 | SHOW_HV = 4, |
| 11 | }; |
| 12 | |
Peter Zijlstra | 18408dd | 2009-08-13 11:47:55 +0200 | [diff] [blame] | 13 | /* |
| 14 | * PERF_SAMPLE_IP | PERF_SAMPLE_TID | * |
| 15 | */ |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 16 | struct ip_event { |
| 17 | struct perf_event_header header; |
| 18 | u64 ip; |
| 19 | u32 pid, tid; |
| 20 | unsigned char __more_data[]; |
| 21 | }; |
| 22 | |
| 23 | struct mmap_event { |
| 24 | struct perf_event_header header; |
| 25 | u32 pid, tid; |
| 26 | u64 start; |
| 27 | u64 len; |
| 28 | u64 pgoff; |
| 29 | char filename[PATH_MAX]; |
| 30 | }; |
| 31 | |
| 32 | struct comm_event { |
| 33 | struct perf_event_header header; |
| 34 | u32 pid, tid; |
| 35 | char comm[16]; |
| 36 | }; |
| 37 | |
| 38 | struct fork_event { |
| 39 | struct perf_event_header header; |
| 40 | u32 pid, ppid; |
| 41 | u32 tid, ptid; |
Arjan van de Ven | 393b2ad | 2009-09-12 07:52:47 +0200 | [diff] [blame] | 42 | u64 time; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | struct lost_event { |
| 46 | struct perf_event_header header; |
| 47 | u64 id; |
| 48 | u64 lost; |
| 49 | }; |
| 50 | |
Peter Zijlstra | 18408dd | 2009-08-13 11:47:55 +0200 | [diff] [blame] | 51 | /* |
| 52 | * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID |
| 53 | */ |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 54 | struct read_event { |
| 55 | struct perf_event_header header; |
Ingo Molnar | dc02bf7 | 2009-09-16 13:45:00 +0200 | [diff] [blame] | 56 | u32 pid, tid; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 57 | u64 value; |
| 58 | u64 time_enabled; |
| 59 | u64 time_running; |
| 60 | u64 id; |
| 61 | }; |
| 62 | |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 63 | struct sample_event{ |
| 64 | struct perf_event_header header; |
| 65 | u64 array[]; |
| 66 | }; |
| 67 | |
| 68 | |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 69 | typedef union event_union { |
| 70 | struct perf_event_header header; |
| 71 | struct ip_event ip; |
| 72 | struct mmap_event mmap; |
| 73 | struct comm_event comm; |
| 74 | struct fork_event fork; |
| 75 | struct lost_event lost; |
| 76 | struct read_event read; |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 77 | struct sample_event sample; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 78 | } event_t; |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 79 | |
| 80 | struct map { |
| 81 | struct list_head node; |
| 82 | u64 start; |
| 83 | u64 end; |
| 84 | u64 pgoff; |
| 85 | u64 (*map_ip)(struct map *, u64); |
| 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 | |
| 94 | static inline u64 vdso__map_ip(struct map *map __used, u64 ip) |
| 95 | { |
| 96 | return ip; |
| 97 | } |
| 98 | |
| 99 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen); |
| 100 | struct map *map__clone(struct map *self); |
| 101 | int map__overlap(struct map *l, struct map *r); |
| 102 | size_t map__fprintf(struct map *self, FILE *fp); |
| 103 | |
| 104 | #endif |