aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/map.c')
-rw-r--r--tools/perf/util/map.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index d302e513e062..3b7ce1bf9f8e 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -20,6 +20,18 @@ static int strcommon(const char *pathname, char *cwd, int cwdlen)
20 return n; 20 return n;
21} 21}
22 22
23void map__init(struct map *self, u64 start, u64 end, u64 pgoff,
24 struct dso *dso)
25{
26 self->start = start;
27 self->end = end;
28 self->pgoff = pgoff;
29 self->dso = dso;
30 self->map_ip = map__map_ip;
31 self->unmap_ip = map__unmap_ip;
32 RB_CLEAR_NODE(&self->rb_node);
33}
34
23struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, 35struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen,
24 unsigned int sym_priv_size) 36 unsigned int sym_priv_size)
25{ 37{
@@ -28,6 +40,7 @@ struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen,
28 if (self != NULL) { 40 if (self != NULL) {
29 const char *filename = event->filename; 41 const char *filename = event->filename;
30 char newfilename[PATH_MAX]; 42 char newfilename[PATH_MAX];
43 struct dso *dso;
31 int anon; 44 int anon;
32 45
33 if (cwd) { 46 if (cwd) {
@@ -47,20 +60,15 @@ struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen,
47 filename = newfilename; 60 filename = newfilename;
48 } 61 }
49 62
50 self->start = event->start; 63 dso = dsos__findnew(filename, sym_priv_size);
51 self->end = event->start + event->len; 64 if (dso == NULL)
52 self->pgoff = event->pgoff;
53
54 self->dso = dsos__findnew(filename, sym_priv_size);
55 if (self->dso == NULL)
56 goto out_delete; 65 goto out_delete;
57 66
67 map__init(self, event->start, event->start + event->len,
68 event->pgoff, dso);
69
58 if (self->dso == vdso || anon) 70 if (self->dso == vdso || anon)
59 self->map_ip = self->unmap_ip = identity__map_ip; 71 self->map_ip = self->unmap_ip = identity__map_ip;
60 else {
61 self->map_ip = map__map_ip;
62 self->unmap_ip = map__unmap_ip;
63 }
64 } 72 }
65 return self; 73 return self;
66out_delete: 74out_delete: