perf probe: Fix use of kernel image path given by 'k' option

Users were not being able to have the explicitely specified vmlinux
pathname used, instead a search on the vmlinux path was always being
made.

Reported-by: Francis Moreau <francis.moro@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: 2nddept-manager@sdl.hitachi.co.jp
Cc: Francis Moreau <francis.moro@gmail.com>
Cc: Franck Bui-Huu <vagabon.xyz@gmail.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LPU-Reference: <m3hbelydz8.fsf_-_@gmail.com>
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by Franck Bui-Huu and committed by Arnaldo Carvalho de Melo fd930ff9 d949750f

+21 -5
+5
tools/perf/builtin-probe.c
··· 249 249 !params.show_lines)) 250 250 usage_with_options(probe_usage, options); 251 251 252 + /* 253 + * Only consider the user's kernel image path if given. 254 + */ 255 + symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL); 256 + 252 257 if (params.list_events) { 253 258 if (params.mod_events) { 254 259 pr_err(" Error: Don't use --list with --add/--del.\n");
+12 -3
tools/perf/util/probe-event.c
··· 114 114 const char *kernel_get_module_path(const char *module) 115 115 { 116 116 struct dso *dso; 117 + struct map *map; 118 + const char *vmlinux_name; 117 119 118 120 if (module) { 119 121 list_for_each_entry(dso, &machine.kernel_dsos, node) { ··· 125 123 } 126 124 pr_debug("Failed to find module %s.\n", module); 127 125 return NULL; 126 + } 127 + 128 + map = machine.vmlinux_maps[MAP__FUNCTION]; 129 + dso = map->dso; 130 + 131 + vmlinux_name = symbol_conf.vmlinux_name; 132 + if (vmlinux_name) { 133 + if (dso__load_vmlinux(dso, map, vmlinux_name, NULL) <= 0) 134 + return NULL; 128 135 } else { 129 - dso = machine.vmlinux_maps[MAP__FUNCTION]->dso; 130 - if (dso__load_vmlinux_path(dso, 131 - machine.vmlinux_maps[MAP__FUNCTION], NULL) < 0) { 136 + if (dso__load_vmlinux_path(dso, map, NULL) < 0) { 132 137 pr_debug("Failed to load kernel map.\n"); 133 138 return NULL; 134 139 }
+2 -2
tools/perf/util/symbol.c
··· 1780 1780 return -1; 1781 1781 } 1782 1782 1783 - static int dso__load_vmlinux(struct dso *self, struct map *map, 1784 - const char *vmlinux, symbol_filter_t filter) 1783 + int dso__load_vmlinux(struct dso *self, struct map *map, 1784 + const char *vmlinux, symbol_filter_t filter) 1785 1785 { 1786 1786 int err = -1, fd; 1787 1787
+2
tools/perf/util/symbol.h
··· 166 166 struct dso *__dsos__findnew(struct list_head *head, const char *name); 167 167 168 168 int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); 169 + int dso__load_vmlinux(struct dso *self, struct map *map, 170 + const char *vmlinux, symbol_filter_t filter); 169 171 int dso__load_vmlinux_path(struct dso *self, struct map *map, 170 172 symbol_filter_t filter); 171 173 int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,