Commit acb6a704 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Arnaldo Carvalho de Melo

perf probe: Walk function lines in lexical blocks

Since some inlined functions are in lexical blocks of given function, we
have to recursively walk through the DIE tree.  Without this fix,
perf-probe -L can miss the inlined functions which is in a lexical block
(like if (..) { func() } case.)

However, even though, to walk the lines in a given function, we don't
need to follow the children DIE of inlined functions because those do
not have any lines in the specified function.

We need to walk though whole trees only if we walk all lines in a given
file, because an inlined function can include another inlined function
in the same file.

Fixes: b0e9cb28 ("perf probe: Fix to search nested inlined functions in CU")
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lore.kernel.org/lkml/157190836514.1859.15996864849678136353.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b77afa1f
...@@ -678,10 +678,9 @@ static int __die_walk_funclines_cb(Dwarf_Die *in_die, void *data) ...@@ -678,10 +678,9 @@ static int __die_walk_funclines_cb(Dwarf_Die *in_die, void *data)
if (lw->retval != 0) if (lw->retval != 0)
return DIE_FIND_CB_END; return DIE_FIND_CB_END;
} }
if (!lw->recursive)
return DIE_FIND_CB_SIBLING;
} }
if (!lw->recursive)
/* Don't need to search recursively */
return DIE_FIND_CB_SIBLING;
if (addr) { if (addr) {
fname = dwarf_decl_file(in_die); fname = dwarf_decl_file(in_die);
...@@ -728,6 +727,10 @@ static int __die_walk_culines_cb(Dwarf_Die *sp_die, void *data) ...@@ -728,6 +727,10 @@ static int __die_walk_culines_cb(Dwarf_Die *sp_die, void *data)
{ {
struct __line_walk_param *lw = data; struct __line_walk_param *lw = data;
/*
* Since inlined function can include another inlined function in
* the same file, we need to walk in it recursively.
*/
lw->retval = __die_walk_funclines(sp_die, true, lw->callback, lw->data); lw->retval = __die_walk_funclines(sp_die, true, lw->callback, lw->data);
if (lw->retval != 0) if (lw->retval != 0)
return DWARF_CB_ABORT; return DWARF_CB_ABORT;
...@@ -817,8 +820,9 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data) ...@@ -817,8 +820,9 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
*/ */
if (rt_die != cu_die) if (rt_die != cu_die)
/* /*
* Don't need walk functions recursively, because nested * Don't need walk inlined functions recursively, because
* inlined functions don't have lines of the specified DIE. * inner inlined functions don't have the lines of the
* specified function.
*/ */
ret = __die_walk_funclines(rt_die, false, callback, data); ret = __die_walk_funclines(rt_die, false, callback, data);
else { else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment