public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Andreas Schwab <schwab@linux-m68k.org>,
	Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>
Cc: Tom Tromey <tromey@adacore.com>
Subject: Re: [PATCH] Change how "print/x" displays floating-point value
Date: Sat, 19 Feb 2022 10:05:17 +0000	[thread overview]
Message-ID: <871qzzdvdu.fsf@redhat.com> (raw)
In-Reply-To: <87zgmovzr9.fsf@igel.home>

Andreas Schwab <schwab@linux-m68k.org> writes:

> On Feb 18 2022, Tom Tromey via Gdb-patches wrote:
>
>> diff --git a/gdb/NEWS b/gdb/NEWS
>> index 9da74e71796..544efa3fe74 100644
>> --- a/gdb/NEWS
>> +++ b/gdb/NEWS
>> @@ -97,6 +97,12 @@ show style disassembler enabled
>>  
>>  * Changed commands
>>  
>> +print
>> +  Printing of floating-point values with base-modifying formats like
>> +  /x has been changed to display the underlying bytes of the value in
>> +  the desired base.  This was GDB's documented behavior, but was never
>> +  implemented correctly.
>
> How does that handle padding?
>
>> diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
>> index 37632985a07..78a2147017d 100644
>> --- a/gdb/testsuite/gdb.base/printcmds.exp
>> +++ b/gdb/testsuite/gdb.base/printcmds.exp
>> @@ -158,8 +158,14 @@ proc test_float_rejected {} {
>>  # Regression test for PR gdb/21675
>>  proc test_radices {} {
>>      gdb_test "print/o 16777211" " = 077777773"
>> -    gdb_test "print/d 1.5" " = 1"
>> -    gdb_test "print/u 1.5" " = 1"
>> +
>> +    # See PR gdb/16242 for this.
>> +    gdb_test "print/d 1.5f" " = 1069547520"
>> +    gdb_test "print/u 1.5f" " = 1069547520"
>> +    gdb_test "print/x 1.5f" " = 0x3fc00000"
>> +    gdb_test "print/t 1.5f" " = 111111110000000000000000000000"
>> +    gdb_test "print/o 1.5f" " = 07760000000"
>
> That assumes a particular representation of the float type that depends
> on the target.

Maybe we can harden the tests in this case with some logic like
(psuedo-code):

  ## Assuming printcmds.c contains:
  ##  float f_var = 1.5f;

  if { sizeof(int) == sizeof(float) } {
    set expected_value [valueof "p/d *((int *) &f_var)"]
    gdb_test "print/d f_var" "$expected_value"
  }

As I think these two methods of printing are now the same, right?

Thanks,
Andrew


  reply	other threads:[~2022-02-19 10:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17 21:29 Tom Tromey
2022-02-17 23:17 ` Andrew Burgess
2022-02-18 16:44   ` Tom Tromey
2022-02-18 17:02     ` Eli Zaretskii
2022-03-10 17:27       ` Tom Tromey
2022-03-10 17:54         ` Eli Zaretskii
2022-03-10 19:19           ` Tom Tromey
2022-02-18 17:41     ` Andreas Schwab
2022-02-19 10:05       ` Andrew Burgess [this message]
2022-03-10 17:30         ` Tom Tromey
2022-03-10 17:30       ` Tom Tromey
2022-03-10 18:23         ` Andreas Schwab
2022-03-10 20:39           ` Tom Tromey
2022-03-10 20:53             ` Andreas Schwab

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=871qzzdvdu.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=schwab@linux-m68k.org \
    --cc=tromey@adacore.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).