aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-04-29 09:55:39 -0600
committerTom Tromey <tromey@adacore.com>2019-05-01 08:09:22 -0600
commit4504bbdec57c77b6468838276e62b2137eedfdd5 (patch)
treeeabe799da4aabe549b571f5601c2d74b92940d79 /gdb/ada-lang.c
parentd48e62f4a263a871b7a62793e8000625735bc2f6 (diff)
downloadgdb-4504bbdec57c77b6468838276e62b2137eedfdd5.zip
gdb-4504bbdec57c77b6468838276e62b2137eedfdd5.tar.gz
gdb-4504bbdec57c77b6468838276e62b2137eedfdd5.tar.bz2
Fix bug in assignment to nested packed structure
A user at AdaCore found a case where assignment to a nested packed structure would fail. The bug is that ada_value_primitive_field doesn't account for the situation where a field is not packed relative to its containing structure, but where the structure itself is packed in its parent. gdb/ChangeLog 2019-05-01 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_value_primitive_field): Treat more fields as bitfields. gdb/testsuite/ChangeLog 2019-05-01 Tom Tromey <tromey@adacore.com> * gdb.ada/packed_array_assign/aggregates.ads (Nested_Packed): New record. (NPR): New variable. * gdb.ada/packed_array_assign.exp: Add nested packed assignment test.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index da70a51..1a56663 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -7189,9 +7189,10 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno,
arg_type = ada_check_typedef (arg_type);
type = TYPE_FIELD_TYPE (arg_type, fieldno);
- /* Handle packed fields. */
-
- if (TYPE_FIELD_BITSIZE (arg_type, fieldno) != 0)
+ /* Handle packed fields. It might be that the field is not packed
+ relative to its containing structure, but the structure itself is
+ packed; in this case we must take the bit-field path. */
+ if (TYPE_FIELD_BITSIZE (arg_type, fieldno) != 0 || value_bitpos (arg1) != 0)
{
int bit_pos = TYPE_FIELD_BITPOS (arg_type, fieldno);
int bit_size = TYPE_FIELD_BITSIZE (arg_type, fieldno);