Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Wu Zhou <woodzltc@cn.ibm.com>
To: Wu Zhou <woodzltc@cn.ibm.com>, gdb-patches@sourceware.org
Subject: Re: [RFC] decimal float point patch based on libdecnumber: gdb     	patch
Date: Sun, 03 Sep 2006 08:53:00 -0000	[thread overview]
Message-ID: <44FA97FA.1070100@cn.ibm.com> (raw)
In-Reply-To: <20060821160834.GA22192@nevyn.them.org>

Daniel,

Sorry for replying late.  I guess I finally find the root cause why exchange_dfp is needed on 
little_endian machines.

It is like this.  The structures decimal32, decimal64 and decimal128 are big-endian in current 
libdecnumber implementation:

typedef struct
{
   uint8_t bytes[DECIMAL128_Bytes];      /* decimal128: 1, 5, 12, 110 bits */
} decimal128;

But variables/constants of _Decimal32, _Decimal64 and _Decimal128 (which are the DFP extension to c 
language types) in the memory are stored in little-endian on x86, and big-endian on ppc64.  So the 
byte swapping is needed on x86.

Ben Elliston is planning to change the memory layout of decimal32/decimal64/decimal128 to host byte 
order in later libdecnumber/gcc.  Then the byte swapping will not be needed in gdb.  But that is 
when GCC gets to stage 1 again, which might be around the end of this year.

So one option is for us to keep the byte swapping code in gdb, and when the byte order in 
libdecnumber is changed to host byte order, we can easily delete them.

Another option is to wait for the byte order in libdecnumber to be changed, and we can revisit this 
patch after that.

Yet another option is to switch back to my original patch, which uses own's code, instead that of 
libdecnumber, to do the conversion between decimal value and printable string.

Which one do you prefer?

Regards
- Wu Zhou

Daniel Jacobowitz wrote:
> On Mon, Aug 21, 2006 at 11:58:14PM +0800, Wu Zhou wrote:
>> But as far as I know, the endianess of struct "value" in the target memory 
>> is architecture depedent. To name a example, in value_from_decfloat, we 
>>  need to set the raw content of val to the dfp constant user inputed, I am 
>> using this:
>>   memcpy (value_contents_raw (val), decbytes, len);
>>
>> decbytes is big-endian on all both x86 and ppc64 platforms.  But the 
>> value_contents_raw (val) is little endian on x86 / x86_64 system, and big 
>> endian on ppc64.  So exchange_dfp is needed.
> 
> No, that's not right.  The format of the byte buffer in struct value is
> supposed to match the target representation of the object being
> described.  If this is always big endian on the target, it should be
> big endian in GDB too.
> 
> You can think of it like this:
> 
> struct A
> {
>   char a, b, c, d, e, f, g, h;
> };
> 
> The first byte in the value buffer is supposed to match "char a", no
> matter what the target endianness is.
> 
> Does that help, or am I not understanding the problem?
> 


  reply	other threads:[~2006-09-03  8:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-21 16:08 Wu Zhou
2006-08-21 18:30 ` Daniel Jacobowitz
2006-08-21 18:34   ` Wu Zhou
2006-08-22  1:31     ` Daniel Jacobowitz
2006-09-03  8:53       ` Wu Zhou [this message]
2006-09-03 16:44         ` Daniel Jacobowitz
2006-09-05  2:34           ` Wu Zhou
  -- strict thread matches above, loose matches on Subject: below --
2006-08-01  9:55 Wu Zhou
2006-08-01 10:51 ` Wu Zhou
2006-08-08 18:16   ` Daniel Jacobowitz
2006-07-23  5:48 Wu Zhou
2006-07-23 14:02 ` Daniel Jacobowitz
2006-06-21 21:03 [RFC] decimal float point patch based on libdecnumber: testcase Wu Zhou
2006-06-21 23:36 ` [RFC] decimal float point patch based on libdecnumber: gdb patch Wu Zhou
2006-06-22  3:27   ` Eli Zaretskii
2006-06-22 14:18     ` Wu Zhou
2006-07-12 20:39   ` Daniel Jacobowitz

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=44FA97FA.1070100@cn.ibm.com \
    --to=woodzltc@cn.ibm.com \
    --cc=gdb-patches@sourceware.org \
    /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