public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [BUGFIX PATCH perf/core v2] perf-probe: Fix to show lines of sys_ functions correctly
@ 2015-08-12 21:36 Masami Hiramatsu
  2015-08-12 21:59 ` 平松雅巳 / HIRAMATU,MASAMI
  0 siblings, 1 reply; 2+ messages in thread
From: Masami Hiramatsu @ 2015-08-12 21:36 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Jiri Olsa, Linux Kernel Mailing List, David Ahern

"perf probe --lines sys_poll" shows only the first line of
sys_poll, because the SYSCALL_DEFINE macro
----
SYSCALL_DEFINE*(foo,...)
{
  body;
}
----
is expanded as below (on debuginfo)

----
static inline int SYSC_foo(...)
{
  body;
}
int SyS_foo(...) <- is an alias of sys_foo.
{
  return SYSC_foo(...);
}
----

So, "perf probe --lines sys_foo" decodes SyS_foo function and
it also skips inlined functions(SYSC_foo) inside the target
function because those functions are usually defined somewhere
else.

To fix this issue, this fix checks whether the inlined function
is defined at the same point of the target function, and if so,
it doesn't skip the inline function.

Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 Changes in v2
  - Fix to add a brace to if statement.
---
 tools/perf/util/dwarf-aux.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 57f3ef4..a509aa84 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -734,15 +734,18 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
 	Dwarf_Lines *lines;
 	Dwarf_Line *line;
 	Dwarf_Addr addr;
-	const char *fname;
+	const char *fname, *decf = NULL;
 	int lineno, ret = 0;
+	int decl = 0, inl;
 	Dwarf_Die die_mem, *cu_die;
 	size_t nlines, i;
 
 	/* Get the CU die */
-	if (dwarf_tag(rt_die) != DW_TAG_compile_unit)
+	if (dwarf_tag(rt_die) != DW_TAG_compile_unit) {
 		cu_die = dwarf_diecu(rt_die, &die_mem, NULL, NULL);
-	else
+		dwarf_decl_line(rt_die, &decl);
+		decf = dwarf_decl_file(rt_die);
+	} else
 		cu_die = rt_die;
 	if (!cu_die) {
 		pr_debug2("Failed to get CU from given DIE.\n");
@@ -767,15 +770,21 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
 			continue;
 		}
 		/* Filter lines based on address */
-		if (rt_die != cu_die)
+		if (rt_die != cu_die) {
 			/*
 			 * Address filtering
 			 * The line is included in given function, and
 			 * no inline block includes it.
 			 */
-			if (!dwarf_haspc(rt_die, addr) ||
-			    die_find_inlinefunc(rt_die, addr, &die_mem))
+			if (!dwarf_haspc(rt_die, addr))
 				continue;
+			if (die_find_inlinefunc(rt_die, addr, &die_mem)) {
+				dwarf_decl_line(&die_mem, &inl);
+				if (inl != decl ||
+				    decf != dwarf_decl_file(&die_mem))
+					continue;
+			}
+		}
 		/* Get source line */
 		fname = dwarf_linesrc(line, NULL, NULL);
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [BUGFIX PATCH perf/core v2] perf-probe: Fix to show lines of sys_ functions correctly
  2015-08-12 21:36 [BUGFIX PATCH perf/core v2] perf-probe: Fix to show lines of sys_ functions correctly Masami Hiramatsu
@ 2015-08-12 21:59 ` 平松雅巳 / HIRAMATU,MASAMI
  0 siblings, 0 replies; 2+ messages in thread
From: 平松雅巳 / HIRAMATU,MASAMI @ 2015-08-12 21:59 UTC (permalink / raw)
  To: 平松雅巳 / HIRAMATU,MASAMI,
	Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Jiri Olsa, Linux Kernel Mailing List, David Ahern

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3043 bytes --]

Sorry, please ignore this. the original one already merged.
I'll send diff patch.

Thanks!

> From: Masami Hiramatsu [mailto:masami.hiramatsu.pt@hitachi.com]
> 
> "perf probe --lines sys_poll" shows only the first line of
> sys_poll, because the SYSCALL_DEFINE macro
> ----
> SYSCALL_DEFINE*(foo,...)
> {
>   body;
> }
> ----
> is expanded as below (on debuginfo)
> 
> ----
> static inline int SYSC_foo(...)
> {
>   body;
> }
> int SyS_foo(...) <- is an alias of sys_foo.
> {
>   return SYSC_foo(...);
> }
> ----
> 
> So, "perf probe --lines sys_foo" decodes SyS_foo function and
> it also skips inlined functions(SYSC_foo) inside the target
> function because those functions are usually defined somewhere
> else.
> 
> To fix this issue, this fix checks whether the inlined function
> is defined at the same point of the target function, and if so,
> it doesn't skip the inline function.
> 
> Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> ---
>  Changes in v2
>   - Fix to add a brace to if statement.
> ---
>  tools/perf/util/dwarf-aux.c |   21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index 57f3ef4..a509aa84 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -734,15 +734,18 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
>  	Dwarf_Lines *lines;
>  	Dwarf_Line *line;
>  	Dwarf_Addr addr;
> -	const char *fname;
> +	const char *fname, *decf = NULL;
>  	int lineno, ret = 0;
> +	int decl = 0, inl;
>  	Dwarf_Die die_mem, *cu_die;
>  	size_t nlines, i;
> 
>  	/* Get the CU die */
> -	if (dwarf_tag(rt_die) != DW_TAG_compile_unit)
> +	if (dwarf_tag(rt_die) != DW_TAG_compile_unit) {
>  		cu_die = dwarf_diecu(rt_die, &die_mem, NULL, NULL);
> -	else
> +		dwarf_decl_line(rt_die, &decl);
> +		decf = dwarf_decl_file(rt_die);
> +	} else
>  		cu_die = rt_die;
>  	if (!cu_die) {
>  		pr_debug2("Failed to get CU from given DIE.\n");
> @@ -767,15 +770,21 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
>  			continue;
>  		}
>  		/* Filter lines based on address */
> -		if (rt_die != cu_die)
> +		if (rt_die != cu_die) {
>  			/*
>  			 * Address filtering
>  			 * The line is included in given function, and
>  			 * no inline block includes it.
>  			 */
> -			if (!dwarf_haspc(rt_die, addr) ||
> -			    die_find_inlinefunc(rt_die, addr, &die_mem))
> +			if (!dwarf_haspc(rt_die, addr))
>  				continue;
> +			if (die_find_inlinefunc(rt_die, addr, &die_mem)) {
> +				dwarf_decl_line(&die_mem, &inl);
> +				if (inl != decl ||
> +				    decf != dwarf_decl_file(&die_mem))
> +					continue;
> +			}
> +		}
>  		/* Get source line */
>  		fname = dwarf_linesrc(line, NULL, NULL);
> 

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-12 21:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-12 21:36 [BUGFIX PATCH perf/core v2] perf-probe: Fix to show lines of sys_ functions correctly Masami Hiramatsu
2015-08-12 21:59 ` 平松雅巳 / HIRAMATU,MASAMI

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox