Commit 664fee3d authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Arnaldo Carvalho de Melo

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: default avatardavid lerner <dlernerdroid@gmail.com>
Signed-off-by: default avatarMasami 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.novalocalSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2b394bc4
...@@ -609,14 +609,18 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod, ...@@ -609,14 +609,18 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
return -EINVAL; return -EINVAL;
} }
/* Get an appropriate symbol from symtab */ symbol = dwarf_diename(sp_die);
symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
if (!symbol) { if (!symbol) {
pr_warning("Failed to find symbol at 0x%lx\n", /* Try to get the symbol name from symtab */
(unsigned long)paddr); symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
return -ENOENT; if (!symbol) {
pr_warning("Failed to find symbol at 0x%lx\n",
(unsigned long)paddr);
return -ENOENT;
}
eaddr = sym.st_value;
} }
tp->offset = (unsigned long)(paddr - sym.st_value); tp->offset = (unsigned long)(paddr - eaddr);
tp->address = (unsigned long)paddr; tp->address = (unsigned long)paddr;
tp->symbol = strdup(symbol); tp->symbol = strdup(symbol);
if (!tp->symbol) if (!tp->symbol)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment