[RFC]: remove inconsistency in printcmd.c: print_scalar_formatted

Jeff Johnston jjohnstn@redhat.com
Fri Dec 12 20:36:00 GMT 2003

There's some code in print_scalar_formatted() I would like to remove.  
It tests if the sizeof the type of the value being printed is greater 
than the sizeof of LONGEST and if so, it may attempt to use 
extract_unsigned_integer().  If that fails, it prints out the value in hex.

There a number of problems with this.  First and foremost is the fact 
that it is comparing the sizeof with the host's LONGEST type, not the 
target.  The second problem is that extract_unsigned_integer() does the 
same size test and returns failure so the call is pointless.  The third 
problem is that this code creates an inconsistency in how doubles/floats 
are treated in comparison to long double.   All  three of these types 
are capable of storing a value greater than  that which can be contained 
in a LONGEST.  At present, floats and possibly doubles will pass the 
size test and end up calling unpack_long().   True long double doesn't 
pass the test and ends up printing in hex.  This problem causes a number 
of new errors on ia64 with the latest changes to structs.exp.  The new 
testcase uses p/c to print out various types and is not ready for the 
hex version of the long double value being printed out.

To remedy the problem, I have removed the code.  I don't think it is 
particularly helpful.  I think if the user asks for an integral format, 
then they should be prepared to take what that choice entails when 
printing a float input. 

With this change, the new failures for the ia64 testsuite go away (no 


-- Jeff J.

2003-12-12  Jeff Johnston  <jjohnstn@redhat.com>

        * printcmd.c (print_scalar_formatted): Do not check for sizeof
        type being greater than sizeof of host's LONGEST.  Always use
        unpack_long() unless format 'f' chosen.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: printcmd.patch
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20031212/e7b7f076/attachment.ksh>

More information about the Gdb-patches mailing list