diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-11-27 13:29:19 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-27 14:22:00 -0500 |
commit | 23ea4a3fadc6b1692dec935397ea15e2affc1cba (patch) | |
tree | 1f85dbff2c21846e19ab5454e04bb6bc49165282 /tools/perf/util | |
parent | 4e06255f5cf2acf6a5abfe7df8c9690463259dea (diff) |
perf symbols: Kernel_maps should be an array of MAP__NR_TYPES entries
So that we can support multiple symbol table types.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1259346563-12568-8-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/symbol.c | 51 | ||||
-rw-r--r-- | tools/perf/util/thread.h | 1 |
2 files changed, 38 insertions, 14 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 956656fcaab4..581db4c43251 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -29,6 +29,7 @@ enum dso_origin { | |||
29 | }; | 29 | }; |
30 | 30 | ||
31 | static void dsos__add(struct list_head *head, struct dso *dso); | 31 | static void dsos__add(struct list_head *head, struct dso *dso); |
32 | static struct map *kernel_maps__find_by_dso_name(const char *name); | ||
32 | static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); | 33 | static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); |
33 | static void kernel_maps__insert(struct map *map); | 34 | static void kernel_maps__insert(struct map *map); |
34 | struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr); | 35 | struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr); |
@@ -43,7 +44,7 @@ static struct symbol_conf symbol_conf__defaults = { | |||
43 | .try_vmlinux_path = true, | 44 | .try_vmlinux_path = true, |
44 | }; | 45 | }; |
45 | 46 | ||
46 | static struct rb_root kernel_maps__functions; | 47 | static struct rb_root kernel_maps[MAP__NR_TYPES]; |
47 | 48 | ||
48 | bool dso__loaded(const struct dso *self, enum map_type type) | 49 | bool dso__loaded(const struct dso *self, enum map_type type) |
49 | { | 50 | { |
@@ -78,10 +79,10 @@ static void symbols__fixup_end(struct rb_root *self) | |||
78 | curr->end = roundup(curr->start, 4096); | 79 | curr->end = roundup(curr->start, 4096); |
79 | } | 80 | } |
80 | 81 | ||
81 | static void kernel_maps__fixup_end(void) | 82 | static void __kernel_maps__fixup_end(struct rb_root *root) |
82 | { | 83 | { |
83 | struct map *prev, *curr; | 84 | struct map *prev, *curr; |
84 | struct rb_node *nd, *prevnd = rb_first(&kernel_maps__functions); | 85 | struct rb_node *nd, *prevnd = rb_first(root); |
85 | 86 | ||
86 | if (prevnd == NULL) | 87 | if (prevnd == NULL) |
87 | return; | 88 | return; |
@@ -101,6 +102,13 @@ static void kernel_maps__fixup_end(void) | |||
101 | curr->end = ~0UL; | 102 | curr->end = ~0UL; |
102 | } | 103 | } |
103 | 104 | ||
105 | static void kernel_maps__fixup_end(void) | ||
106 | { | ||
107 | int i; | ||
108 | for (i = 0; i < MAP__NR_TYPES; ++i) | ||
109 | __kernel_maps__fixup_end(&kernel_maps[i]); | ||
110 | } | ||
111 | |||
104 | static struct symbol *symbol__new(u64 start, u64 len, const char *name) | 112 | static struct symbol *symbol__new(u64 start, u64 len, const char *name) |
105 | { | 113 | { |
106 | size_t namelen = strlen(name) + 1; | 114 | size_t namelen = strlen(name) + 1; |
@@ -449,12 +457,12 @@ static int dso__load_kallsyms(struct dso *self, struct map *map, | |||
449 | return dso__split_kallsyms(self, map, filter); | 457 | return dso__split_kallsyms(self, map, filter); |
450 | } | 458 | } |
451 | 459 | ||
452 | size_t kernel_maps__fprintf(FILE *fp) | 460 | static size_t __kernel_maps__fprintf(enum map_type type, FILE *fp) |
453 | { | 461 | { |
454 | size_t printed = fprintf(fp, "Kernel maps:\n"); | 462 | size_t printed = fprintf(fp, "%s:\n", map_type__name[type]); |
455 | struct rb_node *nd; | 463 | struct rb_node *nd; |
456 | 464 | ||
457 | for (nd = rb_first(&kernel_maps__functions); nd; nd = rb_next(nd)) { | 465 | for (nd = rb_first(&kernel_maps[type]); nd; nd = rb_next(nd)) { |
458 | struct map *pos = rb_entry(nd, struct map, rb_node); | 466 | struct map *pos = rb_entry(nd, struct map, rb_node); |
459 | 467 | ||
460 | printed += fprintf(fp, "Map:"); | 468 | printed += fprintf(fp, "Map:"); |
@@ -465,6 +473,16 @@ size_t kernel_maps__fprintf(FILE *fp) | |||
465 | } | 473 | } |
466 | } | 474 | } |
467 | 475 | ||
476 | return printed; | ||
477 | } | ||
478 | |||
479 | size_t kernel_maps__fprintf(FILE *fp) | ||
480 | { | ||
481 | size_t printed = fprintf(fp, "Kernel maps:\n"); | ||
482 | int i; | ||
483 | for (i = 0; i < MAP__NR_TYPES; ++i) | ||
484 | printed += __kernel_maps__fprintf(i, fp); | ||
485 | |||
468 | return printed + fprintf(fp, "END kernel maps\n"); | 486 | return printed + fprintf(fp, "END kernel maps\n"); |
469 | } | 487 | } |
470 | 488 | ||
@@ -1191,13 +1209,14 @@ out: | |||
1191 | 1209 | ||
1192 | static void kernel_maps__insert(struct map *map) | 1210 | static void kernel_maps__insert(struct map *map) |
1193 | { | 1211 | { |
1194 | maps__insert(&kernel_maps__functions, map); | 1212 | maps__insert(&kernel_maps[map->type], map); |
1195 | } | 1213 | } |
1196 | 1214 | ||
1197 | struct symbol *kernel_maps__find_function(u64 ip, struct map **mapp, | 1215 | static struct symbol *kernel_maps__find_symbol(u64 ip, enum map_type type, |
1198 | symbol_filter_t filter) | 1216 | struct map **mapp, |
1217 | symbol_filter_t filter) | ||
1199 | { | 1218 | { |
1200 | struct map *map = maps__find(&kernel_maps__functions, ip); | 1219 | struct map *map = maps__find(&kernel_maps[type], ip); |
1201 | 1220 | ||
1202 | if (mapp) | 1221 | if (mapp) |
1203 | *mapp = map; | 1222 | *mapp = map; |
@@ -1206,17 +1225,23 @@ struct symbol *kernel_maps__find_function(u64 ip, struct map **mapp, | |||
1206 | ip = map->map_ip(map, ip); | 1225 | ip = map->map_ip(map, ip); |
1207 | return map__find_symbol(map, ip, filter); | 1226 | return map__find_symbol(map, ip, filter); |
1208 | } else | 1227 | } else |
1209 | WARN_ONCE(RB_EMPTY_ROOT(&kernel_maps__functions), | 1228 | WARN_ONCE(RB_EMPTY_ROOT(&kernel_maps[type]), |
1210 | "Empty kernel_maps, was symbol__init() called?\n"); | 1229 | "Empty kernel_maps, was symbol__init() called?\n"); |
1211 | 1230 | ||
1212 | return NULL; | 1231 | return NULL; |
1213 | } | 1232 | } |
1214 | 1233 | ||
1215 | struct map *kernel_maps__find_by_dso_name(const char *name) | 1234 | struct symbol *kernel_maps__find_function(u64 ip, struct map **mapp, |
1235 | symbol_filter_t filter) | ||
1236 | { | ||
1237 | return kernel_maps__find_symbol(ip, MAP__FUNCTION, mapp, filter); | ||
1238 | } | ||
1239 | |||
1240 | static struct map *kernel_maps__find_by_dso_name(const char *name) | ||
1216 | { | 1241 | { |
1217 | struct rb_node *nd; | 1242 | struct rb_node *nd; |
1218 | 1243 | ||
1219 | for (nd = rb_first(&kernel_maps__functions); nd; nd = rb_next(nd)) { | 1244 | for (nd = rb_first(&kernel_maps[MAP__FUNCTION]); nd; nd = rb_next(nd)) { |
1220 | struct map *map = rb_entry(nd, struct map, rb_node); | 1245 | struct map *map = rb_entry(nd, struct map, rb_node); |
1221 | 1246 | ||
1222 | if (map->dso && strcmp(map->dso->name, name) == 0) | 1247 | if (map->dso && strcmp(map->dso->name, name) == 0) |
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 74cba6487edb..54580bb80008 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h | |||
@@ -28,7 +28,6 @@ struct map *maps__find(struct rb_root *maps, u64 ip); | |||
28 | 28 | ||
29 | struct symbol *kernel_maps__find_function(const u64 ip, struct map **mapp, | 29 | struct symbol *kernel_maps__find_function(const u64 ip, struct map **mapp, |
30 | symbol_filter_t filter); | 30 | symbol_filter_t filter); |
31 | struct map *kernel_maps__find_by_dso_name(const char *name); | ||
32 | 31 | ||
33 | static inline struct map *thread__find_map(struct thread *self, u64 ip) | 32 | static inline struct map *thread__find_map(struct thread *self, u64 ip) |
34 | { | 33 | { |