diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-11-27 13:29:14 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-27 14:21:58 -0500 |
commit | b0da954a4759ac19fb80a959e53b613fe376bc12 (patch) | |
tree | e3c43cc6a8aab3a148ab9e25d45ffcb390c55533 | |
parent | 61f37a824d6782503ff66bf653f2e07902b641a1 (diff) |
perf symbols: Split the dsos list into kernel and user parts
We don't need to look at modules in dsos__findnew because the
kernel events come only with user DSOs. Also we need a way to
list just the module DSOs so that we can create multiple sets of
maps, now that we will support maps for the variables in a
symtab.
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-3-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | tools/perf/util/header.c | 12 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 56 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 2 |
3 files changed, 48 insertions, 22 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 4b586569bb02..4805e6dfd23c 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -185,11 +185,11 @@ static int do_write(int fd, const void *buf, size_t size) | |||
185 | return 0; | 185 | return 0; |
186 | } | 186 | } |
187 | 187 | ||
188 | static int dsos__write_buildid_table(int fd) | 188 | static int __dsos__write_buildid_table(struct list_head *head, int fd) |
189 | { | 189 | { |
190 | struct dso *pos; | 190 | struct dso *pos; |
191 | 191 | ||
192 | list_for_each_entry(pos, &dsos, node) { | 192 | list_for_each_entry(pos, head, node) { |
193 | int err; | 193 | int err; |
194 | struct build_id_event b; | 194 | struct build_id_event b; |
195 | size_t len; | 195 | size_t len; |
@@ -212,6 +212,14 @@ static int dsos__write_buildid_table(int fd) | |||
212 | return 0; | 212 | return 0; |
213 | } | 213 | } |
214 | 214 | ||
215 | static int dsos__write_buildid_table(int fd) | ||
216 | { | ||
217 | int err = __dsos__write_buildid_table(&dsos__kernel, fd); | ||
218 | if (err == 0) | ||
219 | err = __dsos__write_buildid_table(&dsos__user, fd); | ||
220 | return err; | ||
221 | } | ||
222 | |||
215 | static int perf_header__adds_write(struct perf_header *self, int fd) | 223 | static int perf_header__adds_write(struct perf_header *self, int fd) |
216 | { | 224 | { |
217 | int nr_sections; | 225 | int nr_sections; |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 687fb7f8cc03..dc25231813ee 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -28,8 +28,7 @@ enum dso_origin { | |||
28 | DSO__ORIG_NOT_FOUND, | 28 | DSO__ORIG_NOT_FOUND, |
29 | }; | 29 | }; |
30 | 30 | ||
31 | static void dsos__add(struct dso *dso); | 31 | static void dsos__add(struct list_head *head, struct dso *dso); |
32 | static struct dso *dsos__find(const char *name); | ||
33 | static struct map *map__new2(u64 start, struct dso *dso); | 32 | static struct map *map__new2(u64 start, struct dso *dso); |
34 | static void kernel_maps__insert(struct map *map); | 33 | static void kernel_maps__insert(struct map *map); |
35 | static int dso__load_kernel_sym(struct dso *self, struct map *map, | 34 | static int dso__load_kernel_sym(struct dso *self, struct map *map, |
@@ -855,7 +854,7 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, | |||
855 | curr_map->unmap_ip = identity__map_ip; | 854 | curr_map->unmap_ip = identity__map_ip; |
856 | curr_dso->origin = DSO__ORIG_KERNEL; | 855 | curr_dso->origin = DSO__ORIG_KERNEL; |
857 | kernel_maps__insert(curr_map); | 856 | kernel_maps__insert(curr_map); |
858 | dsos__add(curr_dso); | 857 | dsos__add(&dsos__kernel, curr_dso); |
859 | } else | 858 | } else |
860 | curr_dso = curr_map->dso; | 859 | curr_dso = curr_map->dso; |
861 | 860 | ||
@@ -907,12 +906,12 @@ static bool dso__build_id_equal(const struct dso *self, u8 *build_id) | |||
907 | return memcmp(self->build_id, build_id, sizeof(self->build_id)) == 0; | 906 | return memcmp(self->build_id, build_id, sizeof(self->build_id)) == 0; |
908 | } | 907 | } |
909 | 908 | ||
910 | bool dsos__read_build_ids(void) | 909 | static bool __dsos__read_build_ids(struct list_head *head) |
911 | { | 910 | { |
912 | bool have_build_id = false; | 911 | bool have_build_id = false; |
913 | struct dso *pos; | 912 | struct dso *pos; |
914 | 913 | ||
915 | list_for_each_entry(pos, &dsos, node) | 914 | list_for_each_entry(pos, head, node) |
916 | if (filename__read_build_id(pos->long_name, pos->build_id, | 915 | if (filename__read_build_id(pos->long_name, pos->build_id, |
917 | sizeof(pos->build_id)) > 0) { | 916 | sizeof(pos->build_id)) > 0) { |
918 | have_build_id = true; | 917 | have_build_id = true; |
@@ -922,6 +921,12 @@ bool dsos__read_build_ids(void) | |||
922 | return have_build_id; | 921 | return have_build_id; |
923 | } | 922 | } |
924 | 923 | ||
924 | bool dsos__read_build_ids(void) | ||
925 | { | ||
926 | return __dsos__read_build_ids(&dsos__kernel) || | ||
927 | __dsos__read_build_ids(&dsos__user); | ||
928 | } | ||
929 | |||
925 | /* | 930 | /* |
926 | * Align offset to 4 bytes as needed for note name and descriptor data. | 931 | * Align offset to 4 bytes as needed for note name and descriptor data. |
927 | */ | 932 | */ |
@@ -1343,7 +1348,7 @@ static int kernel_maps__create_module_maps(void) | |||
1343 | 1348 | ||
1344 | dso->origin = DSO__ORIG_KMODULE; | 1349 | dso->origin = DSO__ORIG_KMODULE; |
1345 | kernel_maps__insert(map); | 1350 | kernel_maps__insert(map); |
1346 | dsos__add(dso); | 1351 | dsos__add(&dsos__kernel, dso); |
1347 | } | 1352 | } |
1348 | 1353 | ||
1349 | free(line); | 1354 | free(line); |
@@ -1445,19 +1450,20 @@ out_fixup: | |||
1445 | return err; | 1450 | return err; |
1446 | } | 1451 | } |
1447 | 1452 | ||
1448 | LIST_HEAD(dsos); | 1453 | LIST_HEAD(dsos__user); |
1454 | LIST_HEAD(dsos__kernel); | ||
1449 | struct dso *vdso; | 1455 | struct dso *vdso; |
1450 | 1456 | ||
1451 | static void dsos__add(struct dso *dso) | 1457 | static void dsos__add(struct list_head *head, struct dso *dso) |
1452 | { | 1458 | { |
1453 | list_add_tail(&dso->node, &dsos); | 1459 | list_add_tail(&dso->node, head); |
1454 | } | 1460 | } |
1455 | 1461 | ||
1456 | static struct dso *dsos__find(const char *name) | 1462 | static struct dso *dsos__find(struct list_head *head, const char *name) |
1457 | { | 1463 | { |
1458 | struct dso *pos; | 1464 | struct dso *pos; |
1459 | 1465 | ||
1460 | list_for_each_entry(pos, &dsos, node) | 1466 | list_for_each_entry(pos, head, node) |
1461 | if (strcmp(pos->name, name) == 0) | 1467 | if (strcmp(pos->name, name) == 0) |
1462 | return pos; | 1468 | return pos; |
1463 | return NULL; | 1469 | return NULL; |
@@ -1465,12 +1471,12 @@ static struct dso *dsos__find(const char *name) | |||
1465 | 1471 | ||
1466 | struct dso *dsos__findnew(const char *name) | 1472 | struct dso *dsos__findnew(const char *name) |
1467 | { | 1473 | { |
1468 | struct dso *dso = dsos__find(name); | 1474 | struct dso *dso = dsos__find(&dsos__user, name); |
1469 | 1475 | ||
1470 | if (!dso) { | 1476 | if (!dso) { |
1471 | dso = dso__new(name); | 1477 | dso = dso__new(name); |
1472 | if (dso != NULL) { | 1478 | if (dso != NULL) { |
1473 | dsos__add(dso); | 1479 | dsos__add(&dsos__user, dso); |
1474 | dso__set_basename(dso); | 1480 | dso__set_basename(dso); |
1475 | } | 1481 | } |
1476 | } | 1482 | } |
@@ -1478,26 +1484,38 @@ struct dso *dsos__findnew(const char *name) | |||
1478 | return dso; | 1484 | return dso; |
1479 | } | 1485 | } |
1480 | 1486 | ||
1481 | void dsos__fprintf(FILE *fp) | 1487 | static void __dsos__fprintf(struct list_head *head, FILE *fp) |
1482 | { | 1488 | { |
1483 | struct dso *pos; | 1489 | struct dso *pos; |
1484 | 1490 | ||
1485 | list_for_each_entry(pos, &dsos, node) | 1491 | list_for_each_entry(pos, head, node) |
1486 | dso__fprintf(pos, fp); | 1492 | dso__fprintf(pos, fp); |
1487 | } | 1493 | } |
1488 | 1494 | ||
1489 | size_t dsos__fprintf_buildid(FILE *fp) | 1495 | void dsos__fprintf(FILE *fp) |
1496 | { | ||
1497 | __dsos__fprintf(&dsos__kernel, fp); | ||
1498 | __dsos__fprintf(&dsos__user, fp); | ||
1499 | } | ||
1500 | |||
1501 | static size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp) | ||
1490 | { | 1502 | { |
1491 | struct dso *pos; | 1503 | struct dso *pos; |
1492 | size_t ret = 0; | 1504 | size_t ret = 0; |
1493 | 1505 | ||
1494 | list_for_each_entry(pos, &dsos, node) { | 1506 | list_for_each_entry(pos, head, node) { |
1495 | ret += dso__fprintf_buildid(pos, fp); | 1507 | ret += dso__fprintf_buildid(pos, fp); |
1496 | ret += fprintf(fp, " %s\n", pos->long_name); | 1508 | ret += fprintf(fp, " %s\n", pos->long_name); |
1497 | } | 1509 | } |
1498 | return ret; | 1510 | return ret; |
1499 | } | 1511 | } |
1500 | 1512 | ||
1513 | size_t dsos__fprintf_buildid(FILE *fp) | ||
1514 | { | ||
1515 | return (__dsos__fprintf_buildid(&dsos__kernel, fp) + | ||
1516 | __dsos__fprintf_buildid(&dsos__user, fp)); | ||
1517 | } | ||
1518 | |||
1501 | static int kernel_maps__create_kernel_map(const struct symbol_conf *conf) | 1519 | static int kernel_maps__create_kernel_map(const struct symbol_conf *conf) |
1502 | { | 1520 | { |
1503 | struct dso *kernel = dso__new(conf->vmlinux_name ?: "[kernel.kallsyms]"); | 1521 | struct dso *kernel = dso__new(conf->vmlinux_name ?: "[kernel.kallsyms]"); |
@@ -1523,8 +1541,8 @@ static int kernel_maps__create_kernel_map(const struct symbol_conf *conf) | |||
1523 | kernel->has_build_id = true; | 1541 | kernel->has_build_id = true; |
1524 | 1542 | ||
1525 | kernel_maps__insert(kernel_map__functions); | 1543 | kernel_maps__insert(kernel_map__functions); |
1526 | dsos__add(kernel); | 1544 | dsos__add(&dsos__kernel, kernel); |
1527 | dsos__add(vdso); | 1545 | dsos__add(&dsos__user, vdso); |
1528 | 1546 | ||
1529 | return 0; | 1547 | return 0; |
1530 | 1548 | ||
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index b42d196dd8e9..5d0371fe8a06 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -104,7 +104,7 @@ size_t kernel_maps__fprintf(FILE *fp); | |||
104 | 104 | ||
105 | int symbol__init(struct symbol_conf *conf); | 105 | int symbol__init(struct symbol_conf *conf); |
106 | 106 | ||
107 | extern struct list_head dsos; | 107 | extern struct list_head dsos__user, dsos__kernel; |
108 | extern struct map *kernel_map__functions; | 108 | extern struct map *kernel_map__functions; |
109 | extern struct dso *vdso; | 109 | extern struct dso *vdso; |
110 | #endif /* __PERF_SYMBOL */ | 110 | #endif /* __PERF_SYMBOL */ |