Skip to content

Commit 664fee3

Browse files
mhiramathitachiacmel
authored andcommitted
perf probe: Do not use dwfl_module_addrsym if dwarf_diename finds symbol name
Do not use dwfl_module_addrsym if dwarf_diename can find the symbol name, since dwfl_module_addrsym can be failed on shared libraries. Without this patch ---- $ perf probe -x ../lib/traceevent/libtraceevent.so -V create_arg_op Failed to find symbol at 0x11df1 Failed to find the address of create_arg_op Error: Failed to show vars. ---- With this patch ---- $ perf probe -x ../lib/traceevent/libtraceevent.so -V create_arg_op Available variables at create_arg_op @<create_arg_op+0> enum filter_op_type btype struct filter_arg* arg ---- This bug was reported on linux-perf-users@vger.kernel.org. Reported-by: david lerner <dlernerdroid@gmail.com> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: david lerner <dlernerdroid@gmail.com> Cc: linux-perf-user@vger.kernel.org Cc: yrl.pp-manager.tt@hitachi.com Link: http://permalink.gmane.org/gmane.linux.kernel.perf.user/1691 Link: http://lkml.kernel.org/r/20140917084101.3722.25299.stgit@kbuild-f20.novalocal Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 2b394bc commit 664fee3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tools/perf/util/probe-finder.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,14 +609,18 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
609609
return -EINVAL;
610610
}
611611

612-
/* Get an appropriate symbol from symtab */
613-
symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
612+
symbol = dwarf_diename(sp_die);
614613
if (!symbol) {
615-
pr_warning("Failed to find symbol at 0x%lx\n",
616-
(unsigned long)paddr);
617-
return -ENOENT;
614+
/* Try to get the symbol name from symtab */
615+
symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
616+
if (!symbol) {
617+
pr_warning("Failed to find symbol at 0x%lx\n",
618+
(unsigned long)paddr);
619+
return -ENOENT;
620+
}
621+
eaddr = sym.st_value;
618622
}
619-
tp->offset = (unsigned long)(paddr - sym.st_value);
623+
tp->offset = (unsigned long)(paddr - eaddr);
620624
tp->address = (unsigned long)paddr;
621625
tp->symbol = strdup(symbol);
622626
if (!tp->symbol)

0 commit comments

Comments
 (0)