Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker via Gdb-patches <gdb-patches@sourceware.org>
To: Tom de Vries <tdevries@suse.de>
Cc: Tom Tromey <tom@tromey.com>,
	gdb-patches@sourceware.org,
	Joel Brobecker <brobecker@adacore.com>
Subject: Re: [PATCH][gdb/testsuite] Fix gdb.ada/literals.exp with aarch64
Date: Thu, 28 Jul 2022 06:10:21 -0700	[thread overview]
Message-ID: <YuKKvZ9XRV8gBHoD@adacore.com> (raw)
In-Reply-To: <8f343881-a96d-9eef-8cbc-9afc69f97d7d@suse.de>

> > Thanks for the patch.
> > 
> > My question is whether it actually makes sense that -1 be
> > a valid output for the print command above. I tried the addition
> > of ...
> > 
> >      | /* Note: Interprets ULLONG_MAX as -1.  */
> >      | yylval.typed_val.type = type_long_long (par_state);
> > 
> > ... to a patch of yours:
> > 
> >      | commit ac3afe36d73c84096685fece885d70b28bc9629f
> >      | Author: Tom de Vries <tdevries@suse.de>
> >      | Date:   Sat Jun 4 13:17:33 2022 +0200
> >      | Subject: [gdb/ada] Fix literal truncation
> >      |
> >      | Make sure we error out on overflow instead of truncating in all cases.
> >      |
> >      | Tested on x86_64-linux, with a build with --enable-targets=all.
> > 
> > Do you remember why we do this? Intuitively, you'd expect that GDB
> > would behave the same regardless of whether it selects type "long"
> > or "long long" for its processing, as long as both types are 64-bit.
> > 
> 
> I have no idea.  AFAICT it's been in gdb since the "Add base ada language
> files" commit from 2002 that we avoid "unsigned long long".
> 
> I've taken care to preserve the behaviour in the commit you refer to (and
> this patch), since I don't have the knowledge to decide that things should
> be different.
> 
> > With the above, we can take this patch as an intermediate remedy,
> > but I think we might need to dig deeper into why we use a signed
> > type in the case of long long but not long, particularly when both
> > types are the same size.
> > 
> > WDYT?
> > 
> 
> I'd be happy to write a patch to change the behaviour of gdb.  But somebody
> knowledgeable in Ada needs to specify what that needs to be.

We're really outside of the Ada language. Would you mind checking
what the C language does? I think it would make sense to do the same,
here. E.g., on x86_64-linux, I get:

    (gdb) p 0xffffffffffffffff
    $1 = 18446744073709551615

What do you think, TomT?

> > >   gdb/testsuite/gdb.ada/literals.exp | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/gdb/testsuite/gdb.ada/literals.exp b/gdb/testsuite/gdb.ada/literals.exp
> > > index a6ac89b540f..744a6bc573c 100644
> > > --- a/gdb/testsuite/gdb.ada/literals.exp
> > > +++ b/gdb/testsuite/gdb.ada/literals.exp
> > > @@ -36,4 +36,4 @@ gdb_test "print 16#f#e1" " = 240"
> > >   gdb_test "print 16#1#e10" " = 1099511627776"
> > >   gdb_test "print/x 16#7fffffffffffffff#" " = 0x7fffffffffffffff"
> > > -gdb_test "print 16#ffffffffffffffff#" " = -1"
> > > +gdb_test "print 16#ffffffffffffffff#" " = (-1|18446744073709551615)"
> > 

-- 
Joel

  reply	other threads:[~2022-07-28 13:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-27 10:34 Tom de Vries via Gdb-patches
2022-07-27 13:31 ` Luis Machado via Gdb-patches
2022-07-27 17:06 ` Joel Brobecker via Gdb-patches
2022-07-27 21:03   ` Tom de Vries via Gdb-patches
2022-07-28 13:10     ` Joel Brobecker via Gdb-patches [this message]
2022-07-28 14:21       ` Tom de Vries via Gdb-patches
2022-07-28 16:28         ` Joel Brobecker via Gdb-patches
2022-07-29 22:24         ` Joel Brobecker via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YuKKvZ9XRV8gBHoD@adacore.com \
    --to=gdb-patches@sourceware.org \
    --cc=brobecker@adacore.com \
    --cc=tdevries@suse.de \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox