perf tools: Factorize the map helpers
[linux-2.6-block.git] / tools / perf / util / event.h
CommitLineData
66e274f3
FW
1#ifndef __PERF_EVENT_H
2#define __PERF_EVENT_H
1fe2c106 3#include "../perf.h"
66e274f3
FW
4#include "util.h"
5#include <linux/list.h>
1fe2c106
FW
6
7struct ip_event {
8 struct perf_event_header header;
9 u64 ip;
10 u32 pid, tid;
11 unsigned char __more_data[];
12};
13
14struct mmap_event {
15 struct perf_event_header header;
16 u32 pid, tid;
17 u64 start;
18 u64 len;
19 u64 pgoff;
20 char filename[PATH_MAX];
21};
22
23struct comm_event {
24 struct perf_event_header header;
25 u32 pid, tid;
26 char comm[16];
27};
28
29struct fork_event {
30 struct perf_event_header header;
31 u32 pid, ppid;
32 u32 tid, ptid;
33};
34
35struct lost_event {
36 struct perf_event_header header;
37 u64 id;
38 u64 lost;
39};
40
41struct read_event {
42 struct perf_event_header header;
43 u32 pid,tid;
44 u64 value;
45 u64 time_enabled;
46 u64 time_running;
47 u64 id;
48};
49
50typedef union event_union {
51 struct perf_event_header header;
52 struct ip_event ip;
53 struct mmap_event mmap;
54 struct comm_event comm;
55 struct fork_event fork;
56 struct lost_event lost;
57 struct read_event read;
58} event_t;
66e274f3
FW
59
60struct map {
61 struct list_head node;
62 u64 start;
63 u64 end;
64 u64 pgoff;
65 u64 (*map_ip)(struct map *, u64);
66 struct dso *dso;
67};
68
69static inline u64 map__map_ip(struct map *map, u64 ip)
70{
71 return ip - map->start + map->pgoff;
72}
73
74static inline u64 vdso__map_ip(struct map *map __used, u64 ip)
75{
76 return ip;
77}
78
79struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen);
80struct map *map__clone(struct map *self);
81int map__overlap(struct map *l, struct map *r);
82size_t map__fprintf(struct map *self, FILE *fp);
83
84#endif