Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [RFC] decimal float point patch based on libdecnumber: gdb    patch
@ 2006-08-21 16:08 Wu Zhou
  2006-08-21 18:30 ` Daniel Jacobowitz
  0 siblings, 1 reply; 16+ messages in thread
From: Wu Zhou @ 2006-08-21 16:08 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel, thanks for your comments.

Quoting Daniel Jacobowitz <drow@false.org>:

> On Tue, Aug 01, 2006 at 05:54:55AM -0400, Wu Zhou wrote:
>> The order of these bytes are now big-endian, i.e. the first byte is
>> the most significant one.  But it is maken to be the same as the
>> endianess of the target through routine exchange_dfp (in dfp.c). If
>> the target is big-endian, no reversion is needed; if it is
>> little-endian, reversion is needed. This is done through the checking
>> of gdbarch_byte_order (current_gdbarch):
>
> This is what confuses me.  Why is it always big-endian in GDB, if it is
> target-endian in the target?  I would have expected it to be
> host-endian in GDB and target-endian in the target.
>
>                 i386 target            ppc64 target
>  i386 host      no byteswap            need byteswap
>  ppc64 host     need byteswap          no byteswap

I don't take this kind of configuration into consideration yet. And  
exchange_dfp is also not for cross platform debugging. it is to handle  
the transfer between the byte array representation of dfp values  and  
gdb's value system.

> Or is it always big-endian?  I looked through libdecnumber and I
> couldn't see any reason for i386 to use little endian ordering in
> the decimal128 type.

decimal128 is defined like this in libdecnumber:

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

It is always big-endian.

When parsing dfp constant in our patch, we are also using a byte array  
to store its value. It is big-endian too:

   struct {
        gdb_byte val[16];
        struct type *type;
   } typed_val_decfloat;

But when transfering them into gdb's value system  
(value_from_decfloat), we need to do endianess transfer in little  
endian machine. This is why exchange_dfp is needed.

>> static void
>> exchange_dfp (const gdb_byte *valaddr, int len, gdb_byte *dec_val)
>> {
>>   int index;
>>
>>   if (gdbarch_byte_order (current_gdbarch) == 1)
>
> The 1 should be BFD_ENDIAN_LITTLE.

Yes. It is.  Thanks!

>> Maybe this can't support cross-debugging (I am not sure though).  But
>> I am planning to take this into consideration.  I have one question
>> first: which data structure  is used to describe the host's byte-order
>> information? Anyone is kind to tell me?

I had a try on ppc64. but remote debugging on ppc64 do not work very  
well. I need to look into the reason.

> There isn't one in GDB right now.  We can add one using autoconf if
> it's really necessary.
>
> Let's straighten this out first, and then I'll take a look at the
> actual patch.


Regards
- Wu Zhou


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb    patch
  2006-08-21 16:08 [RFC] decimal float point patch based on libdecnumber: gdb patch Wu Zhou
@ 2006-08-21 18:30 ` Daniel Jacobowitz
  2006-08-21 18:34   ` Wu Zhou
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-08-21 18:30 UTC (permalink / raw)
  To: Wu Zhou; +Cc: gdb-patches

On Mon, Aug 21, 2006 at 07:07:36AM -0400, Wu Zhou wrote:
> decimal128 is defined like this in libdecnumber:
> 
> typedef struct
> {
>   uint8_t bytes[DECIMAL128_Bytes];      /* decimal128: 1, 5, 12, 110 bits */
> } decimal128;
> 
> It is always big-endian.
> 
> When parsing dfp constant in our patch, we are also using a byte array  
> to store its value. It is big-endian too:
> 
>   struct {
>        gdb_byte val[16];
>        struct type *type;
>   } typed_val_decfloat;
> 
> But when transfering them into gdb's value system  
> (value_from_decfloat), we need to do endianess transfer in little  
> endian machine. This is why exchange_dfp is needed.

Why?  Why can't that use exactly the same big endian representation?
It's big endian on the target, it's big endian in the library, so what
are you doing that needs it to be little endian?

Sorry to keep asking this; I really want to understand this one issue
before I review the code.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb     patch
  2006-08-21 18:30 ` Daniel Jacobowitz
@ 2006-08-21 18:34   ` Wu Zhou
  2006-08-22  1:31     ` Daniel Jacobowitz
  0 siblings, 1 reply; 16+ messages in thread
From: Wu Zhou @ 2006-08-21 18:34 UTC (permalink / raw)
  To: Wu Zhou, gdb-patches

Daniel Jacobowitz wrote:
> On Mon, Aug 21, 2006 at 07:07:36AM -0400, Wu Zhou wrote:
>> decimal128 is defined like this in libdecnumber:
>>
>> typedef struct
>> {
>>   uint8_t bytes[DECIMAL128_Bytes];      /* decimal128: 1, 5, 12, 110 bits */
>> } decimal128;
>>
>> It is always big-endian.
>>
>> When parsing dfp constant in our patch, we are also using a byte array  
>> to store its value. It is big-endian too:
>>
>>   struct {
>>        gdb_byte val[16];
>>        struct type *type;
>>   } typed_val_decfloat;
>>
>> But when transfering them into gdb's value system  
>> (value_from_decfloat), we need to do endianess transfer in little  
>> endian machine. This is why exchange_dfp is needed.
> 
> Why?  Why can't that use exactly the same big endian representation?
> It's big endian on the target, it's big endian in the library, so what
> are you doing that needs it to be little endian?

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.

> Sorry to keep asking this; I really want to understand this one issue
> before I review the code.

no problem at all. I guess I didn't make myself understood.  Or that I have some misunderstanding 
about the problem (correct me if you find any). Maybe a direct talk might be good.  Wish to see you 
on gcc IRC (I see that you are gray when I post this).

Regards
- Wu Zhou


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb     patch
  2006-08-21 18:34   ` Wu Zhou
@ 2006-08-22  1:31     ` Daniel Jacobowitz
  2006-09-03  8:53       ` Wu Zhou
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-08-22  1:31 UTC (permalink / raw)
  To: Wu Zhou; +Cc: gdb-patches

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?

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb      patch
  2006-08-22  1:31     ` Daniel Jacobowitz
@ 2006-09-03  8:53       ` Wu Zhou
  2006-09-03 16:44         ` Daniel Jacobowitz
  0 siblings, 1 reply; 16+ messages in thread
From: Wu Zhou @ 2006-09-03  8:53 UTC (permalink / raw)
  To: Wu Zhou, gdb-patches

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?
> 


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb      patch
  2006-09-03  8:53       ` Wu Zhou
@ 2006-09-03 16:44         ` Daniel Jacobowitz
  2006-09-05  2:34           ` Wu Zhou
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-09-03 16:44 UTC (permalink / raw)
  To: Wu Zhou; +Cc: gdb-patches

On Sun, Sep 03, 2006 at 04:53:14PM +0800, Wu Zhou wrote:
> 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.

OK, that makes sense: note that this is needed precisely when
converting from a target decimal float to a host decimal128.  That
is a better time to do the conversion.

> 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.

This, however, is not correct.  Libdecnumber will presumably change to
use host endianness.  GDB will fetch numbers in target endianness.
If you're using a native i386 debugger, then you won't need to swap;
but if you're using an i386 <-> powerpc debugger, then you will.  The
swap will need to be in the same place, just with a different
condition.

I would recommend that you always store the bytes in struct value in
target endianness.  Then, have two functions which convert between a
"struct value" and a "decimal128".  Then it should be clear which one
has which representation.

Then, for instance, you can use decimal128 in typed_val_decfloat, and
in the argument of value_from_decfloat.  And that function can be
responsible for the exchange.  Similarly, in print_decimal_floating,
you have bytes in target endianness; you can convert them to a "struct
value", which will have the same bytes, and convert the value to a
decimal128 which you can print.

The only part of that which is tricky is converting the bytes back to
a struct value.  You could write a new function, value_from_bytes,
to do that; just like value_from_longest.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb       patch
  2006-09-03 16:44         ` Daniel Jacobowitz
@ 2006-09-05  2:34           ` Wu Zhou
  0 siblings, 0 replies; 16+ messages in thread
From: Wu Zhou @ 2006-09-05  2:34 UTC (permalink / raw)
  To: Wu Zhou, gdb-patches

Daniel Jacobowitz wrote:
>> 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.
> 
> OK, that makes sense: note that this is needed precisely when
> converting from a target decimal float to a host decimal128.  That
> is a better time to do the conversion.

Yes.  It should be a better time.

>> 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.
> 
> This, however, is not correct.  Libdecnumber will presumably change to
> use host endianness.  GDB will fetch numbers in target endianness.
> If you're using a native i386 debugger, then you won't need to swap;
> but if you're using an i386 <-> powerpc debugger, then you will.  The
> swap will need to be in the same place, just with a different
> condition.

Yes. Swapping is still needed in cross debugging. I will give some more thought to this, to see if I 
can work out a solution in the near future.

> I would recommend that you always store the bytes in struct value in
> target endianness.  Then, have two functions which convert between a
> "struct value" and a "decimal128".  Then it should be clear which one
> has which representation.
> 
> Then, for instance, you can use decimal128 in typed_val_decfloat, and
> in the argument of value_from_decfloat.  And that function can be
> responsible for the exchange.  Similarly, in print_decimal_floating,
> you have bytes in target endianness; you can convert them to a "struct
> value", which will have the same bytes, and convert the value to a
> decimal128 which you can print.
> 
> The only part of that which is tricky is converting the bytes back to
> a struct value.  You could write a new function, value_from_bytes,
> to do that; just like value_from_longest.
> 
Thanks for these valuable suggestion.

Regards
- Wu Zhou


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb   patch
  2006-08-01 10:51 ` Wu Zhou
@ 2006-08-08 18:16   ` Daniel Jacobowitz
  0 siblings, 0 replies; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-08-08 18:16 UTC (permalink / raw)
  To: Wu Zhou; +Cc: gdb-patches

On Tue, Aug 01, 2006 at 05:54:55AM -0400, Wu Zhou wrote:
> The order of these bytes are now big-endian, i.e. the first byte is  
> the most significant one.  But it is maken to be the same as the  
> endianess of the target through routine exchange_dfp (in dfp.c). If  
> the target is big-endian, no reversion is needed; if it is  
> little-endian, reversion is needed. This is done through the checking  
> of gdbarch_byte_order (current_gdbarch):

This is what confuses me.  Why is it always big-endian in GDB, if it is
target-endian in the target?  I would have expected it to be
host-endian in GDB and target-endian in the target.

                i386 target            ppc64 target
 i386 host      no byteswap            need byteswap
 ppc64 host     need byteswap          no byteswap

Or is it always big-endian?  I looked through libdecnumber and I
couldn't see any reason for i386 to use little endian ordering in
the decimal128 type.

> static void
> exchange_dfp (const gdb_byte *valaddr, int len, gdb_byte *dec_val)
> {
>   int index;
> 
>   if (gdbarch_byte_order (current_gdbarch) == 1)

The 1 should be BFD_ENDIAN_LITTLE.

> Maybe this can't support cross-debugging (I am not sure though).  But  
> I am planning to take this into consideration.  I have one question  
> first: which data structure  is used to describe the host's byte-order  
> information? Anyone is kind to tell me?

There isn't one in GDB right now.  We can add one using autoconf if
it's really necessary.

Let's straighten this out first, and then I'll take a look at the
actual patch.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb    patch
  2006-08-01  9:55 Wu Zhou
@ 2006-08-01 10:51 ` Wu Zhou
  2006-08-08 18:16   ` Daniel Jacobowitz
  0 siblings, 1 reply; 16+ messages in thread
From: Wu Zhou @ 2006-08-01 10:51 UTC (permalink / raw)
  To: gdb-patches

Sorry, forget to add changelog entries.  And also merge with the  
latest cvs source. Here is the modified patch. Please review and  
comment.

2006-08-01  Wu Zhou  <woodzltc@cn.ibm.com>

	* expression.h (enum exp_opcode): Add an opcode (OP_DECFLOAT) for
	DFP constants.
	(union exp_element): Add decfloatconst to represent DFP elements,
	which is 16 bytes by default.
	* parser-defs.h (write_exp_elt_decfloatcst): Prototype.
	* parse.c (write_exp_elt_decfloatcst): New function to write a decimal
	float const into the expression.
	(operator_length_standard): Set operator length for OP_DECFLOAT
	to 4.
	* c-exp.y (YYSTYPE): Add typed_val_decfloat for decimal floating
	point in YYSTYPE union.
	Add token DECFLOAT for typed_val_decfloat.
	Add expression element handling code for DECFLOAT.
	(parse_number): Parse DFP constants, which end with suffix 'df',
	'dd' or 'dl'.  Return DECFLOAT.
	* c-lang.c (c_create_fundamental_type): Create fundamental types
	for DFP.
	* c-valprint.c (c_val_print): Call print_decimal_floating to print
	DFP values.
	* dwarf2read.c (read_base_type): Read DW_ATE_decimal_float attribute
	code and return TYPE_CODE_DECFLOAT.
	(dwarf_base_type): Set dwarf2_fundamental_type for DFP values.
	* eval.c (evaluate_subexp_standard): Call value_from_decfloat to
	handle OP_DECFLOAT.
	* gdbtypes.h: Add three fundamental types for DFP.
	(enum type_code): Add TYPE_CODE_DECFLOAT as a type code for DFP.
	(struct builtin_type): Add builtin_decfloat, builtin_decdouble
	and builtin_declong.
	* gdbtypes.c: Add three builtin types for DFP.
	(build_gdbtypes): Build these three builtin types for DFP.
	(gdbtypes_post_init): Initialize builtin_decfloat, builtin_decdouble
	and builtin_declong.
	* value.h (value_from_decfloat): Prototype.
	(print_decimal_floating): Prototype.
	* valprint.c (print_decimal_floating): New function to print DFP
	values.
	* value.c (value_from_decfloat): New function to get the value
	from a decimal floating point.
	* valarith.c (value_neg): Add some code to handle the negation
	operation of DFP values.
	* dfp.h: New header file for decimal floating point support in
	GDB.
	* dfp.c: New source file for decimal floating point support in
	GDB.  Implement decimal_from_string and decimal_to_string based
	on libdecnumber API.
	* Makefile.in (LIBDECNUMBER_DIR, LIBDECNUMBER, LIBDECNUMBER_SRC
	LIBDECNUMBER_CFLAGS): New macros for libdecnumber.
	(INTERNAL_CFLAGS_BASE): Add LIBDECNUMBER_CFLAGS in.
	(INSTALLED_LIBS): Add -ldecnumber in.
	(CLIBS): Add LIBDECNUMBER in.
	(decimal128_h, decimal64_h, decimal32_h): New macros for decimal headers.
	(dfp_h): New macros for decimal floating point.
	(dfp.o): New target.
	(COMMON_OBS): Add dfp.o in.
	(valprint.o): Add dfp_h as a new dependence.

Index: expression.h
===================================================================
RCS file: /cvs/src/src/gdb/expression.h,v
retrieving revision 1.18
diff -c -3 -p -r1.18 expression.h
*** expression.h	17 Dec 2005 22:33:59 -0000	1.18
--- expression.h	1 Aug 2006 10:30:16 -0000
***************
*** 1,7 ****
   /* Definitions for expressions stored in reversed prefix form, for GDB.

!    Copyright (C) 1986, 1989, 1992, 1994, 2000, 2003, 2005 Free Software
!    Foundation, Inc.

      This file is part of GDB.

--- 1,7 ----
   /* Definitions for expressions stored in reversed prefix form, for GDB.

!    Copyright (C) 1986, 1989, 1992, 1994, 2000, 2003, 2005, 2006
!    Free Software Foundation, Inc.

      This file is part of GDB.

*************** enum exp_opcode
*** 327,332 ****
--- 327,337 ----
       /* A F90 array range operator (for "exp:exp", "exp:", ":exp"  
and ":").  */
       OP_F90_RANGE,

+     /* OP_DECFLOAT is followed by a type pointer in the next exp_element
+        and a dec long constant value in the following exp_element.
+        Then comes another OP_DECFLOAT.  */
+     OP_DECFLOAT,
+
        /* First extension operator.  Individual language modules define
           extra operators they need as constants with values
           OP_LANGUAGE_SPECIFIC0 + k, for k >= 0, using a separate
*************** union exp_element
*** 354,359 ****
--- 359,365 ----
       struct symbol *symbol;
       LONGEST longconst;
       DOUBLEST doubleconst;
+     gdb_byte decfloatconst[16];
       /* Really sizeof (union exp_element) characters (or less for the last
          element of a string).  */
       char string;
Index: parser-defs.h
===================================================================
RCS file: /cvs/src/src/gdb/parser-defs.h,v
retrieving revision 1.20
diff -c -3 -p -r1.20 parser-defs.h
*** parser-defs.h	17 Dec 2005 22:34:01 -0000	1.20
--- parser-defs.h	1 Aug 2006 10:30:16 -0000
***************
*** 1,7 ****
   /* Parser definitions for GDB.

      Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
!    1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.

      Modified from expread.y by the Department of Computer Science at the
      State University of New York at Buffalo.
--- 1,7 ----
   /* Parser definitions for GDB.

      Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
!    1997, 1998, 1999, 2000, 2002, 2006 Free Software Foundation, Inc.

      Modified from expread.y by the Department of Computer Science at the
      State University of New York at Buffalo.
*************** extern void write_exp_elt_longcst (LONGE
*** 121,126 ****
--- 121,128 ----

   extern void write_exp_elt_dblcst (DOUBLEST);

+ extern void write_exp_elt_decfloatcst (gdb_byte *);
+
   extern void write_exp_elt_type (struct type *);

   extern void write_exp_elt_intern (struct internalvar *);
Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.53
diff -c -3 -p -r1.53 parse.c
*** parse.c	6 Jul 2006 14:00:48 -0000	1.53
--- parse.c	1 Aug 2006 10:30:17 -0000
***************
*** 1,7 ****
   /* Parse expressions for GDB.

      Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
!    1997, 1998, 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.

      Modified from expread.y by the Department of Computer Science at the
      State University of New York at Buffalo, 1991.
--- 1,8 ----
   /* Parse expressions for GDB.

      Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
!    1997, 1998, 1999, 2000, 2001, 2004, 2005, 2006
!    Free Software Foundation, Inc.

      Modified from expread.y by the Department of Computer Science at the
      State University of New York at Buffalo, 1991.
*************** write_exp_elt_dblcst (DOUBLEST expelt)
*** 241,246 ****
--- 242,259 ----
   }

   void
+ write_exp_elt_decfloatcst (gdb_byte expelt[16])
+ {
+   union exp_element tmp;
+   int index;
+
+   for (index = 0; index < 16; index++)
+     tmp.decfloatconst[index] = expelt[index];
+
+   write_exp_elt (tmp);
+ }
+
+ void
   write_exp_elt_type (struct type *expelt)
   {
     union exp_element tmp;
*************** operator_length_standard (struct express
*** 864,869 ****
--- 877,883 ----

       case OP_LONG:
       case OP_DOUBLE:
+     case OP_DECFLOAT:
       case OP_VAR_VALUE:
         oplen = 4;
         break;
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.34
diff -c -3 -p -r1.34 c-exp.y
*** c-exp.y	23 Feb 2006 18:43:41 -0000	1.34
--- c-exp.y	1 Aug 2006 10:30:17 -0000
*************** Boston, MA 02110-1301, USA.  */
*** 53,58 ****
--- 53,59 ----
   #include "charset.h"
   #include "block.h"
   #include "cp-support.h"
+ #include "dfp.h"

   /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
      as well as gratuitiously global symbol names, so we can have multiple
*************** void yyerror (char *);
*** 131,136 ****
--- 132,141 ----
         DOUBLEST dval;
         struct type *type;
       } typed_val_float;
+     struct {
+       gdb_byte val[16];
+       struct type *type;
+     } typed_val_decfloat;
       struct symbol *sym;
       struct type *tval;
       struct stoken sval;
*************** static int parse_number (char *, int, in
*** 163,168 ****
--- 168,174 ----

   %token <typed_val_int> INT
   %token <typed_val_float> FLOAT
+ %token <typed_val_decfloat> DECFLOAT

   /* Both NAME and TYPENAME tokens represent symbols in the input,
      and both convey their data as strings.
*************** exp	:	FLOAT
*** 497,502 ****
--- 503,515 ----
   			  write_exp_elt_opcode (OP_DOUBLE); }
   	;

+ exp	:	DECFLOAT
+ 			{ write_exp_elt_opcode (OP_DECFLOAT);
+ 			  write_exp_elt_type ($1.type);
+ 			  write_exp_elt_decfloatcst ($1.val);
+ 			  write_exp_elt_opcode (OP_DECFLOAT); }
+ 	;
+
   exp	:	variable
   	;

*************** parse_number (p, len, parsed_float, puti
*** 1080,1085 ****
--- 1093,1132 ----
         char saved_char = p[len];

         p[len] = 0;	/* null-terminate the token */
+
+       /* If it ends at "df", "dd" or "dl", take it as type of  
decimal floating
+          point.  Return DECFLOAT.  */
+
+       if (p[len - 2] == 'd' && p[len - 1] == 'f')
+ 	{
+ 	  p[len - 2] = '\0';
+ 	  putithere->typed_val_decfloat.type =
+ 	    builtin_type (current_gdbarch)->builtin_decfloat;
+ 	  decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
+ 	  p[len] = saved_char;
+ 	  return (DECFLOAT);
+ 	}
+
+       if (p[len - 2] == 'd' && p[len - 1] == 'd')
+ 	{
+ 	  p[len - 2] = '\0';
+ 	  putithere->typed_val_decfloat.type =
+ 	    builtin_type (current_gdbarch)->builtin_decdouble;
+ 	  decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
+ 	  p[len] = saved_char;
+ 	  return (DECFLOAT);
+ 	}
+
+       if (p[len - 2] == 'd' && p[len - 1] == 'l')
+ 	{
+ 	  p[len - 2] = '\0';
+ 	  putithere->typed_val_decfloat.type =
+ 	    builtin_type (current_gdbarch)->builtin_declong;
+ 	  decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
+ 	  p[len] = saved_char;
+ 	  return (DECFLOAT);
+ 	}
+
         num = sscanf (p, DOUBLEST_SCAN_FORMAT "%s",
   		    &putithere->typed_val_float.dval, s);
         p[len] = saved_char;	/* restore the input stream */
Index: c-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/c-lang.c,v
retrieving revision 1.39
diff -c -3 -p -r1.39 c-lang.c
*** c-lang.c	17 Dec 2005 22:33:59 -0000	1.39
--- c-lang.c	1 Aug 2006 10:30:17 -0000
***************
*** 1,7 ****
   /* C language support routines for GDB, the GNU debugger.

      Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002,
!    2003, 2004, 2005 Free Software Foundation, Inc.

      This file is part of GDB.

--- 1,7 ----
   /* C language support routines for GDB, the GNU debugger.

      Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002,
!    2003, 2004, 2005, 2006 Free Software Foundation, Inc.

      This file is part of GDB.

*************** c_create_fundamental_type (struct objfil
*** 322,327 ****
--- 322,342 ----
   			TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
   			0, "long double", objfile);
         break;
+     case FT_DECFLOAT:
+       type = init_type (TYPE_CODE_DECFLOAT,
+ 			32 / 8,
+ 			0, "decimal float", objfile);
+       break;
+     case FT_DBL_PREC_DECFLOAT:
+       type = init_type (TYPE_CODE_DECFLOAT,
+ 			64 / 8,
+ 			0, "decimal double", objfile);
+       break;
+     case FT_EXT_PREC_DECFLOAT:
+       type = init_type (TYPE_CODE_DECFLOAT,
+ 			128 / 8,
+ 			0, "decimal long double", objfile);
+       break;
       case FT_COMPLEX:
         type = init_type (TYPE_CODE_FLT,
   			2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
Index: c-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-valprint.c,v
retrieving revision 1.39
diff -c -3 -p -r1.39 c-valprint.c
*** c-valprint.c	18 Jan 2006 21:24:19 -0000	1.39
--- c-valprint.c	1 Aug 2006 10:30:17 -0000
*************** c_val_print (struct type *type, const gd
*** 433,445 ****

       case TYPE_CODE_FLT:
         if (format)
! 	{
! 	  print_scalar_formatted (valaddr + embedded_offset, type, format,  
0, stream);
! 	}
         else
! 	{
! 	  print_floating (valaddr + embedded_offset, type, stream);
! 	}
         break;

       case TYPE_CODE_METHOD:
--- 433,448 ----

       case TYPE_CODE_FLT:
         if (format)
! 	print_scalar_formatted (valaddr + embedded_offset, type, format, 0,  
stream);
         else
! 	print_floating (valaddr + embedded_offset, type, stream);
!       break;
!
!     case TYPE_CODE_DECFLOAT:
!       if (format)
! 	print_scalar_formatted (valaddr + embedded_offset, type, format, 0,  
stream);
!       else
! 	print_decimal_floating (valaddr + embedded_offset, type, stream);
         break;

       case TYPE_CODE_METHOD:
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.201
diff -c -3 -p -r1.201 dwarf2read.c
*** dwarf2read.c	24 Jul 2006 21:37:04 -0000	1.201
--- dwarf2read.c	1 Aug 2006 10:30:17 -0000
*************** read_base_type (struct die_info *die, st
*** 4747,4752 ****
--- 4747,4755 ----
   	case DW_ATE_complex_float:
   	  code = TYPE_CODE_COMPLEX;
   	  break;
+ 	case DW_ATE_decimal_float:
+ 	  code = TYPE_CODE_DECFLOAT;
+ 	  break;
   	case DW_ATE_float:
   	  code = TYPE_CODE_FLT;
   	  break;
*************** dwarf_base_type (int encoding, int size,
*** 7517,7539 ****
         return type;
       case DW_ATE_complex_float:
         if (size == 16)
! 	{
! 	  type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_COMPLEX, cu);
! 	}
         else
! 	{
! 	  type = dwarf2_fundamental_type (objfile, FT_COMPLEX, cu);
! 	}
         return type;
       case DW_ATE_float:
         if (size == 8)
! 	{
! 	  type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_FLOAT, cu);
! 	}
         else
! 	{
! 	  type = dwarf2_fundamental_type (objfile, FT_FLOAT, cu);
! 	}
         return type;
       case DW_ATE_signed:
         switch (size)
--- 7520,7542 ----
         return type;
       case DW_ATE_complex_float:
         if (size == 16)
! 	type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_COMPLEX, cu);
         else
! 	type = dwarf2_fundamental_type (objfile, FT_COMPLEX, cu);
         return type;
       case DW_ATE_float:
         if (size == 8)
! 	type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_FLOAT, cu);
         else
! 	type = dwarf2_fundamental_type (objfile, FT_FLOAT, cu);
!       return type;
!     case DW_ATE_decimal_float:
!       if (size == 16)
! 	type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_DECFLOAT, cu);
!       else if (size == 8)
! 	type = dwarf2_fundamental_type (objfile, FT_EXT_PREC_DECFLOAT, cu);
!       else
! 	type = dwarf2_fundamental_type (objfile, FT_DECFLOAT, cu);
         return type;
       case DW_ATE_signed:
         switch (size)
Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.63
diff -c -3 -p -r1.63 eval.c
*** eval.c	25 Jul 2006 04:24:50 -0000	1.63
--- eval.c	1 Aug 2006 10:30:18 -0000
***************
*** 1,8 ****
   /* Evaluate expressions for GDB.

      Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
!    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005 Free
!    Software Foundation, Inc.

      This file is part of GDB.

--- 1,8 ----
   /* Evaluate expressions for GDB.

      Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
!    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006
!    Free Software Foundation, Inc.

      This file is part of GDB.

*************** evaluate_subexp_standard (struct type *e
*** 451,456 ****
--- 451,461 ----
         return value_from_double (exp->elts[pc + 1].type,
   				exp->elts[pc + 2].doubleconst);

+     case OP_DECFLOAT:
+       (*pos) += 3;
+       return value_from_decfloat (expect_type, exp->elts[pc + 1].type,
+ 				exp->elts[pc + 2].decfloatconst);
+
       case OP_VAR_VALUE:
         (*pos) += 3;
         if (noside == EVAL_SKIP)
Index: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.65
diff -c -3 -p -r1.65 gdbtypes.h
*** gdbtypes.h	1 Feb 2006 23:14:10 -0000	1.65
--- gdbtypes.h	1 Aug 2006 10:30:18 -0000
*************** struct block;
*** 67,73 ****
   #define FT_UNSIGNED_BYTE	27
   #define FT_TEMPLATE_ARG		28

! #define FT_NUM_MEMBERS		29	/* Highest FT_* above, plus one. */

   /* Some macros for char-based bitfields.  */

--- 67,78 ----
   #define FT_UNSIGNED_BYTE	27
   #define FT_TEMPLATE_ARG		28

! /* The following three fundamental types are for decimal floating point.  */
! #define FT_DECFLOAT		29
! #define FT_DBL_PREC_DECFLOAT	30
! #define FT_EXT_PREC_DECFLOAT	31
!
! #define FT_NUM_MEMBERS		32	/* Highest FT_* above, plus one. */

   /* Some macros for char-based bitfields.  */

*************** enum type_code
*** 159,165 ****
       TYPE_CODE_TEMPLATE,		/* C++ template */
       TYPE_CODE_TEMPLATE_ARG,	/* C++ template arg */

!     TYPE_CODE_NAMESPACE		/* C++ namespace.  */
     };

   /* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
--- 164,172 ----
       TYPE_CODE_TEMPLATE,		/* C++ template */
       TYPE_CODE_TEMPLATE_ARG,	/* C++ template arg */

!     TYPE_CODE_NAMESPACE,	/* C++ namespace.  */
!
!     TYPE_CODE_DECFLOAT		/* Decimal floating point.  */
     };

   /* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
*************** struct builtin_type
*** 1005,1010 ****
--- 1012,1020 ----
     struct type *builtin_bool;
     struct type *builtin_long_long;
     struct type *builtin_unsigned_long_long;
+   struct type *builtin_decfloat;
+   struct type *builtin_decdouble;
+   struct type *builtin_declong;
   };

   /* Return the type table for the specified architecture.  */
*************** extern struct type *builtin_type_complex
*** 1028,1033 ****
--- 1038,1046 ----
   extern struct type *builtin_type_double_complex;
   extern struct type *builtin_type_string;
   extern struct type *builtin_type_bool;
+ extern struct type *builtin_type_decfloat;
+ extern struct type *builtin_type_decdouble;
+ extern struct type *builtin_type_declong;

   /* Address/pointer types: */
   /* (C) Language `pointer to data' type.  Some target platforms use an
Index: gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.105
diff -c -3 -p -r1.105 gdbtypes.c
*** gdbtypes.c	1 Mar 2006 19:34:46 -0000	1.105
--- gdbtypes.c	1 Aug 2006 10:30:18 -0000
*************** struct type *builtin_type_int128;
*** 76,81 ****
--- 76,87 ----
   struct type *builtin_type_uint128;
   struct type *builtin_type_bool;

+ /* The following three are about decimal floating point types, which are now
+    considered as potential extension to C99 standard.  */
+ struct type *builtin_type_decfloat;
+ struct type *builtin_type_decdouble;
+ struct type *builtin_type_declong;
+
   /* 128 bit long vector types */
   struct type *builtin_type_v2_double;
   struct type *builtin_type_v4_float;
*************** build_gdbtypes (void)
*** 3379,3384 ****
--- 3385,3405 ----
   #if 0
     TYPE_FLOATFORMAT (builtin_type_long_double) = TARGET_LONG_DOUBLE_FORMAT;
   #endif
+
+   /* Builtin types for decimal floating point types.  */
+   builtin_type_decfloat =
+     init_type (TYPE_CODE_DECFLOAT, 32 / 8,
+ 	       0,
+ 	       "decimal float", (struct objfile *) NULL);
+   builtin_type_decdouble =
+     init_type (TYPE_CODE_DECFLOAT, 64 / 8,
+                0,
+                "decimal double", (struct objfile *) NULL);
+   builtin_type_declong =
+     init_type (TYPE_CODE_DECFLOAT, 128 / 8,
+ 	       0,
+ 	       "decimal long double", (struct objfile *) NULL);
+
     builtin_type_complex =
       init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
   	       0,
*************** gdbtypes_post_init (struct gdbarch *gdba
*** 3604,3609 ****
--- 3625,3645 ----
   	       0,
   	       "bool", (struct objfile *) NULL);

+   /* The following three are about decimal floating point types, which are
+      32-bits, 64-bits and 128-bits respectively.  */
+   builtin_type->builtin_decfloat =
+    init_type (TYPE_CODE_DECFLOAT, 32 / 8,
+                0,
+                "decimal float", (struct objfile *) NULL);
+   builtin_type->builtin_decdouble =
+     init_type (TYPE_CODE_DECFLOAT, 64 / 8,
+                0,
+                "decimal double", (struct objfile *) NULL);
+   builtin_type->builtin_declong =
+     init_type (TYPE_CODE_DECFLOAT, 128 / 8,
+                0,
+                "decimal long double", (struct objfile *) NULL);
+
     /* Pointer/Address types. */

     /* NOTE: on some targets, addresses and pointers are not necessarily
*************** _initialize_gdbtypes (void)
*** 3742,3747 ****
--- 3778,3786 ----
     DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr);
     DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR);
     DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma);
+   DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_decfloat);
+   DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_decdouble);
+   DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_declong);
     deprecated_register_gdbarch_swap (NULL, 0, build_gdbtypes);

     /* Note: These types do not need to be swapped - they are target
Index: value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.92
diff -c -3 -p -r1.92 value.h
*** value.h	13 Jul 2006 04:31:42 -0000	1.92
--- value.h	1 Aug 2006 10:30:18 -0000
***************
*** 1,7 ****
   /* Definitions for values of C expressions, for GDB.

      Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
!    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
      Free Software Foundation, Inc.

      This file is part of GDB.
--- 1,7 ----
   /* Definitions for values of C expressions, for GDB.

      Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
!    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
      Free Software Foundation, Inc.

      This file is part of GDB.
*************** extern LONGEST unpack_field_as_long (str
*** 274,279 ****
--- 274,282 ----
   extern struct value *value_from_longest (struct type *type, LONGEST num);
   extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
   extern struct value *value_from_double (struct type *type, DOUBLEST num);
+ extern struct value *value_from_decfloat (struct type *expect_type,
+ 					  struct type *type,
+ 					  gdb_byte decbytes[16]);
   extern struct value *value_from_string (char *string);

   extern struct value *value_at (struct type *type, CORE_ADDR addr);
*************** extern void print_longest (struct ui_fil
*** 473,478 ****
--- 476,484 ----
   extern void print_floating (const gdb_byte *valaddr, struct type *type,
   			    struct ui_file *stream);

+ extern void print_decimal_floating (const gdb_byte *valaddr, struct  
type *type,
+ 				    struct ui_file *stream);
+
   extern int value_print (struct value *val, struct ui_file *stream,  
int format,
   			enum val_prettyprint pretty);

Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.36
diff -c -3 -p -r1.36 value.c
*** value.c	31 Mar 2006 10:36:18 -0000	1.36
--- value.c	1 Aug 2006 10:30:18 -0000
***************
*** 37,42 ****
--- 37,43 ----
   #include "gdb_assert.h"
   #include "regcache.h"
   #include "block.h"
+ #include "dfp.h"

   /* Prototypes for exported functions. */

*************** value_from_double (struct type *type, DO
*** 1610,1615 ****
--- 1611,1637 ----
   }

   struct value *
+ value_from_decfloat (struct type *expect_type, struct type *type,
+ 		      gdb_byte decbytes[16])
+ {
+   struct value *val = allocate_value (type);
+   int len = TYPE_LENGTH (type);
+
+   if (expect_type)
+     {
+       int expect_len = TYPE_LENGTH (expect_type);
+       char decstr[128];
+       int real_len;
+
+       decimal_to_string (decbytes, len, decstr);
+       decimal_from_string (decbytes, expect_len, decstr);
+     }
+
+   memcpy (value_contents_raw (val), decbytes, len);
+   return val;
+ }
+
+ struct value *
   coerce_ref (struct value *arg)
   {
     struct type *value_type_arg_tmp = check_typedef (value_type (arg));
Index: valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/valprint.c,v
retrieving revision 1.60
diff -c -3 -p -r1.60 valprint.c
*** valprint.c	15 May 2006 16:53:38 -0000	1.60
--- valprint.c	1 Aug 2006 10:30:18 -0000
***************
*** 35,40 ****
--- 35,41 ----
   #include "floatformat.h"
   #include "doublest.h"
   #include "exceptions.h"
+ #include "dfp.h"

   #include <errno.h>

*************** print_floating (const gdb_byte *valaddr,
*** 496,501 ****
--- 497,514 ----
   }

   void
+ print_decimal_floating (const gdb_byte *valaddr, struct type *type,
+ 			struct ui_file *stream)
+ {
+   char decstr[128];
+   unsigned len = TYPE_LENGTH (type);
+
+   decimal_to_string (valaddr, len, decstr);
+   fputs_filtered (decstr, stream);
+   return;
+ }
+
+ void
   print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
   		    unsigned len)
   {
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.45
diff -c -3 -p -r1.45 valarith.c
*** valarith.c	24 Jan 2006 21:21:12 -0000	1.45
--- valarith.c	1 Aug 2006 10:30:18 -0000
***************
*** 1,7 ****
   /* Perform arithmetic and other operations on values, for GDB.

      Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
!    1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
      Free Software Foundation, Inc.

      This file is part of GDB.
--- 1,7 ----
   /* Perform arithmetic and other operations on values, for GDB.

      Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
!    1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
      Free Software Foundation, Inc.

      This file is part of GDB.
*************** value_neg (struct value *arg1)
*** 1378,1383 ****
--- 1378,1397 ----

     type = check_typedef (value_type (arg1));

+   if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT)
+     {
+       struct value *val = allocate_value (result_type);
+       int len = TYPE_LENGTH (type);
+       gdb_byte *decbytes = (gdb_byte *) value_contents (arg1);
+
+       if (gdbarch_byte_order (current_gdbarch))
+ 	decbytes[len-1] = decbytes[len - 1] | 0x80;
+       else
+ 	decbytes[0] = decbytes[0] | 0x80;
+       memcpy (value_contents_raw (val), decbytes, 16);
+       return val;
+     }
+
     if (TYPE_CODE (type) == TYPE_CODE_FLT)
       return value_from_double (result_type, -value_as_double (arg1));
     else if (is_integral_type (type))
Index: dfp.h
===================================================================
RCS file: dfp.h
diff -N dfp.h
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- dfp.h	1 Aug 2006 10:30:18 -0000
***************
*** 0 ****
--- 1,40 ----
+ /* Decimal floating point support for GDB.
+
+    Copyright 2006 Free Software Foundation, Inc.
+
+    This file is part of GDB.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330,
+    Boston, MA 02111-1307, USA.  */
+
+ /* Decimal floating point is one of the extension to IEEE 754, which is
+    described in http://grouper.ieee.org/groups/754/revision.html and
+    http://www2.hursley.ibm.com/decimal/.  It completes binary floating
+    point by representing floating point more exactly.  */
+
+ /* There is a project intended to add DFP support into GCC, described in
+    http://gcc.gnu.org/wiki/Decimal%20Floating-Point.  This file is intended
+    to add DFP support into GDB.  */
+
+ #ifndef DFP_H
+ #define DFP_H
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdint.h>
+
+ extern void decimal_to_string (const uint8_t *, int, char *);
+ extern int decimal_from_string (uint8_t *, int, char *);
+
+ #endif
Index: dfp.c
===================================================================
RCS file: dfp.c
diff -N dfp.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- dfp.c	1 Aug 2006 10:30:18 -0000
***************
*** 0 ****
--- 1,122 ----
+ /* Decimal floating point support for GDB.
+
+    Copyright 2006 Free Software Foundation, Inc.
+
+    This file is part of GDB.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330,
+    Boston, MA 02111-1307, USA.  */
+
+ #include "defs.h"
+ #include "dfp.h"
+ #include <ctype.h>
+
+ /* The order of the following headers is important for making sure
+    decNumber structure is large enough to hold decimal128 digits.  */
+
+ #include "decimal128.h"
+ #include "decimal64.h"
+ #include "decimal32.h"
+ #include "decNumber.h"
+
+ /* In gdb, we are using an array of gdb_byte to represent decimal  
values. The
+    byte order of our representation might be different than that of  
underlying
+    architecture.  This routine does the conversion if it is necessary.  */
+ static void
+ exchange_dfp (const gdb_byte *valaddr, int len, gdb_byte *dec_val)
+ {
+   int index;
+
+   if (gdbarch_byte_order (current_gdbarch) == 1)
+     for (index = 0; index < len; index++)
+       dec_val[index] = valaddr[len - index - 1];
+   else
+     for (index = 0; index < len; index++)
+       dec_val[index] = valaddr[index];
+
+   return;
+ }
+
+ /* Convert deciaml type to its string representation.  LEN is the length
+    of the decimal type, 4 bytes for decimal32, 8 bytes for decimal64 and
+    16 bytes for decimal128.  */
+ void
+ decimal_to_string (const uint8_t *decbytes, int len, char *s)
+ {
+   uint8_t *dec = (uint8_t *)malloc (len);
+
+   exchange_dfp (decbytes, len, dec);
+   switch (len)
+     {
+       case 4:
+         decimal32ToString ((decimal32 *) dec, s);
+         return;
+       case 8:
+         decimal64ToString ((decimal64 *) dec, s);
+         return;
+       case 16:
+         decimal128ToString ((decimal128 *) dec, s);
+         return;
+       default:
+ 	return;
+     }
+
+   free (dec);
+ }
+
+ /* Convert the string form of a decimal value to its decimal representation.
+    LEN is the length of the decimal type, 4 bytes for decimal32, 8 bytes for
+    decimal64 and 16 bytes for decimal128.  */
+ int
+ decimal_from_string (uint8_t *decbytes, int len, char *string)
+ {
+   decNumber dn;
+   decContext set;
+   int index;
+   uint8_t *dec = (uint8_t *)malloc (len);
+
+   switch (len)
+     {
+       case 4:
+ 	decContextDefault (&set, DEC_INIT_DECIMAL32);
+ 	break;
+       case 8:
+ 	decContextDefault (&set, DEC_INIT_DECIMAL64);
+ 	break;
+       case 16:
+ 	decContextDefault (&set, DEC_INIT_DECIMAL128);
+ 	break;
+     }
+
+   set.traps = 0;
+
+   decNumberFromString (&dn, string, &set);
+   switch (len)
+     {
+       case 4:
+ 	decimal32FromNumber ((decimal32 *) dec, &dn, &set);
+ 	break;
+       case 8:
+ 	decimal64FromNumber ((decimal64 *) dec, &dn, &set);
+ 	break;
+       case 16:
+ 	decimal128FromNumber ((decimal128 *) dec, &dn, &set);
+ 	break;
+     }
+
+   exchange_dfp (dec, len, decbytes);
+   free (dec);
+   return 1;
+ }
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.834
diff -c -3 -p -r1.834 Makefile.in
*** Makefile.in	31 Jul 2006 20:15:50 -0000	1.834
--- Makefile.in	1 Aug 2006 10:30:18 -0000
*************** BFD = $(BFD_DIR)/libbfd.a
*** 122,127 ****
--- 122,133 ----
   BFD_SRC = $(srcdir)/$(BFD_DIR)
   BFD_CFLAGS = -I$(BFD_DIR) -I$(BFD_SRC)

+ # Where is the decnumber library?  Typically in ../libdecnumber.
+ LIBDECNUMBER_DIR = ../libdecnumber
+ LIBDECNUMBER = $(LIBDECNUMBER_DIR)/libdecnumber.a
+ LIBDECNUMBER_SRC = $(srcdir)/$(LIBDECNUMBER_DIR)
+ LIBDECNUMBER_CFLAGS = -I$(LIBDECNUMBER_DIR) -I$(LIBDECNUMBER_SRC)
+
   # Where is the READLINE library?  Typically in ../readline.
   READLINE_DIR = ../readline
   READLINE = $(READLINE_DIR)/libreadline.a
*************** CXXFLAGS = -g -O
*** 348,354 ****
   INTERNAL_CFLAGS_BASE = \
   	$(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
   	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
! 	$(BFD_CFLAGS) $(INCLUDE_CFLAGS) \
   	$(INTL_CFLAGS) $(ENABLE_CFLAGS)
   INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS)
   INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS)
--- 354,360 ----
   INTERNAL_CFLAGS_BASE = \
   	$(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
   	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
! 	$(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \
   	$(INTL_CFLAGS) $(ENABLE_CFLAGS)
   INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS)
   INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS)
*************** INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CF
*** 371,380 ****
   # LIBIBERTY appears twice on purpose.
   # If you have the Cygnus libraries installed,
   # you can use 'CLIBS=$(INSTALLED_LIBS)' 'CDEPS='
! INSTALLED_LIBS=-lbfd -lreadline -lopcodes -liberty \
   	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
   	-lintl -liberty
! CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY) \
   	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
   	$(LIBICONV) \
   	$(LIBIBERTY) $(WIN32LIBS)
--- 377,386 ----
   # LIBIBERTY appears twice on purpose.
   # If you have the Cygnus libraries installed,
   # you can use 'CLIBS=$(INSTALLED_LIBS)' 'CDEPS='
! INSTALLED_LIBS=-lbfd -lreadline -lopcodes -liberty -ldecnumber \
   	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
   	-lintl -liberty
! CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY)  
$(LIBDECNUMBER) \
   	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
   	$(LIBICONV) \
   	$(LIBIBERTY) $(WIN32LIBS)
*************** splay_tree_h =  $(INCLUDE_DIR)/splay-tre
*** 604,609 ****
--- 610,619 ----
   safe_ctype_h =  $(INCLUDE_DIR)/safe-ctype.h
   hashtab_h =	$(INCLUDE_DIR)/hashtab.h

+ decimal128_h = $(LIBDECNUMBER_DIR)/decimal128.h
+ decimal64_h = $(LIBDECNUMBER_DIR)/decimal64.h
+ decimal32_h = $(LIBDECNUMBER_DIR)/decimal32.h
+
   #
   # $BUILD/ headers
   #
*************** dictionary_h = dictionary.h
*** 670,675 ****
--- 680,686 ----
   disasm_h = disasm.h
   doublest_h = doublest.h $(floatformat_h)
   dummy_frame_h = dummy-frame.h
+ dfp_h = dfp.h
   dwarf2expr_h = dwarf2expr.h
   dwarf2_frame_h = dwarf2-frame.h
   dwarf2loc_h = dwarf2loc.h
*************** COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
*** 911,917 ****
   	auxv.o \
   	bfd-target.o \
   	blockframe.o breakpoint.o findvar.o regcache.o \
! 	charset.o disasm.o dummy-frame.o \
   	source.o value.o eval.o valops.o valarith.o valprint.o printcmd.o \
   	block.o symtab.o symfile.o symmisc.o linespec.o dictionary.o \
   	infcall.o \
--- 922,928 ----
   	auxv.o \
   	bfd-target.o \
   	blockframe.o breakpoint.o findvar.o regcache.o \
! 	charset.o disasm.o dummy-frame.o dfp.o \
   	source.o value.o eval.o valops.o valarith.o valprint.o printcmd.o \
   	block.o symtab.o symfile.o symmisc.o linespec.o dictionary.o \
   	infcall.o \
*************** dsrec.o: dsrec.c $(defs_h) $(serial_h) $
*** 1922,1927 ****
--- 1933,1939 ----
   dummy-frame.o: dummy-frame.c $(defs_h) $(dummy_frame_h) $(regcache_h) \
   	$(frame_h) $(inferior_h) $(gdb_assert_h) $(frame_unwind_h) \
   	$(command_h) $(gdbcmd_h) $(gdb_string_h)
+ dfp.o: dfp.c $(defs_h) $(dfp_h) $(decimal128_h) $(decimal64_h)  
$(decimal32_h)
   dve3900-rom.o: dve3900-rom.c $(defs_h) $(gdbcore_h) $(target_h)  
$(monitor_h) \
   	$(serial_h) $(inferior_h) $(command_h) $(gdb_string_h) $(regcache_h) \
   	$(mips_tdep_h)
*************** valops.o: valops.c $(defs_h) $(symtab_h)
*** 2792,2798 ****
   valprint.o: valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
   	$(value_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(language_h) \
   	$(annotate_h) $(valprint_h) $(floatformat_h) $(doublest_h) \
! 	$(exceptions_h)
   value.o: value.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
   	$(value_h) $(gdbcore_h) $(command_h) $(gdbcmd_h) $(target_h) \
   	$(language_h) $(scm_lang_h) $(demangle_h) $(doublest_h) \
--- 2804,2810 ----
   valprint.o: valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
   	$(value_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(language_h) \
   	$(annotate_h) $(valprint_h) $(floatformat_h) $(doublest_h) \
! 	$(exceptions_h) $(dfp_h)
   value.o: value.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
   	$(value_h) $(gdbcore_h) $(command_h) $(gdbcmd_h) $(target_h) \
   	$(language_h) $(scm_lang_h) $(demangle_h) $(doublest_h) \


Quoting Wu Zhou <woodzltc@cn.ibm.com>:

> Hi Daniel,
>
> Thanks for your comment.
>
> Quoting Daniel Jacobowitz <drow@false.org>:
>
>> On Sun, Jul 23, 2006 at 01:47:58AM -0400, Wu Zhou wrote:
>>> My point is to keep these usage so as they are consistent with how
>>> flaot/double is handled.  What is your idea on this?
>>
>> I think it would be more useful to search for all reference to decimal
>> float, than it would be to exactly parallel the float/double support.
>
> OK.  I will buy your point.  :-)     The revised patch adopt this preference.
>
>>> But in big-endian machine, this might be not needed. I will try a test
>>> on ppc64.
>
> I made some modification to my patch.  It now works on both x86
> (little endian) and ppc64 (big endian) platforms. All 125 tests pass
> on these two platforms. I didn't do any test on cross-debugging though.
>
> Here are some explanation to my revised patch, wishing that it can
> clarfiy the situation somehow.
>
> I am now still use  array of bytes (gdb_byte val[16]) to represent
> decimal float in gdb.  The reason is that we can't assume that the
> gdb-building compiler supports the decimal extension to C language
> standard. If we can, that will be much easier, we can just use that to
> represent decimal float in gdb.
>
> The order of these bytes are now big-endian, i.e. the first byte is
> the most significant one.  But it is maken to be the same as the
> endianess of the target through routine exchange_dfp (in dfp.c). If
> the target is big-endian, no reversion is needed; if it is
> little-endian, reversion is needed. This is done through the checking
> of gdbarch_byte_order (current_gdbarch):
>
> static void
> exchange_dfp (const gdb_byte *valaddr, int len, gdb_byte *dec_val)
> {
>   int index;
>
>   if (gdbarch_byte_order (current_gdbarch) == 1)
>     for (index = 0; index < len; index++)
>       dec_val[index] = valaddr[len - index - 1];
>   else
>     for (index = 0; index < len; index++)
>       dec_val[index] = valaddr[index];
>
>   return;
> }
>
> Maybe this can't support cross-debugging (I am not sure though).  But
> I am planning to take this into consideration.  I have one question
> first: which data structure  is used to describe the host's byte-order
> information? Anyone is kind to tell me?
>
> Attached below is the revised patch. Please review and comment.    
> Thanks a lot!


Regards
- Wu Zhou


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb   patch
@ 2006-08-01  9:55 Wu Zhou
  2006-08-01 10:51 ` Wu Zhou
  0 siblings, 1 reply; 16+ messages in thread
From: Wu Zhou @ 2006-08-01  9:55 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

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

Hi Daniel,

Thanks for your comment.

Quoting Daniel Jacobowitz <drow@false.org>:

> On Sun, Jul 23, 2006 at 01:47:58AM -0400, Wu Zhou wrote:
>> My point is to keep these usage so as they are consistent with how
>> flaot/double is handled.  What is your idea on this?
>
> I think it would be more useful to search for all reference to decimal
> float, than it would be to exactly parallel the float/double support.

OK.  I will buy your point.  :-)     The revised patch adopt this preference.

>> But in big-endian machine, this might be not needed. I will try a test
>> on ppc64.

I made some modification to my patch.  It now works on both x86  
(little endian) and ppc64 (big endian) platforms. All 125 tests pass  
on these two platforms. I didn't do any test on cross-debugging though.

Here are some explanation to my revised patch, wishing that it can  
clarfiy the situation somehow.

I am now still use  array of bytes (gdb_byte val[16]) to represent  
decimal float in gdb.  The reason is that we can't assume that the  
gdb-building compiler supports the decimal extension to C language  
standard. If we can, that will be much easier, we can just use that to  
represent decimal float in gdb.

The order of these bytes are now big-endian, i.e. the first byte is  
the most significant one.  But it is maken to be the same as the  
endianess of the target through routine exchange_dfp (in dfp.c). If  
the target is big-endian, no reversion is needed; if it is  
little-endian, reversion is needed. This is done through the checking  
of gdbarch_byte_order (current_gdbarch):

static void
exchange_dfp (const gdb_byte *valaddr, int len, gdb_byte *dec_val)
{
   int index;

   if (gdbarch_byte_order (current_gdbarch) == 1)
     for (index = 0; index < len; index++)
       dec_val[index] = valaddr[len - index - 1];
   else
     for (index = 0; index < len; index++)
       dec_val[index] = valaddr[index];

   return;
}

Maybe this can't support cross-debugging (I am not sure though).  But  
I am planning to take this into consideration.  I have one question  
first: which data structure  is used to describe the host's byte-order  
information? Anyone is kind to tell me?

Attached below is the revised patch. Please review and comment.  Thanks a lot!



[-- Attachment #2: dfp-0801.patch --]
[-- Type: text/x-patch, Size: 55695 bytes --]

Index: expression.h
===================================================================
RCS file: /cvs/src/src/gdb/expression.h,v
retrieving revision 1.18
diff -c -3 -p -r1.18 expression.h
*** expression.h	17 Dec 2005 22:33:59 -0000	1.18
--- expression.h	1 Aug 2006 09:13:23 -0000
***************
*** 1,7 ****
  /* Definitions for expressions stored in reversed prefix form, for GDB.
  
!    Copyright (C) 1986, 1989, 1992, 1994, 2000, 2003, 2005 Free Software
!    Foundation, Inc.
  
     This file is part of GDB.
  
--- 1,7 ----
  /* Definitions for expressions stored in reversed prefix form, for GDB.
  
!    Copyright (C) 1986, 1989, 1992, 1994, 2000, 2003, 2005, 2006
!    Free Software Foundation, Inc.
  
     This file is part of GDB.
  
*************** enum exp_opcode
*** 327,332 ****
--- 327,337 ----
      /* A F90 array range operator (for "exp:exp", "exp:", ":exp" and ":").  */
      OP_F90_RANGE,
  
+     /* OP_DECFLOAT is followed by a type pointer in the next exp_element
+        and a dec long constant value in the following exp_element.
+        Then comes another OP_DECFLOAT.  */
+     OP_DECFLOAT,
+ 
       /* First extension operator.  Individual language modules define
          extra operators they need as constants with values 
          OP_LANGUAGE_SPECIFIC0 + k, for k >= 0, using a separate 
*************** union exp_element
*** 354,359 ****
--- 359,365 ----
      struct symbol *symbol;
      LONGEST longconst;
      DOUBLEST doubleconst;
+     gdb_byte decfloatconst[16];
      /* Really sizeof (union exp_element) characters (or less for the last
         element of a string).  */
      char string;
Index: parser-defs.h
===================================================================
RCS file: /cvs/src/src/gdb/parser-defs.h,v
retrieving revision 1.20
diff -c -3 -p -r1.20 parser-defs.h
*** parser-defs.h	17 Dec 2005 22:34:01 -0000	1.20
--- parser-defs.h	1 Aug 2006 09:13:23 -0000
***************
*** 1,7 ****
  /* Parser definitions for GDB.
  
     Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
!    1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
  
     Modified from expread.y by the Department of Computer Science at the
     State University of New York at Buffalo.
--- 1,7 ----
  /* Parser definitions for GDB.
  
     Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
!    1997, 1998, 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
  
     Modified from expread.y by the Department of Computer Science at the
     State University of New York at Buffalo.
*************** extern void write_exp_elt_longcst (LONGE
*** 121,126 ****
--- 121,128 ----
  
  extern void write_exp_elt_dblcst (DOUBLEST);
  
+ extern void write_exp_elt_decfloatcst (gdb_byte *);
+ 
  extern void write_exp_elt_type (struct type *);
  
  extern void write_exp_elt_intern (struct internalvar *);
Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.53
diff -c -3 -p -r1.53 parse.c
*** parse.c	6 Jul 2006 14:00:48 -0000	1.53
--- parse.c	1 Aug 2006 09:13:24 -0000
***************
*** 1,7 ****
  /* Parse expressions for GDB.
  
     Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
!    1997, 1998, 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
  
     Modified from expread.y by the Department of Computer Science at the
     State University of New York at Buffalo, 1991.
--- 1,8 ----
  /* Parse expressions for GDB.
  
     Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
!    1997, 1998, 1999, 2000, 2001, 2004, 2005, 2006
!    Free Software Foundation, Inc.
  
     Modified from expread.y by the Department of Computer Science at the
     State University of New York at Buffalo, 1991.
*************** void
*** 191,197 ****
  write_exp_elt_opcode (enum exp_opcode expelt)
  {
    union exp_element tmp;
-   memset (&tmp, 0, sizeof (union exp_element));
  
    tmp.opcode = expelt;
  
--- 192,197 ----
*************** void
*** 202,208 ****
  write_exp_elt_sym (struct symbol *expelt)
  {
    union exp_element tmp;
-   memset (&tmp, 0, sizeof (union exp_element));
  
    tmp.symbol = expelt;
  
--- 202,207 ----
*************** void
*** 213,219 ****
  write_exp_elt_block (struct block *b)
  {
    union exp_element tmp;
-   memset (&tmp, 0, sizeof (union exp_element));
    tmp.block = b;
    write_exp_elt (tmp);
  }
--- 212,217 ----
*************** void
*** 222,228 ****
  write_exp_elt_longcst (LONGEST expelt)
  {
    union exp_element tmp;
-   memset (&tmp, 0, sizeof (union exp_element));
  
    tmp.longconst = expelt;
  
--- 220,225 ----
*************** void
*** 233,239 ****
  write_exp_elt_dblcst (DOUBLEST expelt)
  {
    union exp_element tmp;
-   memset (&tmp, 0, sizeof (union exp_element));
  
    tmp.doubleconst = expelt;
  
--- 230,235 ----
*************** write_exp_elt_dblcst (DOUBLEST expelt)
*** 241,250 ****
  }
  
  void
  write_exp_elt_type (struct type *expelt)
  {
    union exp_element tmp;
-   memset (&tmp, 0, sizeof (union exp_element));
  
    tmp.type = expelt;
  
--- 237,257 ----
  }
  
  void
+ write_exp_elt_decfloatcst (gdb_byte expelt[16])
+ {
+   union exp_element tmp;
+   int index;
+ 
+   for (index = 0; index < 16; index++)
+     tmp.decfloatconst[index] = expelt[index];
+ 
+   write_exp_elt (tmp);
+ }
+ 
+ void
  write_exp_elt_type (struct type *expelt)
  {
    union exp_element tmp;
  
    tmp.type = expelt;
  
*************** void
*** 255,261 ****
  write_exp_elt_intern (struct internalvar *expelt)
  {
    union exp_element tmp;
-   memset (&tmp, 0, sizeof (union exp_element));
  
    tmp.internalvar = expelt;
  
--- 262,267 ----
*************** operator_length_standard (struct express
*** 864,869 ****
--- 870,876 ----
  
      case OP_LONG:
      case OP_DOUBLE:
+     case OP_DECFLOAT:
      case OP_VAR_VALUE:
        oplen = 4;
        break;
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.34
diff -c -3 -p -r1.34 c-exp.y
*** c-exp.y	23 Feb 2006 18:43:41 -0000	1.34
--- c-exp.y	1 Aug 2006 09:13:24 -0000
*************** Boston, MA 02110-1301, USA.  */
*** 53,58 ****
--- 53,59 ----
  #include "charset.h"
  #include "block.h"
  #include "cp-support.h"
+ #include "dfp.h"
  
  /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
     as well as gratuitiously global symbol names, so we can have multiple
*************** void yyerror (char *);
*** 131,136 ****
--- 132,141 ----
        DOUBLEST dval;
        struct type *type;
      } typed_val_float;
+     struct {
+       gdb_byte val[16];
+       struct type *type;
+     } typed_val_decfloat;
      struct symbol *sym;
      struct type *tval;
      struct stoken sval;
*************** static int parse_number (char *, int, in
*** 163,168 ****
--- 168,174 ----
  
  %token <typed_val_int> INT
  %token <typed_val_float> FLOAT
+ %token <typed_val_decfloat> DECFLOAT
  
  /* Both NAME and TYPENAME tokens represent symbols in the input,
     and both convey their data as strings.
*************** exp	:	FLOAT
*** 497,502 ****
--- 503,515 ----
  			  write_exp_elt_opcode (OP_DOUBLE); }
  	;
  
+ exp	:	DECFLOAT
+ 			{ write_exp_elt_opcode (OP_DECFLOAT);
+ 			  write_exp_elt_type ($1.type);
+ 			  write_exp_elt_decfloatcst ($1.val);
+ 			  write_exp_elt_opcode (OP_DECFLOAT); }
+ 	;
+ 
  exp	:	variable
  	;
  
*************** parse_number (p, len, parsed_float, puti
*** 1080,1085 ****
--- 1093,1132 ----
        char saved_char = p[len];
  
        p[len] = 0;	/* null-terminate the token */
+ 
+       /* If it ends at "df", "dd" or "dl", take it as type of decimal floating
+          point.  Return DECFLOAT.  */
+ 
+       if (p[len - 2] == 'd' && p[len - 1] == 'f')
+ 	{
+ 	  p[len - 2] = '\0';
+ 	  putithere->typed_val_decfloat.type = 
+ 	    builtin_type (current_gdbarch)->builtin_decfloat;
+ 	  decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
+ 	  p[len] = saved_char;
+ 	  return (DECFLOAT);
+ 	}
+ 
+       if (p[len - 2] == 'd' && p[len - 1] == 'd')
+ 	{
+ 	  p[len - 2] = '\0';
+ 	  putithere->typed_val_decfloat.type = 
+ 	    builtin_type (current_gdbarch)->builtin_decdouble;
+ 	  decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
+ 	  p[len] = saved_char;
+ 	  return (DECFLOAT);
+ 	}
+ 
+       if (p[len - 2] == 'd' && p[len - 1] == 'l')
+ 	{
+ 	  p[len - 2] = '\0';
+ 	  putithere->typed_val_decfloat.type = 
+ 	    builtin_type (current_gdbarch)->builtin_declong;
+ 	  decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
+ 	  p[len] = saved_char;
+ 	  return (DECFLOAT);
+ 	}
+ 
        num = sscanf (p, DOUBLEST_SCAN_FORMAT "%s",
  		    &putithere->typed_val_float.dval, s);
        p[len] = saved_char;	/* restore the input stream */
Index: c-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/c-lang.c,v
retrieving revision 1.39
diff -c -3 -p -r1.39 c-lang.c
*** c-lang.c	17 Dec 2005 22:33:59 -0000	1.39
--- c-lang.c	1 Aug 2006 09:13:24 -0000
***************
*** 1,7 ****
  /* C language support routines for GDB, the GNU debugger.
  
     Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002,
!    2003, 2004, 2005 Free Software Foundation, Inc.
  
     This file is part of GDB.
  
--- 1,7 ----
  /* C language support routines for GDB, the GNU debugger.
  
     Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002,
!    2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  
     This file is part of GDB.
  
*************** c_create_fundamental_type (struct objfil
*** 322,327 ****
--- 322,342 ----
  			TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
  			0, "long double", objfile);
        break;
+     case FT_DECFLOAT:
+       type = init_type (TYPE_CODE_DECFLOAT,
+ 			32 / 8,
+ 			0, "decimal float", objfile);
+       break;
+     case FT_DBL_PREC_DECFLOAT:
+       type = init_type (TYPE_CODE_DECFLOAT,
+ 			64 / 8,
+ 			0, "decimal double", objfile);
+       break;
+     case FT_EXT_PREC_DECFLOAT:
+       type = init_type (TYPE_CODE_DECFLOAT,
+ 			128 / 8,
+ 			0, "decimal long double", objfile);
+       break;
      case FT_COMPLEX:
        type = init_type (TYPE_CODE_FLT,
  			2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
Index: c-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-valprint.c,v
retrieving revision 1.39
diff -c -3 -p -r1.39 c-valprint.c
*** c-valprint.c	18 Jan 2006 21:24:19 -0000	1.39
--- c-valprint.c	1 Aug 2006 09:13:24 -0000
*************** c_val_print (struct type *type, const gd
*** 433,445 ****
  
      case TYPE_CODE_FLT:
        if (format)
! 	{
! 	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
! 	}
        else
! 	{
! 	  print_floating (valaddr + embedded_offset, type, stream);
! 	}
        break;
  
      case TYPE_CODE_METHOD:
--- 433,448 ----
  
      case TYPE_CODE_FLT:
        if (format)
! 	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
        else
! 	print_floating (valaddr + embedded_offset, type, stream);
!       break;
! 
!     case TYPE_CODE_DECFLOAT:
!       if (format)
! 	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
!       else
! 	print_decimal_floating (valaddr + embedded_offset, type, stream);
        break;
  
      case TYPE_CODE_METHOD:
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.201
diff -c -3 -p -r1.201 dwarf2read.c
*** dwarf2read.c	24 Jul 2006 21:37:04 -0000	1.201
--- dwarf2read.c	1 Aug 2006 09:13:24 -0000
*************** struct dwarf2_per_objfile
*** 180,189 ****
    /* A chain of compilation units that are currently read in, so that
       they can be freed later.  */
    struct dwarf2_per_cu_data *read_in_chain;
- 
-   /* A flag indicating wether this objfile has a section loaded at a
-      VMA of 0.  */
-   int has_section_at_zero;
  };
  
  static struct dwarf2_per_objfile *dwarf2_per_objfile;
--- 180,185 ----
*************** dwarf2_has_info (struct objfile *objfile
*** 1113,1119 ****
     in.  */
  
  static void
! dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr)
  {
    if (strcmp (sectp->name, INFO_SECTION) == 0)
      {
--- 1109,1115 ----
     in.  */
  
  static void
! dwarf2_locate_sections (bfd *ignore_abfd, asection *sectp, void *ignore_ptr)
  {
    if (strcmp (sectp->name, INFO_SECTION) == 0)
      {
*************** dwarf2_locate_sections (bfd *abfd, asect
*** 1174,1183 ****
        dwarf2_per_objfile->ranges_size = bfd_get_section_size (sectp);
        dwarf_ranges_section = sectp;
      }
-   
-   if ((bfd_get_section_flags (abfd, sectp) & SEC_LOAD)
-       && bfd_section_vma (abfd, sectp) == 0)
-     dwarf2_per_objfile->has_section_at_zero = 1;
  }
  
  /* Build a partial symbol table.  */
--- 1170,1175 ----
*************** dwarf2_get_pc_bounds (struct die_info *d
*** 3185,3191 ****
       labels are not in the output, so the relocs get a value of 0.
       If this is a discarded function, mark the pc bounds as invalid,
       so that GDB will ignore it.  */
!   if (low == 0 && !dwarf2_per_objfile->has_section_at_zero)
      return 0;
  
    *lowpc = low;
--- 3177,3183 ----
       labels are not in the output, so the relocs get a value of 0.
       If this is a discarded function, mark the pc bounds as invalid,
       so that GDB will ignore it.  */
!   if (low == 0 && (bfd_get_file_flags (obfd) & HAS_RELOC) == 0)
      return 0;
  
    *lowpc = low;
*************** read_base_type (struct die_info *die, st
*** 4747,4752 ****
--- 4739,4747 ----
  	case DW_ATE_complex_float:
  	  code = TYPE_CODE_COMPLEX;
  	  break;
+ 	case DW_ATE_decimal_float:
+ 	  code = TYPE_CODE_DECFLOAT;
+ 	  break;
  	case DW_ATE_float:
  	  code = TYPE_CODE_FLT;
  	  break;
*************** read_subrange_type (struct die_info *die
*** 4867,4889 ****
    set_die_type (die, range_type, cu);
  }
    
- static void
- read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu)
- {
-   struct type *type;
-   struct attribute *attr;
- 
-   if (die->type)
-     return;
- 
-   /* For now, we only support the C meaning of an unspecified type: void.  */
- 
-   attr = dwarf2_attr (die, DW_AT_name, cu);
-   type = init_type (TYPE_CODE_VOID, 0, 0, attr ? DW_STRING (attr) : "",
- 		    cu->objfile);
- 
-   set_die_type (die, type, cu);
- }
  
  /* Read a whole compilation unit into a linked list of dies.  */
  
--- 4862,4867 ----
*************** read_partial_die (struct partial_die_inf
*** 5513,5519 ****
    if (has_low_pc_attr && has_high_pc_attr
        && part_die->lowpc < part_die->highpc
        && (part_die->lowpc != 0
! 	  || dwarf2_per_objfile->has_section_at_zero))
      part_die->has_pc_info = 1;
    return info_ptr;
  }
--- 5491,5497 ----
    if (has_low_pc_attr && has_high_pc_attr
        && part_die->lowpc < part_die->highpc
        && (part_die->lowpc != 0
! 	  || (bfd_get_file_flags (abfd) & HAS_RELOC)))
      part_die->has_pc_info = 1;
    return info_ptr;
  }
*************** read_type_die (struct die_info *die, str
*** 7370,7378 ****
      case DW_TAG_base_type:
        read_base_type (die, cu);
        break;
-     case DW_TAG_unspecified_type:
-       read_unspecified_type (die, cu);
-       break;
      default:
        complaint (&symfile_complaints, _("unexpected tag in read_type_die: '%s'"),
  		 dwarf_tag_name (die->tag));
--- 7348,7353 ----
*************** dwarf_base_type (int encoding, int size,
*** 7517,7539 ****
        return type;
      case DW_ATE_complex_float:
        if (size == 16)
! 	{
! 	  type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_COMPLEX, cu);
! 	}
        else
! 	{
! 	  type = dwarf2_fundamental_type (objfile, FT_COMPLEX, cu);
! 	}
        return type;
      case DW_ATE_float:
        if (size == 8)
! 	{
! 	  type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_FLOAT, cu);
! 	}
        else
! 	{
! 	  type = dwarf2_fundamental_type (objfile, FT_FLOAT, cu);
! 	}
        return type;
      case DW_ATE_signed:
        switch (size)
--- 7492,7514 ----
        return type;
      case DW_ATE_complex_float:
        if (size == 16)
! 	type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_COMPLEX, cu);
        else
! 	type = dwarf2_fundamental_type (objfile, FT_COMPLEX, cu);
        return type;
      case DW_ATE_float:
        if (size == 8)
! 	type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_FLOAT, cu);
        else
! 	type = dwarf2_fundamental_type (objfile, FT_FLOAT, cu);
!       return type;
!     case DW_ATE_decimal_float:
!       if (size == 16)
! 	type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_DECFLOAT, cu);
!       else if (size == 8)
! 	type = dwarf2_fundamental_type (objfile, FT_EXT_PREC_DECFLOAT, cu);
!       else
! 	type = dwarf2_fundamental_type (objfile, FT_DECFLOAT, cu);
        return type;
      case DW_ATE_signed:
        switch (size)
*************** static void
*** 9332,9342 ****
  dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
  			     struct dwarf2_cu *cu)
  {
!   if ((attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8)
!       /* ".debug_loc" may not exist at all, or the offset may be outside
! 	 the section.  If so, fall through to the complaint in the
! 	 other branch.  */
!       && DW_UNSND (attr) < dwarf2_per_objfile->loc_size)
      {
        struct dwarf2_loclist_baton *baton;
  
--- 9307,9313 ----
  dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
  			     struct dwarf2_cu *cu)
  {
!   if (attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8)
      {
        struct dwarf2_loclist_baton *baton;
  
Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.63
diff -c -3 -p -r1.63 eval.c
*** eval.c	25 Jul 2006 04:24:50 -0000	1.63
--- eval.c	1 Aug 2006 09:13:24 -0000
***************
*** 1,8 ****
  /* Evaluate expressions for GDB.
  
     Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
!    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005 Free
!    Software Foundation, Inc.
  
     This file is part of GDB.
  
--- 1,8 ----
  /* Evaluate expressions for GDB.
  
     Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
!    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006
!    Free Software Foundation, Inc.
  
     This file is part of GDB.
  
*************** evaluate_struct_tuple (struct value *str
*** 283,292 ****
  	      if (variantno < 0)
  		{
  		  fieldno++;
- 		  /* Skip static fields.  */
- 		  while (fieldno < TYPE_NFIELDS (struct_type)
- 			 && TYPE_FIELD_STATIC_KIND (struct_type, fieldno))
- 		    fieldno++;
  		  subfieldno = fieldno;
  		  if (fieldno >= TYPE_NFIELDS (struct_type))
  		    error (_("too many initializers"));
--- 283,288 ----
*************** evaluate_subexp_standard (struct type *e
*** 451,456 ****
--- 447,457 ----
        return value_from_double (exp->elts[pc + 1].type,
  				exp->elts[pc + 2].doubleconst);
  
+     case OP_DECFLOAT:
+       (*pos) += 3;
+       return value_from_decfloat (expect_type, exp->elts[pc + 1].type,
+ 				exp->elts[pc + 2].decfloatconst);
+ 
      case OP_VAR_VALUE:
        (*pos) += 3;
        if (noside == EVAL_SKIP)
*************** evaluate_subexp_for_address (struct expr
*** 2132,2138 ****
    enum exp_opcode op;
    int pc;
    struct symbol *var;
-   struct value *x;
  
    pc = (*pos);
    op = exp->elts[pc].opcode;
--- 2133,2138 ----
*************** evaluate_subexp_for_address (struct expr
*** 2141,2164 ****
      {
      case UNOP_IND:
        (*pos)++;
!       x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
! 
!       /* We can't optimize out "&*" if there's a user-defined operator*.  */
!       if (unop_user_defined_p (op, x))
! 	{
! 	  x = value_x_unop (x, op, noside);
! 	  if (noside == EVAL_AVOID_SIDE_EFFECTS)
! 	    {
! 	      if (VALUE_LVAL (x) == lval_memory)
! 		return value_zero (lookup_pointer_type (value_type (x)),
! 				   not_lval);
! 	      else
! 		error (_("Attempt to take address of non-lval"));
! 	    }
! 	  return value_addr (x);
! 	}
! 
!       return x;
  
      case UNOP_MEMVAL:
        (*pos) += 3;
--- 2141,2147 ----
      {
      case UNOP_IND:
        (*pos)++;
!       return evaluate_subexp (NULL_TYPE, exp, pos, noside);
  
      case UNOP_MEMVAL:
        (*pos) += 3;
*************** evaluate_subexp_for_address (struct expr
*** 2197,2212 ****
  
      default:
      default_case:
-       x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
        if (noside == EVAL_AVOID_SIDE_EFFECTS)
  	{
  	  if (VALUE_LVAL (x) == lval_memory)
  	    return value_zero (lookup_pointer_type (value_type (x)),
  			       not_lval);
  	  else
  	    error (_("Attempt to take address of non-lval"));
  	}
!       return value_addr (x);
      }
  }
  
--- 2180,2195 ----
  
      default:
      default_case:
        if (noside == EVAL_AVOID_SIDE_EFFECTS)
  	{
+ 	  struct value *x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
  	  if (VALUE_LVAL (x) == lval_memory)
  	    return value_zero (lookup_pointer_type (value_type (x)),
  			       not_lval);
  	  else
  	    error (_("Attempt to take address of non-lval"));
  	}
!       return value_addr (evaluate_subexp (NULL_TYPE, exp, pos, noside));
      }
  }
  
Index: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.65
diff -c -3 -p -r1.65 gdbtypes.h
*** gdbtypes.h	1 Feb 2006 23:14:10 -0000	1.65
--- gdbtypes.h	1 Aug 2006 09:13:25 -0000
*************** struct block;
*** 67,73 ****
  #define FT_UNSIGNED_BYTE	27
  #define FT_TEMPLATE_ARG		28
  
! #define FT_NUM_MEMBERS		29	/* Highest FT_* above, plus one. */
  
  /* Some macros for char-based bitfields.  */
  
--- 67,78 ----
  #define FT_UNSIGNED_BYTE	27
  #define FT_TEMPLATE_ARG		28
  
! /* The following three fundamental types are for decimal floating point.  */
! #define FT_DECFLOAT		29	
! #define FT_DBL_PREC_DECFLOAT	30
! #define FT_EXT_PREC_DECFLOAT	31	
! 
! #define FT_NUM_MEMBERS		32	/* Highest FT_* above, plus one. */
  
  /* Some macros for char-based bitfields.  */
  
*************** enum type_code
*** 159,165 ****
      TYPE_CODE_TEMPLATE,		/* C++ template */
      TYPE_CODE_TEMPLATE_ARG,	/* C++ template arg */
  
!     TYPE_CODE_NAMESPACE		/* C++ namespace.  */
    };
  
  /* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
--- 164,172 ----
      TYPE_CODE_TEMPLATE,		/* C++ template */
      TYPE_CODE_TEMPLATE_ARG,	/* C++ template arg */
  
!     TYPE_CODE_NAMESPACE,	/* C++ namespace.  */
! 
!     TYPE_CODE_DECFLOAT		/* Decimal floating point.  */
    };
  
  /* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
*************** struct builtin_type
*** 1005,1010 ****
--- 1012,1020 ----
    struct type *builtin_bool;
    struct type *builtin_long_long;
    struct type *builtin_unsigned_long_long;
+   struct type *builtin_decfloat;
+   struct type *builtin_decdouble;
+   struct type *builtin_declong;
  };
  
  /* Return the type table for the specified architecture.  */
*************** extern struct type *builtin_type_complex
*** 1028,1033 ****
--- 1038,1046 ----
  extern struct type *builtin_type_double_complex;
  extern struct type *builtin_type_string;
  extern struct type *builtin_type_bool;
+ extern struct type *builtin_type_decfloat;
+ extern struct type *builtin_type_decdouble;
+ extern struct type *builtin_type_declong;
  
  /* Address/pointer types: */
  /* (C) Language `pointer to data' type.  Some target platforms use an
Index: gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.105
diff -c -3 -p -r1.105 gdbtypes.c
*** gdbtypes.c	1 Mar 2006 19:34:46 -0000	1.105
--- gdbtypes.c	1 Aug 2006 09:13:25 -0000
*************** struct type *builtin_type_int128;
*** 76,81 ****
--- 76,87 ----
  struct type *builtin_type_uint128;
  struct type *builtin_type_bool;
  
+ /* The following three are about decimal floating point types, which are now 
+    considered as potential extension to C99 standard.  */ 
+ struct type *builtin_type_decfloat;
+ struct type *builtin_type_decdouble;
+ struct type *builtin_type_declong;
+ 
  /* 128 bit long vector types */
  struct type *builtin_type_v2_double;
  struct type *builtin_type_v4_float;
*************** build_gdbtypes (void)
*** 3379,3384 ****
--- 3385,3405 ----
  #if 0
    TYPE_FLOATFORMAT (builtin_type_long_double) = TARGET_LONG_DOUBLE_FORMAT;
  #endif
+ 
+   /* Builtin types for decimal floating point types.  */
+   builtin_type_decfloat =
+     init_type (TYPE_CODE_DECFLOAT, 32 / 8,
+ 	       0,
+ 	       "decimal float", (struct objfile *) NULL);
+   builtin_type_decdouble =
+     init_type (TYPE_CODE_DECFLOAT, 64 / 8,
+                0,
+                "decimal double", (struct objfile *) NULL);
+   builtin_type_declong =
+     init_type (TYPE_CODE_DECFLOAT, 128 / 8,
+ 	       0,
+ 	       "decimal long double", (struct objfile *) NULL);
+ 
    builtin_type_complex =
      init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
  	       0,
*************** gdbtypes_post_init (struct gdbarch *gdba
*** 3604,3609 ****
--- 3625,3645 ----
  	       0,
  	       "bool", (struct objfile *) NULL);
  
+   /* The following three are about decimal floating point types, which are 
+      32-bits, 64-bits and 128-bits respectively.  */
+   builtin_type->builtin_decfloat = 
+    init_type (TYPE_CODE_DECFLOAT, 32 / 8,
+                0,
+                "decimal float", (struct objfile *) NULL);
+   builtin_type->builtin_decdouble =
+     init_type (TYPE_CODE_DECFLOAT, 64 / 8,
+                0,
+                "decimal double", (struct objfile *) NULL);
+   builtin_type->builtin_declong =
+     init_type (TYPE_CODE_DECFLOAT, 128 / 8,
+                0,
+                "decimal long double", (struct objfile *) NULL);
+ 
    /* Pointer/Address types. */
  
    /* NOTE: on some targets, addresses and pointers are not necessarily
*************** _initialize_gdbtypes (void)
*** 3742,3747 ****
--- 3778,3786 ----
    DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr);
    DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR);
    DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma);
+   DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_decfloat);
+   DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_decdouble);
+   DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_declong);
    deprecated_register_gdbarch_swap (NULL, 0, build_gdbtypes);
  
    /* Note: These types do not need to be swapped - they are target
Index: value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.92
diff -c -3 -p -r1.92 value.h
*** value.h	13 Jul 2006 04:31:42 -0000	1.92
--- value.h	1 Aug 2006 09:13:25 -0000
***************
*** 1,7 ****
  /* Definitions for values of C expressions, for GDB.
  
     Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
!    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
     Free Software Foundation, Inc.
  
     This file is part of GDB.
--- 1,7 ----
  /* Definitions for values of C expressions, for GDB.
  
     Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
!    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
     Free Software Foundation, Inc.
  
     This file is part of GDB.
*************** extern LONGEST unpack_field_as_long (str
*** 274,279 ****
--- 274,282 ----
  extern struct value *value_from_longest (struct type *type, LONGEST num);
  extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
  extern struct value *value_from_double (struct type *type, DOUBLEST num);
+ extern struct value *value_from_decfloat (struct type *expect_type, 
+ 					   struct type *type,
+ 					   gdb_byte decbytes[16]);
  extern struct value *value_from_string (char *string);
  
  extern struct value *value_at (struct type *type, CORE_ADDR addr);
*************** extern struct value *value_ind (struct v
*** 325,332 ****
  
  extern struct value *value_addr (struct value *arg1);
  
- extern struct value *value_ref (struct value *arg1);
- 
  extern struct value *value_assign (struct value *toval,
  				   struct value *fromval);
  
--- 328,333 ----
*************** extern struct type *value_rtti_target_ty
*** 369,376 ****
  extern struct value *value_full_object (struct value *, struct type *, int,
  					int, int);
  
- extern struct value *value_cast_pointers (struct type *, struct value *);
- 
  extern struct value *value_cast (struct type *type, struct value *arg2);
  
  extern struct value *value_zero (struct type *type, enum lval_type lv);
--- 370,375 ----
*************** extern void print_longest (struct ui_fil
*** 473,478 ****
--- 472,480 ----
  extern void print_floating (const gdb_byte *valaddr, struct type *type,
  			    struct ui_file *stream);
  
+ extern void print_decimal_floating (const gdb_byte *valaddr, struct type *type,
+ 				    struct ui_file *stream);
+ 
  extern int value_print (struct value *val, struct ui_file *stream, int format,
  			enum val_prettyprint pretty);
  
Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.36
diff -c -3 -p -r1.36 value.c
*** value.c	31 Mar 2006 10:36:18 -0000	1.36
--- value.c	1 Aug 2006 09:13:25 -0000
***************
*** 37,42 ****
--- 37,43 ----
  #include "gdb_assert.h"
  #include "regcache.h"
  #include "block.h"
+ #include "dfp.h"
  
  /* Prototypes for exported functions. */
  
*************** value_from_double (struct type *type, DO
*** 1610,1615 ****
--- 1611,1637 ----
  }
  
  struct value *
+ value_from_decfloat (struct type *expect_type, struct type *type, 
+ 		      gdb_byte decbytes[16])
+ {
+   struct value *val = allocate_value (type);
+   int len = TYPE_LENGTH (type);
+ 
+   if (expect_type)
+     {
+       int expect_len = TYPE_LENGTH (expect_type);
+       char decstr[128];
+       int real_len;
+ 
+       decimal_to_string (decbytes, len, decstr);
+       decimal_from_string (decbytes, expect_len, decstr);
+     }
+ 
+   memcpy (value_contents_raw (val), decbytes, len);
+   return val;
+ }
+ 
+ struct value *
  coerce_ref (struct value *arg)
  {
    struct type *value_type_arg_tmp = check_typedef (value_type (arg));
Index: valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/valprint.c,v
retrieving revision 1.60
diff -c -3 -p -r1.60 valprint.c
*** valprint.c	15 May 2006 16:53:38 -0000	1.60
--- valprint.c	1 Aug 2006 09:13:25 -0000
***************
*** 35,40 ****
--- 35,41 ----
  #include "floatformat.h"
  #include "doublest.h"
  #include "exceptions.h"
+ #include "dfp.h"
  
  #include <errno.h>
  
*************** print_floating (const gdb_byte *valaddr,
*** 496,501 ****
--- 497,514 ----
  }
  
  void
+ print_decimal_floating (const gdb_byte *valaddr, struct type *type,
+ 			struct ui_file *stream)
+ {
+   char decstr[128];
+   unsigned len = TYPE_LENGTH (type);
+ 
+   decimal_to_string (valaddr, len, decstr);
+   fputs_filtered (decstr, stream);
+   return;
+ }
+ 
+ void
  print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
  		    unsigned len)
  {
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.45
diff -c -3 -p -r1.45 valarith.c
*** valarith.c	24 Jan 2006 21:21:12 -0000	1.45
--- valarith.c	1 Aug 2006 09:13:25 -0000
***************
*** 1,7 ****
  /* Perform arithmetic and other operations on values, for GDB.
  
     Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
!    1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
     Free Software Foundation, Inc.
  
     This file is part of GDB.
--- 1,7 ----
  /* Perform arithmetic and other operations on values, for GDB.
  
     Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
!    1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
     Free Software Foundation, Inc.
  
     This file is part of GDB.
*************** value_neg (struct value *arg1)
*** 1378,1383 ****
--- 1378,1397 ----
  
    type = check_typedef (value_type (arg1));
  
+   if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT)
+     {
+       struct value *val = allocate_value (result_type);
+       int len = TYPE_LENGTH (type);
+       gdb_byte *decbytes = (gdb_byte *) value_contents (arg1);
+ 
+       if (gdbarch_byte_order (current_gdbarch))
+ 	decbytes[len-1] = decbytes[len - 1] | 0x80;
+       else
+ 	decbytes[0] = decbytes[0] | 0x80;
+       memcpy (value_contents_raw (val), decbytes, 16);
+       return val;
+     }
+ 
    if (TYPE_CODE (type) == TYPE_CODE_FLT)
      return value_from_double (result_type, -value_as_double (arg1));
    else if (is_integral_type (type))
Index: dfp.h
===================================================================
RCS file: dfp.h
diff -N dfp.h
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- dfp.h	1 Aug 2006 09:13:25 -0000
***************
*** 0 ****
--- 1,40 ----
+ /* Decimal floating point support for GDB.
+ 
+    Copyright 2006 Free Software Foundation, Inc.
+ 
+    This file is part of GDB.
+ 
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330,
+    Boston, MA 02111-1307, USA.  */
+ 
+ /* Decimal floating point is one of the extension to IEEE 754, which is
+    described in http://grouper.ieee.org/groups/754/revision.html and
+    http://www2.hursley.ibm.com/decimal/.  It completes binary floating
+    point by representing floating point more exactly.  */
+ 
+ /* There is a project intended to add DFP support into GCC, described in
+    http://gcc.gnu.org/wiki/Decimal%20Floating-Point.  This file is intended
+    to add DFP support into GDB.  */
+ 
+ #ifndef DFP_H
+ #define DFP_H
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdint.h>
+ 
+ extern void decimal_to_string (const uint8_t *, int, char *);
+ extern int decimal_from_string (uint8_t *, int, char *);
+ 
+ #endif
Index: dfp.c
===================================================================
RCS file: dfp.c
diff -N dfp.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- dfp.c	1 Aug 2006 09:13:25 -0000
***************
*** 0 ****
--- 1,122 ----
+ /* Decimal floating point support for GDB.
+ 
+    Copyright 2006 Free Software Foundation, Inc.
+ 
+    This file is part of GDB.
+ 
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330,
+    Boston, MA 02111-1307, USA.  */
+ 
+ #include "defs.h"
+ #include "dfp.h"
+ #include <ctype.h>
+ 
+ /* The order of the following headers is important for making sure
+    decNumber structure is large enough to hold decimal128 digits.  */
+ 
+ #include "decimal128.h"
+ #include "decimal64.h"
+ #include "decimal32.h"
+ #include "decNumber.h"
+ 
+ /* In gdb, we are using an array of gdb_byte to represent decimal values. The
+    byte order of our representation might be different than that of underlying
+    architecture.  This routine does the conversion if it is necessary.  */
+ static void
+ exchange_dfp (const gdb_byte *valaddr, int len, gdb_byte *dec_val)
+ {
+   int index;
+ 
+   if (gdbarch_byte_order (current_gdbarch) == 1)
+     for (index = 0; index < len; index++)
+       dec_val[index] = valaddr[len - index - 1];
+   else
+     for (index = 0; index < len; index++)
+       dec_val[index] = valaddr[index];
+ 
+   return;
+ }
+ 
+ /* Convert deciaml type to its string representation.  LEN is the length
+    of the decimal type, 4 bytes for decimal32, 8 bytes for decimal64 and
+    16 bytes for decimal128.  */
+ void
+ decimal_to_string (const uint8_t *decbytes, int len, char *s)
+ {
+   uint8_t *dec = (uint8_t *)malloc (len);
+ 
+   exchange_dfp (decbytes, len, dec);
+   switch (len)
+     {
+       case 4:
+         decimal32ToString ((decimal32 *) dec, s);
+         return;
+       case 8:
+         decimal64ToString ((decimal64 *) dec, s);
+         return;
+       case 16:
+         decimal128ToString ((decimal128 *) dec, s);
+         return;
+       default:
+ 	return;
+     }
+ 
+   free (dec);
+ }
+ 
+ /* Convert the string form of a decimal value to its decimal representation.
+    LEN is the length of the decimal type, 4 bytes for decimal32, 8 bytes for
+    decimal64 and 16 bytes for decimal128.  */
+ int
+ decimal_from_string (uint8_t *decbytes, int len, char *string)
+ {
+   decNumber dn;
+   decContext set;
+   int index;
+   uint8_t *dec = (uint8_t *)malloc (len);
+ 
+   switch (len)
+     {
+       case 4:
+ 	decContextDefault (&set, DEC_INIT_DECIMAL32);
+ 	break;
+       case 8:
+ 	decContextDefault (&set, DEC_INIT_DECIMAL64);
+ 	break;
+       case 16:
+ 	decContextDefault (&set, DEC_INIT_DECIMAL128);
+ 	break;
+     }
+ 
+   set.traps = 0;
+ 
+   decNumberFromString (&dn, string, &set);
+   switch (len)
+     {
+       case 4:
+ 	decimal32FromNumber ((decimal32 *) dec, &dn, &set);
+ 	break;
+       case 8:
+ 	decimal64FromNumber ((decimal64 *) dec, &dn, &set);
+ 	break;
+       case 16:
+ 	decimal128FromNumber ((decimal128 *) dec, &dn, &set);
+ 	break;
+     }
+ 
+   exchange_dfp (dec, len, decbytes);
+   free (dec);
+   return 1;
+ }
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.834
diff -c -3 -p -r1.834 Makefile.in
*** Makefile.in	31 Jul 2006 20:15:50 -0000	1.834
--- Makefile.in	1 Aug 2006 09:13:25 -0000
*************** BFD = $(BFD_DIR)/libbfd.a
*** 122,127 ****
--- 122,133 ----
  BFD_SRC = $(srcdir)/$(BFD_DIR)
  BFD_CFLAGS = -I$(BFD_DIR) -I$(BFD_SRC)
  
+ # Where is the decnumber library?  Typically in ../libdecnumber.
+ LIBDECNUMBER_DIR = ../libdecnumber
+ LIBDECNUMBER = $(LIBDECNUMBER_DIR)/libdecnumber.a
+ LIBDECNUMBER_SRC = $(srcdir)/$(LIBDECNUMBER_DIR)
+ LIBDECNUMBER_CFLAGS = -I$(LIBDECNUMBER_DIR) -I$(LIBDECNUMBER_SRC)
+ 
  # Where is the READLINE library?  Typically in ../readline.
  READLINE_DIR = ../readline
  READLINE = $(READLINE_DIR)/libreadline.a
*************** CXXFLAGS = -g -O
*** 348,354 ****
  INTERNAL_CFLAGS_BASE = \
  	$(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
  	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
! 	$(BFD_CFLAGS) $(INCLUDE_CFLAGS) \
  	$(INTL_CFLAGS) $(ENABLE_CFLAGS)
  INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS)
  INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS)
--- 354,360 ----
  INTERNAL_CFLAGS_BASE = \
  	$(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
  	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
! 	$(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \
  	$(INTL_CFLAGS) $(ENABLE_CFLAGS)
  INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS)
  INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS)
*************** INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CF
*** 371,380 ****
  # LIBIBERTY appears twice on purpose.
  # If you have the Cygnus libraries installed,
  # you can use 'CLIBS=$(INSTALLED_LIBS)' 'CDEPS='
! INSTALLED_LIBS=-lbfd -lreadline -lopcodes -liberty \
  	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
  	-lintl -liberty
! CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY) \
  	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
  	$(LIBICONV) \
  	$(LIBIBERTY) $(WIN32LIBS)
--- 377,386 ----
  # LIBIBERTY appears twice on purpose.
  # If you have the Cygnus libraries installed,
  # you can use 'CLIBS=$(INSTALLED_LIBS)' 'CDEPS='
! INSTALLED_LIBS=-lbfd -lreadline -lopcodes -liberty -ldecnumber \
  	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
  	-lintl -liberty
! CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
  	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
  	$(LIBICONV) \
  	$(LIBIBERTY) $(WIN32LIBS)
*************** SFILES = ada-exp.y ada-lang.c ada-typepr
*** 532,537 ****
--- 538,544 ----
  	infcmd.c inflow.c infrun.c \
  	interps.c \
  	jv-exp.y jv-lang.c jv-valprint.c jv-typeprint.c \
+ 	kod.c kod-cisco.c \
  	language.c linespec.c \
  	m2-exp.y m2-lang.c m2-typeprint.c m2-valprint.c \
  	macrotab.c macroexp.c macrocmd.c macroscope.c main.c maint.c \
*************** splay_tree_h =  $(INCLUDE_DIR)/splay-tre
*** 604,609 ****
--- 611,620 ----
  safe_ctype_h =  $(INCLUDE_DIR)/safe-ctype.h
  hashtab_h =	$(INCLUDE_DIR)/hashtab.h
  
+ decimal128_h = $(LIBDECNUMBER_DIR)/decimal128.h
+ decimal64_h = $(LIBDECNUMBER_DIR)/decimal64.h
+ decimal32_h = $(LIBDECNUMBER_DIR)/decimal32.h
+ 
  #
  # $BUILD/ headers
  #
*************** amd64_nat_h = amd64-nat.h
*** 639,645 ****
  amd64_tdep_h = amd64-tdep.h $(i386_tdep_h)
  annotate_h = annotate.h $(symtab_h) $(gdbtypes_h)
  arch_utils_h = arch-utils.h
- arm_linux_tdep_h = arm-linux-tdep.h
  arm_tdep_h = arm-tdep.h
  auxv_h = auxv.h
  ax_gdb_h = ax-gdb.h
--- 650,655 ----
*************** dictionary_h = dictionary.h
*** 670,675 ****
--- 680,686 ----
  disasm_h = disasm.h
  doublest_h = doublest.h $(floatformat_h)
  dummy_frame_h = dummy-frame.h
+ dfp_h = dfp.h
  dwarf2expr_h = dwarf2expr.h
  dwarf2_frame_h = dwarf2-frame.h
  dwarf2loc_h = dwarf2loc.h
*************** inf_ptrace_h = inf-ptrace.h
*** 726,731 ****
--- 737,743 ----
  inf_ttrace_h = inf-ttrace.h
  interps_h = interps.h $(exceptions_h)
  jv_lang_h = jv-lang.h
+ kod_h = kod.h
  language_h = language.h
  libunwind_frame_h = libunwind-frame.h $(libunwind_h)
  linespec_h = linespec.h
*************** COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
*** 911,917 ****
  	auxv.o \
  	bfd-target.o \
  	blockframe.o breakpoint.o findvar.o regcache.o \
! 	charset.o disasm.o dummy-frame.o \
  	source.o value.o eval.o valops.o valarith.o valprint.o printcmd.o \
  	block.o symtab.o symfile.o symmisc.o linespec.o dictionary.o \
  	infcall.o \
--- 923,929 ----
  	auxv.o \
  	bfd-target.o \
  	blockframe.o breakpoint.o findvar.o regcache.o \
! 	charset.o disasm.o dummy-frame.o dfp.o \
  	source.o value.o eval.o valops.o valarith.o valprint.o printcmd.o \
  	block.o symtab.o symfile.o symmisc.o linespec.o dictionary.o \
  	infcall.o \
*************** COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
*** 927,932 ****
--- 939,945 ----
  	memattr.o mem-break.o target.o parse.o language.o buildsym.o \
  	std-regs.o \
  	signals.o \
+ 	kod.o kod-cisco.o \
  	gdb-events.o \
  	exec.o bcache.o objfiles.o observer.o minsyms.o maint.o demangle.o \
  	dbxread.o coffread.o coff-pe-read.o elfread.o \
*************** init.c: $(INIT_FILES)
*** 1152,1160 ****
  	@rm -f init.c-tmp init.l-tmp
  	@touch init.c-tmp
  	@echo gdbtypes > init.l-tmp
! 	@-LANG=c ; export LANG ; \
! 	LC_ALL=c ; export LC_ALL ; \
! 	echo $(INIT_FILES) | \
  	tr ' ' '\012' | \
  	sed \
  	    -e '/^gdbtypes.[co]$$/d' \
--- 1165,1171 ----
  	@rm -f init.c-tmp init.l-tmp
  	@touch init.c-tmp
  	@echo gdbtypes > init.l-tmp
! 	@-echo $(INIT_FILES) | \
  	tr ' ' '\012' | \
  	sed \
  	    -e '/^gdbtypes.[co]$$/d' \
*************** MAKEOVERRIDES=
*** 1407,1416 ****
  
  ALLDEPFILES = \
  	aix-thread.c \
! 	alpha-nat.c alphabsd-nat.c alpha-linux-nat.c \
! 	alpha-tdep.c alpha-mdebug-tdep.c \
! 	alpha-linux-tdep.c alpha-osf1-tdep.c \
! 	alphabsd-tdep.c alphafbsd-tdep.c alphanbsd-tdep.c alphaobsd-tdep.c \
  	amd64-nat.c amd64-tdep.c \
  	amd64bsd-nat.c amd64fbsd-nat.c amd64fbsd-tdep.c \
  	amd64nbsd-nat.c amd64nbsd-tdep.c \
--- 1418,1426 ----
  
  ALLDEPFILES = \
  	aix-thread.c \
! 	alpha-nat.c alphabsd-nat.c alpha-linux-nat.c linux-fork.c \
! 	alpha-tdep.c alpha-linux-tdep.c alphabsd-tdep.c alphanbsd-tdep.c \
! 	alpha-osf1-tdep.c alphafbsd-tdep.c alpha-mdebug-tdep.c \
  	amd64-nat.c amd64-tdep.c \
  	amd64bsd-nat.c amd64fbsd-nat.c amd64fbsd-tdep.c \
  	amd64nbsd-nat.c amd64nbsd-tdep.c \
*************** ALLDEPFILES = \
*** 1418,1424 ****
  	amd64-linux-nat.c amd64-linux-tdep.c \
  	amd64-sol2-tdep.c \
  	arm-linux-nat.c arm-linux-tdep.c arm-tdep.c \
! 	armnbsd-nat.c armnbsd-tdep.c armobsd-tdep.c \
  	avr-tdep.c \
  	bsd-uthread.c bsd-kvm.c \
  	coff-solib.c \
--- 1428,1434 ----
  	amd64-linux-nat.c amd64-linux-tdep.c \
  	amd64-sol2-tdep.c \
  	arm-linux-nat.c arm-linux-tdep.c arm-tdep.c \
! 	armnbsd-nat.c armnbsd-tdep.c \
  	avr-tdep.c \
  	bsd-uthread.c bsd-kvm.c \
  	coff-solib.c \
*************** ALLDEPFILES = \
*** 1444,1450 ****
  	inf-ptrace.c inf-ttrace.c \
  	infptrace.c inftarg.c irix5-nat.c \
  	libunwind-frame.c \
- 	linux-fork.c \
  	lynx-nat.c \
  	m68hc11-tdep.c \
  	m32r-tdep.c \
--- 1454,1459 ----
*************** printcmd.o: $(srcdir)/printcmd.c
*** 1534,1539 ****
--- 1543,1553 ----
  procfs.o: $(srcdir)/procfs.c
  	$(CC) -c $(INTERNAL_WARN_CFLAGS) $(srcdir)/procfs.c
  
+ # FIXME: Thread-db.o gets warnings because the definitions of the register
+ # sets are different from kernel to kernel.
+ linux-thread-db.o: $(srcdir)/linux-thread-db.c
+ 	$(CC) -c $(INTERNAL_WARN_CFLAGS) $(srcdir)/linux-thread-db.c
+ 
  v850ice.o: $(srcdir)/v850ice.c
  	$(CC) -c $(INTERNAL_CFLAGS) $(IDE_CFLAGS) $(ITCL_CFLAGS) \
  		$(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS) \
*************** aix-thread.o: aix-thread.c $(defs_h) $(g
*** 1694,1701 ****
  	$(target_h) $(inferior_h) $(regcache_h) $(gdbcmd_h) $(ppc_tdep_h) \
  	$(gdb_string_h)
  alphabsd-nat.o: alphabsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
! 	$(alpha_tdep_h) $(alphabsd_tdep_h) $(inf_ptrace_h) $(gregset_h) \
! 	$(bsd_kvm_h)
  alphabsd-tdep.o: alphabsd-tdep.c $(defs_h) $(alpha_tdep_h) \
  	$(alphabsd_tdep_h)
  alphafbsd-tdep.o: alphafbsd-tdep.c $(defs_h) $(value_h) $(osabi_h) \
--- 1708,1714 ----
  	$(target_h) $(inferior_h) $(regcache_h) $(gdbcmd_h) $(ppc_tdep_h) \
  	$(gdb_string_h)
  alphabsd-nat.o: alphabsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
! 	$(alpha_tdep_h) $(alphabsd_tdep_h) $(inf_ptrace_h) $(gregset_h)
  alphabsd-tdep.o: alphabsd-tdep.c $(defs_h) $(alpha_tdep_h) \
  	$(alphabsd_tdep_h)
  alphafbsd-tdep.o: alphafbsd-tdep.c $(defs_h) $(value_h) $(osabi_h) \
*************** alpha-mdebug-tdep.o: alpha-mdebug-tdep.c
*** 1708,1720 ****
  	$(block_h) $(gdb_assert_h) $(alpha_tdep_h) $(mdebugread_h)
  alpha-nat.o: alpha-nat.c $(defs_h) $(gdb_string_h) $(inferior_h) \
  	$(gdbcore_h) $(target_h) $(regcache_h) $(alpha_tdep_h) $(gregset_h)
! alphanbsd-tdep.o: alphanbsd-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \
! 	$(regcache_h) $(regset_h) $(value_h) $(osabi_h) $(gdb_string_h) \
! 	$(gdb_assert_h) $(alpha_tdep_h) $(alphabsd_tdep_h) $(nbsd_tdep_h) \
! 	$(solib_svr4_h)
! alphaobsd-tdep.o: alphaobsd-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \
! 	$(osabi_h) $(obsd_tdep_h) $(alpha_tdep_h) $(alphabsd_tdep_h) \
! 	$(solib_svr4_h)
  alpha-osf1-tdep.o: alpha-osf1-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \
  	$(value_h) $(osabi_h) $(gdb_string_h) $(objfiles_h) $(alpha_tdep_h)
  alpha-tdep.o: alpha-tdep.c $(defs_h) $(doublest_h) $(frame_h) \
--- 1721,1729 ----
  	$(block_h) $(gdb_assert_h) $(alpha_tdep_h) $(mdebugread_h)
  alpha-nat.o: alpha-nat.c $(defs_h) $(gdb_string_h) $(inferior_h) \
  	$(gdbcore_h) $(target_h) $(regcache_h) $(alpha_tdep_h) $(gregset_h)
! alphanbsd-tdep.o: alphanbsd-tdep.c $(defs_h) $(gdbcore_h) $(frame_h) \
! 	$(regcache_h) $(value_h) $(osabi_h) $(gdb_string_h) $(alpha_tdep_h) \
! 	$(alphabsd_tdep_h) $(nbsd_tdep_h) $(solib_svr4_h)
  alpha-osf1-tdep.o: alpha-osf1-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \
  	$(value_h) $(osabi_h) $(gdb_string_h) $(objfiles_h) $(alpha_tdep_h)
  alpha-tdep.o: alpha-tdep.c $(defs_h) $(doublest_h) $(frame_h) \
*************** arch-utils.o: arch-utils.c $(defs_h) $(a
*** 1770,1794 ****
  	$(floatformat_h)
  arm-linux-nat.o: arm-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \
  	$(gdb_string_h) $(regcache_h) $(arm_tdep_h) $(gregset_h) \
! 	$(target_h) $(linux_nat_h) $(gdb_proc_service_h) $(arm_linux_tdep_h)
  arm-linux-tdep.o: arm-linux-tdep.c $(defs_h) $(target_h) $(value_h) \
  	$(gdbtypes_h) $(floatformat_h) $(gdbcore_h) $(frame_h) $(regcache_h) \
  	$(doublest_h) $(solib_svr4_h) $(osabi_h) $(arm_tdep_h) \
- 	$(regset_h) $(arm_linux_tdep_h) \
  	$(glibc_tdep_h) $(trad_frame_h) $(tramp_frame_h) $(gdb_string_h)
  armnbsd-nat.o: armnbsd-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) \
  	$(regcache_h) $(target_h) $(gdb_string_h) $(arm_tdep_h) $(inf_ptrace_h)
  armnbsd-tdep.o: armnbsd-tdep.c $(defs_h) $(osabi_h) $(gdb_string_h) \
! 	$(arm_tdep_h) $(solib_svr4_h)
! armobsd-tdep.o: armobsd-tdep.c $(defs_h) $(osabi_h) $(trad_frame_h) \
! 	$(tramp_frame_h) $(obsd_tdep_h) $(arm_tdep_h) $(solib_svr4_h)
  arm-tdep.o: arm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(gdbcmd_h) \
  	$(gdbcore_h) $(gdb_string_h) $(dis_asm_h) $(regcache_h) \
  	$(doublest_h) $(value_h) $(arch_utils_h) $(osabi_h) \
  	$(frame_unwind_h) $(frame_base_h) $(trad_frame_h) $(arm_tdep_h) \
  	$(gdb_sim_arm_h) $(elf_bfd_h) $(coff_internal_h) $(elf_arm_h) \
  	$(gdb_assert_h) $(bfd_in2_h) $(libcoff_h) $(objfiles_h) \
! 	$(dwarf2_frame_h) $(gdbtypes_h)
  auxv.o: auxv.c $(defs_h) $(target_h) $(gdbtypes_h) $(command_h) \
  	$(inferior_h) $(valprint_h) $(gdb_assert_h) $(auxv_h) \
  	$(elf_common_h)
--- 1779,1800 ----
  	$(floatformat_h)
  arm-linux-nat.o: arm-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \
  	$(gdb_string_h) $(regcache_h) $(arm_tdep_h) $(gregset_h) \
! 	$(target_h) $(linux_nat_h) $(gdb_proc_service_h)
  arm-linux-tdep.o: arm-linux-tdep.c $(defs_h) $(target_h) $(value_h) \
  	$(gdbtypes_h) $(floatformat_h) $(gdbcore_h) $(frame_h) $(regcache_h) \
  	$(doublest_h) $(solib_svr4_h) $(osabi_h) $(arm_tdep_h) \
  	$(glibc_tdep_h) $(trad_frame_h) $(tramp_frame_h) $(gdb_string_h)
  armnbsd-nat.o: armnbsd-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) \
  	$(regcache_h) $(target_h) $(gdb_string_h) $(arm_tdep_h) $(inf_ptrace_h)
  armnbsd-tdep.o: armnbsd-tdep.c $(defs_h) $(osabi_h) $(gdb_string_h) \
! 	$(arm_tdep_h) $(nbsd_tdep_h) $(solib_svr4_h)
  arm-tdep.o: arm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(gdbcmd_h) \
  	$(gdbcore_h) $(gdb_string_h) $(dis_asm_h) $(regcache_h) \
  	$(doublest_h) $(value_h) $(arch_utils_h) $(osabi_h) \
  	$(frame_unwind_h) $(frame_base_h) $(trad_frame_h) $(arm_tdep_h) \
  	$(gdb_sim_arm_h) $(elf_bfd_h) $(coff_internal_h) $(elf_arm_h) \
  	$(gdb_assert_h) $(bfd_in2_h) $(libcoff_h) $(objfiles_h) \
! 	$(dwarf2_frame_h)
  auxv.o: auxv.c $(defs_h) $(target_h) $(gdbtypes_h) $(command_h) \
  	$(inferior_h) $(valprint_h) $(gdb_assert_h) $(auxv_h) \
  	$(elf_common_h)
*************** dsrec.o: dsrec.c $(defs_h) $(serial_h) $
*** 1922,1927 ****
--- 1928,1934 ----
  dummy-frame.o: dummy-frame.c $(defs_h) $(dummy_frame_h) $(regcache_h) \
  	$(frame_h) $(inferior_h) $(gdb_assert_h) $(frame_unwind_h) \
  	$(command_h) $(gdbcmd_h) $(gdb_string_h)
+ dfp.o: dfp.c $(defs_h) $(dfp_h) $(decimal128_h) $(decimal64_h) $(decimal32_h)
  dve3900-rom.o: dve3900-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \
  	$(serial_h) $(inferior_h) $(command_h) $(gdb_string_h) $(regcache_h) \
  	$(mips_tdep_h)
*************** jv-typeprint.o: jv-typeprint.c $(defs_h)
*** 2203,2208 ****
--- 2210,2218 ----
  jv-valprint.o: jv-valprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) \
  	$(gdbcore_h) $(expression_h) $(value_h) $(demangle_h) $(valprint_h) \
  	$(language_h) $(jv_lang_h) $(c_lang_h) $(annotate_h) $(gdb_string_h)
+ kod.o: kod.c $(defs_h) $(command_h) $(gdbcmd_h) $(target_h) $(gdb_string_h) \
+ 	$(kod_h)
+ kod-cisco.o: kod-cisco.c $(defs_h) $(gdb_string_h) $(kod_h)
  language.o: language.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
  	$(value_h) $(gdbcmd_h) $(expression_h) $(language_h) $(target_h) \
  	$(parser_defs_h) $(jv_lang_h) $(demangle_h)
*************** valops.o: valops.c $(defs_h) $(symtab_h)
*** 2792,2798 ****
  valprint.o: valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
  	$(value_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(language_h) \
  	$(annotate_h) $(valprint_h) $(floatformat_h) $(doublest_h) \
! 	$(exceptions_h)
  value.o: value.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
  	$(value_h) $(gdbcore_h) $(command_h) $(gdbcmd_h) $(target_h) \
  	$(language_h) $(scm_lang_h) $(demangle_h) $(doublest_h) \
--- 2802,2808 ----
  valprint.o: valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
  	$(value_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(language_h) \
  	$(annotate_h) $(valprint_h) $(floatformat_h) $(doublest_h) \
! 	$(exceptions_h) $(dfp_h)
  value.o: value.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
  	$(value_h) $(gdbcore_h) $(command_h) $(gdbcmd_h) $(target_h) \
  	$(language_h) $(scm_lang_h) $(demangle_h) $(doublest_h) \

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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb  patch
  2006-07-23  5:48 Wu Zhou
@ 2006-07-23 14:02 ` Daniel Jacobowitz
  0 siblings, 0 replies; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-07-23 14:02 UTC (permalink / raw)
  To: Wu Zhou; +Cc: gdb-patches

On Sun, Jul 23, 2006 at 01:47:58AM -0400, Wu Zhou wrote:
> My point is to keep these usage so as they are consistent with how  
> flaot/double is handled.  What is your idea on this?

I think it would be more useful to search for all reference to decimal
float, than it would be to exactly parallel the float/double support.

> >Why is reverse_dfp necessary?  It says GDB uses the opposite endianness
> >from decNumber, but I don't see why.  This might be a related problem,
> >but are you accomodating target endianness when you read values from
> >the target?  If not, a cross debugger will do the wrong thing.
> 
> We are using an array of gdb_byte to represent decimal values.  The  
> first byte is the most significant. This might be not the same as the  
> underlying byte order of the architecuture.  In this kind of  
> situation, reverse_dfp is needed to do conversion.
> 
> But in big-endian machine, this might be not needed. I will try a test  
> on ppc64.

This is where you're getting in trouble; it's too hard to keep track of
which format is which.  You need to make it clear when a decimal
floating point number is in "target format" and when it is in "host
format".

It might be easier to understand if you used two separate routines,
even if they both do the same thing.  That is, have a
decfloat_to_target and a decfloat_to_host.  They can consider the
endianness of the host and the endianness of the target.

I don't understand "the first byte is the most significant".  Does
decNumber always use that layout whether the host system is little
endian or big endian?  Then why does the target sometimes have it in
the other order?

> BTW, I am not very sure what you means by saying "are you accomodating  
> target endianness when you read values from the target?". I guess you  
> mean that I _need_ to accommodate the endianness when reading values  
> from the target, right? Then putting some code into  
> decimal_from_string / decimal_to_string to convert the byte order if  
> needed is right what you want to see, right?  Any advices?

I don't know where you should put it.  Probably, whenever you store it
as an opaque representation (array of bytes), store it in the target's
byte order.  When you store it in a local _Decimal128 store it in the
host byte order.

It's important to take advantage of type safety here if you can.  When
it's stored as a series of bytes it should always be in the same order,
not sometimes in target order and sometimes in host order.  Everyone
will just get confused.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb  patch
@ 2006-07-23  5:48 Wu Zhou
  2006-07-23 14:02 ` Daniel Jacobowitz
  0 siblings, 1 reply; 16+ messages in thread
From: Wu Zhou @ 2006-07-23  5:48 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Hi Daniel,

Thanks for reviewing this patch.

Quoting Daniel Jacobowitz <drow@false.org>:

> On Thu, Jun 22, 2006 at 07:36:17AM +0800, Wu Zhou wrote:
>>
>> Appended is the patch.  I had tested it with the latest gcc-4.2 cvs tree
>> on x86, with option "--enable-decimal-float". All the 121 tests passed.
>> Please review and comment.  Thanks a lot.
>
> Sometimes you use DECDBL and sometimes you use DECDOUBLE and sometimes
> you use DECFLOAT and sometimes you use DECFLT.  Let's pick one or the
> other and use it everywhere.  This makes it easier to search for
> code that knows about decimal float.  "decfloat" might be more
> readable?

I was using these different names because I wa simulating what  
float/double/long double are using.

DECDBL is not used anywhere, but decdbl is. :-)
It is only used in write_exp_elt_decdblcst and its reference.  That is  
to simulate write_exp_elt_dblcst. I am not very sure why gdb named it  
dbl though.

DECDOUBLE is used in OP_DECDOUBLE and value_from_decdouble.  This is  
to simulate OP_DOUBLE and value_from_double. All three kinds of float  
constants and variables are handled by them.  So I am using them for  
DECDOUBLE too.

DECFLT is only used in TYPE_CODE_DECFLT.  This is to simulate  
TYPE_CODE_FLT, which is used to refer to types of float, double, long  
double at the same time. The length can differentiate them.

DECFLOAT is used in parsing and fundamental type representation  
dwarf2read.c and C language handling.  such as FT_DECFLOAT,  
FT_DBL_PREC_DECFLOAT  and FT_EXT_PREC_DECFLOAT.  This is the same what  
FLOAT is used in these scanario.

My point is to keep these usage so as they are consistent with how  
flaot/double is handled.  What is your idea on this?

> Why is reverse_dfp necessary?  It says GDB uses the opposite endianness
> from decNumber, but I don't see why.  This might be a related problem,
> but are you accomodating target endianness when you read values from
> the target?  If not, a cross debugger will do the wrong thing.

We are using an array of gdb_byte to represent decimal values.  The  
first byte is the most significant. This might be not the same as the  
underlying byte order of the architecuture.  In this kind of  
situation, reverse_dfp is needed to do conversion.

But in big-endian machine, this might be not needed. I will try a test  
on ppc64.

I am now also thinking that the place where reverse_dfp is defined is  
not very good. Maybe we can put them into decimal_to_string /  
decimal_from_string. Then other gdb code don't need to know the  
existence of that.

BTW, I am not very sure what you means by saying "are you accomodating  
target endianness when you read values from the target?". I guess you  
mean that I _need_ to accommodate the endianness when reading values  
from the target, right? Then putting some code into  
decimal_from_string / decimal_to_string to convert the byte order if  
needed is right what you want to see, right?  Any advices?

>> Index: expression.h
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/expression.h,v
>> retrieving revision 1.18
>> diff -u -r1.18 expression.h
>> --- expression.h	17 Dec 2005 22:33:59 -0000	1.18
>> +++ expression.h	21 Jun 2006 23:08:51 -0000
>> @@ -327,6 +327,11 @@
>>      /* A F90 array range operator (for "exp:exp", "exp:", ":exp"   
>> and ":").  */
>>      OP_F90_RANGE,
>>
>> +    /* OP_DECDOUBLE is followed by a type pointer in the next exp_element
>> +       and a dec long constant value in the following exp_element.
>> +       Then comes another OP_DECDOUBLE.  */
>> +    OP_DECDOUBLE,
>> +
>
> A comment on the format of the data would be nice here.  Is it in
> target byte order?

The first byte is the most significant byte.  I don't have code to  
make it into the target byte order yet.  reverse_dfp can partially do  
that.  But it need to be more general. And I am planning to add some  
code into decimal_to_string / decimal_from_string to test the target  
byte order and determine if the conversion is needed. What is your  
thought?

>> Index: c-valprint.c
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/c-valprint.c,v
>> retrieving revision 1.39
>> diff -u -r1.39 c-valprint.c
>> --- c-valprint.c	18 Jan 2006 21:24:19 -0000	1.39
>> +++ c-valprint.c	21 Jun 2006 23:08:52 -0000
>> @@ -442,6 +442,17 @@
>>  	}
>>        break;
>>
>> +    case TYPE_CODE_DECFLT:
>> +      if (format)
>> +	{
>> +	  print_scalar_formatted (valaddr + embedded_offset, type,   
>> format, 0, stream);
>> +	}
>> +      else
>> +	{
>> +	  print_decimal_floating (valaddr + embedded_offset, type, stream);
>> +	}
>> +      break;
>> +
>>      case TYPE_CODE_METHOD:
>>        {
>>  	struct value *v = value_at (type, address);
>
> You don't need the braces in this; please omit them when you don't need
> to.  It saves a level of indentation, which generally makes them easier
> to read.

Thanks.  I will delete them when I update my patch.

Regards
- Wu Zhou


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb patch
  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-07-12 20:39   ` Daniel Jacobowitz
  1 sibling, 0 replies; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-07-12 20:39 UTC (permalink / raw)
  To: Wu Zhou; +Cc: gdb-patches

On Thu, Jun 22, 2006 at 07:36:17AM +0800, Wu Zhou wrote:
> 
> Appended is the patch.  I had tested it with the latest gcc-4.2 cvs tree 
> on x86, with option "--enable-decimal-float". All the 121 tests passed.
> Please review and comment.  Thanks a lot.

Sometimes you use DECDBL and sometimes you use DECDOUBLE and sometimes
you use DECFLOAT and sometimes you use DECFLT.  Let's pick one or the
other and use it everywhere.  This makes it easier to search for
code that knows about decimal float.  "decfloat" might be more
readable?

Why is reverse_dfp necessary?  It says GDB uses the opposite endianness
from decNumber, but I don't see why.  This might be a related problem,
but are you accomodating target endianness when you read values from
the target?  If not, a cross debugger will do the wrong thing.

> Index: expression.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/expression.h,v
> retrieving revision 1.18
> diff -u -r1.18 expression.h
> --- expression.h	17 Dec 2005 22:33:59 -0000	1.18
> +++ expression.h	21 Jun 2006 23:08:51 -0000
> @@ -327,6 +327,11 @@
>      /* A F90 array range operator (for "exp:exp", "exp:", ":exp" and ":").  */
>      OP_F90_RANGE,
>  
> +    /* OP_DECDOUBLE is followed by a type pointer in the next exp_element
> +       and a dec long constant value in the following exp_element.
> +       Then comes another OP_DECDOUBLE.  */
> +    OP_DECDOUBLE,
> +

A comment on the format of the data would be nice here.  Is it in
target byte order?

> Index: c-valprint.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/c-valprint.c,v
> retrieving revision 1.39
> diff -u -r1.39 c-valprint.c
> --- c-valprint.c	18 Jan 2006 21:24:19 -0000	1.39
> +++ c-valprint.c	21 Jun 2006 23:08:52 -0000
> @@ -442,6 +442,17 @@
>  	}
>        break;
>  
> +    case TYPE_CODE_DECFLT:
> +      if (format)
> +	{
> +	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
> +	}
> +      else
> +	{
> +	  print_decimal_floating (valaddr + embedded_offset, type, stream);
> +	}
> +      break;
> +
>      case TYPE_CODE_METHOD:
>        {
>  	struct value *v = value_at (type, address);

You don't need the braces in this; please omit them when you don't need
to.  It saves a level of indentation, which generally makes them easier
to read.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb patch
  2006-06-22  3:27   ` Eli Zaretskii
@ 2006-06-22 14:18     ` Wu Zhou
  0 siblings, 0 replies; 16+ messages in thread
From: Wu Zhou @ 2006-06-22 14:18 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: drow, gdb-patches

Eli,

Thanks for your comments!  See below for my response.

On Thu, 22 Jun 2006, Eli Zaretskii wrote:

> > Date: Thu, 22 Jun 2006 07:36:17 +0800 (CST)
> > From: Wu Zhou <woodzltc@cn.ibm.com>
> > 
> > 
> > Appended is the patch.  I had tested it with the latest gcc-4.2 cvs tree 
> > on x86, with option "--enable-decimal-float". All the 121 tests passed.
> 
> Thanks.
> 
> > Please review and comment.  Thanks a lot.
> 
> Does this patch affect user-visible behavior in any way?  If so, we
> need to reflect that in the user manual.

Yes. I am thinking of adding some text to describe this.

> 
> > 	* Makefile.in: Add decimal floating point related entry.  Add
> > 	some macro to specify the libdecnumber directory, cflags and the
> > 	name of libdecnumber library.
> 
> The ChangeLog entry for Makefile.in should cite the target(s) and
> macros in which you made the changes, as if they were functions in a
> source file.

Thanks for the correction.  I didn't add any changelog for such things 
(Makefile.in) before.  Learn something new.  :-)  Will change that in the 
next round patch.

Regards
- Wu Zhou


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

* Re: [RFC] decimal float point patch based on libdecnumber: gdb patch
  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
  1 sibling, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2006-06-22  3:27 UTC (permalink / raw)
  To: Wu Zhou; +Cc: drow, gdb-patches

> Date: Thu, 22 Jun 2006 07:36:17 +0800 (CST)
> From: Wu Zhou <woodzltc@cn.ibm.com>
> 
> 
> Appended is the patch.  I had tested it with the latest gcc-4.2 cvs tree 
> on x86, with option "--enable-decimal-float". All the 121 tests passed.

Thanks.

> Please review and comment.  Thanks a lot.

Does this patch affect user-visible behavior in any way?  If so, we
need to reflect that in the user manual.

> 	* Makefile.in: Add decimal floating point related entry.  Add
> 	some macro to specify the libdecnumber directory, cflags and the
> 	name of libdecnumber library.

The ChangeLog entry for Makefile.in should cite the target(s) and
macros in which you made the changes, as if they were functions in a
source file.


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

* [RFC] decimal float point patch based on libdecnumber: gdb patch
  2006-06-21 21:03 [RFC] decimal float point patch based on libdecnumber: testcase Wu Zhou
@ 2006-06-21 23:36 ` Wu Zhou
  2006-06-22  3:27   ` Eli Zaretskii
  2006-07-12 20:39   ` Daniel Jacobowitz
  0 siblings, 2 replies; 16+ messages in thread
From: Wu Zhou @ 2006-06-21 23:36 UTC (permalink / raw)
  To: drow, gdb-patches


Appended is the patch.  I had tested it with the latest gcc-4.2 cvs tree 
on x86, with option "--enable-decimal-float". All the 121 tests passed.
Please review and comment.  Thanks a lot.

2006-06-21  Wu Zhou  <woodzltc@cn.ibm.com>

	* expression.h (enum exp_opcode): Add an opcode (OP_DECDOUBLE) for
	DFP constants.
	(union exp_element): Add decdoubleconst to represent DFP elements,
	which is 16 bytes by default.
	* parser-defs.h (write_exp_elt_decdblcst): Prototype.
	* parse.c (write_exp_elt_decdblcst): New function to write a decimal
	double const into the expression.
	(operator_length_standard): Set operator length for OP_DECDOUBLE 
	to 4.
	* c-exp.y (YYSTYPE): Add typed_val_decfloat for decimal floating 
	point in YYSTYPE union.
	Add token DECFLOAT for typed_val_decfloat.
	Add expression element handling code for DECFLOAT.
	(parse_number): Parse DFP constants, which end with suffix 'df',
	'dd' or 'dl'.  Return DECFLOAT.
	* c-lang.c (c_create_fundamental_type): Create fundamental types
	for DFP.
	* c-valprint.c (c_val_print): Call print_decimal_floating to print
	DFP values.
	* dwarf2read.c (read_base_type): Read DW_ATE_decimal_float attribute
	code and return TYPE_CODE_DECFLT.
	(dwarf_base_type): Set dwarf2_fundamental_type for DFP values.
	* eval.c (evaluate_subexp_standard): Call value_from_decdouble to
	handle OP_DECDOUBLE.
	* gdbtypes.h: Add three fundamental types for DFP.
	(enum type_code): Add TYPE_CODE_DECFLT as a type code for DFP.
	(struct builtin_type): Add builtin_decfloat, builtin_decdouble
	and builtin_declong.
	* gdbtypes.c: Add three builtin types for DFP.
	(build_gdbtypes): Build these three builtin types for DFP.
	(gdbtypes_post_init): Initialize builtin_decfloat, builtin_decdouble
	and builtin_declong.
	* value.h (value_from_decdouble): Prototype.
	(print_decimal_floating): Prototype.
	* valprint.c (print_decimal_floating): New function to print DFP
	values.
	* value.c (value_from_decdouble): New function to get the value
	from a decimal double.
	* valarith.c (value_neg): Add some code to handle the negation
	operation of DFP values.
	* dfp.h: New header file for decimal floating point support in
	GDB.
	* dfp.c: New source file for decimal floating point support in
	GDB.  Implement decimal_from_string and decimal_to_string based
	on libdecnumber API.
	* Makefile.in: Add decimal floating point related entry.  Add
	some macro to specify the libdecnumber directory, cflags and the
	name of libdecnumber library.

Index: expression.h
===================================================================
RCS file: /cvs/src/src/gdb/expression.h,v
retrieving revision 1.18
diff -u -r1.18 expression.h
--- expression.h	17 Dec 2005 22:33:59 -0000	1.18
+++ expression.h	21 Jun 2006 23:08:51 -0000
@@ -327,6 +327,11 @@
     /* A F90 array range operator (for "exp:exp", "exp:", ":exp" and ":").  */
     OP_F90_RANGE,
 
+    /* OP_DECDOUBLE is followed by a type pointer in the next exp_element
+       and a dec long constant value in the following exp_element.
+       Then comes another OP_DECDOUBLE.  */
+    OP_DECDOUBLE,
+
      /* First extension operator.  Individual language modules define
         extra operators they need as constants with values 
         OP_LANGUAGE_SPECIFIC0 + k, for k >= 0, using a separate 
@@ -354,6 +359,7 @@
     struct symbol *symbol;
     LONGEST longconst;
     DOUBLEST doubleconst;
+    gdb_byte decdoubleconst[16];
     /* Really sizeof (union exp_element) characters (or less for the last
        element of a string).  */
     char string;
Index: parser-defs.h
===================================================================
RCS file: /cvs/src/src/gdb/parser-defs.h,v
retrieving revision 1.20
diff -u -r1.20 parser-defs.h
--- parser-defs.h	17 Dec 2005 22:34:01 -0000	1.20
+++ parser-defs.h	21 Jun 2006 23:08:51 -0000
@@ -121,6 +121,8 @@
 
 extern void write_exp_elt_dblcst (DOUBLEST);
 
+extern void write_exp_elt_decdblcst (gdb_byte *);
+
 extern void write_exp_elt_type (struct type *);
 
 extern void write_exp_elt_intern (struct internalvar *);
Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.52
diff -u -r1.52 parse.c
--- parse.c	24 Jan 2006 15:20:10 -0000	1.52
+++ parse.c	21 Jun 2006 23:08:51 -0000
@@ -236,6 +236,18 @@
 }
 
 void
+write_exp_elt_decdblcst (gdb_byte expelt[16])
+{
+  union exp_element tmp;
+  int index;
+
+  for (index = 0; index < 16; index++)
+    tmp.decdoubleconst[index] = expelt[index];
+
+  write_exp_elt (tmp);
+}
+
+void
 write_exp_elt_type (struct type *expelt)
 {
   union exp_element tmp;
@@ -857,6 +869,7 @@
 
     case OP_LONG:
     case OP_DOUBLE:
+    case OP_DECDOUBLE:
     case OP_VAR_VALUE:
       oplen = 4;
       break;
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.34
diff -u -r1.34 c-exp.y
--- c-exp.y	23 Feb 2006 18:43:41 -0000	1.34
+++ c-exp.y	21 Jun 2006 23:08:51 -0000
@@ -53,6 +53,7 @@
 #include "charset.h"
 #include "block.h"
 #include "cp-support.h"
+#include "dfp.h"
 
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    as well as gratuitiously global symbol names, so we can have multiple
@@ -131,6 +132,10 @@
       DOUBLEST dval;
       struct type *type;
     } typed_val_float;
+    struct {
+      gdb_byte val[16];
+      struct type *type;
+    } typed_val_decfloat;
     struct symbol *sym;
     struct type *tval;
     struct stoken sval;
@@ -163,6 +168,7 @@
 
 %token <typed_val_int> INT
 %token <typed_val_float> FLOAT
+%token <typed_val_decfloat> DECFLOAT
 
 /* Both NAME and TYPENAME tokens represent symbols in the input,
    and both convey their data as strings.
@@ -497,6 +503,13 @@
 			  write_exp_elt_opcode (OP_DOUBLE); }
 	;
 
+exp	:	DECFLOAT
+			{ write_exp_elt_opcode (OP_DECDOUBLE);
+			  write_exp_elt_type ($1.type);
+			  write_exp_elt_decdblcst ($1.val);
+			  write_exp_elt_opcode (OP_DECDOUBLE); }
+	;
+
 exp	:	variable
 	;
 
@@ -1080,6 +1093,49 @@
       char saved_char = p[len];
 
       p[len] = 0;	/* null-terminate the token */
+
+      /* If it ends at "df", "dd" or "dl", take it as type of decimal floating
+         point.  Return DECFLOAT.  */
+
+      if (p[len - 2] == 'd' && p[len - 1] == 'f')
+	{
+	  gdb_byte *dec_val = (gdb_byte *)malloc (4);
+	  p[len - 2] = '\0';
+	  putithere->typed_val_decfloat.type = 
+	    builtin_type (current_gdbarch)->builtin_decfloat;
+	  decimal_from_string (dec_val, 4, p);
+	  reverse_dfp (dec_val, 4, putithere->typed_val_decfloat.val);
+	  free (dec_val);
+	  p[len] = saved_char;
+	  return (DECFLOAT);
+	}
+
+      if (p[len - 2] == 'd' && p[len - 1] == 'd')
+	{
+	  gdb_byte *dec_val = (gdb_byte *)malloc (8);
+	  p[len - 2] = '\0';
+	  putithere->typed_val_decfloat.type = 
+	    builtin_type (current_gdbarch)->builtin_decdouble;
+	  decimal_from_string (dec_val, 8, p);
+	  reverse_dfp (dec_val, 8, putithere->typed_val_decfloat.val);
+	  free (dec_val);
+	  p[len] = saved_char;
+	  return (DECFLOAT);
+	}
+
+      if (p[len - 2] == 'd' && p[len - 1] == 'l')
+	{
+	  gdb_byte *dec_val = (gdb_byte *)malloc (16);
+	  p[len - 2] = '\0';
+	  putithere->typed_val_decfloat.type = 
+	    builtin_type (current_gdbarch)->builtin_declong;
+	  decimal_from_string (dec_val, 16, p);
+	  reverse_dfp (dec_val, 16, putithere->typed_val_decfloat.val);
+	  free (dec_val);
+	  p[len] = saved_char;
+	  return (DECFLOAT);
+	}
+
       num = sscanf (p, DOUBLEST_SCAN_FORMAT "%s",
 		    &putithere->typed_val_float.dval, s);
       p[len] = saved_char;	/* restore the input stream */
Index: c-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/c-lang.c,v
retrieving revision 1.39
diff -u -r1.39 c-lang.c
--- c-lang.c	17 Dec 2005 22:33:59 -0000	1.39
+++ c-lang.c	21 Jun 2006 23:08:52 -0000
@@ -322,6 +322,21 @@
 			TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
 			0, "long double", objfile);
       break;
+    case FT_DECFLOAT:
+      type = init_type (TYPE_CODE_DECFLT,
+			32 / 8,
+			0, "decimal float", objfile);
+      break;
+    case FT_DBL_PREC_DECFLOAT:
+      type = init_type (TYPE_CODE_DECFLT,
+			64 / 8,
+			0, "decimal double", objfile);
+      break;
+    case FT_EXT_PREC_DECFLOAT:
+      type = init_type (TYPE_CODE_DECFLT,
+			128 / 8,
+			0, "decimal long double", objfile);
+      break;
     case FT_COMPLEX:
       type = init_type (TYPE_CODE_FLT,
 			2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
Index: c-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-valprint.c,v
retrieving revision 1.39
diff -u -r1.39 c-valprint.c
--- c-valprint.c	18 Jan 2006 21:24:19 -0000	1.39
+++ c-valprint.c	21 Jun 2006 23:08:52 -0000
@@ -442,6 +442,17 @@
 	}
       break;
 
+    case TYPE_CODE_DECFLT:
+      if (format)
+	{
+	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	}
+      else
+	{
+	  print_decimal_floating (valaddr + embedded_offset, type, stream);
+	}
+      break;
+
     case TYPE_CODE_METHOD:
       {
 	struct value *v = value_at (type, address);
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.198
diff -u -r1.198 dwarf2read.c
--- dwarf2read.c	9 Jun 2006 00:44:28 -0000	1.198
+++ dwarf2read.c	21 Jun 2006 23:08:52 -0000
@@ -4739,6 +4739,9 @@
 	case DW_ATE_complex_float:
 	  code = TYPE_CODE_COMPLEX;
 	  break;
+	case DW_ATE_decimal_float:
+	  code = TYPE_CODE_DECFLT;
+	  break;
 	case DW_ATE_float:
 	  code = TYPE_CODE_FLT;
 	  break;
@@ -7507,6 +7510,14 @@
 	  type = dwarf2_fundamental_type (objfile, FT_FLOAT, cu);
 	}
       return type;
+    case DW_ATE_decimal_float:
+      if (size == 16)
+	type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_DECFLOAT, cu);
+      else if (size == 8)
+	type = dwarf2_fundamental_type (objfile, FT_EXT_PREC_DECFLOAT, cu);
+      else
+	type = dwarf2_fundamental_type (objfile, FT_DECFLOAT, cu);
+      return type;
     case DW_ATE_signed:
       switch (size)
 	{
Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.61
diff -u -r1.61 eval.c
--- eval.c	18 Feb 2006 20:47:54 -0000	1.61
+++ eval.c	21 Jun 2006 23:08:52 -0000
@@ -447,6 +447,11 @@
       return value_from_double (exp->elts[pc + 1].type,
 				exp->elts[pc + 2].doubleconst);
 
+    case OP_DECDOUBLE:
+      (*pos) += 3;
+      return value_from_decdouble (expect_type, exp->elts[pc + 1].type,
+				exp->elts[pc + 2].decdoubleconst);
+
     case OP_VAR_VALUE:
       (*pos) += 3;
       if (noside == EVAL_SKIP)
Index: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.65
diff -u -r1.65 gdbtypes.h
--- gdbtypes.h	1 Feb 2006 23:14:10 -0000	1.65
+++ gdbtypes.h	21 Jun 2006 23:08:52 -0000
@@ -67,7 +67,12 @@
 #define FT_UNSIGNED_BYTE	27
 #define FT_TEMPLATE_ARG		28
 
-#define FT_NUM_MEMBERS		29	/* Highest FT_* above, plus one. */
+/* The following three fundamental types are for decimal floating point.  */
+#define FT_DECFLOAT		29	
+#define FT_DBL_PREC_DECFLOAT	30
+#define FT_EXT_PREC_DECFLOAT	31	
+
+#define FT_NUM_MEMBERS		32	/* Highest FT_* above, plus one. */
 
 /* Some macros for char-based bitfields.  */
 
@@ -159,7 +164,9 @@
     TYPE_CODE_TEMPLATE,		/* C++ template */
     TYPE_CODE_TEMPLATE_ARG,	/* C++ template arg */
 
-    TYPE_CODE_NAMESPACE		/* C++ namespace.  */
+    TYPE_CODE_NAMESPACE,	/* C++ namespace.  */
+
+    TYPE_CODE_DECFLT		/* Decimal floating point.  */
   };
 
 /* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
@@ -1005,6 +1012,9 @@
   struct type *builtin_bool;
   struct type *builtin_long_long;
   struct type *builtin_unsigned_long_long;
+  struct type *builtin_decfloat;
+  struct type *builtin_decdouble;
+  struct type *builtin_declong;
 };
 
 /* Return the type table for the specified architecture.  */
@@ -1028,6 +1038,9 @@
 extern struct type *builtin_type_double_complex;
 extern struct type *builtin_type_string;
 extern struct type *builtin_type_bool;
+extern struct type *builtin_type_decfloat;
+extern struct type *builtin_type_decdouble;
+extern struct type *builtin_type_declong;
 
 /* Address/pointer types: */
 /* (C) Language `pointer to data' type.  Some target platforms use an
Index: gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.105
diff -u -r1.105 gdbtypes.c
--- gdbtypes.c	1 Mar 2006 19:34:46 -0000	1.105
+++ gdbtypes.c	21 Jun 2006 23:08:52 -0000
@@ -76,6 +76,12 @@
 struct type *builtin_type_uint128;
 struct type *builtin_type_bool;
 
+/* The following three are about decimal floating point types, which are now 
+   considered as potential extension to C99 standard.  */ 
+struct type *builtin_type_decfloat;
+struct type *builtin_type_decdouble;
+struct type *builtin_type_declong;
+
 /* 128 bit long vector types */
 struct type *builtin_type_v2_double;
 struct type *builtin_type_v4_float;
@@ -3379,6 +3385,21 @@
 #if 0
   TYPE_FLOATFORMAT (builtin_type_long_double) = TARGET_LONG_DOUBLE_FORMAT;
 #endif
+
+  /* Builtin types for decimal floating point types.  */
+  builtin_type_decfloat =
+    init_type (TYPE_CODE_DECFLT, 32 / 8,
+	       0,
+	       "decimal float", (struct objfile *) NULL);
+  builtin_type_decdouble =
+    init_type (TYPE_CODE_DECFLT, 64 / 8,
+               0,
+               "decimal double", (struct objfile *) NULL);
+  builtin_type_declong =
+    init_type (TYPE_CODE_DECFLT, 128 / 8,
+	       0,
+	       "decimal long double", (struct objfile *) NULL);
+
   builtin_type_complex =
     init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
 	       0,
@@ -3604,6 +3625,21 @@
 	       0,
 	       "bool", (struct objfile *) NULL);
 
+  /* The following three are about decimal floating point types, which are 
+     32-bits, 64-bits and 128-bits respectively.  */
+  builtin_type->builtin_decfloat = 
+   init_type (TYPE_CODE_DECFLT, 32 / 8,
+               0,
+               "decimal float", (struct objfile *) NULL);
+  builtin_type->builtin_decdouble =
+    init_type (TYPE_CODE_DECFLT, 64 / 8,
+               0,
+               "decimal double", (struct objfile *) NULL);
+  builtin_type->builtin_declong =
+    init_type (TYPE_CODE_DECFLT, 128 / 8,
+               0,
+               "decimal long double", (struct objfile *) NULL);
+
   /* Pointer/Address types. */
 
   /* NOTE: on some targets, addresses and pointers are not necessarily
@@ -3742,6 +3778,9 @@
   DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr);
   DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR);
   DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma);
+  DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_decfloat);
+  DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_decdouble);
+  DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_declong);
   deprecated_register_gdbarch_swap (NULL, 0, build_gdbtypes);
 
   /* Note: These types do not need to be swapped - they are target
Index: value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.91
diff -u -r1.91 value.h
--- value.h	31 Mar 2006 10:36:18 -0000	1.91
+++ value.h	21 Jun 2006 23:08:52 -0000
@@ -274,6 +274,7 @@
 extern struct value *value_from_longest (struct type *type, LONGEST num);
 extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
 extern struct value *value_from_double (struct type *type, DOUBLEST num);
+extern struct value *value_from_decdouble (struct type *expect_type, struct type *type, gdb_byte decbytes[16]);
 extern struct value *value_from_string (char *string);
 
 extern struct value *value_at (struct type *type, CORE_ADDR addr);
@@ -469,6 +470,9 @@
 extern void print_floating (const gdb_byte *valaddr, struct type *type,
 			    struct ui_file *stream);
 
+extern void print_decimal_floating (const gdb_byte *valaddr, struct type *type,
+			    struct ui_file *stream);
+
 extern int value_print (struct value *val, struct ui_file *stream, int format,
 			enum val_prettyprint pretty);
 
Index: valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/valprint.c,v
retrieving revision 1.60
diff -u -r1.60 valprint.c
--- valprint.c	15 May 2006 16:53:38 -0000	1.60
+++ valprint.c	21 Jun 2006 23:08:53 -0000
@@ -35,6 +35,7 @@
 #include "floatformat.h"
 #include "doublest.h"
 #include "exceptions.h"
+#include "dfp.h"
 
 #include <errno.h>
 
@@ -496,6 +497,21 @@
 }
 
 void
+print_decimal_floating (const gdb_byte *valaddr, struct type *type,
+		struct ui_file *stream)
+{
+  char decstr[128];
+  unsigned len = TYPE_LENGTH (type);
+  gdb_byte *dec_val = (gdb_byte *)malloc (len);
+
+  reverse_dfp (valaddr, len, dec_val);
+  decimal_to_string (dec_val, len, decstr);
+  fputs_filtered (decstr, stream);
+  free (dec_val);
+  return;
+}
+
+void
 print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
 		    unsigned len)
 {
Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.36
diff -u -r1.36 value.c
--- value.c	31 Mar 2006 10:36:18 -0000	1.36
+++ value.c	21 Jun 2006 23:08:53 -0000
@@ -37,6 +37,7 @@
 #include "gdb_assert.h"
 #include "regcache.h"
 #include "block.h"
+#include "dfp.h"
 
 /* Prototypes for exported functions. */
 
@@ -1610,6 +1611,30 @@
 }
 
 struct value *
+value_from_decdouble (struct type *expect_type, struct type *type, 
+		      gdb_byte decbytes[16])
+{
+  struct value *val = allocate_value (type);
+  int len = TYPE_LENGTH (type);
+  gdb_byte *dec_val = (gdb_byte *)malloc (16);
+
+  if (expect_type)
+    {
+      int expect_len = TYPE_LENGTH (expect_type);
+      char decstr[128];
+      int real_len;
+
+      reverse_dfp (decbytes, expect_len, dec_val);
+      decimal_to_string (dec_val, len, decstr);
+      decimal_from_string (dec_val, expect_len, decstr);
+      reverse_dfp (dec_val, expect_len, decbytes);
+    }
+
+  memcpy (value_contents_raw (val), decbytes, len);
+  return val;
+}
+
+struct value *
 coerce_ref (struct value *arg)
 {
   struct type *value_type_arg_tmp = check_typedef (value_type (arg));
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.45
diff -u -r1.45 valarith.c
--- valarith.c	24 Jan 2006 21:21:12 -0000	1.45
+++ valarith.c	21 Jun 2006 23:08:53 -0000
@@ -1378,6 +1378,18 @@
 
   type = check_typedef (value_type (arg1));
 
+  if (TYPE_CODE (type) == TYPE_CODE_DECFLT)
+    {
+      struct value *val = allocate_value (result_type);
+      int len = TYPE_LENGTH (type);
+      gdb_byte *decbytes = (gdb_byte *) value_contents (arg1);
+
+      /* To change the first bit is ok.  */
+      decbytes[len-1] = decbytes[len - 1] | 0x80;
+      memcpy (value_contents_raw (val), decbytes, 16);
+      return val;
+    }
+
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
     return value_from_double (result_type, -value_as_double (arg1));
   else if (is_integral_type (type))
Index: dfp.h
===================================================================
RCS file: dfp.h
diff -N dfp.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dfp.h	21 Jun 2006 23:08:53 -0000
@@ -0,0 +1,45 @@
+/* Decimal floating point support for GDB.
+
+   Copyright 2006 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* Decimal floating point is one of the extension to IEEE 754, which is
+   described in http://grouper.ieee.org/groups/754/revision.html and
+   http://www2.hursley.ibm.com/decimal/.  It completes binary floating
+   point by representing floating point more exactly.  */
+
+/* There is a project intended to add DFP support into GCC, described in
+   http://gcc.gnu.org/wiki/Decimal%20Floating-Point.  This file is intended
+   to add DFP support into GDB.  */
+
+#ifndef DFP_H
+#define DFP_H
+#include <string.h>
+#include <stdio.h>
+#include <stdint.h>
+
+/* The conversion from decimal floating point to string, and reverse.  */
+extern void decimal_to_string (const uint8_t *, int, char *);
+extern void decimal_from_string (uint8_t *, int, char *);
+
+/* The value struct of gdb and decimal type of libdecnumber are using
+   different endian for storing the content.  This routine is used to
+   convert between these two.  */
+extern void reverse_dfp (const gdb_byte *, int, gdb_byte *);
+#endif
Index: dfp.c
===================================================================
RCS file: dfp.c
diff -N dfp.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dfp.c	21 Jun 2006 23:08:53 -0000
@@ -0,0 +1,104 @@
+/* Decimal floating point support for GDB.
+
+   Copyright 2006 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include "defs.h"
+#include "dfp.h"
+#include <ctype.h>
+
+/* The order of the following headers is important for making sure
+   decNumber structure is large enough to hold decimal128 digits.  */
+
+#include "decimal128.h"
+#include "decimal64.h"
+#include "decimal32.h"
+#include "decNumber.h"
+
+void
+reverse_dfp (const gdb_byte *valaddr, int len, gdb_byte *dec_val)
+{
+  int index;
+
+  for (index = 0; index < len; index++)
+    dec_val[index] = valaddr[len - index - 1];
+
+  return;
+}
+
+/* Convert deciaml type to its string representation.  LEN is the length
+   of the decimal type, 4 bytes for decimal32, 8 bytes for decimal64 and
+   16 bytes for decimal128.  */
+void
+decimal_to_string (const uint8_t *dec, int len, char *s)
+{
+  switch (len)
+    {
+      case 4:
+        decimal32ToString ((decimal32 *)dec, s);
+        return;
+      case 8:
+        decimal64ToString ((decimal64 *)dec, s);
+        return;
+      case 16:
+        decimal128ToString ((decimal128 *)dec, s);
+        return;
+      default:
+	error ("We don't support decimal number of %d bytes.", len);
+    }
+}
+
+void
+decimal_from_string (uint8_t *dec, int len, char *string)
+{
+  decNumber dn;
+  decContext set;
+  switch (len)
+    {
+      case 4:
+	decContextDefault (&set, DEC_INIT_DECIMAL32);
+	break;
+      case 8:
+	decContextDefault (&set, DEC_INIT_DECIMAL64);
+	break;
+      case 16:
+	decContextDefault (&set, DEC_INIT_DECIMAL128);
+	break;
+      default:
+	error ("We don't support decimal number of %d bytes.", len);
+    }
+
+  set.traps = 0;
+
+  decNumberFromString (&dn, string, &set);
+  switch (len)
+    {
+      case 4:
+	decimal32FromNumber ((decimal32 *)dec, &dn, &set);
+	return;
+      case 8:
+	decimal64FromNumber ((decimal64 *)dec, &dn, &set);
+	return;
+      case 16:
+	decimal128FromNumber ((decimal128 *)dec, &dn, &set);
+	return;
+      default:
+	error ("We don't support decimal number of %d bytes.", len);
+    }
+}
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.821
diff -u -r1.821 Makefile.in
--- Makefile.in	31 May 2006 15:14:36 -0000	1.821
+++ Makefile.in	21 Jun 2006 23:08:53 -0000
@@ -122,6 +122,12 @@
 BFD_SRC = $(srcdir)/$(BFD_DIR)
 BFD_CFLAGS = -I$(BFD_DIR) -I$(BFD_SRC)
 
+# Where is the decnumber library?  Typically in ../libdecnumber.
+LIBDECNUMBER_DIR = ../libdecnumber
+LIBDECNUMBER = $(LIBDECNUMBER_DIR)/libdecnumber.a
+LIBDECNUMBER_SRC = $(srcdir)/$(LIBDECNUMBER_DIR)
+LIBDECNUMBER_CFLAGS = -I$(LIBDECNUMBER_DIR) -I$(LIBDECNUMBER_SRC)
+
 # Where is the READLINE library?  Typically in ../readline.
 READLINE_DIR = ../readline
 READLINE = $(READLINE_DIR)/libreadline.a
@@ -348,7 +354,7 @@
 INTERNAL_CFLAGS_BASE = \
 	$(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
 	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
-	$(BFD_CFLAGS) $(INCLUDE_CFLAGS) \
+	$(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \
 	$(INTL_CFLAGS) $(ENABLE_CFLAGS)
 INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS)
 INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS)
@@ -371,10 +377,10 @@
 # LIBIBERTY appears twice on purpose.
 # If you have the Cygnus libraries installed,
 # you can use 'CLIBS=$(INSTALLED_LIBS)' 'CDEPS='
-INSTALLED_LIBS=-lbfd -lreadline -lopcodes -liberty \
+INSTALLED_LIBS=-lbfd -lreadline -lopcodes -liberty -ldecnumber \
 	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
 	-lintl -liberty
-CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY) \
+CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
 	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
 	$(LIBICONV) \
 	$(LIBIBERTY) $(WIN32LIBS)
@@ -605,6 +611,10 @@
 safe_ctype_h =  $(INCLUDE_DIR)/safe-ctype.h
 hashtab_h =	$(INCLUDE_DIR)/hashtab.h
 
+decimal128_h = $(LIBDECNUMBER_DIR)/decimal128.h
+decimal64_h = $(LIBDECNUMBER_DIR)/decimal64.h
+decimal32_h = $(LIBDECNUMBER_DIR)/decimal32.h
+
 #
 # $BUILD/ headers
 #
@@ -670,6 +680,7 @@
 disasm_h = disasm.h
 doublest_h = doublest.h $(floatformat_h)
 dummy_frame_h = dummy-frame.h
+dfp_h = dfp.h
 dwarf2expr_h = dwarf2expr.h
 dwarf2_frame_h = dwarf2-frame.h
 dwarf2loc_h = dwarf2loc.h
@@ -912,7 +923,7 @@
 	auxv.o \
 	bfd-target.o \
 	blockframe.o breakpoint.o findvar.o regcache.o \
-	charset.o disasm.o dummy-frame.o \
+	charset.o disasm.o dummy-frame.o dfp.o \
 	source.o value.o eval.o valops.o valarith.o valprint.o printcmd.o \
 	block.o symtab.o symfile.o symmisc.o linespec.o dictionary.o \
 	infcall.o \
@@ -1917,6 +1928,7 @@
 dummy-frame.o: dummy-frame.c $(defs_h) $(dummy_frame_h) $(regcache_h) \
 	$(frame_h) $(inferior_h) $(gdb_assert_h) $(frame_unwind_h) \
 	$(command_h) $(gdbcmd_h) $(gdb_string_h)
+dfp.o: dfp.c $(defs_h) $(dfp_h) $(decimal128_h) $(decimal64_h) $(decimal32_h)
 dve3900-rom.o: dve3900-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \
 	$(serial_h) $(inferior_h) $(command_h) $(gdb_string_h) $(regcache_h) \
 	$(mips_tdep_h)
@@ -2790,7 +2802,7 @@
 valprint.o: valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
 	$(value_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(language_h) \
 	$(annotate_h) $(valprint_h) $(floatformat_h) $(doublest_h) \
-	$(exceptions_h)
+	$(exceptions_h) $(dfp_h)
 value.o: value.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
 	$(value_h) $(gdbcore_h) $(command_h) $(gdbcmd_h) $(target_h) \
 	$(language_h) $(scm_lang_h) $(demangle_h) $(doublest_h) \


Here is the patch to add libdecnumber code into gdb top-level repository.  
I didn't figure out how to add a whole new directory into the cvs.  Anyone 
can help me on this?  I only attach the makefile change here:

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/Makefile.in,v
retrieving revision 1.244
diff -r1.244 Makefile.in
396a397,401
> @if libdecnumber
> HOST_LIB_PATH_libdecnumber = \
>   $$r/$(HOST_SUBDIR)/libdecnumber/.libs:$$r/$(HOST_SUBDIR)/prev-libdecnumber/.libs:
> @endif libdecnumber
> 


Regards
- Wu Zhou

On Thu, 22 Jun 2006, Wu Zhou wrote:

> Hello Daniel/all,
> 
> About one week ago, I said that I will rework my dfp patch based on libdecnumber.
> OK.  Here it is.  This post is about what it can support right now.  The
> testcase can tell easily about this.  The gdb patch will be posted in 
> another email.
> 
> The functions this patch provides are much the same as before.  But it is 
> more exensible because it is based on libdecnumber.  I list here what is 
> available now.  If you think any functionality is desirable, please tell 
> me.  I will try to add them in.
> 
> - for dfp constants, this patch supports two kind of representation: 
> scientific one and non-scientific one.  To input any dfp constants, you 
> need to add suffix to differentiate it from binary float: "df" for deciaml 
> float (32 bits), "dd" for deciaml double (64 bits), and "dl" for deciaml
> long (128 bits).  When printing dfp constants, it will strip the suffix.  
> 
> - it supports the displaying of dfp values in variables, struct, function 
> argument and also back trace.  Any more is needed?
> 
> - it support the negation operation (-dfp), assign operation (d1 = d2 or 
> d1 = -d2),
> 
> - it can handle finite dfp numbers, infinity (positive and negative), and 
> NaN (not a number).  
> 
> - it can also support the max, normalized min and subnormalized min well.
> 
> - we can't do conversion between binary float and decimal float right, or 
> between two different dfp types right now
> 
> Here goes the testcase.  Please review.  Any comment or suggestion is 
> highly appreciated.  
> 
> P.S: I am trying to make it self explanatory.  But if you think more 
> comment is needed in some place, feel free to tell me.
> 
> 2006-06-21  Wu Zhou  <woodzltc@cn.ibm.com>
> 
> 	* gdb.base/dfp-exprs.exp: New testcase to verify that gdb can
> 	handle dfp constants correctly.
> 	* gdb.base/dfp-test.c: New test file, used for dfp-test.exp.
> 	* gdb.base/dfp-test.exp: New testcase toverify that gdb can handle
> 	dfp related operation.
> 
> Index: gdb.base/dfp-exprs.exp
> ===================================================================
> RCS file: gdb.base/dfp-exprs.exp
> diff -N gdb.base/dfp-exprs.exp
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ gdb.base/dfp-exprs.exp	21 Jun 2006 21:00:23 -0000
> @@ -0,0 +1,88 @@
> +# Copyright (C) 2005 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +# 
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +# 
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
> +
> +# This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
> +
> +# This file is part of the gdb testsuite.  It contains test for evaluating 
> +# simple decimal floating point (DFP) expression.
> +
> +if $tracelevel then {
> +	strace $tracelevel
> +}
> +
> +proc test_dfp_literals_accepted {} {
> +
> +    # Test various dfp values, covering 32-bit, 64-bit and 128-bit ones
> +
> +    # _Decimal32 constants, which can support up to 7 digits
> +    gdb_test "p 1.2df" " = 1.2"
> +    gdb_test "p -1.2df" " = -1.2"
> +    gdb_test "p 1.234567df" " = 1.234567" 
> +    gdb_test "p -1.234567df" " = -1.234567"
> +    gdb_test "p 1234567.df" " = 1234567"
> +    gdb_test "p -1234567.df" " = -1234567"
> +
> +    gdb_test "p 1.2E1df" " = 12"
> +    gdb_test "p 1.2E10df" " = 1.2E\\+10"
> +    gdb_test "p 1.2E-10df" " = 1.2E-10"
> +
> +    # The largest exponent for 32-bit dfp value is 96.
> +    gdb_test "p 1.2E96df" " = 1.200000E\\+96"
> +
> +    # _Decimal64 constants, which can support up to 16 digits
> +    gdb_test "p 1.2dd" " = 1.2"
> +    gdb_test "p -1.2dd" " = -1.2"
> +    gdb_test "p 1.234567890123456dd" " = 1.234567890123456"
> +    gdb_test "p -1.234567890123456dd" " = -1.234567890123456"
> +    gdb_test "p 1234567890123456.dd" " = 1234567890123456"
> +    gdb_test "p -1234567890123456.dd" " = -1234567890123456"
> +
> +    gdb_test "p 1.2E1dd" " = 12"
> +    gdb_test "p 1.2E10dd" " = 1.2E\\+10"
> +    gdb_test "p 1.2E-10dd" " = 1.2E-10"
> +
> +    # The largest exponent for 64-bit dfp value is 384.
> +    gdb_test "p 1.2E384dd" " = 1.200000000000000E\\+384"
> +
> +    # _Decimal128 constants, which can support up to 34 digits
> +    gdb_test "p 1.2dl" " = 1.2"
> +    gdb_test "p -1.2dl" " = -1.2"
> +    gdb_test "p 1.234567890123456789012345678901234dl" " = 1.234567890123456789012345678901234"
> +    gdb_test "p -1.234567890123456789012345678901234dl" " = -1.234567890123456789012345678901234"
> +    gdb_test "p 1234567890123456789012345678901234.dl" " = 1234567890123456789012345678901234"
> +    gdb_test "p -1234567890123456789012345678901234.dl" " = -1234567890123456789012345678901234"
> +
> +    gdb_test "p 1.2E1dl" " = 12"
> +    gdb_test "p 1.2E10dl" " = 1.2E\\+10"
> +    gdb_test "p 1.2E-10dl" " = 1.2E-10"
> +
> +    # The largest exponent for 128-bit dfp value is 6144.
> +    gdb_test "p 1.2E6144dl" " = 1.200000000000000000000000000000000E\\+6144"  
> +}
> +
> +proc test_arithmetic_expressions {} {
> +
> +# Arithmetic operations for DFP types are not yet implemented in GDB.
> +
> +}
> +
> +# Start with a fresh gdb.
> +
> +gdb_exit
> +gdb_start
> +gdb_reinitialize_dir $srcdir/$subdir
> +
> +test_dfp_literals_accepted
> Index: gdb.base/dfp-test.c
> ===================================================================
> RCS file: gdb.base/dfp-test.c
> diff -N gdb.base/dfp-test.c
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ gdb.base/dfp-test.c	21 Jun 2006 21:00:23 -0000
> @@ -0,0 +1,95 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> +   Copyright 2006 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 2 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program; if not, write to the Free Software
> +   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
> +   02111-1307, USA.  */
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +volatile _Decimal32 d32;
> +volatile _Decimal64 d64;
> +volatile _Decimal128 d128;
> +
> +struct decstruct
> +{
> +  int int4;
> +  long long8;
> +  _Decimal32 dec32;
> +  _Decimal64 dec64;
> +  _Decimal128 dec128;
> +} ds;
> +
> +static _Decimal32
> +arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2,
> +         _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5)
> +{
> +  return arg0;
> +}
> +
> +static _Decimal64
> +arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2,
> +         _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5)
> +{
> +  return arg0;
> +}
> +
> +static _Decimal128
> +arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2,
> +         _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5)
> +{
> +  return arg0;
> +}
> +
> +int main()
> +{
> +  /* An finite 32-bits decimal floating point.  */
> +  d32 = 1.2345df;		/* Initialize d32.  */
> +
> +  /* Non-finite 32-bits decimal floating point: infinity and NaN.  */
> +  d32 = __builtin_infd32();	/* Positive infd32.  */
> +  d32 = -__builtin_infd32();	/* Negative infd32.  */
> +  d32 = __builtin_nand32("");
> +
> +  /* An finite 64-bits decimal floating point.  */
> +  d64 = 1.2345dd;		/* Initialize d64.  */
> +
> +  /* Non-finite 64-bits decimal floating point: infinity and NaN.  */
> +  d64 = __builtin_infd64();	/* Positive infd64.  */
> +  d64 = -__builtin_infd64();	/* Negative infd64.  */
> +  d64 = __builtin_nand64("");
> +
> +  /* An finite 128-bits decimal floating point.  */
> +  d128 = 1.2345dl;		/* Initialize d128.  */
> +
> +  /* Non-finite 128-bits decimal floating point: infinity and NaN.  */
> +  d128 = __builtin_infd128();	/* Positive infd128.  */
> +  d128 = -__builtin_infd128();	/* Negative infd128.  */
> +  d128 = __builtin_nand128("");
> +
> +  /* Functions with decimal floating point as parameter and return value.  */
> +  d32 = arg0_32 (0.1df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df);
> +  d64 = arg0_64 (0.1dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd);
> +  d128 = arg0_128 (0.1dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl);
> +
> +  ds.int4 = 1;
> +  ds.long8 = 2;
> +  ds.dec32 = 1.2345df;
> +  ds.dec64 = 1.2345dd;
> +  ds.dec128 = 1.2345dl;
> +
> +  return 0;	/* Exit point.  */
> +}
> Index: gdb.base/dfp-test.exp
> ===================================================================
> RCS file: gdb.base/dfp-test.exp
> diff -N gdb.base/dfp-test.exp
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ gdb.base/dfp-test.exp	21 Jun 2006 21:00:23 -0000
> @@ -0,0 +1,247 @@
> +# Copyright 2005 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
> +
> +#  This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
> +
> +# This file is part of the gdb testsuite.  It is intended to test that
> +# gdb could correctly hane decimal floating point introduced in IEEE 754R.
> +
> +proc d32_set_tests {} {
> +
> +    gdb_test "p d32=123.45df" " = 123.45"
> +    gdb_test "p d32=12345.df" " = 12345"
> +    gdb_test "p d32=12345.67df" " = 12345.67"
> +    gdb_test "p d32=1234567.df" " = 1234567"
> +
> +    gdb_test "p d32=1.234567E0df" " = 1.234567" 
> +    gdb_test "p d32=1.234567E10df" " = 1.234567E\\+10"
> +    gdb_test "p d32=1.234567E+96df" " = 1.234567E\\+96"
> +
> +    # Test that gdb could handle the max, normalized min and subnormalized min.
> +    gdb_test "p d32=9.999999E96df" " = 9.999999E\\+96"
> +    gdb_test "p d32=1.0E-95df" " = 1.0E\\-95"
> +    gdb_test "p d32=1.E-101df" " = 1E\\-101"
> +    gdb_test "p d32=0.000001E-95df" " = 1E\\-101"
> +
> +    # Test that gdb could detect coefficient/exponent out of range.
> +    # The coefficient out of range will be rounded to its nearest value.
> +    # And the exponent out of range will be handled as infinity.
> +    gdb_test "p d32=1.2345678df" " = 1.234568" "1.2345678 is rounded to 1.234568"
> +    gdb_test "p d32=1.0E-101df" " = 1E-101" "1.0E-101 is rounded to 1E-101"
> +    gdb_test "p d32=1.234567E+97df" " = Infinity" "1.234567E+97 is Infinity"
> +
> +    # Test that gdb could detect the errors in the string representation of _Decimal32
> +    gdb_test "p d32=12345.df" " = 12345" "12345. is an valid number"
> +    gdb_test "p d32=12345df" ".*Invalid number.*" "12345 is an invalid number"
> +    gdb_test "p d32=1.23Edf" " = NaN" "1.23E is NaN (not a number)"
> +    gdb_test "p d32=1.23E45Adf" " = NaN" "1.23E45A is NaN (not a number)"
> +}
> +
> +proc d64_set_tests {} {
> +
> +    gdb_test "p d64=123.45dd" " = 123.45"
> +    gdb_test "p d64=12345.dd" " = 12345"
> +    gdb_test "p d64=12345.67dd" " = 12345.67"
> +    gdb_test "p d64=1.234567890123456dd" " = 1.234567890123456"
> +
> +    gdb_test "p d64=1.234567890123456E10dd" " = 12345678901.23456"
> +    gdb_test "p d64=1.234567890123456E100dd" " = 1.234567890123456E\\+100"
> +    gdb_test "p d64=1.234567890123456E384dd" " = 1.234567890123456E\\+384"
> +
> +    # Test that gdb could handle the max, normalized min and subnormalized min.
> +    gdb_test "p d64=9.999999999999999E384dd" " = 9.999999999999999E\\+384"
> +    gdb_test "p d64=1.E-383dd" " = 1E\\-383"
> +    gdb_test "p d64=1.E-398dd" " = 1E\\-398"
> +    gdb_test "p d64=0.000000000000001E-383dd" " = 1E\\-398"
> +
> +    # Test that gdb could detect coefficient/exponent out of range.
> +    # The coefficient out of range will be rounded to its nearest value.
> +    # And the exponent out of range will be handled as infinity.
> +    gdb_test "p d64=1.2345678901234567dd" " = 1.234567890123457" "1.2345678901234567 is rounded to 1.234567890123457" 
> +    gdb_test "p d64=9.9999999999999999E384dd" " = Infinity" "d64=9.9999999999999999E384 is Infinity"
> +    gdb_test "p d64=1.234567890123456E385dd" " = Infinity" "d64=1.234567890123456E385 is Infinity"
> +
> +    # Test that gdb could detect the errors in the string representation of _Decimal64
> +    gdb_test "p d64=12345dd" ".*Invalid number.*" "12345dd is an invalid number"
> +    gdb_test "p d64=1.23Edd" " = NaN" "1.23E is NaN (not a number)"
> +    gdb_test "p d64=1.23E45Add" "= NaN" "1.23E45A is NaN (not a number)"
> +}
> +
> +proc d128_set_tests {} {
> +
> +    gdb_test "p d128=123.45dl" " = 123.45"
> +    gdb_test "p d128=12345.dl" " = 12345"
> +    gdb_test "p d128=12345.67dl" " = 12345.67"
> +    gdb_test "p d128=1.234567890123456789012345678901234dl" " = 1.234567890123456789012345678901234"
> +
> +    gdb_test "p d128=1.234567890123456E10dl" " = 12345678901.23456"
> +    gdb_test "p d128=1.234567890123456E100dl" " = 1.234567890123456E\\+100"
> +    gdb_test "p d128=1.234567890123456E1000dl" " = 1.234567890123456E\\+1000"
> +
> +    # Test that gdb could handle the max, normalized min and subnormalized min.
> +    gdb_test "p d128=9.999999999999999999999999999999999E6144dl" " = 9.999999999999999999999999999999999E\\+6144"
> +    gdb_test "p d128=1.E-6143dl" " = 1E\\-6143"
> +    gdb_test "p d128=1.E-6176dl" " = 1E\\-6176"
> +    gdb_test "p d128=0.000000000000000000000000000000001E-6143dl" " = 1E\\-6176"
> +
> +    # Test that gdb could detect coefficient/exponent out of range.
> +    # The coefficient out of range will be rounded to its nearest value.
> +    # And the exponent out of range will be handled as infinity.
> +    gdb_test "p d128=1.2345678901234567890123456789012345dl" "1.234567890123456789012345678901234" "1.2345678901234567890123456789012345 is rounded to 1.234567890123456789012345678901234"
> +    gdb_test "p d128=1.234567890123456E6145dl" "Infinity" "d128=1.234567890123456E6145 is Infinity"
> +
> +    # Test that gdb could detect the errors in the string representation of _Decimal128
> +    gdb_test "p d128=12345dl" ".*Invalid number.*" "12345dl is an invalid number"
> +    gdb_test "p d128=1.23Edl" " = NaN" "1.23E is NaN (not a number)"
> +    gdb_test "p d128=1.23E45Adl" "= NaN" "1.23E45A is NaN (not a number)"
> +}
> +
> +
> +if $tracelevel {
> +    strace $tracelevel
> +}
> +
> +set testfile "dfp-test"
> +set srcfile ${testfile}.c
> +set binfile ${objdir}/${subdir}/${testfile}
> +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
> +    untested "Couldn't compile ${srcfile}"
> +    return -1
> +}
> +
> +gdb_exit
> +gdb_start
> +gdb_reinitialize_dir $srcdir/$subdir
> +gdb_load ${binfile}
> +
> +if ![runto_main] then {
> +    perror "couldn't run to breakpoint"
> +    continue
> +}
> +
> +# Different tests on 32-bits decimal floating point, including the printing 
> +# of finite numbers, infinite and NaN, and also the setting of different
> +# decimal value.
> +
> +if [gdb_test "next" \
> +    ".*Positive infd32.*" \
> +    "next after initializing d32"] then { gdb_suppress_tests }
> +gdb_test "print d32" "1.2345" "d32 is initialized to 1.2345"
> +
> +if [gdb_test "next" \
> +    ".*Negative infd32.*" \
> +    "next after assigning builtin infinity to d32"] then { gdb_suppress_tests }
> +gdb_test "print d32" "Infinity" "d32 is positive Infinity"
> +
> +if [gdb_test "next" \
> +    ".*__builtin_nand32.*" \
> +    "next after assigning negative builtin infinity to d32"] then { gdb_suppress_tests }
> +gdb_test "print d32" "-Infinity" "d32 is negative Infinity"
> +
> +if [gdb_test "next" \
> +    ".*d64 = 1.2345.*" \
> +    "next after assigning builtin NaN to d32"] then { gdb_suppress_tests }
> +gdb_test "print d32" "NaN" "d32 is NaN"
> +
> +d32_set_tests 
> +
> +
> +# Different tests on 64-bits decimal floating point, including the display
> +# of finite number, infinite and NaN, and also the setting of different
> +# decimal value.
> +
> +if [gdb_test "next" \
> +    ".*Positive infd64.*" \
> +    "next after initializing d64"] then { gdb_suppress_tests }
> +gdb_test "print d64" "1.2345" "d64 is initialized to 1.2345"
> +
> +if [gdb_test "next" \
> +    ".*Negative infd64.*" \
> +    "next after assigning builtin infinity to d64"] then { gdb_suppress_tests }
> +gdb_test "print d64" "Infinity" "d64 is positive Infinity"
> +
> +if [gdb_test "next" \
> +    ".*__builtin_nand64.*" \
> +    "next after assigning negative builtin infinity to d64"] then { gdb_suppress_tests }
> +gdb_test "print d64" "-Infinity" "d64 is negative Infinity"
> +
> +if [gdb_test "next" \
> +    ".*d128 = 1.2345.*" \
> +    "next after assigning builtin NaN to d64"] then { gdb_suppress_tests }
> +gdb_test "print d64" "NaN" "d64 is NaN"
> +
> +d64_set_tests 
> +
> +
> +# Different tests on 128-bits decimal floating point, including the display
> +# of finite number, infinite and NaN, and also the setting of different
> +# decimal value.
> +
> +if [gdb_test "next" \
> +    ".*Positive infd128.*" \
> +    "next after initializing d128"] then { gdb_suppress_tests }
> +gdb_test "print d128" "1.2345" "d128 is initialized to 1.2345"
> +
> +d128_set_tests
> +
> +if [gdb_test "next" \
> +    ".*Negative infd128.*" \
> +    "next after assigning builtin infinity to d128"] then { gdb_suppress_tests }
> +gdb_test "print d128" "Infinity" "d128 is positive Infinity"
> +
> +if [gdb_test "next" \
> +    ".*__builtin_nand128.*" \
> +    "next after assigning negative builtin infinity to d128"] then { gdb_suppress_tests }
> +gdb_test "print d128" "-Infinity" "d128 is negative Infinity"
> +
> +if [gdb_test "next" \
> +    ".*arg0_32.*" \
> +    "next after assigning builtin NaN to d128"] then { gdb_suppress_tests }
> +gdb_test "print d128" "NaN" "d128 is NaN"
> +
> +# The following tests are intended to verify that gdb can correctly handle 
> +# DFP types in function arguments.
> +
> +gdb_breakpoint arg0_32
> +gdb_continue_to_breakpoint "entry to arg0_32"
> +gdb_test "backtrace" ".*arg0_32 \\(arg0=0.1, arg1=1.0, arg2=2.0, arg3=3.0, arg4=4.0, arg5=5.0\\).*" "backtrace at arg0_32"
> +
> +gdb_breakpoint arg0_64
> +gdb_continue_to_breakpoint "entry to arg0_64"
> +gdb_test "backtrace" ".*arg0_64 \\(arg0=0.1, arg1=1.0, arg2=2.0, arg3=3.0, arg4=4.0, arg5=5.0\\).*" "backtrace at arg0_64"
> +
> +gdb_breakpoint arg0_128
> +gdb_continue_to_breakpoint "entry to arg0_128"
> +gdb_test "backtrace" ".*arg0_128 \\(arg0=0.1, arg1=1.0, arg2=2.0, arg3=3.0, arg4=4.0, arg5=5.0\\).*" "backtrace at arg0_128"
> +
> +# The following tests are intended to verify that gdb can handle DFP types
> +# correctly in struct.
> +
> +gdb_breakpoint [gdb_get_line_number "Exit point"]
> +gdb_continue_to_breakpoint "Setting a decimal struct"
> +gdb_test "print ds.dec32" " = 1.2345"
> +gdb_test "print ds.dec64" " = 1.2345"
> +gdb_test "print ds.dec128" " = 1.2345"
> +
> +# The following tests are intended to verify that gdb can handle "d1=d2"
> +# and "d1=-d2" correctly.
> +
> +gdb_test "print ds.dec32=d32" " = 0.1"
> +gdb_test "print ds.dec64=d64" " = 0.1"
> +gdb_test "print ds.dec128=d128" " = 0.1"
> +gdb_test "print ds.dec32 = -d32" " = -0.1"
> +gdb_test "print ds.dec64 = -d64" " = -0.1"
> +gdb_test "print ds.dec128 = -d128" " = -0.1"
> 
> 
> Regards
> - Wu Zhou
> 


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

end of thread, other threads:[~2006-09-05  2:34 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-21 16:08 [RFC] decimal float point patch based on libdecnumber: gdb patch 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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox