From: Tankut Baris Aktemur <tankutbaris.aktemur@amd.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 2/2] gdb, dwarf: update complaint logic in read_tag_pointer_type
Date: Tue, 28 Jul 2026 17:07:46 +0000 [thread overview]
Message-ID: <20260728170746.1037942-2-tankutbaris.aktemur@amd.com> (raw)
In-Reply-To: <20260728170746.1037942-1-tankutbaris.aktemur@amd.com>
There is nested branching in `read_tag_pointer_type` with non-trivial
conditions. I think what is meant there is if there is a non-default
address class attribute for the type, alignment and size changes are
acceptable. Otherwise we should check for unexpected size and
alignment, and complain about them. This patch updates the logic.
In particular:
- If addr_class is default, byte_size does not match the expectation,
and the architecture defines the address_class_dwarf_to_id hook
method, code before the patch does not complain about pointer size
whereas the new code complains.
- If addr_class is non-default, byte_size does not match the
expectation, and the architecture does not define the
address_class_dwarf_to_id hook method, code before the patch
complains about pointer size whereas the code after does not
complain.
(Similar cases for alignment mismatch instead of type size, too.)
I think the new behavior is what was intended and it yields simpler
code.
---
gdb/dwarf2/read.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 7db76140319..ca475f53745 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -12043,10 +12043,7 @@ read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu)
/* If the pointer size, alignment, or address class is different
than the default, create a type variant marked as such and set
the length accordingly. */
- if (type->length () != byte_size
- || (alignment != 0 && TYPE_RAW_ALIGN (type) != 0
- && alignment != TYPE_RAW_ALIGN (type))
- || addr_class != DW_ADDR_none)
+ if (addr_class != DW_ADDR_none)
{
if (gdbarch_address_class_dwarf_to_id_p (gdbarch))
{
@@ -12055,22 +12052,19 @@ read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu)
addr_class);
type = make_type_with_address_class (type, aclass);
}
- else if (type->length () != byte_size)
- {
- complaint (_("invalid pointer size %s"), pulongest (byte_size));
- }
- else if (TYPE_RAW_ALIGN (type) != alignment)
- {
- complaint (_("Invalid DW_AT_alignment"
- " - DIE at %s [in module %s]"),
- sect_offset_str (die->sect_off),
- objfile_name (cu->per_objfile->objfile));
- }
else
{
/* Should we also complain about unhandled address classes? */
}
}
+ else if (type->length () != byte_size)
+ complaint (_("invalid pointer size %s"), pulongest (byte_size));
+ else if (alignment != 0 && TYPE_RAW_ALIGN (type) != 0
+ && TYPE_RAW_ALIGN (type) != alignment)
+ complaint (_("Invalid DW_AT_alignment"
+ " - DIE at %s [in module %s]"),
+ sect_offset_str (die->sect_off),
+ objfile_name (cu->per_objfile->objfile));
type->set_length (byte_size);
set_type_align (type, alignment);
--
2.53.0
prev parent reply other threads:[~2026-07-28 17:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 17:07 [PATCH 1/2] gdb, dwarf: update code style " Tankut Baris Aktemur
2026-07-28 17:07 ` Tankut Baris Aktemur [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260728170746.1037942-2-tankutbaris.aktemur@amd.com \
--to=tankutbaris.aktemur@amd.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox