]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Change how "print/x" displays floating-point value
authorTom Tromey <tromey@adacore.com>
Thu, 17 Feb 2022 20:43:59 +0000 (13:43 -0700)
committerTom Tromey <tromey@adacore.com>
Thu, 10 Mar 2022 19:19:08 +0000 (12:19 -0700)
commit56262a931b7ca8ee3ec9104bc7e9e0b40cf3d64e
tree06824fe8a8a0723d02b917c5f9aec87d17e73d6e
parentfdda16e1fa9637f9b6ca846eebe881cd2901d75a
Change how "print/x" displays floating-point value

Currently, "print/x" will display a floating-point value by first
casting it to an integer type.  This yields weird results like:

    (gdb) print/x 1.5
    $1 = 0x1

This has confused users multiple times -- see PR gdb/16242, where
there are several dups.  I've also seen some confusion from this
internally at AdaCore.

The manual says:

    'x'
 Regard the bits of the value as an integer, and print the integer
 in hexadecimal.

... which seems more useful.  So, perhaps what happened is that this
was incorrectly implemented (or maybe correctly implemented and then
regressed, as there don't seem to be any tests).

This patch fixes the bug.

There was a previous discussion where we agreed to preserve the old
behavior:

    https://sourceware.org/legacy-ml/gdb-patches/2017-06/msg00314.html

However, I think it makes more sense to follow the manual.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16242
gdb/NEWS
gdb/doc/gdb.texinfo
gdb/printcmd.c
gdb/testsuite/gdb.base/printcmds.c
gdb/testsuite/gdb.base/printcmds.exp
gdb/testsuite/gdb.base/return-nodebug.exp