perf symbols: Improve debugging information about symtab origins
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 22 Feb 2010 19:15:39 +0000 (16:15 -0300)
committerIngo Molnar <mingo@elte.hu>
Thu, 25 Feb 2010 11:27:17 +0000 (12:27 +0100)
Be more clear about DSO long names and tell from which file
kernel symbols were obtained, all in --verbose mode:

    [root@mica ~]# perf report -v > /dev/null
    Looking at the vmlinux_path (5 entries long)
    Using /lib/modules/2.6.33-rc8-tip-00777-g0918527-dirty/build/vmlinux for symbols
    [root@mica ~]# mv /lib/modules/2.6.33-rc8-tip-00777-g0918527-dirty/build/vmlinux /tmp/dd
    [root@mica ~]# perf report -v > /dev/null
    Looking at the vmlinux_path (5 entries long)
    Using /proc/kallsyms for symbols
    [root@mica ~]#

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: <1266866139-6361-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/util/map.c
tools/perf/util/map.h
tools/perf/util/symbol.c
tools/perf/util/thread.c

index 138e3cb2b727a8ab20aa624281ead9c3e7a53179..e509cd59c67d985a2ecb9946b61e7ae7065efca4 100644 (file)
@@ -5,6 +5,11 @@
 #include <stdio.h>
 #include "debug.h"
 
+const char *map_type__name[MAP__NR_TYPES] = {
+       [MAP__FUNCTION] = "Functions",
+       [MAP__VARIABLE] = "Variables",
+};
+
 static inline int is_anon_memory(const char *filename)
 {
        return strcmp(filename, "//anon") == 0;
index 86f77cb1d06034bc6ce86f34a26054236fc76422..b756368076c6ce4478ccb18ccdd61bd45e2fd408 100644 (file)
@@ -13,6 +13,8 @@ enum map_type {
 
 #define MAP__NR_TYPES (MAP__VARIABLE + 1)
 
+extern const char *map_type__name[MAP__NR_TYPES];
+
 struct dso;
 struct ref_reloc_sym;
 struct map_groups;
index 320b15178e95533461a55a54aade1736f88ed404..7aab4e5f3669b10da143d786ac98c8a319b4cab3 100644 (file)
@@ -367,6 +367,10 @@ size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp)
        struct rb_node *nd;
        size_t ret = fprintf(fp, "dso: %s (", self->short_name);
 
+       if (self->short_name != self->long_name)
+               ret += fprintf(fp, "%s, ", self->long_name);
+       ret += fprintf(fp, "%s, %sloaded, ", map_type__name[type],
+                      self->loaded ? "" : "NOT ");
        ret += dso__fprintf_buildid(self, fp);
        ret += fprintf(fp, ")\n");
        for (nd = rb_first(&self->symbols[type]); nd; nd = rb_next(nd)) {
@@ -1580,6 +1584,9 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
        err = dso__load_sym(self, map, vmlinux, fd, filter, 0);
        close(fd);
 
+       if (err > 0)
+               pr_debug("Using %s for symbols\n", vmlinux);
+
        return err;
 }
 
@@ -1594,7 +1601,6 @@ int dso__load_vmlinux_path(struct dso *self, struct map *map,
        for (i = 0; i < vmlinux_path__nr_entries; ++i) {
                err = dso__load_vmlinux(self, map, vmlinux_path[i], filter);
                if (err > 0) {
-                       pr_debug("Using %s for symbols\n", vmlinux_path[i]);
                        dso__set_long_name(self, strdup(vmlinux_path[i]));
                        break;
                }
@@ -1661,12 +1667,16 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
 
                if (asprintf(&kallsyms_allocated_filename,
                             "%s/.debug/[kernel.kallsyms]/%s",
-                            getenv("HOME"), sbuild_id) == -1)
+                            getenv("HOME"), sbuild_id) == -1) {
+                       pr_err("Not enough memory for kallsyms file lookup\n");
                        return -1;
+               }
 
                kallsyms_filename = kallsyms_allocated_filename;
 
                if (access(kallsyms_filename, F_OK)) {
+                       pr_err("No kallsyms or vmlinux with build-id %s "
+                              "was found\n", sbuild_id);
                        free(kallsyms_allocated_filename);
                        return -1;
                }
@@ -1680,6 +1690,8 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
 
 do_kallsyms:
        err = dso__load_kallsyms(self, kallsyms_filename, map, filter);
+       if (err > 0)
+               pr_debug("Using %s for symbols\n", kallsyms_filename);
        free(kallsyms_allocated_filename);
 
 out_try_fixup:
index 9e8995eaf2b61332e650fb2c4dfde6d615c6ae3e..c090654cb6c0f58e9db9f62ea24091dbec1d0439 100644 (file)
@@ -53,11 +53,6 @@ int thread__comm_len(struct thread *self)
        return self->comm_len;
 }
 
-static const char *map_type__name[MAP__NR_TYPES] = {
-       [MAP__FUNCTION] = "Functions",
-       [MAP__VARIABLE] = "Variables",
-};
-
 static size_t __map_groups__fprintf_maps(struct map_groups *self,
                                         enum map_type type, FILE *fp)
 {