aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-27 13:29:16 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-27 14:21:59 -0500
commit3610583c29563e23dd038d2870f59c88438bf7a3 (patch)
treecb8d20387bcc8e37b0db2432f339387a4fd52150 /tools/perf/util/symbol.c
parent605ca4ba017455d39ac6991c58eb1e80fb8af48d (diff)
perf symbols: Add a 'type' field to struct map
That way we will be able to check if the right symtab is loaded in the underlying DSO. 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-5-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r--tools/perf/util/symbol.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 0b8a298d41ad..45a4a9a7618b 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -29,7 +29,7 @@ enum dso_origin {
29}; 29};
30 30
31static void dsos__add(struct list_head *head, struct dso *dso); 31static void dsos__add(struct list_head *head, struct dso *dso);
32static struct map *map__new2(u64 start, struct dso *dso); 32static struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
33static void kernel_maps__insert(struct map *map); 33static void kernel_maps__insert(struct map *map);
34static int dso__load_kernel_sym(struct dso *self, struct map *map, 34static int dso__load_kernel_sym(struct dso *self, struct map *map,
35 symbol_filter_t filter); 35 symbol_filter_t filter);
@@ -45,6 +45,16 @@ static struct symbol_conf symbol_conf__defaults = {
45 45
46static struct rb_root kernel_maps__functions; 46static struct rb_root kernel_maps__functions;
47 47
48bool dso__loaded(const struct dso *self, enum map_type type)
49{
50 return self->loaded & (1 << type);
51}
52
53static void dso__set_loaded(struct dso *self, enum map_type type)
54{
55 self->loaded |= (1 << type);
56}
57
48static void symbols__fixup_end(struct rb_root *self) 58static void symbols__fixup_end(struct rb_root *self)
49{ 59{
50 struct rb_node *nd, *prevnd = rb_first(self); 60 struct rb_node *nd, *prevnd = rb_first(self);
@@ -387,7 +397,7 @@ static int kernel_maps__split_kallsyms(symbol_filter_t filter)
387 if (dso == NULL) 397 if (dso == NULL)
388 return -1; 398 return -1;
389 399
390 map = map__new2(pos->start, dso); 400 map = map__new2(pos->start, dso, MAP__FUNCTION);
391 if (map == NULL) { 401 if (map == NULL) {
392 dso__delete(dso); 402 dso__delete(dso);
393 return -1; 403 return -1;
@@ -846,7 +856,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
846 curr_dso = dso__new(dso_name); 856 curr_dso = dso__new(dso_name);
847 if (curr_dso == NULL) 857 if (curr_dso == NULL)
848 goto out_elf_end; 858 goto out_elf_end;
849 curr_map = map__new2(start, curr_dso); 859 curr_map = map__new2(start, curr_dso,
860 MAP__FUNCTION);
850 if (curr_map == NULL) { 861 if (curr_map == NULL) {
851 dso__delete(curr_dso); 862 dso__delete(curr_dso);
852 goto out_elf_end; 863 goto out_elf_end;
@@ -1076,7 +1087,7 @@ int dso__load(struct dso *self, struct map *map, symbol_filter_t filter)
1076 int ret = -1; 1087 int ret = -1;
1077 int fd; 1088 int fd;
1078 1089
1079 self->loaded = 1; 1090 dso__set_loaded(self, map->type);
1080 1091
1081 if (self->kernel) 1092 if (self->kernel)
1082 return dso__load_kernel_sym(self, map, filter); 1093 return dso__load_kernel_sym(self, map, filter);
@@ -1275,7 +1286,7 @@ static int dsos__set_modules_path(void)
1275 * they are loaded) and for vmlinux, where only after we load all the 1286 * they are loaded) and for vmlinux, where only after we load all the
1276 * symbols we'll know where it starts and ends. 1287 * symbols we'll know where it starts and ends.
1277 */ 1288 */
1278static struct map *map__new2(u64 start, struct dso *dso) 1289static struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
1279{ 1290{
1280 struct map *self = malloc(sizeof(*self)); 1291 struct map *self = malloc(sizeof(*self));
1281 1292
@@ -1283,7 +1294,7 @@ static struct map *map__new2(u64 start, struct dso *dso)
1283 /* 1294 /*
1284 * ->end will be filled after we load all the symbols 1295 * ->end will be filled after we load all the symbols
1285 */ 1296 */
1286 map__init(self, start, 0, 0, dso); 1297 map__init(self, type, start, 0, 0, dso);
1287 } 1298 }
1288 1299
1289 return self; 1300 return self;
@@ -1333,7 +1344,7 @@ static int kernel_maps__create_module_maps(void)
1333 if (dso == NULL) 1344 if (dso == NULL)
1334 goto out_delete_line; 1345 goto out_delete_line;
1335 1346
1336 map = map__new2(start, dso); 1347 map = map__new2(start, dso, MAP__FUNCTION);
1337 if (map == NULL) { 1348 if (map == NULL) {
1338 dso__delete(dso); 1349 dso__delete(dso);
1339 goto out_delete_line; 1350 goto out_delete_line;
@@ -1394,7 +1405,7 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
1394 if (fd < 0) 1405 if (fd < 0)
1395 return -1; 1406 return -1;
1396 1407
1397 self->loaded = 1; 1408 dso__set_loaded(self, map->type);
1398 err = dso__load_sym(self, map, self->long_name, fd, filter, 1, 0); 1409 err = dso__load_sym(self, map, self->long_name, fd, filter, 1, 0);
1399 1410
1400 close(fd); 1411 close(fd);
@@ -1522,7 +1533,7 @@ static int kernel_maps__create_kernel_map(const struct symbol_conf *conf)
1522 if (kernel == NULL) 1533 if (kernel == NULL)
1523 return -1; 1534 return -1;
1524 1535
1525 kernel_map__functions = map__new2(0, kernel); 1536 kernel_map__functions = map__new2(0, kernel, MAP__FUNCTION);
1526 if (kernel_map__functions == NULL) 1537 if (kernel_map__functions == NULL)
1527 goto out_delete_kernel_dso; 1538 goto out_delete_kernel_dso;
1528 1539
@@ -1533,7 +1544,7 @@ static int kernel_maps__create_kernel_map(const struct symbol_conf *conf)
1533 vdso = dso__new("[vdso]"); 1544 vdso = dso__new("[vdso]");
1534 if (vdso == NULL) 1545 if (vdso == NULL)
1535 goto out_delete_kernel_map; 1546 goto out_delete_kernel_map;
1536 vdso->loaded = 1; 1547 dso__set_loaded(vdso, MAP__FUNCTION);
1537 1548
1538 if (sysfs__read_build_id("/sys/kernel/notes", kernel->build_id, 1549 if (sysfs__read_build_id("/sys/kernel/notes", kernel->build_id,
1539 sizeof(kernel->build_id)) == 0) 1550 sizeof(kernel->build_id)) == 0)