All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf dwarf-aux: Print array type name with "[]"
@ 2024-05-07  4:13 Namhyung Kim
  2024-05-07 23:57 ` Masami Hiramatsu
  0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2024-05-07  4:13 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
  Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
	linux-perf-users, Masami Hiramatsu

It's confusing both pointers and arrays are printed as *.  Let's print
array types with [] so that we can identify them easily.  Although it's
interchangable, sometimes it can cause confusion with size like in the
below example.

Note that it is not the same with C syntax where it goes to the variable
names, but we want to have it in the type names (like in Go language).

Before:
  mov [20] 0x68(reg5) -> reg0 type='struct page**' size=0x80 (die:0x4e61d32)

After:
  mov [20] 0x68(reg5) -> reg0 type='struct page*[]' size=0x80 (die:0x4e61d32)

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/dwarf-aux.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index c0a492e65388..ec988f294497 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -1110,8 +1110,10 @@ int die_get_typename_from_type(Dwarf_Die *type_die, struct strbuf *buf)
 	const char *tmp = "";
 
 	tag = dwarf_tag(type_die);
-	if (tag == DW_TAG_array_type || tag == DW_TAG_pointer_type)
+	if (tag == DW_TAG_pointer_type)
 		tmp = "*";
+	else if (tag == DW_TAG_array_type)
+		tmp = "[]";
 	else if (tag == DW_TAG_subroutine_type) {
 		/* Function pointer */
 		return strbuf_add(buf, "(function_type)", 15);
-- 
2.45.0.rc1.225.g2a3ae87e7f-goog


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

* Re: [PATCH] perf dwarf-aux: Print array type name with "[]"
  2024-05-07  4:13 [PATCH] perf dwarf-aux: Print array type name with "[]" Namhyung Kim
@ 2024-05-07 23:57 ` Masami Hiramatsu
  2024-05-08  0:42   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu @ 2024-05-07 23:57 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang, Jiri Olsa,
	Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
	linux-perf-users, Masami Hiramatsu

On Mon,  6 May 2024 21:13:38 -0700
Namhyung Kim <namhyung@kernel.org> wrote:

> It's confusing both pointers and arrays are printed as *.  Let's print
> array types with [] so that we can identify them easily.  Although it's
> interchangable, sometimes it can cause confusion with size like in the
> below example.
> 
> Note that it is not the same with C syntax where it goes to the variable
> names, but we want to have it in the type names (like in Go language).
> 
> Before:
>   mov [20] 0x68(reg5) -> reg0 type='struct page**' size=0x80 (die:0x4e61d32)
> 
> After:
>   mov [20] 0x68(reg5) -> reg0 type='struct page*[]' size=0x80 (die:0x4e61d32)
> 

Good improvement!

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thank you!

> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/util/dwarf-aux.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index c0a492e65388..ec988f294497 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -1110,8 +1110,10 @@ int die_get_typename_from_type(Dwarf_Die *type_die, struct strbuf *buf)
>  	const char *tmp = "";
>  
>  	tag = dwarf_tag(type_die);
> -	if (tag == DW_TAG_array_type || tag == DW_TAG_pointer_type)
> +	if (tag == DW_TAG_pointer_type)
>  		tmp = "*";
> +	else if (tag == DW_TAG_array_type)
> +		tmp = "[]";
>  	else if (tag == DW_TAG_subroutine_type) {
>  		/* Function pointer */
>  		return strbuf_add(buf, "(function_type)", 15);
> -- 
> 2.45.0.rc1.225.g2a3ae87e7f-goog
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

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

* Re: [PATCH] perf dwarf-aux: Print array type name with "[]"
  2024-05-07 23:57 ` Masami Hiramatsu
@ 2024-05-08  0:42   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-05-08  0:42 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Namhyung Kim, Ian Rogers, Kan Liang, Jiri Olsa, Adrian Hunter,
	Peter Zijlstra, Ingo Molnar, LKML, linux-perf-users

On Wed, May 08, 2024 at 08:57:51AM +0900, Masami Hiramatsu wrote:
> On Mon,  6 May 2024 21:13:38 -0700
> Namhyung Kim <namhyung@kernel.org> wrote:
> 
> > It's confusing both pointers and arrays are printed as *.  Let's print
> > array types with [] so that we can identify them easily.  Although it's
> > interchangable, sometimes it can cause confusion with size like in the
> > below example.
> > 
> > Note that it is not the same with C syntax where it goes to the variable
> > names, but we want to have it in the type names (like in Go language).
> > 
> > Before:
> >   mov [20] 0x68(reg5) -> reg0 type='struct page**' size=0x80 (die:0x4e61d32)
> > 
> > After:
> >   mov [20] 0x68(reg5) -> reg0 type='struct page*[]' size=0x80 (die:0x4e61d32)
> > 
> 
> Good improvement!
> 
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Indeed,

Thanks, applied to perf-tools-next,

- Arnaldo

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

end of thread, other threads:[~2024-05-08  0:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-07  4:13 [PATCH] perf dwarf-aux: Print array type name with "[]" Namhyung Kim
2024-05-07 23:57 ` Masami Hiramatsu
2024-05-08  0:42   ` Arnaldo Carvalho de Melo

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.