public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* -format options
@ 2007-08-27 15:39 Andrew Cagney
  2007-08-27 15:58 ` Chris Moller
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2007-08-27 15:39 UTC (permalink / raw)
  To: frysk

Hi,

some questions, and ideas.

What should the -format qualifier do when applied to floating point?  
For instance:
  (fhpd) print 1.0 -format x
  0x1
i.e., convert the cooked value to decimal and then print in hex; or:
  (fhpd) print 1.0 -format x
  0x3ff0000000000000
i.e., print the raw value in hex.  I think the answer depends on the 
next question.

What possible format options are there and how should they interact? 
Here's a possible list:
  bi[t]s, [o]ctal, [d]ecimal, he[x]adecimal, [f]loat, [v]alue (i.e., 
default)
  [r]aw, [c]ooked
  [b]ig-endian, [l]ittle-endian, [n]ative (for default)
  [s]igned, [u]nsigned, [i]nteger (for default???)
  reset: -
are there others?  I've tried to make each set largely orthogonal; does 
this work?  Would other combinations be better?  For signed/unsigned is 
there a better "default" to integer.  Should [o][x][t] just imply unsigned?

How should these options be specified; Either:
    -format rx
or
    -format x -data r -order b
for dumping each field in big-endian raw hex.  I prefer the more terse 
former.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: -format options
  2007-08-27 15:39 -format options Andrew Cagney
@ 2007-08-27 15:58 ` Chris Moller
  2007-08-27 16:16   ` Andrew Cagney
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Moller @ 2007-08-27 15:58 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: frysk

[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]

Any reason you couldn't just pass a kind of printf format string to
-format.  E.g.,

    print 1.0 "%g 0x%08x"

would print the value first as a double--1.0--and then again in hex. 
(Unlike printf, each % substitution would refer to the same value.)

cm


Andrew Cagney wrote:
> Hi,
>
> some questions, and ideas.
>
> What should the -format qualifier do when applied to floating point? 
> For instance:
>  (fhpd) print 1.0 -format x
>  0x1
> i.e., convert the cooked value to decimal and then print in hex; or:
>  (fhpd) print 1.0 -format x
>  0x3ff0000000000000
> i.e., print the raw value in hex.  I think the answer depends on the
> next question.
>
> What possible format options are there and how should they interact?
> Here's a possible list:
>  bi[t]s, [o]ctal, [d]ecimal, he[x]adecimal, [f]loat, [v]alue (i.e.,
> default)
>  [r]aw, [c]ooked
>  [b]ig-endian, [l]ittle-endian, [n]ative (for default)
>  [s]igned, [u]nsigned, [i]nteger (for default???)
>  reset: -
> are there others?  I've tried to make each set largely orthogonal;
> does this work?  Would other combinations be better?  For
> signed/unsigned is there a better "default" to integer.  Should
> [o][x][t] just imply unsigned?
>
> How should these options be specified; Either:
>    -format rx
> or
>    -format x -data r -order b
> for dumping each field in big-endian raw hex.  I prefer the more terse
> former.
>

-- 
Chris Moller

  Java: the blunt scissors of programming languages.
      -- Dave Thomas



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: -format options
  2007-08-27 15:58 ` Chris Moller
@ 2007-08-27 16:16   ` Andrew Cagney
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2007-08-27 16:16 UTC (permalink / raw)
  To: Chris Moller; +Cc: frysk

Chris Moller wrote:
> Any reason you couldn't just pass a kind of printf format string to
> -format.  E.g.,
>
>     print 1.0 "%g 0x%08x"
>
> would print the value first as a double--1.0--and then again in hex. 
> (Unlike printf, each % substitution would refer to the same value.)
>   
interesting idea; I'm not sure how well it will interact with more 
complex values for instance:

     (fhpd) print a_struct
     { i = 1, f = 1.0 }

and:

    (fhpd) print a_struct -format rx
    { i - 0x1, f = 0x3f800000 }

however a separate << printf <format> option list >> command might make 
for an interesting extension; for instance:

    (fhpd) printf "%x\n", a_struct
    0x1, 0x3f800000

i.e., apply a printf format to all elements of the value.

Andrew

PS: The fhpd outlines the command << print -format >>

> cm
>
>
> Andrew Cagney wrote:
>   
>> Hi,
>>
>> some questions, and ideas.
>>
>> What should the -format qualifier do when applied to floating point? 
>> For instance:
>>  (fhpd) print 1.0 -format x
>>  0x1
>> i.e., convert the cooked value to decimal and then print in hex; or:
>>  (fhpd) print 1.0 -format x
>>  0x3ff0000000000000
>> i.e., print the raw value in hex.  I think the answer depends on the
>> next question.
>>
>> What possible format options are there and how should they interact?
>> Here's a possible list:
>>  bi[t]s, [o]ctal, [d]ecimal, he[x]adecimal, [f]loat, [v]alue (i.e.,
>> default)
>>  [r]aw, [c]ooked
>>  [b]ig-endian, [l]ittle-endian, [n]ative (for default)
>>  [s]igned, [u]nsigned, [i]nteger (for default???)
>>  reset: -
>> are there others?  I've tried to make each set largely orthogonal;
>> does this work?  Would other combinations be better?  For
>> signed/unsigned is there a better "default" to integer.  Should
>> [o][x][t] just imply unsigned?
>>
>> How should these options be specified; Either:
>>    -format rx
>> or
>>    -format x -data r -order b
>> for dumping each field in big-endian raw hex.  I prefer the more terse
>> former.
>>
>>     
>
>   

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-27 16:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-27 15:39 -format options Andrew Cagney
2007-08-27 15:58 ` Chris Moller
2007-08-27 16:16   ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).