[PATCH 4/7] encoders: Fix diagnostic messages for unexpected tags in enumerations
Arnaldo Carvalho de Melo <[email protected]> Thu, 18 Jun 2026 14:33:13 -0300
| Newsgroups | org.kernel.vger.dwarves |
|---|---|
| Message-ID | <[email protected]> |
From: Arnaldo Carvalho de Melo <[email protected]> Print the actual unexpected child tag's name and id instead of the parent enumeration's, so the diagnostic message is useful for debugging. Fixes: a1b3ec41fcc2433d ("dwarf_loader: Initial support for DW_TAG_subprogram in DW_TAG_enumeration") Assisted-by: Claude:claude-opus-4-6-1m Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> --- btf_encoder.c | 2 +- ctf_encoder.c | 2 +- dwarves_fprintf.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/btf_encoder.c b/btf_encoder.c index be880f3fdb32f792..12c22b003b7990bf 100644 --- a/btf_encoder.c +++ b/btf_encoder.c @@ -1800,7 +1800,7 @@ static int32_t btf_encoder__add_enum_type(struct btf_encoder *encoder, struct ta type__for_each_enumerator(etype, pos) { if (pos->tag.tag != DW_TAG_enumerator) { fprintf(stderr, "Unexpected DW_TAG_%s <%llx>, skipping it...\n", - dwarf_tag_name(tag->tag), tag__orig_id(tag, cu)); + dwarf_tag_name(pos->tag.tag), tag__orig_id(&pos->tag, cu)); continue; } name = enumerator__name(pos); diff --git a/ctf_encoder.c b/ctf_encoder.c index 1c61c76ba20e06bc..f2c63c2b039026f8 100644 --- a/ctf_encoder.c +++ b/ctf_encoder.c @@ -157,7 +157,7 @@ static int enumeration_type__encode(struct tag *tag, const struct cu *cu, uint32 type__for_each_enumerator(etype, pos) { if (pos->tag.tag != DW_TAG_enumerator) { fprintf(stderr, "Unexpected DW_TAG_%s <%llx>, skipping it...\n", - dwarf_tag_name(tag->tag), tag__orig_id(tag, cu)); + dwarf_tag_name(pos->tag.tag), tag__orig_id(&pos->tag, cu)); continue; } ctf__add_enumerator(ctf, pos->name, pos->value, &position); diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index a3c8b391b9222fcd..4b6edcce81ebce71 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -501,8 +501,8 @@ size_t enumeration__fprintf(const struct tag *tag, const struct cu *cu, (unsigned long long)pos->value); break; default: - printed += fprintf(fp, "/* Unexpected %s <%llx> */\n", dwarf_tag_name(tag->tag), - tag__orig_id(tag, cu)); + printed += fprintf(fp, "/* Unexpected %s <%llx> */\n", dwarf_tag_name(pos->tag.tag), + tag__orig_id(&pos->tag, cu)); continue; } printed += fprintf(fp, ",\n"); -- 2.54.0