diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-10-30 14:28:23 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-02 10:52:11 -0500 |
commit | afb7b4f08e274cecd8337f9444affa288a9cd4c1 (patch) | |
tree | a78e90d009d06b28113d9b6d1f01c8a6d7735d42 /tools/perf/util | |
parent | 3ed67776fc23061180896086a206a02be649dd26 (diff) |
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')
-rw-r--r-- | tools/perf/util/event.h | 2 | ||||
-rw-r--r-- | tools/perf/util/map.c | 28 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 12 |
3 files changed, 23 insertions, 19 deletions
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 3064a05f0f52..4a158a01bb97 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -105,6 +105,8 @@ struct symbol; | |||
105 | 105 | ||
106 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); | 106 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); |
107 | 107 | ||
108 | void map__init(struct map *self, u64 start, u64 end, u64 pgoff, | ||
109 | struct dso *dso); | ||
108 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, | 110 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, |
109 | unsigned int sym_priv_size); | 111 | unsigned int sym_priv_size); |
110 | struct map *map__clone(struct map *self); | 112 | struct map *map__clone(struct map *self); |
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 | ||
23 | void 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 | |||
23 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, | 35 | struct 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; |
66 | out_delete: | 74 | out_delete: |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 0273d83f728f..13677b5dbe5e 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1132,18 +1132,12 @@ static struct map *map__new2(u64 start, struct dso *dso) | |||
1132 | struct map *self = malloc(sizeof(*self)); | 1132 | struct map *self = malloc(sizeof(*self)); |
1133 | 1133 | ||
1134 | if (self != NULL) { | 1134 | if (self != NULL) { |
1135 | self->start = start; | ||
1136 | /* | 1135 | /* |
1137 | * Will be filled after we load all the symbols | 1136 | * ->end will be filled after we load all the symbols |
1138 | */ | 1137 | */ |
1139 | self->end = 0; | 1138 | map__init(self, start, 0, 0, dso); |
1140 | |||
1141 | self->pgoff = 0; | ||
1142 | self->dso = dso; | ||
1143 | self->map_ip = map__map_ip; | ||
1144 | self->unmap_ip = map__unmap_ip; | ||
1145 | RB_CLEAR_NODE(&self->rb_node); | ||
1146 | } | 1139 | } |
1140 | |||
1147 | return self; | 1141 | return self; |
1148 | } | 1142 | } |
1149 | 1143 | ||