[PATCH -tip 2/5] [BUGFIX] perf probe: Fix line walker to check CU correctly

Masami Hiramatsu
2011-07-10T10:42:10Z

Fix line walker to check whether a given DIE is CU or not.
Actually this function accepts CU, subprogram and
inlined_subroutine DIEs.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
---

tools/perf/util/probe-finder.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 1a35637..52b87f3 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -599,8 +599,9 @@ static int __die_walk_culines_cb(Dwarf_Die *sp_die, void *data)
}

/*
- * Walk on lines inside given PDIE. If the PDIE is subprogram, walk only on
- * the lines inside the subprogram, otherwise PDIE must be a CU DIE.
+ * Walk on lines inside given PDIE. If the PDIE is subprogram or
+ * inlined_subprogram, walk only on the lines inside the DIE,
+ * otherwise PDIE must be a CU DIE.
*/
static int die_walk_lines(Dwarf_Die *pdie, line_walk_handler_t handler,
void *data)
@@ -614,12 +615,12 @@ static int die_walk_lines(Dwarf_Die *pdie, line_walk_handler_t handler,
size_t nlines, i;

/* Get the CU die */
- if (dwarf_tag(pdie) == DW_TAG_subprogram)
+ if (dwarf_tag(pdie) != DW_TAG_compile_unit)
cu_die = dwarf_diecu(pdie, &die_mem, NULL, NULL);
else
cu_die = pdie;
if (!cu_die) {
- pr_debug2("Failed to get CU from subprogram\n");
+ pr_debug2("Failed to get CU from given DIE\n");
return -EINVAL;
}