This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
exp/2266: append_composite_type_field() is wrong for structs as opposed to unions
- From: dporges at chipwrights dot com
- To: gdb-gnats at sources dot redhat dot com
- Date: 29 May 2007 21:05:57 -0000
- Subject: exp/2266: append_composite_type_field() is wrong for structs as opposed to unions
- Reply-to: dporges at chipwrights dot com
>Number: 2266
>Category: exp
>Synopsis: append_composite_type_field() is wrong for structs as opposed to unions
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue May 29 21:08:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator: dporges@chipwrights.com
>Release: 6.6
>Organization:
>Environment:
Linux, cygwin
>Description:
The code in append_composite_type_field(), which builds up internal structure and union types, is wrong for structure fields beyond the first field. The computation of the bit position of a field is:
FIELD_BITPOS (f[0]) = (FIELD_BITPOS (f[-1])
+ TYPE_LENGTH (field) * TARGET_CHAR_BIT);
-- "field" is the _current_ field, but you want to add the size of the _previous_ field to the previous bitpos to get the bitpos of the current field.
>How-To-Repeat:
Not repeatable in any existing build, because it looks like no existing target uses internal register types that are structs with more than one field in them.
>Fix:
How about
FIELD_BITPOS (f[0]) = (FIELD_BITPOS (f[-1])
+ TYPE_LENGTH (FIELD_TYPE(f[-1])) * TARGET_CHAR_BIT);
>Release-Note:
>Audit-Trail:
>Unformatted: