* [PATCH][gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7
@ 2022-05-13 8:36 Tom de Vries
2022-05-23 12:51 ` [committed][gdb/ada] " Tom de Vries
0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2022-05-13 8:36 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
Hi,
This test in test-case gdb.ada/dynamic-iface.exp passes with gcc 8:
...
(gdb) print obj^M
$1 = (n => 3, a => "ABC", value => 93)^M
(gdb) PASS: gdb.ada/dynamic-iface.exp: print local as interface
...
but fails with gcc 7:
...
(gdb) print obj^M
$1 = ()^M
(gdb) FAIL: gdb.ada/dynamic-iface.exp: print local as interface
...
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 = <ref> new concrete.intermediate with record
value: integer;
end record
...
and with gcc 7:
...
type = <ref> tagged record null; end record
...
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 == last)
{
struct value *tem = value_addr (tag);
tem = value_ptradd (tem, 1);
tem = value_cast (ptr_type, tem);
offset_to_top = value_as_long (value_ind (tem));
}
...
resulting in an offset_to_top for gcc 8:
...
(gdb) p offset_to_top
$1 = -16
...
and for gcc 7:
...
(gdb) p offset_to_top
$1 = 16
...
The difference is expected, it bisects to gcc commit d0567dc0dbf ("[multiple
changes]") which mentions this change.
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 = -offset_to_top;
}
...
but it's not activated because of the 'else'.
Fix this by removing the 'else'.
Tested on x86_64-linux, with gcc 7.5.0.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29057
Any comments?
Thanks,
- Tom
[gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7
---
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 8333671c48b..e0a7a302e3a 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 = value_cast (ptr_type, tem);
offset_to_top = 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [committed][gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7
2022-05-13 8:36 [PATCH][gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7 Tom de Vries
@ 2022-05-23 12:51 ` Tom de Vries
2022-05-25 1:26 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2022-05-23 12:51 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
On 5/13/22 10:36, Tom de Vries wrote:
> Hi,
>
> This test in test-case gdb.ada/dynamic-iface.exp passes with gcc 8:
> ...
> (gdb) print obj^M
> $1 = (n => 3, a => "ABC", value => 93)^M
> (gdb) PASS: gdb.ada/dynamic-iface.exp: print local as interface
> ...
> but fails with gcc 7:
> ...
> (gdb) print obj^M
> $1 = ()^M
> (gdb) FAIL: gdb.ada/dynamic-iface.exp: print local as interface
> ...
>
> 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 = <ref> new concrete.intermediate with record
> value: integer;
> end record
> ...
> and with gcc 7:
> ...
> type = <ref> tagged record null; end record
> ...
>
> 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 == last)
> {
> struct value *tem = value_addr (tag);
> tem = value_ptradd (tem, 1);
> tem = value_cast (ptr_type, tem);
> offset_to_top = value_as_long (value_ind (tem));
> }
> ...
> resulting in an offset_to_top for gcc 8:
> ...
> (gdb) p offset_to_top
> $1 = -16
> ...
> and for gcc 7:
> ...
> (gdb) p offset_to_top
> $1 = 16
> ...
>
> The difference is expected, it bisects to gcc commit d0567dc0dbf ("[multiple
> changes]") which mentions this change.
>
> 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 = -offset_to_top;
> }
> ...
> but it's not activated because of the 'else'.
>
> Fix this by removing the 'else'.
>
> Tested on x86_64-linux, with gcc 7.5.0.
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29057
>
> Any comments?
>
Committed.
Thanks,
- Tom
> [gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7
>
> ---
> 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 8333671c48b..e0a7a302e3a 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 = value_cast (ptr_type, tem);
> offset_to_top = 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [committed][gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7
2022-05-23 12:51 ` [committed][gdb/ada] " Tom de Vries
@ 2022-05-25 1:26 ` Tom Tromey
0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2022-05-25 1:26 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches, Tom Tromey
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>> ...
>> but it's not activated because of the 'else'.
>> Fix this by removing the 'else'.
>> Tested on x86_64-linux, with gcc 7.5.0.
>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29057
>> Any comments?
>>
Tom> Committed.
Thanks for doing this. It took me a little while to remember what was
going on here and why this patch would help.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-25 1:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 8:36 [PATCH][gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7 Tom de Vries
2022-05-23 12:51 ` [committed][gdb/ada] " Tom de Vries
2022-05-25 1:26 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).