diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-20 11:15:33 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-20 11:15:33 -0400 |
commit | b36f19d572151abb987ce308a3e066b977a2146f (patch) | |
tree | 07f520f8b3da969d288e34a121cc31a0209eb519 /tools/perf/util/hist.c | |
parent | 17930b405e0ecdc8ecc4d336377a92950e2de76a (diff) |
perf annotate: Use build-ids to find the right DSO
We were still using the pathname found on the MMAP event, that could not
be the one we used when recording, so use the build-id cache for that,
only falling back to use the pathname in the MMAP event if no build-ids
are available.
With this we now also are able to do secure, seamless offline annotation.
Example:
[root@doppio linux-2.6-tip]# perf report -g none -v 2> /dev/null | head -10
8.12% Xorg /usr/lib64/libpixman-1.so.0.14.0 0x0000000000026d02 B [.] pixman_rasterize_edges
4.68% firefox /usr/lib64/xulrunner-1.9.1/libxul.so 0x00000000005dbdba B [.] 0x000000005dbdba
3.70% swapper /lib/modules/2.6.34-rc6/build/vmlinux 0xffffffff81022cea ! [k] read_hpet
2.96% init /lib/modules/2.6.34-rc6/build/vmlinux 0xffffffff81022cea ! [k] read_hpet
2.73% swapper /lib/modules/2.6.34-rc6/build/vmlinux 0xffffffff8100a738 ! [k] mwait_idle_with_hints
[root@doppio linux-2.6-tip]# perf annotate -v pixman_rasterize_edges 2>&1 | grep Executing
Executing: objdump --start-address=0x000000371ce26670 --stop-address=0x000000371ce2709f -dS /root/.debug/.build-id/bd/6ac5199137aaeb279f864717d8d061477466c1|grep -v /root/.debug/.build-id/bd/6ac5199137aaeb279f864717d8d061477466c1|expand
[root@doppio linux-2.6-tip]# perf buildid-list | grep libpixman-1.so.0.14.0
bd6ac5199137aaeb279f864717d8d061477466c1 /usr/lib64/libpixman-1.so.0.14.0
[root@doppio linux-2.6-tip]#
Reported-by: Stephane Eranian <eranian@google.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/hist.c')
-rw-r--r-- | tools/perf/util/hist.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 9a71c94f057a..739c39fd0ade 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include "build-id.h" | ||
1 | #include "util.h" | 2 | #include "util.h" |
2 | #include "hist.h" | 3 | #include "hist.h" |
3 | #include "session.h" | 4 | #include "session.h" |
@@ -988,22 +989,35 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head) | |||
988 | struct symbol *sym = self->ms.sym; | 989 | struct symbol *sym = self->ms.sym; |
989 | struct map *map = self->ms.map; | 990 | struct map *map = self->ms.map; |
990 | struct dso *dso = map->dso; | 991 | struct dso *dso = map->dso; |
991 | const char *filename = dso->long_name; | 992 | char *filename = dso__build_id_filename(dso, NULL, 0); |
992 | char command[PATH_MAX * 2]; | 993 | char command[PATH_MAX * 2]; |
993 | FILE *file; | 994 | FILE *file; |
995 | int err = -1; | ||
994 | u64 len; | 996 | u64 len; |
995 | 997 | ||
996 | if (!filename) | 998 | if (filename == NULL) { |
997 | return -1; | 999 | if (dso->has_build_id) { |
1000 | pr_err("Can't annotate %s: not enough memory\n", | ||
1001 | sym->name); | ||
1002 | return -1; | ||
1003 | } | ||
1004 | /* | ||
1005 | * If we don't have build-ids, well, lets hope that this | ||
1006 | * DSO is the same as when 'perf record' ran. | ||
1007 | */ | ||
1008 | filename = dso->long_name; | ||
1009 | } | ||
998 | 1010 | ||
999 | if (dso->origin == DSO__ORIG_KERNEL) { | 1011 | if (dso->origin == DSO__ORIG_KERNEL) { |
1000 | if (dso->annotate_warned) | 1012 | if (dso->annotate_warned) { |
1001 | return 0; | 1013 | err = 0; |
1014 | goto out_free_filename; | ||
1015 | } | ||
1002 | dso->annotate_warned = 1; | 1016 | dso->annotate_warned = 1; |
1003 | pr_err("Can't annotate %s: No vmlinux file was found in the " | 1017 | pr_err("Can't annotate %s: No vmlinux file was found in the " |
1004 | "path:\n", sym->name); | 1018 | "path:\n", sym->name); |
1005 | vmlinux_path__fprintf(stderr); | 1019 | vmlinux_path__fprintf(stderr); |
1006 | return -1; | 1020 | goto out_free_filename; |
1007 | } | 1021 | } |
1008 | 1022 | ||
1009 | pr_debug("%s: filename=%s, sym=%s, start=%#Lx, end=%#Lx\n", __func__, | 1023 | pr_debug("%s: filename=%s, sym=%s, start=%#Lx, end=%#Lx\n", __func__, |
@@ -1025,14 +1039,18 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head) | |||
1025 | 1039 | ||
1026 | file = popen(command, "r"); | 1040 | file = popen(command, "r"); |
1027 | if (!file) | 1041 | if (!file) |
1028 | return -1; | 1042 | goto out_free_filename; |
1029 | 1043 | ||
1030 | while (!feof(file)) | 1044 | while (!feof(file)) |
1031 | if (hist_entry__parse_objdump_line(self, file, head) < 0) | 1045 | if (hist_entry__parse_objdump_line(self, file, head) < 0) |
1032 | break; | 1046 | break; |
1033 | 1047 | ||
1034 | pclose(file); | 1048 | pclose(file); |
1035 | return 0; | 1049 | err = 0; |
1050 | out_free_filename: | ||
1051 | if (dso->has_build_id) | ||
1052 | free(filename); | ||
1053 | return err; | ||
1036 | } | 1054 | } |
1037 | 1055 | ||
1038 | void hists__inc_nr_events(struct hists *self, u32 type) | 1056 | void hists__inc_nr_events(struct hists *self, u32 type) |