public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/6] perf probe: Attempt to improve C++ probing
@ 2018-05-14  4:19 Holger Freyther
  2018-05-14 13:08 ` Masami Hiramatsu
  2018-05-14 13:31 ` Masami Hiramatsu
  0 siblings, 2 replies; 5+ messages in thread
From: Holger Freyther @ 2018-05-14  4:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Holger Hans Peter Freyther

From: Holger Hans Peter Freyther <holgar+kernel@google.com>

Currently perf probe -x app --funcs will list and demangle C++ functions
but the other probe actions can't work with them. When asking probe to not
demangle it will not list any of the application symbols creating the
impression that there are no symbols at all.

Make --funcs --no-demangle list all C++ functions and modify the handling
for listing code, variables and adding the uprobe work with the demangled
C++ function name.

I tried to keep this as minimal as possible but having to keep the dso in
the debuginfo and passing it everywhere to be able to demangle the linkage
name isn't pretty (and for C++ demangling the struct dso is not of much
use. Maybe having a static "empty" dso could avoid a lot of the changes).

Maybe the easiest first patch is to default to --no-demangle and change
the DEFAULT_FUNC_FILTER to not include mangled C++ symbols. The remaining
tooling would work then.

This has seen very little testing outside the following commands.

My test set includes:

 ./perf probe -x . -L "std::vector<int, std::allocator<int> >::at"
 ./perf probe -x . -L "std::vector<int, std::allocator<int> >::at:2-3"

 ./perf probe -x . -V "std::vector<int, std::allocator<int> >::at"
 ./perf probe -x . -V "std::vector<int, std::allocator<int> >::at:2"
 ./perf probe -x . -V "std::vector<int, std::allocator<int> >::size%return"


Holger Hans Peter Freyther (6):
  perf probe: Do not exclude mangled C++ funcs
  perf probe: Parse linerange for C++ functions
  perf probe: Make listing of C++ functions work
  perf probe: Show variables for C++ functions
  perf probe: Make listing of variables work for C++ functions
  perf probe: Make it possible to add a C++ uprobe

 tools/perf/builtin-probe.c     |   2 +-
 tools/perf/util/probe-event.c  |  77 ++++++++++++++++++++-
 tools/perf/util/probe-finder.c | 152 ++++++++++++++++++++++++++++++-----------
 tools/perf/util/probe-finder.h |   3 +
 tools/perf/util/string.c       |  57 ++++++++++++++++
 tools/perf/util/string2.h      |   1 +
 6 files changed, 247 insertions(+), 45 deletions(-)

-- 
2.7.4

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

* Re: [RFC 0/6] perf probe: Attempt to improve C++ probing
  2018-05-14  4:19 Holger Freyther
@ 2018-05-14 13:08 ` Masami Hiramatsu
  2018-05-14 13:31 ` Masami Hiramatsu
  1 sibling, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2018-05-14 13:08 UTC (permalink / raw)
  To: Holger Freyther; +Cc: linux-kernel, Holger Hans Peter Freyther

Hi Holger,

Thank you for your great work!

On Mon, 14 May 2018 12:19:34 +0800
Holger Freyther <automatic+kernel@freyther.de> wrote:

> From: Holger Hans Peter Freyther <holgar+kernel@google.com>
> 
> Currently perf probe -x app --funcs will list and demangle C++ functions
> but the other probe actions can't work with them. When asking probe to not
> demangle it will not list any of the application symbols creating the
> impression that there are no symbols at all.
> 
> Make --funcs --no-demangle list all C++ functions and modify the handling
> for listing code, variables and adding the uprobe work with the demangled
> C++ function name.
> 
> I tried to keep this as minimal as possible but having to keep the dso in
> the debuginfo and passing it everywhere to be able to demangle the linkage
> name isn't pretty (and for C++ demangling the struct dso is not of much
> use. Maybe having a static "empty" dso could avoid a lot of the changes).
> 
> Maybe the easiest first patch is to default to --no-demangle and change
> the DEFAULT_FUNC_FILTER to not include mangled C++ symbols. The remaining
> tooling would work then.
> 
> This has seen very little testing outside the following commands.
> 
> My test set includes:
> 
>  ./perf probe -x . -L "std::vector<int, std::allocator<int> >::at"
>  ./perf probe -x . -L "std::vector<int, std::allocator<int> >::at:2-3"
> 
>  ./perf probe -x . -V "std::vector<int, std::allocator<int> >::at"
>  ./perf probe -x . -V "std::vector<int, std::allocator<int> >::at:2"
>  ./perf probe -x . -V "std::vector<int, std::allocator<int> >::size%return"

OK, let me review it.

> 
> 
> Holger Hans Peter Freyther (6):
>   perf probe: Do not exclude mangled C++ funcs
>   perf probe: Parse linerange for C++ functions
>   perf probe: Make listing of C++ functions work
>   perf probe: Show variables for C++ functions
>   perf probe: Make listing of variables work for C++ functions
>   perf probe: Make it possible to add a C++ uprobe
> 
>  tools/perf/builtin-probe.c     |   2 +-
>  tools/perf/util/probe-event.c  |  77 ++++++++++++++++++++-
>  tools/perf/util/probe-finder.c | 152 ++++++++++++++++++++++++++++++-----------
>  tools/perf/util/probe-finder.h |   3 +
>  tools/perf/util/string.c       |  57 ++++++++++++++++
>  tools/perf/util/string2.h      |   1 +
>  6 files changed, 247 insertions(+), 45 deletions(-)
> 
> -- 
> 2.7.4
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [RFC 0/6] perf probe: Attempt to improve C++ probing
  2018-05-14  4:19 Holger Freyther
  2018-05-14 13:08 ` Masami Hiramatsu
@ 2018-05-14 13:31 ` Masami Hiramatsu
  2018-05-15 14:10   ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2018-05-14 13:31 UTC (permalink / raw)
  To: Holger Freyther, Arnaldo Carvalho de Melo
  Cc: linux-kernel, Holger Hans Peter Freyther

On Mon, 14 May 2018 12:19:34 +0800
Holger Freyther <automatic+kernel@freyther.de> wrote:

> From: Holger Hans Peter Freyther <holgar+kernel@google.com>
> 
> Currently perf probe -x app --funcs will list and demangle C++ functions
> but the other probe actions can't work with them. When asking probe to not
> demangle it will not list any of the application symbols creating the
> impression that there are no symbols at all.
> 
> Make --funcs --no-demangle list all C++ functions and modify the handling
> for listing code, variables and adding the uprobe work with the demangled
> C++ function name.
> 
> I tried to keep this as minimal as possible but having to keep the dso in
> the debuginfo and passing it everywhere to be able to demangle the linkage
> name isn't pretty (and for C++ demangling the struct dso is not of much
> use. Maybe having a static "empty" dso could avoid a lot of the changes).
> 
> Maybe the easiest first patch is to default to --no-demangle and change
> the DEFAULT_FUNC_FILTER to not include mangled C++ symbols. The remaining
> tooling would work then.
> 
> This has seen very little testing outside the following commands.
> 
> My test set includes:
> 
>  ./perf probe -x . -L "std::vector<int, std::allocator<int> >::at"
>  ./perf probe -x . -L "std::vector<int, std::allocator<int> >::at:2-3"
> 
>  ./perf probe -x . -V "std::vector<int, std::allocator<int> >::at"
>  ./perf probe -x . -V "std::vector<int, std::allocator<int> >::at:2"
>  ./perf probe -x . -V "std::vector<int, std::allocator<int> >::size%return"

OK, this series looks good to me :)

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
for this series.

Arnaldo, could you pull this series?

Thank you!


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [RFC 0/6] perf probe: Attempt to improve C++ probing
       [not found] <20180513110617.91669-1-automatic+kernel@freyther.de>
@ 2018-05-14 16:11 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-05-14 16:11 UTC (permalink / raw)
  To: Holger Freyther
  Cc: linux-perf-users, Holger Hans Peter Freyther, Ravi Bangoria,
	Jiri Olsa, Wang Nan, Namhyung Kim, Linux Kernel Mailing List

Em Sun, May 13, 2018 at 07:06:11PM +0800, Holger Freyther escreveu:
> From: Holger Hans Peter Freyther <holgar+kernel@google.com>
 
> Currently perf probe -x app --funcs will list and demangle C++ functions
> but the other probe actions can't work with them. When asking probe to not
> demangle it will not list any of the application symbols creating the
> impression that there are no symbols at all.
 
> Make --funcs --no-demangle list all C++ functions and modify the handling
> for listing code, variables and adding the uprobe work with the demangled
> C++ function name.
 
> I tried to keep this as minimal as possible but having to keep the dso in
> the debuginfo and passing it everywhere to be able to demangle the linkage
> name isn't pretty (and for C++ demangling the struct dso is not of much
> use. Maybe having a static "empty" dso could avoid a lot of the changes).
 
> Maybe the easiest first patch is to default to --no-demangle and change
> the DEFAULT_FUNC_FILTER to not include mangled C++ symbols. The remaining
> tooling would work then.
 
> My test set includes:
 
>  ./perf probe -x . -L "std::vector<int, std::allocator<int> >::at"
>  ./perf probe -x . -L "std::vector<int, std::allocator<int> >::at:2-3"
> 
>  ./perf probe -x . -V "std::vector<int, std::allocator<int> >::at"
>  ./perf probe -x . -V "std::vector<int, std::allocator<int> >::at:2"
>  ./perf probe -x . -V "std::vector<int, std::allocator<int> >::size%return"

Great stuff! Masami already gave his Acked-by, please address Namhyung's
concerns and consider adding a 'perf test' entry for C++ symbols found
in libstdc++, placing some probe in place and then running some program
that uses that function, then parsing the output of some tool using that
probe, something like you'll find in "perf test inet_pton", see:

[acme@jouet perf]$ ls -la tools/perf/tests/shell/
total 28
drwxrwxr-x. 3 acme acme 4096 May 11 11:53 .
drwxrwxr-x. 4 acme acme 4096 May 11 11:53 ..
drwxrwxr-x. 2 acme acme 4096 Apr 12 14:48 lib
-rwxrwxr-x. 1 acme acme  302 Apr 12 14:48 probe_vfs_getname.sh
-rwxrwxr-x. 1 acme acme 2050 May 11 11:53 record+probe_libc_inet_pton.sh
-rwxrwxr-x. 1 acme acme 1185 Apr 12 14:48 record+script_probe_vfs_getname.sh
-rwxrwxr-x. 1 acme acme 1176 Apr 12 14:48 trace+probe_vfs_getname.sh
[acme@jouet perf]$ 

[root@jouet ~]# perf test inet_pton
64: probe libc's inet_pton & backtrace it with ping       : Ok
[root@jouet ~]# perf test -v inet_pton
64: probe libc's inet_pton & backtrace it with ping       :
--- start ---
test child forked, pid 2441
ping 2478 0 143807.377533: probe_libc:inet_pton: (7f7259040e40)
113e40 __GI___inet_pton (/usr/lib64/libc-2.26.so)
e02b4 getaddrinfo (/usr/lib64/libc-2.26.so)
2f40 [unknown] (/usr/bin/ping)
test child finished with 0
---- end ----
probe libc's inet_pton & backtrace it with ping: Ok
[root@jouet ~]#

- Arnaldo

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

* Re: [RFC 0/6] perf probe: Attempt to improve C++ probing
  2018-05-14 13:31 ` Masami Hiramatsu
@ 2018-05-15 14:10   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-05-15 14:10 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Holger Freyther, linux-kernel, Holger Hans Peter Freyther

Em Mon, May 14, 2018 at 10:31:07PM +0900, Masami Hiramatsu escreveu:
> On Mon, 14 May 2018 12:19:34 +0800 Holger Freyther <automatic+kernel@freyther.de> wrote:
> >  ./perf probe -x . -V "std::vector<int, std::allocator<int> >::size%return"
 
> OK, this series looks good to me :)
 
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
> for this series.
 
> Arnaldo, could you pull this series?

Sure, I'm just waiting for Holger to comment on Namhyung points,

Thanks,

- Arnaldo

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

end of thread, other threads:[~2018-05-15 14:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20180513110617.91669-1-automatic+kernel@freyther.de>
2018-05-14 16:11 ` [RFC 0/6] perf probe: Attempt to improve C++ probing Arnaldo Carvalho de Melo
2018-05-14  4:19 Holger Freyther
2018-05-14 13:08 ` Masami Hiramatsu
2018-05-14 13:31 ` Masami Hiramatsu
2018-05-15 14:10   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox