diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 11 |
2 files changed, 13 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 96efdb0..621cbbb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-11-30 Tom Tromey <tom@tromey.com> + + * dwarf2read.c (dwarf2_add_field): Include field offset when + computing variant part length. + 2019-11-30 Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS: Mention define-prefix. Tell that command names can now contain a . character. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 40626a1..fd7d21c 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -15252,13 +15252,18 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, /* Normally a DW_TAG_variant_part won't have a size, but our representation requires one, so set it to the maximum of the - child sizes. */ + child sizes, being sure to account for the offset at which + each child is seen. */ if (TYPE_LENGTH (fp->type) == 0) { unsigned max = 0; for (int i = 0; i < TYPE_NFIELDS (fp->type); ++i) - if (TYPE_LENGTH (TYPE_FIELD_TYPE (fp->type, i)) > max) - max = TYPE_LENGTH (TYPE_FIELD_TYPE (fp->type, i)); + { + unsigned len = ((TYPE_FIELD_BITPOS (fp->type, i) + 7) / 8 + + TYPE_LENGTH (TYPE_FIELD_TYPE (fp->type, i))); + if (len > max) + max = len; + } TYPE_LENGTH (fp->type) = max; } } |