Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf probe: Fix 'function unused' warning

By 'make build-test' a warning is found in probe-event.c that, after
commit 419e873828 (perf probe: Show the error reason comes from
invalid DSO) the only user of kernel_get_module_dso() is
open_debuginfo(). Which is not compiled if HAVE_DWARF_SUPPORT not set.

'make build-test' found this problem when make_minimal.

This patch moves kernel_get_module_dso() to HAVE_DWARF_SUPPORT ifdef
section.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1432779905-206143-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Wang Nan and committed by
Arnaldo Carvalho de Melo
60fb7742 44848cdb

+33 -32
+33 -32
tools/perf/util/probe-event.c
··· 200 200 } 201 201 202 202 203 - static int kernel_get_module_dso(const char *module, struct dso **pdso) 204 - { 205 - struct dso *dso; 206 - struct map *map; 207 - const char *vmlinux_name; 208 - int ret = 0; 209 - 210 - if (module) { 211 - list_for_each_entry(dso, &host_machine->kernel_dsos.head, 212 - node) { 213 - if (strncmp(dso->short_name + 1, module, 214 - dso->short_name_len - 2) == 0) 215 - goto found; 216 - } 217 - pr_debug("Failed to find module %s.\n", module); 218 - return -ENOENT; 219 - } 220 - 221 - map = host_machine->vmlinux_maps[MAP__FUNCTION]; 222 - dso = map->dso; 223 - 224 - vmlinux_name = symbol_conf.vmlinux_name; 225 - dso->load_errno = 0; 226 - if (vmlinux_name) 227 - ret = dso__load_vmlinux(dso, map, vmlinux_name, false, NULL); 228 - else 229 - ret = dso__load_vmlinux_path(dso, map, NULL); 230 - found: 231 - *pdso = dso; 232 - return ret; 233 - } 234 - 235 203 static int convert_exec_to_group(const char *exec, char **result) 236 204 { 237 205 char *ptr1, *ptr2, *exec_copy; ··· 247 279 } 248 280 249 281 #ifdef HAVE_DWARF_SUPPORT 282 + 283 + static int kernel_get_module_dso(const char *module, struct dso **pdso) 284 + { 285 + struct dso *dso; 286 + struct map *map; 287 + const char *vmlinux_name; 288 + int ret = 0; 289 + 290 + if (module) { 291 + list_for_each_entry(dso, &host_machine->kernel_dsos.head, 292 + node) { 293 + if (strncmp(dso->short_name + 1, module, 294 + dso->short_name_len - 2) == 0) 295 + goto found; 296 + } 297 + pr_debug("Failed to find module %s.\n", module); 298 + return -ENOENT; 299 + } 300 + 301 + map = host_machine->vmlinux_maps[MAP__FUNCTION]; 302 + dso = map->dso; 303 + 304 + vmlinux_name = symbol_conf.vmlinux_name; 305 + dso->load_errno = 0; 306 + if (vmlinux_name) 307 + ret = dso__load_vmlinux(dso, map, vmlinux_name, false, NULL); 308 + else 309 + ret = dso__load_vmlinux_path(dso, map, NULL); 310 + found: 311 + *pdso = dso; 312 + return ret; 313 + } 314 + 250 315 /* 251 316 * Some binaries like glibc have special symbols which are on the symbol 252 317 * table, but not in the debuginfo. If we can find the address of the