From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id A43FD38F8600; Mon, 23 May 2022 12:50:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A43FD38F8600 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7 X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 27049a382fe50249c6408d3d92bb7a833c2194a6 X-Git-Newrev: 05527d8ca1082b4607e9ddc3209691f454b3b186 Message-Id: <20220523125007.A43FD38F8600@sourceware.org> Date: Mon, 23 May 2022 12:50:07 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2022 12:50:07 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D05527d8ca108= 2b4607e9ddc3209691f454b3b186 commit 05527d8ca1082b4607e9ddc3209691f454b3b186 Author: Tom de Vries Date: Mon May 23 14:50:02 2022 +0200 [gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7 =20 This test in test-case gdb.ada/dynamic-iface.exp passes with gcc 8: ... (gdb) print obj^M $1 =3D (n =3D> 3, a =3D> "ABC", value =3D> 93)^M (gdb) PASS: gdb.ada/dynamic-iface.exp: print local as interface ... but fails with gcc 7: ... (gdb) print obj^M $1 =3D ()^M (gdb) FAIL: gdb.ada/dynamic-iface.exp: print local as interface ... =20 More concretely, we have trouble finding the type of obj. With gcc 8: ... $ gdb -q -batch main -ex "b concrete.adb:20" -ex run -ex "ptype obj" ... type =3D new concrete.intermediate with record value: integer; end record ... and with gcc 7: ... type =3D tagged record null; end record ... =20 The translation from tagged type to "full view" type happens in ada_tag_value_at_base_address, where we hit this code: ... /* Storage_Offset'Last is used to indicate that a dynamic offset to top is used. In this situation the offset is stored just after the tag, in the object itself. */ if (offset_to_top =3D=3D last) { struct value *tem =3D value_addr (tag); tem =3D value_ptradd (tem, 1); tem =3D value_cast (ptr_type, tem); offset_to_top =3D value_as_long (value_ind (tem)); } ... resulting in an offset_to_top for gcc 8: ... (gdb) p offset_to_top $1 =3D -16 ... and for gcc 7: ... (gdb) p offset_to_top $1 =3D 16 ... =20 The difference is expected, it bisects to gcc commit d0567dc0dbf ("[mul= tiple changes]") which mentions this change. =20 There's some code right after the code quoted above that deals with this change: ... else if (offset_to_top > 0) { /* OFFSET_TO_TOP used to be a positive value to be subtracted from the base address. This was however incompatible with C++ dispatch table: C++ uses a *negative* value to *add* to the base address. Ada's convention has therefore been changed in GNAT 19.0w 20171023: since then, C++ and Ada use the same convention. Here, we support both cases by checking the sign of OFFSET_TO_TOP. */ offset_to_top =3D -offset_to_top; } ... but it's not activated because of the 'else'. =20 Fix this by removing the 'else'. =20 Tested on x86_64-linux, with gcc 7.5.0. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29057 Diff: --- gdb/ada-lang.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 7e4988be5d0..6ab01fd27d4 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6492,7 +6492,8 @@ ada_tag_value_at_base_address (struct value *obj) tem =3D value_cast (ptr_type, tem); offset_to_top =3D value_as_long (value_ind (tem)); } - else if (offset_to_top > 0) + + if (offset_to_top > 0) { /* OFFSET_TO_TOP used to be a positive value to be subtracted from the base address. This was however incompatible with