All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH perf/core 1/2] perf probe: Do not access kallsyms when analyzing user binaries
@ 2014-09-17  8:40 Masami Hiramatsu
  2014-09-17  8:41 ` [PATCH perf/core 2/2] perf probe: Do not use dwfl_module_addrsym if dwarf_diename finds symbol name Masami Hiramatsu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2014-09-17  8:40 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-perf-user, david lerner, LKML, yrl.pp-manager.tt

Do not access kallsyms to show available variables and
show source lines in user binaries.
This behavior always requires the root privilege when
sysctl sets kernel.kptr_restrict=1, but we don't need
it just for analyzing user binaries.

Without this patch (by normal user, kptr_restrict=1):
  ----
  $ perf probe -x ./perf -V add_cmdname
  Failed to init vmlinux path.
    Error: Failed to show vars.
  $ perf probe -x ./perf -L add_cmdname
  Failed to init vmlinux path.
    Error: Failed to show lines.
  ----

With this patch:
  ----
  $ perf probe -x ./perf -V add_cmdname
  Available variables at add_cmdname
          @<perf_unknown_cmd_config+144>
                  (No matched variables)
          @<list_commands_in_dir+160>
                  (No matched variables)
          @<add_cmdname+0>
                  char*   name
                  size_t  len
                  struct cmdnames*        cmds
  $ perf probe -x ./perf -L add_cmdname
  <add_cmdname@/home/fedora/ksrc/linux-3/tools/perf/util/help.c:0>
        0  void add_cmdname(struct cmdnames *cmds, const char *name, size_t len)
        1  {
        2         struct cmdname *ent = malloc(sizeof(*ent) + len + 1);

        4         ent->len = len;
        5         memcpy(ent->name, name, len);
        6         ent->name[len] = 0;
  ...
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 tools/perf/builtin-probe.c    |    3 ++-
 tools/perf/util/probe-event.c |    6 +++---
 tools/perf/util/probe-event.h |    3 ++-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 347729e..a9b82c4b 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -470,7 +470,8 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 			usage_with_options(probe_usage, options);
 		}
 
-		ret = show_line_range(&params.line_range, params.target);
+		ret = show_line_range(&params.line_range, params.target,
+				      params.uprobes);
 		if (ret < 0)
 			pr_err_with_code("  Error: Failed to show lines.", ret);
 		return ret;
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index f73595f..041e63c 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -697,11 +697,11 @@ end:
 	return ret;
 }
 
-int show_line_range(struct line_range *lr, const char *module)
+int show_line_range(struct line_range *lr, const char *module, bool user)
 {
 	int ret;
 
-	ret = init_symbol_maps(false);
+	ret = init_symbol_maps(user);
 	if (ret < 0)
 		return ret;
 	ret = __show_line_range(lr, module);
@@ -776,7 +776,7 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs,
 	int i, ret = 0;
 	struct debuginfo *dinfo;
 
-	ret = init_symbol_maps(false);
+	ret = init_symbol_maps(pevs->uprobes);
 	if (ret < 0)
 		return ret;
 
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index 776c934..e01e994 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -128,7 +128,8 @@ extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
 				 bool force_add);
 extern int del_perf_probe_events(struct strlist *dellist);
 extern int show_perf_probe_events(void);
-extern int show_line_range(struct line_range *lr, const char *module);
+extern int show_line_range(struct line_range *lr, const char *module,
+			   bool user);
 extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
 			       int max_probe_points, const char *module,
 			       struct strfilter *filter, bool externs);



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH perf/core 2/2] perf probe: Do not use dwfl_module_addrsym if dwarf_diename finds symbol name
  2014-09-17  8:40 [PATCH perf/core 1/2] perf probe: Do not access kallsyms when analyzing user binaries Masami Hiramatsu
@ 2014-09-17  8:41 ` Masami Hiramatsu
  2014-09-19  5:23   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
  2014-09-17 20:59 ` [PATCH perf/core 1/2] perf probe: Do not access kallsyms when analyzing user binaries Arnaldo Carvalho de Melo
  2014-09-19  5:22 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
  2 siblings, 1 reply; 6+ messages in thread
From: Masami Hiramatsu @ 2014-09-17  8:41 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-perf-user, david lerner, LKML, yrl.pp-manager.tt

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.
http://permalink.gmane.org/gmane.linux.kernel.perf.user/1691

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Reported-by: david lerner <dlernerdroid@gmail.com>
---
 tools/perf/util/probe-finder.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 9c59356..c7918f8 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -609,14 +609,18 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
 		return -EINVAL;
 	}
 
-	/* Get an appropriate symbol from symtab */
-	symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
+	symbol = dwarf_diename(sp_die);
 	if (!symbol) {
-		pr_warning("Failed to find symbol at 0x%lx\n",
-			   (unsigned long)paddr);
-		return -ENOENT;
+		/* Try to get the symbol name from symtab */
+		symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
+		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->symbol = strdup(symbol);
 	if (!tp->symbol)



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH perf/core 1/2] perf probe: Do not access kallsyms when analyzing user binaries
  2014-09-17  8:40 [PATCH perf/core 1/2] perf probe: Do not access kallsyms when analyzing user binaries Masami Hiramatsu
  2014-09-17  8:41 ` [PATCH perf/core 2/2] perf probe: Do not use dwfl_module_addrsym if dwarf_diename finds symbol name Masami Hiramatsu
@ 2014-09-17 20:59 ` Arnaldo Carvalho de Melo
  2014-09-18  0:36   ` Masami Hiramatsu
  2014-09-19  5:22 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
  2 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-09-17 20:59 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: linux-perf-user, david lerner, LKML, yrl.pp-manager.tt

Em Wed, Sep 17, 2014 at 08:40:54AM +0000, Masami Hiramatsu escreveu:
> Do not access kallsyms to show available variables and
> show source lines in user binaries.
> This behavior always requires the root privilege when
> sysctl sets kernel.kptr_restrict=1, but we don't need
> it just for analyzing user binaries.

> +++ b/tools/perf/util/probe-event.c
> @@ -697,11 +697,11 @@ end:
>  	return ret;
>  }
>  
> -int show_line_range(struct line_range *lr, const char *module)
> +int show_line_range(struct line_range *lr, const char *module, bool user)
>  {

make -C tools/perf build-test fails for the static build on:

acme@linux-goap:~/git/linux> cat /etc/os-release
NAME=openSUSE
VERSION="12.3 (Dartmouth)"
VERSION_ID="12.3"
PRETTY_NAME="openSUSE 12.3 (Dartmouth) (i586)"
ID=opensuse
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:opensuse:12.3"
acme@linux-goap:~/git/linux> 

util/probe-event.c:824:5: error: conflicting types for 'show_line_range'
In file included from util/probe-event.c:45:0:
util/probe-event.h:131:12: note: previous declaration of
'show_line_range' was here
make[3]: *** [util/probe-event.o] Error 1
make[2]: *** [all] Error 2
  test: test -x ./perf
make[1]: *** [make_static] Error 1
make: *** [build-test] Error 2
make: Leaving directory `/home/acme/git/linux/tools/perf'
acme@linux-goap:~/git/linux>

And on:

acme@ubuntu13:~/git/linux$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="13.10, Saucy Salamander"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 13.10"
VERSION_ID="13.10"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
acme@ubuntu13:~/git/linux$ 

  CC       util/probe-event.o
util/probe-event.c:824:5: error: conflicting types for ‘show_line_range’
 int show_line_range(struct line_range *lr __maybe_unused,
     ^
In file included from util/probe-event.c:45:0:
util/probe-event.h:131:12: note: previous declaration of
‘show_line_range’ was here
 extern int show_line_range(struct line_range *lr, const char *module,
            ^
make[3]: *** [util/probe-event.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [all] Error 2
  test: test -x ./perf
make[1]: *** [make_static] Error 1
make: *** [build-test] Error 2
make: Leaving directory `/home/acme/git/linux/tools/perf'

---------------------------------------------------------------------

Probably because I had not installed needed DWARF support libraries and
you forgot to update this:

int show_line_range(struct line_range *lr __maybe_unused,
                    const char *module __maybe_unused)
{
        pr_warning("Debuginfo-analysis is not supported.\n");
        return -ENOSYS;
}


Fixing it up by adding the missing 'bool user'.

- Arnaldo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: [PATCH perf/core 1/2] perf probe: Do not access kallsyms when analyzing user binaries
  2014-09-17 20:59 ` [PATCH perf/core 1/2] perf probe: Do not access kallsyms when analyzing user binaries Arnaldo Carvalho de Melo
@ 2014-09-18  0:36   ` Masami Hiramatsu
  0 siblings, 0 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2014-09-18  0:36 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-perf-user, david lerner, LKML, yrl.pp-manager.tt

(2014/09/18 5:59), Arnaldo Carvalho de Melo wrote:
> Em Wed, Sep 17, 2014 at 08:40:54AM +0000, Masami Hiramatsu escreveu:
>> Do not access kallsyms to show available variables and
>> show source lines in user binaries.
>> This behavior always requires the root privilege when
>> sysctl sets kernel.kptr_restrict=1, but we don't need
>> it just for analyzing user binaries.
> 
>> +++ b/tools/perf/util/probe-event.c
>> @@ -697,11 +697,11 @@ end:
>>  	return ret;
>>  }
>>  
>> -int show_line_range(struct line_range *lr, const char *module)
>> +int show_line_range(struct line_range *lr, const char *module, bool user)
>>  {
> 
> make -C tools/perf build-test fails for the static build on:
> 
> acme@linux-goap:~/git/linux> cat /etc/os-release
> NAME=openSUSE
> VERSION="12.3 (Dartmouth)"
> VERSION_ID="12.3"
> PRETTY_NAME="openSUSE 12.3 (Dartmouth) (i586)"
> ID=opensuse
> ANSI_COLOR="0;32"
> CPE_NAME="cpe:/o:opensuse:opensuse:12.3"
> acme@linux-goap:~/git/linux> 
> 
> util/probe-event.c:824:5: error: conflicting types for 'show_line_range'
> In file included from util/probe-event.c:45:0:
> util/probe-event.h:131:12: note: previous declaration of
> 'show_line_range' was here
> make[3]: *** [util/probe-event.o] Error 1
> make[2]: *** [all] Error 2
>   test: test -x ./perf
> make[1]: *** [make_static] Error 1
> make: *** [build-test] Error 2
> make: Leaving directory `/home/acme/git/linux/tools/perf'
> acme@linux-goap:~/git/linux>
> 
> And on:
> 
> acme@ubuntu13:~/git/linux$ cat /etc/os-release 
> NAME="Ubuntu"
> VERSION="13.10, Saucy Salamander"
> ID=ubuntu
> ID_LIKE=debian
> PRETTY_NAME="Ubuntu 13.10"
> VERSION_ID="13.10"
> HOME_URL="http://www.ubuntu.com/"
> SUPPORT_URL="http://help.ubuntu.com/"
> BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
> acme@ubuntu13:~/git/linux$ 
> 
>   CC       util/probe-event.o
> util/probe-event.c:824:5: error: conflicting types for ‘show_line_range’
>  int show_line_range(struct line_range *lr __maybe_unused,
>      ^
> In file included from util/probe-event.c:45:0:
> util/probe-event.h:131:12: note: previous declaration of
> ‘show_line_range’ was here
>  extern int show_line_range(struct line_range *lr, const char *module,
>             ^
> make[3]: *** [util/probe-event.o] Error 1
> make[3]: *** Waiting for unfinished jobs....
> make[2]: *** [all] Error 2
>   test: test -x ./perf
> make[1]: *** [make_static] Error 1
> make: *** [build-test] Error 2
> make: Leaving directory `/home/acme/git/linux/tools/perf'
> 
> ---------------------------------------------------------------------
> 
> Probably because I had not installed needed DWARF support libraries and
> you forgot to update this:
> 
> int show_line_range(struct line_range *lr __maybe_unused,
>                     const char *module __maybe_unused)
> {
>         pr_warning("Debuginfo-analysis is not supported.\n");
>         return -ENOSYS;
> }

Oops! Right, I forgot that. Maybe I should move this to the header file
so that I can easily avoid this kind of mistake...

> Fixing it up by adding the missing 'bool user'.

Thank you!



-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:perf/core] perf probe: Do not access kallsyms when analyzing user binaries
  2014-09-17  8:40 [PATCH perf/core 1/2] perf probe: Do not access kallsyms when analyzing user binaries Masami Hiramatsu
  2014-09-17  8:41 ` [PATCH perf/core 2/2] perf probe: Do not use dwfl_module_addrsym if dwarf_diename finds symbol name Masami Hiramatsu
  2014-09-17 20:59 ` [PATCH perf/core 1/2] perf probe: Do not access kallsyms when analyzing user binaries Arnaldo Carvalho de Melo
@ 2014-09-19  5:22 ` tip-bot for Masami Hiramatsu
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2014-09-19  5:22 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, masami.hiramatsu.pt, tglx, dlernerdroid

Commit-ID:  2b394bc4468c2f5e6814a8dbb2a923c0448f8497
Gitweb:     http://git.kernel.org/tip/2b394bc4468c2f5e6814a8dbb2a923c0448f8497
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Wed, 17 Sep 2014 08:40:54 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 17 Sep 2014 18:01:14 -0300

perf probe: Do not access kallsyms when analyzing user binaries

Do not access kallsyms to show available variables and show source lines
in user binaries.

This behavior always requires the root privilege when sysctl sets
kernel.kptr_restrict=1, but we don't need it just for analyzing user
binaries.

Without this patch (by normal user, kptr_restrict=1):
  ----
  $ perf probe -x ./perf -V add_cmdname
  Failed to init vmlinux path.
    Error: Failed to show vars.
  $ perf probe -x ./perf -L add_cmdname
  Failed to init vmlinux path.
    Error: Failed to show lines.
  ----

With this patch:
  ----
  $ perf probe -x ./perf -V add_cmdname
  Available variables at add_cmdname
          @<perf_unknown_cmd_config+144>
                  (No matched variables)
          @<list_commands_in_dir+160>
                  (No matched variables)
          @<add_cmdname+0>
                  char*   name
                  size_t  len
                  struct cmdnames*        cmds
  $ perf probe -x ./perf -L add_cmdname
  <add_cmdname@/home/fedora/ksrc/linux-3/tools/perf/util/help.c:0>
        0  void add_cmdname(struct cmdnames *cmds, const char *name, size_t len)
        1  {
        2         struct cmdname *ent = malloc(sizeof(*ent) + len + 1);

        4         ent->len = len;
        5         memcpy(ent->name, name, len);
        6         ent->name[len] = 0;
  ...
  ----

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://lkml.kernel.org/r/20140917084054.3722.73975.stgit@kbuild-f20.novalocal
[ Added missing 'bool user' argument to the !DWARF show_line_range() stub ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-probe.c    | 3 ++-
 tools/perf/util/probe-event.c | 9 +++++----
 tools/perf/util/probe-event.h | 3 ++-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 4d6858d..04412b4 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -472,7 +472,8 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 			usage_with_options(probe_usage, options);
 		}
 
-		ret = show_line_range(&params.line_range, params.target);
+		ret = show_line_range(&params.line_range, params.target,
+				      params.uprobes);
 		if (ret < 0)
 			pr_err_with_code("  Error: Failed to show lines.", ret);
 		return ret;
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index f73595f..be37b5a 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -697,11 +697,11 @@ end:
 	return ret;
 }
 
-int show_line_range(struct line_range *lr, const char *module)
+int show_line_range(struct line_range *lr, const char *module, bool user)
 {
 	int ret;
 
-	ret = init_symbol_maps(false);
+	ret = init_symbol_maps(user);
 	if (ret < 0)
 		return ret;
 	ret = __show_line_range(lr, module);
@@ -776,7 +776,7 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs,
 	int i, ret = 0;
 	struct debuginfo *dinfo;
 
-	ret = init_symbol_maps(false);
+	ret = init_symbol_maps(pevs->uprobes);
 	if (ret < 0)
 		return ret;
 
@@ -822,7 +822,8 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
 }
 
 int show_line_range(struct line_range *lr __maybe_unused,
-		    const char *module __maybe_unused)
+		    const char *module __maybe_unused,
+		    bool user __maybe_unused)
 {
 	pr_warning("Debuginfo-analysis is not supported.\n");
 	return -ENOSYS;
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index 776c934..e01e994 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -128,7 +128,8 @@ extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
 				 bool force_add);
 extern int del_perf_probe_events(struct strlist *dellist);
 extern int show_perf_probe_events(void);
-extern int show_line_range(struct line_range *lr, const char *module);
+extern int show_line_range(struct line_range *lr, const char *module,
+			   bool user);
 extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
 			       int max_probe_points, const char *module,
 			       struct strfilter *filter, bool externs);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:perf/core] perf probe: Do not use dwfl_module_addrsym if dwarf_diename finds symbol name
  2014-09-17  8:41 ` [PATCH perf/core 2/2] perf probe: Do not use dwfl_module_addrsym if dwarf_diename finds symbol name Masami Hiramatsu
@ 2014-09-19  5:23   ` tip-bot for Masami Hiramatsu
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2014-09-19  5:23 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, masami.hiramatsu.pt, tglx, dlernerdroid

Commit-ID:  664fee3dc37939bb8010906913fa9dbc52abb587
Gitweb:     http://git.kernel.org/tip/664fee3dc37939bb8010906913fa9dbc52abb587
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Wed, 17 Sep 2014 08:41:01 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 17 Sep 2014 18:01:43 -0300

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>
---
 tools/perf/util/probe-finder.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 9c59356..c7918f8 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -609,14 +609,18 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
 		return -EINVAL;
 	}
 
-	/* Get an appropriate symbol from symtab */
-	symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
+	symbol = dwarf_diename(sp_die);
 	if (!symbol) {
-		pr_warning("Failed to find symbol at 0x%lx\n",
-			   (unsigned long)paddr);
-		return -ENOENT;
+		/* Try to get the symbol name from symtab */
+		symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
+		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->symbol = strdup(symbol);
 	if (!tp->symbol)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-09-19  5:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-17  8:40 [PATCH perf/core 1/2] perf probe: Do not access kallsyms when analyzing user binaries Masami Hiramatsu
2014-09-17  8:41 ` [PATCH perf/core 2/2] perf probe: Do not use dwfl_module_addrsym if dwarf_diename finds symbol name Masami Hiramatsu
2014-09-19  5:23   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2014-09-17 20:59 ` [PATCH perf/core 1/2] perf probe: Do not access kallsyms when analyzing user binaries Arnaldo Carvalho de Melo
2014-09-18  0:36   ` Masami Hiramatsu
2014-09-19  5:22 ` [tip:perf/core] " tip-bot for Masami Hiramatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.