* [PATCH 1/2] perf dwarf-aux: Fix off-by-one in die_get_varname()
@ 2023-06-12 23:41 Namhyung Kim
2023-06-12 23:41 ` [PATCH 2/2] perf dwarf-aux: Allow unnamed struct/union/enum Namhyung Kim
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Namhyung Kim @ 2023-06-12 23:41 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Jiri Olsa
Cc: Ian Rogers, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Masami Hiramatsu
The die_get_varname() returns "(unknown_type)" string if it failed to
find a type for the variable. But it had a space before the opening
parenthesis and it made the closing parenthesis cut off due to the
off-by-one in the string length (14).
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/dwarf-aux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index e4593a71556b..1ac88b79687d 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -1103,7 +1103,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf)
ret = die_get_typename(vr_die, buf);
if (ret < 0) {
pr_debug("Failed to get type, make it unknown.\n");
- ret = strbuf_add(buf, " (unknown_type)", 14);
+ ret = strbuf_add(buf, "(unknown_type)", 14);
}
return ret < 0 ? ret : strbuf_addf(buf, "\t%s", dwarf_diename(vr_die));
--
2.41.0.162.gfafddb0af9-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] perf dwarf-aux: Allow unnamed struct/union/enum
2023-06-12 23:41 [PATCH 1/2] perf dwarf-aux: Fix off-by-one in die_get_varname() Namhyung Kim
@ 2023-06-12 23:41 ` Namhyung Kim
2023-06-13 14:32 ` [PATCH 1/2] perf dwarf-aux: Fix off-by-one in die_get_varname() Arnaldo Carvalho de Melo
2023-06-13 14:34 ` Arnaldo Carvalho de Melo
2 siblings, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2023-06-12 23:41 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Jiri Olsa
Cc: Ian Rogers, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Masami Hiramatsu
It's possible some struct/union/enum type don't have type name. Allow
the empty name after "struct"/"union"/"enum" string rather than fail.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/dwarf-aux.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 1ac88b79687d..759434552653 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -1074,16 +1074,18 @@ int die_get_typename(Dwarf_Die *vr_die, struct strbuf *buf)
/* Function pointer */
return strbuf_add(buf, "(function_type)", 15);
} else {
- if (!dwarf_diename(&type))
- return -ENOENT;
+ const char *name = dwarf_diename(&type);
+
if (tag == DW_TAG_union_type)
tmp = "union ";
else if (tag == DW_TAG_structure_type)
tmp = "struct ";
else if (tag == DW_TAG_enumeration_type)
tmp = "enum ";
+ else if (name == NULL)
+ return -ENOENT;
/* Write a base name */
- return strbuf_addf(buf, "%s%s", tmp, dwarf_diename(&type));
+ return strbuf_addf(buf, "%s%s", tmp, name ?: "");
}
ret = die_get_typename(&type, buf);
return ret ? ret : strbuf_addstr(buf, tmp);
--
2.41.0.162.gfafddb0af9-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] perf dwarf-aux: Fix off-by-one in die_get_varname()
2023-06-12 23:41 [PATCH 1/2] perf dwarf-aux: Fix off-by-one in die_get_varname() Namhyung Kim
2023-06-12 23:41 ` [PATCH 2/2] perf dwarf-aux: Allow unnamed struct/union/enum Namhyung Kim
@ 2023-06-13 14:32 ` Arnaldo Carvalho de Melo
2023-06-13 14:34 ` Arnaldo Carvalho de Melo
2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-06-13 14:32 UTC (permalink / raw)
To: Namhyung Kim
Cc: Jiri Olsa, Ian Rogers, Adrian Hunter, Peter Zijlstra, Ingo Molnar,
LKML, linux-perf-users, Masami Hiramatsu
Em Mon, Jun 12, 2023 at 04:41:01PM -0700, Namhyung Kim escreveu:
> The die_get_varname() returns "(unknown_type)" string if it failed to
> find a type for the variable. But it had a space before the opening
> parenthesis and it made the closing parenthesis cut off due to the
> off-by-one in the string length (14).
Thanks, applied and added:
Fixes: 88fd633cdfa19060 ("perf probe: No need to use formatting strbuf method")
I introduced this long ago :-\
- Arnaldo
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/util/dwarf-aux.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index e4593a71556b..1ac88b79687d 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -1103,7 +1103,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf)
> ret = die_get_typename(vr_die, buf);
> if (ret < 0) {
> pr_debug("Failed to get type, make it unknown.\n");
> - ret = strbuf_add(buf, " (unknown_type)", 14);
> + ret = strbuf_add(buf, "(unknown_type)", 14);
> }
>
> return ret < 0 ? ret : strbuf_addf(buf, "\t%s", dwarf_diename(vr_die));
> --
> 2.41.0.162.gfafddb0af9-goog
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] perf dwarf-aux: Fix off-by-one in die_get_varname()
2023-06-12 23:41 [PATCH 1/2] perf dwarf-aux: Fix off-by-one in die_get_varname() Namhyung Kim
2023-06-12 23:41 ` [PATCH 2/2] perf dwarf-aux: Allow unnamed struct/union/enum Namhyung Kim
2023-06-13 14:32 ` [PATCH 1/2] perf dwarf-aux: Fix off-by-one in die_get_varname() Arnaldo Carvalho de Melo
@ 2023-06-13 14:34 ` Arnaldo Carvalho de Melo
2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-06-13 14:34 UTC (permalink / raw)
To: Namhyung Kim
Cc: Jiri Olsa, Ian Rogers, Adrian Hunter, Peter Zijlstra, Ingo Molnar,
LKML, linux-perf-users, Masami Hiramatsu
Em Mon, Jun 12, 2023 at 04:41:01PM -0700, Namhyung Kim escreveu:
> The die_get_varname() returns "(unknown_type)" string if it failed to
> find a type for the variable. But it had a space before the opening
> parenthesis and it made the closing parenthesis cut off due to the
> off-by-one in the string length (14).
Thanks, applied both patches.
- Arnaldo
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/util/dwarf-aux.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index e4593a71556b..1ac88b79687d 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -1103,7 +1103,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf)
> ret = die_get_typename(vr_die, buf);
> if (ret < 0) {
> pr_debug("Failed to get type, make it unknown.\n");
> - ret = strbuf_add(buf, " (unknown_type)", 14);
> + ret = strbuf_add(buf, "(unknown_type)", 14);
> }
>
> return ret < 0 ? ret : strbuf_addf(buf, "\t%s", dwarf_diename(vr_die));
> --
> 2.41.0.162.gfafddb0af9-goog
>
--
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-13 14:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-12 23:41 [PATCH 1/2] perf dwarf-aux: Fix off-by-one in die_get_varname() Namhyung Kim
2023-06-12 23:41 ` [PATCH 2/2] perf dwarf-aux: Allow unnamed struct/union/enum Namhyung Kim
2023-06-13 14:32 ` [PATCH 1/2] perf dwarf-aux: Fix off-by-one in die_get_varname() Arnaldo Carvalho de Melo
2023-06-13 14:34 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).