diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-01-24 19:59:59 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-01-25 10:49:28 -0500 |
commit | 237a7e04a1a4461843a998fae78517dbbd08602e (patch) | |
tree | 04bd9e55668c067686e6be6b55e9c9f2ffec8ea9 /tools | |
parent | d8639f068a59c842882339173f58311a583c555f (diff) |
perf tools: Stop using 'self' in map.[ch]
As suggested by tglx, 'self' should be replaced by something that is
more useful.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-vse2c54m0yahx6p79tmoel03@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/map.c | 118 | ||||
-rw-r--r-- | tools/perf/util/map.h | 24 |
2 files changed, 70 insertions, 72 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index ff94425779a2..b6b163642c7d 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -29,29 +29,29 @@ static inline int is_no_dso_memory(const char *filename) | |||
29 | !strcmp(filename, "[heap]"); | 29 | !strcmp(filename, "[heap]"); |
30 | } | 30 | } |
31 | 31 | ||
32 | void map__init(struct map *self, enum map_type type, | 32 | void map__init(struct map *map, enum map_type type, |
33 | u64 start, u64 end, u64 pgoff, struct dso *dso) | 33 | u64 start, u64 end, u64 pgoff, struct dso *dso) |
34 | { | 34 | { |
35 | self->type = type; | 35 | map->type = type; |
36 | self->start = start; | 36 | map->start = start; |
37 | self->end = end; | 37 | map->end = end; |
38 | self->pgoff = pgoff; | 38 | map->pgoff = pgoff; |
39 | self->dso = dso; | 39 | map->dso = dso; |
40 | self->map_ip = map__map_ip; | 40 | map->map_ip = map__map_ip; |
41 | self->unmap_ip = map__unmap_ip; | 41 | map->unmap_ip = map__unmap_ip; |
42 | RB_CLEAR_NODE(&self->rb_node); | 42 | RB_CLEAR_NODE(&map->rb_node); |
43 | self->groups = NULL; | 43 | map->groups = NULL; |
44 | self->referenced = false; | 44 | map->referenced = false; |
45 | self->erange_warned = false; | 45 | map->erange_warned = false; |
46 | } | 46 | } |
47 | 47 | ||
48 | struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, | 48 | struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, |
49 | u64 pgoff, u32 pid, char *filename, | 49 | u64 pgoff, u32 pid, char *filename, |
50 | enum map_type type) | 50 | enum map_type type) |
51 | { | 51 | { |
52 | struct map *self = malloc(sizeof(*self)); | 52 | struct map *map = malloc(sizeof(*map)); |
53 | 53 | ||
54 | if (self != NULL) { | 54 | if (map != NULL) { |
55 | char newfilename[PATH_MAX]; | 55 | char newfilename[PATH_MAX]; |
56 | struct dso *dso; | 56 | struct dso *dso; |
57 | int anon, no_dso, vdso; | 57 | int anon, no_dso, vdso; |
@@ -74,10 +74,10 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, | |||
74 | if (dso == NULL) | 74 | if (dso == NULL) |
75 | goto out_delete; | 75 | goto out_delete; |
76 | 76 | ||
77 | map__init(self, type, start, start + len, pgoff, dso); | 77 | map__init(map, type, start, start + len, pgoff, dso); |
78 | 78 | ||
79 | if (anon || no_dso) { | 79 | if (anon || no_dso) { |
80 | self->map_ip = self->unmap_ip = identity__map_ip; | 80 | map->map_ip = map->unmap_ip = identity__map_ip; |
81 | 81 | ||
82 | /* | 82 | /* |
83 | * Set memory without DSO as loaded. All map__find_* | 83 | * Set memory without DSO as loaded. All map__find_* |
@@ -85,12 +85,12 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, | |||
85 | * unnecessary map__load warning. | 85 | * unnecessary map__load warning. |
86 | */ | 86 | */ |
87 | if (no_dso) | 87 | if (no_dso) |
88 | dso__set_loaded(dso, self->type); | 88 | dso__set_loaded(dso, map->type); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | return self; | 91 | return map; |
92 | out_delete: | 92 | out_delete: |
93 | free(self); | 93 | free(map); |
94 | return NULL; | 94 | return NULL; |
95 | } | 95 | } |
96 | 96 | ||
@@ -113,48 +113,48 @@ struct map *map__new2(u64 start, struct dso *dso, enum map_type type) | |||
113 | return map; | 113 | return map; |
114 | } | 114 | } |
115 | 115 | ||
116 | void map__delete(struct map *self) | 116 | void map__delete(struct map *map) |
117 | { | 117 | { |
118 | free(self); | 118 | free(map); |
119 | } | 119 | } |
120 | 120 | ||
121 | void map__fixup_start(struct map *self) | 121 | void map__fixup_start(struct map *map) |
122 | { | 122 | { |
123 | struct rb_root *symbols = &self->dso->symbols[self->type]; | 123 | struct rb_root *symbols = &map->dso->symbols[map->type]; |
124 | struct rb_node *nd = rb_first(symbols); | 124 | struct rb_node *nd = rb_first(symbols); |
125 | if (nd != NULL) { | 125 | if (nd != NULL) { |
126 | struct symbol *sym = rb_entry(nd, struct symbol, rb_node); | 126 | struct symbol *sym = rb_entry(nd, struct symbol, rb_node); |
127 | self->start = sym->start; | 127 | map->start = sym->start; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | void map__fixup_end(struct map *self) | 131 | void map__fixup_end(struct map *map) |
132 | { | 132 | { |
133 | struct rb_root *symbols = &self->dso->symbols[self->type]; | 133 | struct rb_root *symbols = &map->dso->symbols[map->type]; |
134 | struct rb_node *nd = rb_last(symbols); | 134 | struct rb_node *nd = rb_last(symbols); |
135 | if (nd != NULL) { | 135 | if (nd != NULL) { |
136 | struct symbol *sym = rb_entry(nd, struct symbol, rb_node); | 136 | struct symbol *sym = rb_entry(nd, struct symbol, rb_node); |
137 | self->end = sym->end; | 137 | map->end = sym->end; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | #define DSO__DELETED "(deleted)" | 141 | #define DSO__DELETED "(deleted)" |
142 | 142 | ||
143 | int map__load(struct map *self, symbol_filter_t filter) | 143 | int map__load(struct map *map, symbol_filter_t filter) |
144 | { | 144 | { |
145 | const char *name = self->dso->long_name; | 145 | const char *name = map->dso->long_name; |
146 | int nr; | 146 | int nr; |
147 | 147 | ||
148 | if (dso__loaded(self->dso, self->type)) | 148 | if (dso__loaded(map->dso, map->type)) |
149 | return 0; | 149 | return 0; |
150 | 150 | ||
151 | nr = dso__load(self->dso, self, filter); | 151 | nr = dso__load(map->dso, map, filter); |
152 | if (nr < 0) { | 152 | if (nr < 0) { |
153 | if (self->dso->has_build_id) { | 153 | if (map->dso->has_build_id) { |
154 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; | 154 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; |
155 | 155 | ||
156 | build_id__sprintf(self->dso->build_id, | 156 | build_id__sprintf(map->dso->build_id, |
157 | sizeof(self->dso->build_id), | 157 | sizeof(map->dso->build_id), |
158 | sbuild_id); | 158 | sbuild_id); |
159 | pr_warning("%s with build id %s not found", | 159 | pr_warning("%s with build id %s not found", |
160 | name, sbuild_id); | 160 | name, sbuild_id); |
@@ -184,43 +184,41 @@ int map__load(struct map *self, symbol_filter_t filter) | |||
184 | * Only applies to the kernel, as its symtabs aren't relative like the | 184 | * Only applies to the kernel, as its symtabs aren't relative like the |
185 | * module ones. | 185 | * module ones. |
186 | */ | 186 | */ |
187 | if (self->dso->kernel) | 187 | if (map->dso->kernel) |
188 | map__reloc_vmlinux(self); | 188 | map__reloc_vmlinux(map); |
189 | 189 | ||
190 | return 0; | 190 | return 0; |
191 | } | 191 | } |
192 | 192 | ||
193 | struct symbol *map__find_symbol(struct map *self, u64 addr, | 193 | struct symbol *map__find_symbol(struct map *map, u64 addr, |
194 | symbol_filter_t filter) | 194 | symbol_filter_t filter) |
195 | { | 195 | { |
196 | if (map__load(self, filter) < 0) | 196 | if (map__load(map, filter) < 0) |
197 | return NULL; | 197 | return NULL; |
198 | 198 | ||
199 | return dso__find_symbol(self->dso, self->type, addr); | 199 | return dso__find_symbol(map->dso, map->type, addr); |
200 | } | 200 | } |
201 | 201 | ||
202 | struct symbol *map__find_symbol_by_name(struct map *self, const char *name, | 202 | struct symbol *map__find_symbol_by_name(struct map *map, const char *name, |
203 | symbol_filter_t filter) | 203 | symbol_filter_t filter) |
204 | { | 204 | { |
205 | if (map__load(self, filter) < 0) | 205 | if (map__load(map, filter) < 0) |
206 | return NULL; | 206 | return NULL; |
207 | 207 | ||
208 | if (!dso__sorted_by_name(self->dso, self->type)) | 208 | if (!dso__sorted_by_name(map->dso, map->type)) |
209 | dso__sort_by_name(self->dso, self->type); | 209 | dso__sort_by_name(map->dso, map->type); |
210 | 210 | ||
211 | return dso__find_symbol_by_name(self->dso, self->type, name); | 211 | return dso__find_symbol_by_name(map->dso, map->type, name); |
212 | } | 212 | } |
213 | 213 | ||
214 | struct map *map__clone(struct map *self) | 214 | struct map *map__clone(struct map *map) |
215 | { | 215 | { |
216 | struct map *map = malloc(sizeof(*self)); | 216 | struct map *clone = malloc(sizeof(*clone)); |
217 | 217 | ||
218 | if (!map) | 218 | if (clone != NULL) |
219 | return NULL; | 219 | memcpy(clone, map, sizeof(*clone)); |
220 | 220 | ||
221 | memcpy(map, self, sizeof(*self)); | 221 | return clone; |
222 | |||
223 | return map; | ||
224 | } | 222 | } |
225 | 223 | ||
226 | int map__overlap(struct map *l, struct map *r) | 224 | int map__overlap(struct map *l, struct map *r) |
@@ -237,10 +235,10 @@ int map__overlap(struct map *l, struct map *r) | |||
237 | return 0; | 235 | return 0; |
238 | } | 236 | } |
239 | 237 | ||
240 | size_t map__fprintf(struct map *self, FILE *fp) | 238 | size_t map__fprintf(struct map *map, FILE *fp) |
241 | { | 239 | { |
242 | return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n", | 240 | return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n", |
243 | self->start, self->end, self->pgoff, self->dso->name); | 241 | map->start, map->end, map->pgoff, map->dso->name); |
244 | } | 242 | } |
245 | 243 | ||
246 | size_t map__fprintf_dsoname(struct map *map, FILE *fp) | 244 | size_t map__fprintf_dsoname(struct map *map, FILE *fp) |
@@ -528,9 +526,9 @@ static u64 map__reloc_unmap_ip(struct map *map, u64 ip) | |||
528 | return ip - (s64)map->pgoff; | 526 | return ip - (s64)map->pgoff; |
529 | } | 527 | } |
530 | 528 | ||
531 | void map__reloc_vmlinux(struct map *self) | 529 | void map__reloc_vmlinux(struct map *map) |
532 | { | 530 | { |
533 | struct kmap *kmap = map__kmap(self); | 531 | struct kmap *kmap = map__kmap(map); |
534 | s64 reloc; | 532 | s64 reloc; |
535 | 533 | ||
536 | if (!kmap->ref_reloc_sym || !kmap->ref_reloc_sym->unrelocated_addr) | 534 | if (!kmap->ref_reloc_sym || !kmap->ref_reloc_sym->unrelocated_addr) |
@@ -542,9 +540,9 @@ void map__reloc_vmlinux(struct map *self) | |||
542 | if (!reloc) | 540 | if (!reloc) |
543 | return; | 541 | return; |
544 | 542 | ||
545 | self->map_ip = map__reloc_map_ip; | 543 | map->map_ip = map__reloc_map_ip; |
546 | self->unmap_ip = map__reloc_unmap_ip; | 544 | map->unmap_ip = map__reloc_unmap_ip; |
547 | self->pgoff = reloc; | 545 | map->pgoff = reloc; |
548 | } | 546 | } |
549 | 547 | ||
550 | void maps__insert(struct rb_root *maps, struct map *map) | 548 | void maps__insert(struct rb_root *maps, struct map *map) |
@@ -567,9 +565,9 @@ void maps__insert(struct rb_root *maps, struct map *map) | |||
567 | rb_insert_color(&map->rb_node, maps); | 565 | rb_insert_color(&map->rb_node, maps); |
568 | } | 566 | } |
569 | 567 | ||
570 | void maps__remove(struct rb_root *self, struct map *map) | 568 | void maps__remove(struct rb_root *maps, struct map *map) |
571 | { | 569 | { |
572 | rb_erase(&map->rb_node, self); | 570 | rb_erase(&map->rb_node, maps); |
573 | } | 571 | } |
574 | 572 | ||
575 | struct map *maps__find(struct rb_root *maps, u64 ip) | 573 | struct map *maps__find(struct rb_root *maps, u64 ip) |
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index bcb39e2a6965..a887f2c9dfbb 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
@@ -57,9 +57,9 @@ struct map_groups { | |||
57 | struct machine *machine; | 57 | struct machine *machine; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | static inline struct kmap *map__kmap(struct map *self) | 60 | static inline struct kmap *map__kmap(struct map *map) |
61 | { | 61 | { |
62 | return (struct kmap *)(self + 1); | 62 | return (struct kmap *)(map + 1); |
63 | } | 63 | } |
64 | 64 | ||
65 | static inline u64 map__map_ip(struct map *map, u64 ip) | 65 | static inline u64 map__map_ip(struct map *map, u64 ip) |
@@ -85,27 +85,27 @@ struct symbol; | |||
85 | 85 | ||
86 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); | 86 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); |
87 | 87 | ||
88 | void map__init(struct map *self, enum map_type type, | 88 | void map__init(struct map *map, enum map_type type, |
89 | u64 start, u64 end, u64 pgoff, struct dso *dso); | 89 | u64 start, u64 end, u64 pgoff, struct dso *dso); |
90 | struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, | 90 | struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, |
91 | u64 pgoff, u32 pid, char *filename, | 91 | u64 pgoff, u32 pid, char *filename, |
92 | enum map_type type); | 92 | enum map_type type); |
93 | struct map *map__new2(u64 start, struct dso *dso, enum map_type type); | 93 | struct map *map__new2(u64 start, struct dso *dso, enum map_type type); |
94 | void map__delete(struct map *self); | 94 | void map__delete(struct map *map); |
95 | struct map *map__clone(struct map *self); | 95 | struct map *map__clone(struct map *map); |
96 | int map__overlap(struct map *l, struct map *r); | 96 | int map__overlap(struct map *l, struct map *r); |
97 | size_t map__fprintf(struct map *self, FILE *fp); | 97 | size_t map__fprintf(struct map *map, FILE *fp); |
98 | size_t map__fprintf_dsoname(struct map *map, FILE *fp); | 98 | size_t map__fprintf_dsoname(struct map *map, FILE *fp); |
99 | 99 | ||
100 | int map__load(struct map *self, symbol_filter_t filter); | 100 | int map__load(struct map *map, symbol_filter_t filter); |
101 | struct symbol *map__find_symbol(struct map *self, | 101 | struct symbol *map__find_symbol(struct map *map, |
102 | u64 addr, symbol_filter_t filter); | 102 | u64 addr, symbol_filter_t filter); |
103 | struct symbol *map__find_symbol_by_name(struct map *self, const char *name, | 103 | struct symbol *map__find_symbol_by_name(struct map *map, const char *name, |
104 | symbol_filter_t filter); | 104 | symbol_filter_t filter); |
105 | void map__fixup_start(struct map *self); | 105 | void map__fixup_start(struct map *map); |
106 | void map__fixup_end(struct map *self); | 106 | void map__fixup_end(struct map *map); |
107 | 107 | ||
108 | void map__reloc_vmlinux(struct map *self); | 108 | void map__reloc_vmlinux(struct map *map); |
109 | 109 | ||
110 | size_t __map_groups__fprintf_maps(struct map_groups *mg, | 110 | size_t __map_groups__fprintf_maps(struct map_groups *mg, |
111 | enum map_type type, int verbose, FILE *fp); | 111 | enum map_type type, int verbose, FILE *fp); |