diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-10-30 16:28:23 -0200 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-02 16:52:11 +0100 |
commit | afb7b4f08e274cecd8337f9444affa288a9cd4c1 (patch) | |
tree | a78e90d009d06b28113d9b6d1f01c8a6d7735d42 /tools/perf/util/map.c | |
parent | 3ed67776fc23061180896086a206a02be649dd26 (diff) | |
download | lwn-afb7b4f08e274cecd8337f9444affa288a9cd4c1.tar.gz lwn-afb7b4f08e274cecd8337f9444affa288a9cd4c1.zip |
perf tools: Factor out the map initialization
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1256927305-4628-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/map.c')
-rw-r--r-- | tools/perf/util/map.c | 28 |
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) return n; } +void map__init(struct map *self, u64 start, u64 end, u64 pgoff, + struct dso *dso) +{ + self->start = start; + self->end = end; + self->pgoff = pgoff; + self->dso = dso; + self->map_ip = map__map_ip; + self->unmap_ip = map__unmap_ip; + RB_CLEAR_NODE(&self->rb_node); +} + struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, unsigned int sym_priv_size) { @@ -28,6 +40,7 @@ struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, if (self != NULL) { const char *filename = event->filename; char newfilename[PATH_MAX]; + struct dso *dso; int anon; if (cwd) { @@ -47,20 +60,15 @@ struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, filename = newfilename; } - self->start = event->start; - self->end = event->start + event->len; - self->pgoff = event->pgoff; - - self->dso = dsos__findnew(filename, sym_priv_size); - if (self->dso == NULL) + dso = dsos__findnew(filename, sym_priv_size); + if (dso == NULL) goto out_delete; + map__init(self, event->start, event->start + event->len, + event->pgoff, dso); + if (self->dso == vdso || anon) self->map_ip = self->unmap_ip = identity__map_ip; - else { - self->map_ip = map__map_ip; - self->unmap_ip = map__unmap_ip; - } } return self; out_delete: |