[commit/Ada] field of PAD structure is a non-scalar bitfield
Joel Brobecker
brobecker@adacore.com
Sat May 3 04:51:00 GMT 2008
Hello,
We have noticed a problem in the debugger when trying to print a record
containing a packed array. What happened is that the compiler wrapped
our variable into a PAD type. These wrapper are often used to handle
alignment and packing. exp_dbug.ads says, among other things:
-- When the debugger sees an object of a type whose name has a
-- suffix of ___PAD or ___JM, the type will be a record containing
-- a single field, and the name of that field will be all upper case.
-- In this case, it should look inside to get the value of the inner
-- field, and neither the outer structure name, nor the field name
-- should appear when the value is printed.
The problem appeared because the field inside the PAD record was
defined as a bit-field in the debugging info:
.uleb128 0x24 # (DIE (0xf40) DW_TAG_member)
.ascii "F\0" # DW_AT_name
.byte 0x9 # DW_AT_decl_file
.byte 0x15 # DW_AT_decl_line
.long 0xf50 # DW_AT_type
.byte 0x4 # DW_AT_byte_size
.byte 0x18 # DW_AT_bit_size
.byte 0x8 # DW_AT_bit_offset
.byte 0x2 # DW_AT_data_member_location
.byte 0x23 # DW_OP_plus_uconst
.uleb128 0x0
I just learned that Ada makes frequent uses of non-scalar bitfields.
And indeed, we have a function in ada-lang.c that we use to get
record fields which also happens to handle the case of bit-field
components as well (the function handles other cases such as
tagged types, variant records, etc).
So I fixed the problem by using that function to get the "F" field
inside our PAD type.
2008-05-02 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (unwrap_value): Handle the case where the "F" field
inside a PAD type is a bitfield.
Tested on x86-linux, no regression. Checked in.
--
Joel
-------------- next part --------------
Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.139
diff -u -p -r1.139 ada-lang.c
--- ada-lang.c 30 Apr 2008 21:13:49 -0000 1.139
+++ ada-lang.c 2 May 2008 23:40:33 -0000
@@ -7973,8 +7973,7 @@ unwrap_value (struct value *val)
struct type *type = ada_check_typedef (value_type (val));
if (ada_is_aligner_type (type))
{
- struct value *v = value_struct_elt (&val, NULL, "F",
- NULL, "internal structure");
+ struct value *v = ada_value_struct_elt (val, "F", 0);
struct type *val_type = ada_check_typedef (value_type (v));
if (ada_type_name (val_type) == NULL)
TYPE_NAME (val_type) = ada_type_name (type);
More information about the Gdb-patches
mailing list