aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-02-17 13:43:59 -0700
committerTom Tromey <tromey@adacore.com>2022-03-10 12:19:08 -0700
commit56262a931b7ca8ee3ec9104bc7e9e0b40cf3d64e (patch)
tree06824fe8a8a0723d02b917c5f9aec87d17e73d6e /gdb/doc
parentfdda16e1fa9637f9b6ca846eebe881cd2901d75a (diff)
downloadgdb-56262a931b7ca8ee3ec9104bc7e9e0b40cf3d64e.zip
gdb-56262a931b7ca8ee3ec9104bc7e9e0b40cf3d64e.tar.gz
gdb-56262a931b7ca8ee3ec9104bc7e9e0b40cf3d64e.tar.bz2
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
Diffstat (limited to 'gdb/doc')
-rw-r--r--gdb/doc/gdb.texinfo28
1 files changed, 15 insertions, 13 deletions
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index e61cef3..d216fa1 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -10756,23 +10756,24 @@ letters supported are:
@table @code
@item x
-Regard the bits of the value as an integer, and print the integer in
-hexadecimal.
+Print the binary representation of the value in hexadecimal.
@item d
-Print as integer in signed decimal.
+Print the binary representation of the value in decimal.
@item u
-Print as integer in unsigned decimal.
+Print the binary representation of the value as an decimal, as if it
+were unsigned.
@item o
-Print as integer in octal.
+Print the binary representation of the value in octal.
@item t
-Print as integer in binary. The letter @samp{t} stands for ``two''.
-@footnote{@samp{b} cannot be used because these format letters are also
-used with the @code{x} command, where @samp{b} stands for ``byte'';
-see @ref{Memory,,Examining Memory}.}
+Print the binary representation of the value in binary. The letter
+@samp{t} stands for ``two''. @footnote{@samp{b} cannot be used
+because these format letters are also used with the @code{x} command,
+where @samp{b} stands for ``byte''; see @ref{Memory,,Examining
+Memory}.}
@item a
@cindex unknown address, locating
@@ -10791,10 +10792,11 @@ The command @code{info symbol 0x54320} yields similar results.
@xref{Symbols, info symbol}.
@item c
-Regard as an integer and print it as a character constant. This
-prints both the numerical value and its character representation. The
-character representation is replaced with the octal escape @samp{\nnn}
-for characters outside the 7-bit @sc{ascii} range.
+Cast the value to an integer (unlike other formats, this does not just
+reinterpret the underlying bits) and print it as a character constant.
+This prints both the numerical value and its character representation.
+The character representation is replaced with the octal escape
+@samp{\nnn} for characters outside the 7-bit @sc{ascii} range.
Without this format, @value{GDBN} displays @code{char},
@w{@code{unsigned char}}, and @w{@code{signed char}} data as character