perf dwarf-aux: Print array type name with "[]"
authorNamhyung Kim <namhyung@kernel.org>
Tue, 7 May 2024 04:13:38 +0000 (21:13 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 8 May 2024 00:39:42 +0000 (21:39 -0300)
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)

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240507041338.2081775-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/dwarf-aux.c

index c0a492e65388d8abb67999dd78dd9f2beba9f82a..ec988f2944972cc4a7d14e23be299780d22a5e23 100644 (file)
@@ -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);