aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada/variant/pkg.adb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-04-24 13:40:31 -0600
committerTom Tromey <tromey@adacore.com>2020-04-24 13:40:32 -0600
commit7d79de9a4be2d1abb0320c322967f1aad39b1f7d (patch)
treefa576d23c30849b3b5eeda590d1ce1b8094ac791 /gdb/testsuite/gdb.ada/variant/pkg.adb
parentf8e89861cfb6acbfa097814f5864afd5563a3011 (diff)
downloadfsf-binutils-gdb-7d79de9a4be2d1abb0320c322967f1aad39b1f7d.zip
fsf-binutils-gdb-7d79de9a4be2d1abb0320c322967f1aad39b1f7d.tar.gz
fsf-binutils-gdb-7d79de9a4be2d1abb0320c322967f1aad39b1f7d.tar.bz2
Add support for variable field offsets
In Ada, a field can have a variable offset. This patch adds support for this case to gdb, using the existing dynamic type resolution code. Doing just this, though, would break C++ virtual base handling. It turns out that virtual base handling only worked by the ugliest of hacks. In particular, the DWARF reader would call decode_locdesc for a virtual base location. Here's an example of such an expression from gdb's m-static test case: <241> DW_AT_data_member_location: 6 byte block: 12 6 48 1c 6 22 (DW_OP_dup; DW_OP_deref; DW_OP_lit24; DW_OP_minus; DW_OP_deref; DW_OP_plus) When examining this, decode_locdesc would treat DW_OP_deref as a no-op and compute some answer (here, -24). This would be stored as the offset. Later, in gnu-v3-abi.c, the real offset would be computed by digging around in the vtable. This patch cleans up this area. In particular, it now evaluates the location expression on demand. Note there is a new FIXME in gnu-v3-abi.c. I think some of the callers are incorrect here, and have only worked because this member is unused. I will file a bug for this. I didn't fix this problem in this series because I felt it was already too complex. gdb/ChangeLog 2020-04-24 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (handle_data_member_location): New overload. (dwarf2_add_field): Use it. (decode_locdesc): Add "computed" parameter. Update comment. * gdbtypes.c (is_dynamic_type_internal): Also look for FIELD_LOC_KIND_DWARF_BLOCK. (resolve_dynamic_struct): Handle FIELD_LOC_KIND_DWARF_BLOCK. * gdbtypes.c (is_dynamic_type_internal): Add special case for C++ virtual base classes. * gnu-v3-abi.c (gnuv3_baseclass_offset): Handle FIELD_LOC_KIND_DWARF_BLOCK. gdb/testsuite/ChangeLog 2020-04-24 Tom Tromey <tromey@adacore.com> * gdb.ada/variant.exp: Add dynamic field offset tests. * gdb.ada/variant/pck.ads (Nested_And_Variable): New type. * gdb.ada/variant/pkg.adb: Add new variables.
Diffstat (limited to 'gdb/testsuite/gdb.ada/variant/pkg.adb')
-rw-r--r--gdb/testsuite/gdb.ada/variant/pkg.adb11
1 files changed, 11 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/variant/pkg.adb b/gdb/testsuite/gdb.ada/variant/pkg.adb
index 0cc38f5..91cf080 100644
--- a/gdb/testsuite/gdb.ada/variant/pkg.adb
+++ b/gdb/testsuite/gdb.ada/variant/pkg.adb
@@ -22,6 +22,17 @@ procedure Pkg is
ST1 : constant Second_Type := (I => -4, One => 1, X => 2);
ST2 : constant Second_Type := (I => 99, One => 1, Y => 77);
+ NAV1 : constant Nested_And_Variable := (One => 0, Two => 93,
+ Str => (others => 'z'));
+ NAV2 : constant Nested_And_Variable := (One => 3, OneValue => 33,
+ Str => (others => 'z'),
+ Str2 => (others => 'q'),
+ Two => 0);
+ NAV3 : constant Nested_And_Variable := (One => 3, OneValue => 33,
+ Str => (others => 'z'),
+ Str2 => (others => 'q'),
+ Two => 7, TwoValue => 88);
+
begin
R := (C => 'd');
Q := (C => Character'First, X_First => 27);