Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1493661

[tip:perf/core] perf probe: Skip if the function address is 0

From tip-bot for Masami Hiramatsu <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:perf/core] perf probe: Skip if the function address is 0
Date 2016-09-29 20:30 +0200
Message-ID <smOfL-7Gi-9@gated-at.bofh.it> (permalink)
References <skAJX-5CZ-31@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Commit-ID:  0ad45b33c58dca60dec7e1fb44766753bc4a7a38
Gitweb:     http://git.kernel.org/tip/0ad45b33c58dca60dec7e1fb44766753bc4a7a38
Author:     Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate: Sat, 24 Sep 2016 00:35:07 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 29 Sep 2016 11:17:07 -0300

perf probe: Skip if the function address is 0

Skip probes if the entry address of the target function is 0.  This can
happen when we're handling C++ debuginfo files.

E.g. without this fix, below case still fail.
  ----
  $ ./perf probe -x /usr/lib64/libstdc++.so.6 -vD is_open
  probe-definition(0): is_open
  symbol:is_open file:(null) line:0 offset:0 return:0 lazy:(null)
  0 arguments
  symbol:catch file:(null) line:0 offset:0 return:0 lazy:(null)
  symbol:throw file:(null) line:0 offset:0 return:0 lazy:(null)
  symbol:rethrow file:(null) line:0 offset:0 return:0 lazy:(null)
  Open Debuginfo file: /usr/lib/debug/usr/lib64/libstdc++.so.6.0.22.debug
  Try to find probe point from debuginfo.
  Matched function: is_open [295df]
  found inline addr: 0x8ca80
  Probe point found: is_open+0
  found inline addr: 0x8ca70
  Probe point found: is_open+0
  found inline addr: 0x8ca60
  Probe point found: is_open+0
  Matched function: is_open [6527f]
  Matched function: is_open [9fe8a]
  Probe point found: is_open+0
  Matched function: is_open [19710b]
  found inline addr: 0xecca9
  Probe point found: stdio_filebuf+57
  found inline addr: 0x0
  Probe point found: swap+0
  Matched function: is_open [19fc9d]
  Probe point found: is_open+0
  Found 7 probe_trace_events.
  p:probe_libstdc++/is_open /usr/lib64/libstdc++.so.6.0.22:0x8ca80
  p:probe_libstdc++/is_open_1 /usr/lib64/libstdc++.so.6.0.22:0x8ca70
  p:probe_libstdc++/is_open_2 /usr/lib64/libstdc++.so.6.0.22:0x8ca60
  p:probe_libstdc++/is_open_3 /usr/lib64/libstdc++.so.6.0.22:0xb0ad0
  p:probe_libstdc++/is_open_4 /usr/lib64/libstdc++.so.6.0.22:0xecca9
  Failed to synthesize probe trace event.
    Error: Failed to add events. Reason: Invalid argument (Code: -22)
  ----
This is because some instances have entry_pc == 0 (see 19710b and
19fc9d). With this fix, those are skipped.

  ----
  $ ./perf probe -x /usr/lib64/libstdc++.so.6 -D is_open
  p:probe_libstdc++/is_open /usr/lib64/libstdc++.so.6.0.22:0x8ca80
  p:probe_libstdc++/is_open_1 /usr/lib64/libstdc++.so.6.0.22:0x8ca70
  p:probe_libstdc++/is_open_2 /usr/lib64/libstdc++.so.6.0.22:0x8ca60
  p:probe_libstdc++/is_open_3 /usr/lib64/libstdc++.so.6.0.22:0xb0ad0
  p:probe_libstdc++/is_open_4 /usr/lib64/libstdc++.so.6.0.22:0xecca9
  ----

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/147464490707.29804.14277897643725143867.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-finder.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 5fe8325..df4debe 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -955,6 +955,11 @@ static int probe_point_inline_cb(Dwarf_Die *in_die, void *data)
 				   dwarf_diename(in_die));
 			return -ENOENT;
 		}
+		if (addr == 0) {
+			pr_debug("%s has no valid entry address. skipped.\n",
+				 dwarf_diename(in_die));
+			return -ENOENT;
+		}
 		pf->addr = addr;
 		pf->addr += pp->offset;
 		pr_debug("found inline addr: 0x%jx\n",
@@ -998,8 +1003,13 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data)
 	} else if (die_is_func_instance(sp_die)) {
 		/* Instances always have the entry address */
 		dwarf_entrypc(sp_die, &pf->addr);
+		/* But in some case the entry address is 0 */
+		if (pf->addr == 0) {
+			pr_debug("%s has no entry PC. Skipped\n",
+				 dwarf_diename(sp_die));
+			param->retval = 0;
 		/* Real function */
-		if (pp->lazy_line)
+		} else if (pp->lazy_line)
 			param->retval = find_probe_point_lazy(sp_die, pf);
 		else {
 			skip_prologue(sp_die, pf);

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH perf/core 0/4] perf-probe fixes for C++ Masami Hiramatsu <mhiramat@kernel.org> - 2016-09-23 17:40 +0200
  [PATCH perf/core 4/4] perf-probe: Match linkage name with mangled name Masami Hiramatsu <mhiramat@kernel.org> - 2016-09-23 17:40 +0200
    [tip:perf/core] perf probe: Match linkage name with mangled name tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-09-29 20:30 +0200
  [PATCH perf/core 3/4] perf-probe: Fix to cut off incompatible chars from group name Masami Hiramatsu <mhiramat@kernel.org> - 2016-09-23 17:40 +0200
    [tip:perf/core] perf probe: Fix to cut off incompatible chars from  group name tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-09-29 20:30 +0200
  [PATCH perf/core 2/4] perf-probe: Skip if the function address is 0 Masami Hiramatsu <mhiramat@kernel.org> - 2016-09-23 17:40 +0200
    [tip:perf/core] perf probe: Skip if the function address is 0 tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-09-29 20:30 +0200
  [PATCH perf/core 1/4] perf-probe: Ignore the error of finding inline instance Masami Hiramatsu <mhiramat@kernel.org> - 2016-09-23 17:40 +0200
    [tip:perf/core] perf probe: Ignore the error of finding inline  instance tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-09-29 20:30 +0200
  Re: [PATCH perf/core 0/4] perf-probe fixes for C++ Jiri Olsa <jolsa@redhat.com> - 2016-09-25 13:20 +0200
    Re: [PATCH perf/core 0/4] perf-probe fixes for C++ Masami Hiramatsu <mhiramat@kernel.org> - 2016-09-27 20:20 +0200

csiph-web