All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Masami Hiramatsu" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Ravi Bangoria <ravi.bangoria@linux.ibm.com>,
	"Steven Rostedt (VMware)" <rostedt@goodmis.org>,
	Tom Zanussi <tom.zanussi@linux.intel.com>,
	Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
	linux-kernel@vger.kernel.org
Subject: [tip: perf/core] perf probe: Return a better scope DIE if there is no best scope
Date: Tue, 12 Nov 2019 11:17:54 -0000	[thread overview]
Message-ID: <157355747423.29376.8608445663818956550.tip-bot2@tip-bot2> (raw)
In-Reply-To: <157291300887.19771.14936015360963292236.stgit@devnote2>

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     c701636aeec4c173208697d68da6e4271125564b
Gitweb:        https://git.kernel.org/tip/c701636aeec4c173208697d68da6e4271125564b
Author:        Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate:    Tue, 05 Nov 2019 09:16:49 +09:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Thu, 07 Nov 2019 08:30:18 -03:00

perf probe: Return a better scope DIE if there is no best scope

Make find_best_scope() returns innermost DIE at given address if there
is no best matched scope DIE. Since Gcc sometimes generates intuitively
strange line info which is out of inlined function address range, we
need this fixup.

Without this, sometimes perf probe failed to probe on a line inside an
inlined function:

  # perf probe -D ksys_open:3
  Failed to find scope of probe point.
    Error: Failed to add events.

With this fix, 'perf probe' can probe it:

  # perf probe -D ksys_open:3
  p:probe/ksys_open _text+25707308
  p:probe/ksys_open_1 _text+25710596
  p:probe/ksys_open_2 _text+25711114
  p:probe/ksys_open_3 _text+25711343
  p:probe/ksys_open_4 _text+25714058
  p:probe/ksys_open_5 _text+2819653
  p:probe/ksys_open_6 _text+2819701

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
Link: http://lore.kernel.org/lkml/157291300887.19771.14936015360963292236.stgit@devnote2
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-finder.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 88e17a4..582f8c3 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -744,6 +744,16 @@ static int find_best_scope_cb(Dwarf_Die *fn_die, void *data)
 	return 0;
 }
 
+/* Return innermost DIE */
+static int find_inner_scope_cb(Dwarf_Die *fn_die, void *data)
+{
+	struct find_scope_param *fsp = data;
+
+	memcpy(fsp->die_mem, fn_die, sizeof(Dwarf_Die));
+	fsp->found = true;
+	return 1;
+}
+
 /* Find an appropriate scope fits to given conditions */
 static Dwarf_Die *find_best_scope(struct probe_finder *pf, Dwarf_Die *die_mem)
 {
@@ -755,8 +765,13 @@ static Dwarf_Die *find_best_scope(struct probe_finder *pf, Dwarf_Die *die_mem)
 		.die_mem = die_mem,
 		.found = false,
 	};
+	int ret;
 
-	cu_walk_functions_at(&pf->cu_die, pf->addr, find_best_scope_cb, &fsp);
+	ret = cu_walk_functions_at(&pf->cu_die, pf->addr, find_best_scope_cb,
+				   &fsp);
+	if (!ret && !fsp.found)
+		cu_walk_functions_at(&pf->cu_die, pf->addr,
+				     find_inner_scope_cb, &fsp);
 
 	return fsp.found ? die_mem : NULL;
 }

  parent reply	other threads:[~2019-11-12 11:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05  0:16 [PATCH 0/5] perf/probe: Support multiprobe and immediates Masami Hiramatsu
2019-11-05  0:16 ` [PATCH 1/5] perf probe: Return a better scope DIE if there is no best scope Masami Hiramatsu
2019-11-06 19:51   ` Arnaldo Carvalho de Melo
2019-11-12 11:17   ` tip-bot2 for Masami Hiramatsu [this message]
2019-11-05  0:16 ` [PATCH 2/5] perf probe: Generate event name with line number Masami Hiramatsu
2019-11-06 19:54   ` Arnaldo Carvalho de Melo
2019-11-07 13:43     ` Masami Hiramatsu
2019-11-07 13:55       ` Arnaldo Carvalho de Melo
2019-11-05  0:17 ` [PATCH 3/5] perf probe: Support multiprobe event Masami Hiramatsu
2019-11-06 19:56   ` Arnaldo Carvalho de Melo
2019-11-07 13:47     ` Masami Hiramatsu
2019-11-05  0:17 ` [PATCH 4/5] perf probe: Support DW_AT_const_value constant value Masami Hiramatsu
2019-11-06 19:56   ` Arnaldo Carvalho de Melo
2019-11-05  0:17 ` [PATCH 5/5] perf probe: Trace a magic number if variable is not found Masami Hiramatsu
2019-11-06 20:00   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=157355747423.29376.8608445663818956550.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=acme@redhat.com \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=ravi.bangoria@linux.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=tom.zanussi@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.