perf top: Don't stop if no kernel symtab is found
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 27 May 2011 16:42:16 +0000 (13:42 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 27 May 2011 19:02:29 +0000 (16:02 -0300)
We now just warn the user about the fact and go on providing just
userspace samples.

This fixes a problem when no vmlinux is explicetely passed by the user,
thus symbol_conf.vmlinux_name is NULL, no suitable vmlinux is found, and
then we get:

 aldebaran:~> perf top -p 7557
 [kernel.kallsyms] with build id 44d9a989eabbd79e486bc079d6b743d397c204e0
 not found, continuing without symbols
 The (null) file can't be used

Reported-by: Ingo Molnar <mingo@elte.hu>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
Link: http://lkml.kernel.org/n/tip-cj2g81hn64wv2bipmqk4fy2m@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-top.c

index 472f62790022f7945b6d219101282aa0dad260bd..f2f3f4937aa245142eda2082274b7b200e41db4e 100644 (file)
@@ -81,6 +81,7 @@ static bool                   use_tui, use_stdio;
 static int                     default_interval                =      0;
 
 static bool                    kptr_restrict_warned;
+static bool                    vmlinux_warned;
 static bool                    inherit                         =  false;
 static int                     realtime_prio                   =      0;
 static bool                    group                           =  false;
@@ -754,6 +755,7 @@ static void perf_event__process_sample(const union perf_event *event,
        }
 
        if (al.sym == NULL) {
+               const char *msg = "Kernel samples will not be resolved.\n";
                /*
                 * As we do lazy loading of symtabs we only will know if the
                 * specified vmlinux file is invalid when we actually have a
@@ -765,12 +767,20 @@ static void perf_event__process_sample(const union perf_event *event,
                 * --hide-kernel-symbols, even if the user specifies an
                 * invalid --vmlinux ;-)
                 */
-               if (al.map == machine->vmlinux_maps[MAP__FUNCTION] &&
+               if (!kptr_restrict_warned && !vmlinux_warned &&
+                   al.map == machine->vmlinux_maps[MAP__FUNCTION] &&
                    RB_EMPTY_ROOT(&al.map->dso->symbols[MAP__FUNCTION])) {
-                       ui__warning("The %s file can't be used\n",
-                                   symbol_conf.vmlinux_name);
-                       exit_browser(0);
-                       exit(1);
+                       if (symbol_conf.vmlinux_name) {
+                               ui__warning("The %s file can't be used.\n%s",
+                                           symbol_conf.vmlinux_name, msg);
+                       } else {
+                               ui__warning("A vmlinux file was not found.\n%s",
+                                           msg);
+                       }
+
+                       if (use_browser <= 0)
+                               sleep(5);
+                       vmlinux_warned = true;
                }
 
                return;