[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231104195202.e8c300fcdc3938e2bf13f5cf@kernel.org>
Date: Sat, 4 Nov 2023 19:52:02 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Ingo Molnar <mingo@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
linux-perf-users@...r.kernel.org,
Linus Torvalds <torvalds@...ux-foundation.org>,
Stephane Eranian <eranian@...gle.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
linux-toolchains@...r.kernel.org, linux-trace-devel@...r.kernel.org
Subject: Re: [PATCH 04/48] perf dwarf-aux: Fix die_get_typename() for void *
On Wed, 11 Oct 2023 20:50:27 -0700
Namhyung Kim <namhyung@...nel.org> wrote:
> The die_get_typename() is to return a C-like type name from DWARF debug
> entry and it follows data type if the target entry is a pointer type.
> But I found void pointers don't have the type attribte to follow and
> then the function returns an error for that case. This results in a
> broken type string for void pointer types.
>
> For example, the following type entries are pointer types.
>
> <1><48c>: Abbrev Number: 4 (DW_TAG_pointer_type)
> <48d> DW_AT_byte_size : 8
> <48d> DW_AT_type : <0x481>
> <1><491>: Abbrev Number: 211 (DW_TAG_pointer_type)
> <493> DW_AT_byte_size : 8
> <1><494>: Abbrev Number: 4 (DW_TAG_pointer_type)
> <495> DW_AT_byte_size : 8
> <495> DW_AT_type : <0x49e>
>
> The first one at offset 48c and the third one at offset 494 have type
> information. Then they are pointer types for the referenced types.
> But the second one at offset 491 doesn't have the type attribute.
This looks good to me!
Acked-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
Thanks!
>
> Cc: Masami Hiramatsu <mhiramat@...nel.org>
> Signed-off-by: Namhyung Kim <namhyung@...nel.org>
> ---
> tools/perf/util/dwarf-aux.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index 2941d88f2199..4849c3bbfd95 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -1090,7 +1090,14 @@ int die_get_typename(Dwarf_Die *vr_die, struct strbuf *buf)
> return strbuf_addf(buf, "%s%s", tmp, name ?: "");
> }
> ret = die_get_typename(&type, buf);
> - return ret ? ret : strbuf_addstr(buf, tmp);
> + if (ret < 0) {
> + /* void pointer has no type attribute */
> + if (tag == DW_TAG_pointer_type && ret == -ENOENT)
> + return strbuf_addf(buf, "void*");
> +
> + return ret;
> + }
> + return strbuf_addstr(buf, tmp);
> }
>
> /**
> --
> 2.42.0.655.g421f12c284-goog
>
--
Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists