aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c79
1 files changed, 1 insertions, 78 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index fee663adeea2..543c4524f8c2 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -51,83 +51,6 @@ struct sym_ext {
51 char *path; 51 char *path;
52}; 52};
53 53
54struct map {
55 struct list_head node;
56 u64 start;
57 u64 end;
58 u64 pgoff;
59 u64 (*map_ip)(struct map *, u64);
60 struct dso *dso;
61};
62
63static u64 map__map_ip(struct map *map, u64 ip)
64{
65 return ip - map->start + map->pgoff;
66}
67
68static u64 vdso__map_ip(struct map *map __used, u64 ip)
69{
70 return ip;
71}
72
73static struct map *map__new(struct mmap_event *event)
74{
75 struct map *self = malloc(sizeof(*self));
76
77 if (self != NULL) {
78 const char *filename = event->filename;
79
80 self->start = event->start;
81 self->end = event->start + event->len;
82 self->pgoff = event->pgoff;
83
84 self->dso = dsos__findnew(filename);
85 if (self->dso == NULL)
86 goto out_delete;
87
88 if (self->dso == vdso)
89 self->map_ip = vdso__map_ip;
90 else
91 self->map_ip = map__map_ip;
92 }
93 return self;
94out_delete:
95 free(self);
96 return NULL;
97}
98
99static struct map *map__clone(struct map *self)
100{
101 struct map *map = malloc(sizeof(*self));
102
103 if (!map)
104 return NULL;
105
106 memcpy(map, self, sizeof(*self));
107
108 return map;
109}
110
111static int map__overlap(struct map *l, struct map *r)
112{
113 if (l->start > r->start) {
114 struct map *t = l;
115 l = r;
116 r = t;
117 }
118
119 if (l->end > r->start)
120 return 1;
121
122 return 0;
123}
124
125static size_t map__fprintf(struct map *self, FILE *fp)
126{
127 return fprintf(fp, " %Lx-%Lx %Lx %s\n",
128 self->start, self->end, self->pgoff, self->dso->name);
129}
130
131 54
132struct thread { 55struct thread {
133 struct rb_node rb_node; 56 struct rb_node rb_node;
@@ -797,7 +720,7 @@ static int
797process_mmap_event(event_t *event, unsigned long offset, unsigned long head) 720process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
798{ 721{
799 struct thread *thread = threads__findnew(event->mmap.pid); 722 struct thread *thread = threads__findnew(event->mmap.pid);
800 struct map *map = map__new(&event->mmap); 723 struct map *map = map__new(&event->mmap, NULL, 0);
801 724
802 dprintf("%p [%p]: PERF_EVENT_MMAP %d: [%p(%p) @ %p]: %s\n", 725 dprintf("%p [%p]: PERF_EVENT_MMAP %d: [%p(%p) @ %p]: %s\n",
803 (void *)(offset + head), 726 (void *)(offset + head),