aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2013-08-07 07:38:47 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-08-07 16:35:31 -0400
commit39b12f7812710e9a5896805d96812b3ede7491e8 (patch)
tree86e56aa9aeebb18872a2ab256839978a79d2c4ad /tools/perf/util/symbol.c
parent5b7ba82a75915e739709d0ace4bb559cb280db09 (diff)
perf tools: Make it possible to read object code from vmlinux
The new "object code reading" test shows that it is not possible to read object code from vmlinux. That is because the mappings do not map to the dso. This patch fixes that. A side-effect of changing the kernel map is that the "reloc" offset must be taken into account. As a result of that separate map functions for relocation are no longer needed. Also fixing up the maps to match the symbols no longer makes sense and so is not done. The vmlinux dso data_type is now set to either DSO_BINARY_TYPE__VMLINUX or DSO_BINARY_TYPE__GUEST_VMLINUX as approprite, which enables the correct file name to be determined by dso__binary_type_file(). This patch breaks the "vmlinux symtab matches kallsyms" test. That is fixed in a following patch. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1375875537-4509-4-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r--tools/perf/util/symbol.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index ea62ecd191fa..04300dd5221f 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -917,6 +917,10 @@ int dso__load_vmlinux(struct dso *dso, struct map *map,
917 symsrc__destroy(&ss); 917 symsrc__destroy(&ss);
918 918
919 if (err > 0) { 919 if (err > 0) {
920 if (dso->kernel == DSO_TYPE_GUEST_KERNEL)
921 dso->data_type = DSO_BINARY_TYPE__GUEST_VMLINUX;
922 else
923 dso->data_type = DSO_BINARY_TYPE__VMLINUX;
920 dso__set_long_name(dso, (char *)vmlinux); 924 dso__set_long_name(dso, (char *)vmlinux);
921 dso__set_loaded(dso, map->type); 925 dso__set_loaded(dso, map->type);
922 pr_debug("Using %s for symbols\n", symfs_vmlinux); 926 pr_debug("Using %s for symbols\n", symfs_vmlinux);
@@ -989,7 +993,7 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map,
989 dso__set_long_name(dso, 993 dso__set_long_name(dso,
990 strdup(symbol_conf.vmlinux_name)); 994 strdup(symbol_conf.vmlinux_name));
991 dso->lname_alloc = 1; 995 dso->lname_alloc = 1;
992 goto out_fixup; 996 return err;
993 } 997 }
994 return err; 998 return err;
995 } 999 }
@@ -997,7 +1001,7 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map,
997 if (vmlinux_path != NULL) { 1001 if (vmlinux_path != NULL) {
998 err = dso__load_vmlinux_path(dso, map, filter); 1002 err = dso__load_vmlinux_path(dso, map, filter);
999 if (err > 0) 1003 if (err > 0)
1000 goto out_fixup; 1004 return err;
1001 } 1005 }
1002 1006
1003 /* do not try local files if a symfs was given */ 1007 /* do not try local files if a symfs was given */
@@ -1058,7 +1062,6 @@ do_kallsyms:
1058 1062
1059 if (err > 0) { 1063 if (err > 0) {
1060 dso__set_long_name(dso, strdup("[kernel.kallsyms]")); 1064 dso__set_long_name(dso, strdup("[kernel.kallsyms]"));
1061out_fixup:
1062 map__fixup_start(map); 1065 map__fixup_start(map);
1063 map__fixup_end(map); 1066 map__fixup_end(map);
1064 } 1067 }
@@ -1089,7 +1092,7 @@ static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map,
1089 if (symbol_conf.default_guest_vmlinux_name != NULL) { 1092 if (symbol_conf.default_guest_vmlinux_name != NULL) {
1090 err = dso__load_vmlinux(dso, map, 1093 err = dso__load_vmlinux(dso, map,
1091 symbol_conf.default_guest_vmlinux_name, filter); 1094 symbol_conf.default_guest_vmlinux_name, filter);
1092 goto out_try_fixup; 1095 return err;
1093 } 1096 }
1094 1097
1095 kallsyms_filename = symbol_conf.default_guest_kallsyms; 1098 kallsyms_filename = symbol_conf.default_guest_kallsyms;
@@ -1101,15 +1104,10 @@ static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map,
1101 } 1104 }
1102 1105
1103 err = dso__load_kallsyms(dso, kallsyms_filename, map, filter); 1106 err = dso__load_kallsyms(dso, kallsyms_filename, map, filter);
1104 if (err > 0)
1105 pr_debug("Using %s for symbols\n", kallsyms_filename);
1106
1107out_try_fixup:
1108 if (err > 0) { 1107 if (err > 0) {
1109 if (kallsyms_filename != NULL) { 1108 pr_debug("Using %s for symbols\n", kallsyms_filename);
1110 machine__mmap_name(machine, path, sizeof(path)); 1109 machine__mmap_name(machine, path, sizeof(path));
1111 dso__set_long_name(dso, strdup(path)); 1110 dso__set_long_name(dso, strdup(path));
1112 }
1113 map__fixup_start(map); 1111 map__fixup_start(map);
1114 map__fixup_end(map); 1112 map__fixup_end(map);
1115 } 1113 }