[RFC] print/x of a float/double should printf ("%a")

Daniel Jacobowitz drow@false.org
Sun Feb 18 16:09:00 GMT 2007


On Sun, Feb 18, 2007 at 04:45:57PM +0100, Andreas Schwab wrote:
> Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 
> > currently "print/x (float) a" does an integer "print/x (long) a".
> >
> > Ulrich Drepper requested to use instead printf ("%a") (man excerpt below):

Can we do this without relying on the system printf?  I was going to
say that it ought to be easy... except it's 500 lines in glibc, so
maybe it isn't.  I suppose we could do it this way and put the glibc
code into gnulib later.

The nasty bit about doing it this way, using the system printf, is
that it potentially loses bits.  For the hex format, which is supposed
to be a precise representation, this could be confusin.

> That makes /x different between print and x.  IMHO this should use a new
> format letter so that it can also be used with x.

Do you really think so?  I actually think this is perfectly
appropriate.  x/d and x/x both format untyped memory, which is
presumed to be an integer.  p/d and p/x should behave the same as x/d
and x/x for integers, but I think hex float is the most sensible thing
for p/x to do (and you can always "p/x {double} $address").  You can't
use this representation with 'x' readily because you may not be able
to specify the type - e.g. you can't use 'x' to display 80-bit
extended.

Of course, we also want a way to show the bits of a register as normal
hex, not hex floating point.

-- 
Daniel Jacobowitz
CodeSourcery



More information about the Gdb-patches mailing list