perf annotate: Properly notify the user that vmlinux is missing
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 15 Mar 2010 16:04:33 +0000 (13:04 -0300)
committerIngo Molnar <mingo@elte.hu>
Mon, 15 Mar 2010 16:16:25 +0000 (17:16 +0100)
Before this patch we would not find a vmlinux, then try to pass
objdump "[kernel.kallsyms]" as the filename, it would get
confused and produce no output:

 [root@doppio ~]# perf annotate n_tty_write

 ------------------------------------------------
  Percent |      Source code & Disassembly of [kernel.kallsyms]
 ------------------------------------------------

Now we check that and emit meaningful warning:

 [root@doppio ~]# perf annotate n_tty_write
 Can't annotate n_tty_write: No vmlinux file was found in the
 path: [0] vmlinux
 [1] /boot/vmlinux
 [2] /boot/vmlinux-2.6.34-rc1-tip+
 [3] /lib/modules/2.6.34-rc1-tip+/build/vmlinux
 [4] /usr/lib/debug/lib/modules/2.6.34-rc1-tip+/vmlinux
 [root@doppio ~]#

This bug was introduced when we added automatic search for
vmlinux, before that time the user had to specify a vmlinux
file.

v2: Print the warning just for the first symbol found when no
    symbol name is specified, otherwise it will spam the screen
    repeating the warning for each symbol.

Reported-by: Ingo Molnar <mingo@elte.hu>
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>
Cc: <stable@kernel.org>
LKML-Reference: <1268669073-6856-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/builtin-annotate.c
tools/perf/util/newt.c
tools/perf/util/symbol.h

index 6ad7148451c5bcc32995c08e75a920d0898e4c7e..45d14660d53db2c1c9830284d83ae07e1fe91307 100644 (file)
@@ -452,6 +452,16 @@ static void annotate_sym(struct hist_entry *he)
        if (!filename)
                return;
 
+       if (dso->origin == DSO__ORIG_KERNEL) {
+               if (dso->annotate_warned)
+                       return;
+               dso->annotate_warned = 1;
+               pr_err("Can't annotate %s: No vmlinux file was found in the "
+                      "path:\n", sym->name);
+               vmlinux_path__fprintf(stderr);
+               return;
+       }
+
        pr_debug("%s: filename=%s, sym=%s, start=%#Lx, end=%#Lx\n", __func__,
                 filename, sym->name, map->unmap_ip(map, sym->start),
                 map->unmap_ip(map, sym->end));
index 2836394459d9bc53a8941e51fc73956bd06ad57d..2d19e7a3e6e826282a8aa2a1b04190f7c9810b39 100644 (file)
@@ -63,7 +63,7 @@ static void hist_entry__annotate_browser(struct hist_entry *self)
        if (self->sym == NULL)
                return;
 
-       if (asprintf(&str, "perf annotate %s | expand", self->sym->name) < 0)
+       if (asprintf(&str, "perf annotate %s 2>&1 | expand", self->sym->name) < 0)
                return;
 
        fp = popen(str, "r");
index d983bbaf99c59596bc7a3cd0b6fb44adb72ffa74..5bd91d1427044c048129cc51632012a89c27db00 100644 (file)
@@ -106,6 +106,7 @@ struct dso {
        u8               has_build_id:1;
        u8               kernel:1;
        u8               hit:1;
+       u8               annotate_warned:1;
        unsigned char    origin;
        u8               sorted_by_name;
        u8               loaded;