public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, paulus@samba.org,
	hpa@zytor.com, mingo@redhat.com, a.p.zijlstra@chello.nl,
	masami.hiramatsu.pt@hitachi.com, tglx@linutronix.de,
	mingo@elte.hu
Subject: [tip:perf/urgent] perf probe: Fix local variable searching loop
Date: Sat, 23 Oct 2010 19:40:34 GMT	[thread overview]
Message-ID: <tip-378eeaad3e1cfea7f6614018fb335de93df2ba1f@git.kernel.org> (raw)
In-Reply-To: <20101021101309.3542.46434.stgit@ltc236.sdl.hitachi.co.jp>

Commit-ID:  378eeaad3e1cfea7f6614018fb335de93df2ba1f
Gitweb:     http://git.kernel.org/tip/378eeaad3e1cfea7f6614018fb335de93df2ba1f
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 21 Oct 2010 19:13:09 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 21 Oct 2010 15:58:05 -0200

perf probe: Fix local variable searching loop

Fix to check the die's address and search into the die only if it has given
address.

This will avoid finding wrong variables in wrong basic block.

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
LKML-Reference: <20101021101309.3542.46434.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-finder.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index a2d1f79..abcaec5 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -329,25 +329,35 @@ static Dwarf_Die *die_find_inlinefunc(Dwarf_Die *sp_die, Dwarf_Addr addr,
 	return die_find_child(sp_die, __die_find_inline_cb, &addr, die_mem);
 }
 
+struct __find_variable_param {
+	const char *name;
+	Dwarf_Addr addr;
+};
+
 static int __die_find_variable_cb(Dwarf_Die *die_mem, void *data)
 {
-	const char *name = data;
+	struct __find_variable_param *fvp = data;
 	int tag;
 
 	tag = dwarf_tag(die_mem);
 	if ((tag == DW_TAG_formal_parameter ||
 	     tag == DW_TAG_variable) &&
-	    die_compare_name(die_mem, name))
+	    die_compare_name(die_mem, fvp->name))
 		return DIE_FIND_CB_FOUND;
 
-	return DIE_FIND_CB_CONTINUE;
+	if (dwarf_haspc(die_mem, fvp->addr))
+		return DIE_FIND_CB_CONTINUE;
+	else
+		return DIE_FIND_CB_SIBLING;
 }
 
-/* Find a variable called 'name' */
-static Dwarf_Die *die_find_variable(Dwarf_Die *sp_die, const char *name,
-				    Dwarf_Die *die_mem)
+/* Find a variable called 'name' at given address */
+static Dwarf_Die *die_find_variable_at(Dwarf_Die *sp_die, const char *name,
+				       Dwarf_Addr addr, Dwarf_Die *die_mem)
 {
-	return die_find_child(sp_die, __die_find_variable_cb, (void *)name,
+	struct __find_variable_param fvp = { .name = name, .addr = addr};
+
+	return die_find_child(sp_die, __die_find_variable_cb, (void *)&fvp,
 			      die_mem);
 }
 
@@ -731,7 +741,7 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf)
 	pr_debug("Searching '%s' variable in context.\n",
 		 pf->pvar->var);
 	/* Search child die for local variables and parameters. */
-	if (die_find_variable(sp_die, pf->pvar->var, &vr_die))
+	if (die_find_variable_at(sp_die, pf->pvar->var, pf->addr, &vr_die))
 		ret = convert_variable(&vr_die, pf);
 	else {
 		/* Search upper class */

  reply	other threads:[~2010-10-23 19:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-21 10:12 [PATCH -tip 0/7] Perf probe update (--vars/--module) Masami Hiramatsu
2010-10-21 10:13 ` [PATCH -tip 1/7] [BUGFIX] perf probe: Fix type searching Masami Hiramatsu
2010-10-23 19:40   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2010-10-21 10:13 ` [PATCH -tip 2/7] [BUGFIX] perf probe: Fix local variable searching loop Masami Hiramatsu
2010-10-23 19:40   ` tip-bot for Masami Hiramatsu [this message]
2010-10-21 10:13 ` [PATCH -tip 3/7] perf probe: Support global variables Masami Hiramatsu
2010-10-23 19:40   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2010-10-21 10:13 ` [PATCH -tip 4/7] perf probe: Show accessible local variables Masami Hiramatsu
2010-10-23 19:41   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2010-10-21 10:13 ` [PATCH -tip 5/7] perf probe: Function style fix Masami Hiramatsu
2010-10-23 19:41   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2010-10-21 10:13 ` [PATCH -tip 6/7] perf probe: Show accessible global variables Masami Hiramatsu
2010-10-21 20:50   ` Arnaldo Carvalho de Melo
2010-10-22  2:25     ` Masami Hiramatsu
2010-10-22  5:31       ` Masami Hiramatsu
2010-10-23 19:42   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2010-10-21 10:13 ` [PATCH -tip 7/7] perf probe: Add basic module support Masami Hiramatsu
2010-10-23 19:42   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu

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=tip-378eeaad3e1cfea7f6614018fb335de93df2ba1f@git.kernel.org \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox