Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "J. Johnston" <jjohnstn@redhat.com>
To: "J. Johnston" <jjohnstn@redhat.com>
Cc: Kevin Buettner <kevinb@redhat.com>,
	gdb-patches@sources.redhat.com, drow@mvista.com
Subject: Re: [RFC]: remove inconsistency in printcmd.c: print_scalar_formatted
Date: Mon, 19 Jan 2004 22:23:00 -0000	[thread overview]
Message-ID: <400C58E6.4070908@redhat.com> (raw)
In-Reply-To: <3FDA636F.30204@redhat.com>

Ping.  Could we continue discussing this topic and come to some form of 
resolution?  The new additional ia64 test failures are annoying.

-- Jeff J.


J. Johnston wrote:
> Kevin Buettner wrote:
> 
>> On Dec 12,  3:36pm, Jeff Johnston wrote:
>>
>>
>>> 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.
>>
>>
>>
>> I think this is (sort of) okay.  The assumption that's being made is that
>> the space needed to hold the bits on the target will be the same as that
>> on the host.  I think gdb has serious problems on host/target 
>> combinations
>> where this is untrue.
>>
>>
>>> The second problem is that extract_unsigned_integer() does the same 
>>> size test and returns failure so the call is pointless.
>>
>>
>>
>> You mean extract_long_unsigned_integer(), right?  When I studied it
>> just now, the call didn't appear to be pointless.  It looks to me
>> like the code you're deleting is intended to handle the case where
>> the space needed by a LONGEST isn't large enough to hold the target's
>> type.
>>
> 
> Yes, sorry about the name typo.  The extract_long_unsigned_integer() 
> function ends up testing the type_size - leading zeroes vs the 
> sizeof(LONGEST).  For most floats this will fail because of the biased 
> exponent so it returns false.
> 
>   if (len <= (int) sizeof (LONGEST))
>     {
>       *pval = (LONGEST) extract_unsigned_integer (first_addr,
>                                                   sizeof (LONGEST));
>       return 1;
>     }
> 
>   return 0;
> }
> 
>>
>>> 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.
>>
>>
>>
>> I think this is the real problem.  The extract_long_unsigned_integer()
>> call attempts to fetch the bits from the type with no conversion
>> (other than leading zero removal if the type is overlong), but, if
>> I'm not mistaken, unpack_long() attempts to do a type conversion
>> and these two approaches to fetching the data definitely yield different
>> kinds of results.
>>
>>
>>> 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. 
>>
>>
>>
>> I think you're right.
>>
>> Something that I've wanted from time to time is a way to print the
>> bits comprising a value as some other type.  E.g, if I have a float,
>> I'd like to be be able to print the bits that comprise the float as an
>> int (or vice versa).  At first, I thought that was the intent of
>> print_scalar_formatted(), but I see now that it's not.  If the value
>> is stored in memory, you can do it with the appropriate cast, e.g,
>> if ``val'' is of type float, you can do ``print *(int *)&val'', but
>> AFAIK, you can't do this for values stored in registers or convenience
>> variables.  If we had such a mechanism, then I think we'd need some
>> code similar to the chunk that you're deleting.
>>
> 
> I suppose new format specifiers could always be added in the future to 
> do just what you want.
> 
> -- Jeff J.
> 
> 


  reply	other threads:[~2004-01-19 22:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-12 20:36 Jeff Johnston
2003-12-12 22:17 ` Kevin Buettner
2003-12-12 23:05   ` Daniel Jacobowitz
2003-12-13  0:55   ` J. Johnston
2004-01-19 22:23     ` J. Johnston [this message]
2004-01-19 22:57       ` Andrew Cagney
2004-01-19 23:18         ` Daniel Jacobowitz
2004-01-19 23:27           ` Kevin Buettner
2004-01-20  0:41           ` Andrew Cagney
2004-01-20  1:22             ` Daniel Jacobowitz
     [not found]               ` <400C8CC0.3040706@gnu.org>
2004-01-20  5:48                 ` Daniel Jacobowitz
2004-01-20  6:55                   ` Eli Zaretskii
2004-01-20 14:52                     ` Daniel Jacobowitz
2004-01-20 19:15                       ` Eli Zaretskii
2004-01-20 19:33                         ` Daniel Jacobowitz
2004-01-20 20:32                           ` Eli Zaretskii
2004-01-20 16:50                     ` Andrew Cagney
2004-01-20 19:10                       ` Eli Zaretskii
2004-01-20 21:29                   ` Andrew Cagney
2004-02-19 22:53                     ` Jeff Johnston

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=400C58E6.4070908@redhat.com \
    --to=jjohnstn@redhat.com \
    --cc=drow@mvista.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=kevinb@redhat.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