* Fix cross-endian DFP for GDB
@ 2008-06-27 17:57 Joseph S. Myers
2008-06-27 18:18 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Joseph S. Myers @ 2008-06-27 17:57 UTC (permalink / raw)
To: gdb-patches
This patch fixes problems GDB has with decimal floating point when
host and target endianness differ. decimal_convert failed to convert
endianness. This patch fixes the following failures in a cross from
i686-pc-linux-gnu to powerpc-linux-gnu. OK to commit?
FAIL: gdb.base/dfp-exprs.exp: p (_Decimal128) 3.7df
FAIL: gdb.base/dfp-test.exp: p d32=9.999999E96df
FAIL: gdb.base/dfp-test.exp: p d64=9.999999999999999E384dd
FAIL: gdb.base/dfp-test.exp: p d128=1.234567890123456789012345678901234dl
FAIL: gdb.base/dfp-test.exp: p d128=9.999999999999999999999999999999999E6144dl
FAIL: gdb.base/dfp-test.exp: 1.2345678901234567890123456789012345 is rounded to 1.234567890123456789012345678901234
FAIL: gdb.base/dfp-test.exp: print ds.dec128 = ds.dec32
FAIL: gdb.base/printcmds.exp: printf "%DDf\n",1.234567890123456789012345678901234dl
FAIL: gdb.base/printcmds.exp: printf "%DDf\n",-1.234567890123456789012345678901234dl
FAIL: gdb.base/printcmds.exp: printf "%DDf\n",1234567890123456789012345678901234.dl
FAIL: gdb.base/printcmds.exp: printf "%DDf\n",-1234567890123456789012345678901234.dl
2008-06-27 Joseph Myers <joseph@codesourcery.com>
* dfp.c (decimal_convert): Call match_endianness before and after
conversion.
Index: dfp.c
===================================================================
RCS file: /cvs/src/src/gdb/dfp.c,v
retrieving revision 1.6
diff -u -p -r1.6 dfp.c
--- dfp.c 16 Jan 2008 16:16:44 -0000 1.6
+++ dfp.c 27 Jun 2008 17:27:20 -0000
@@ -395,7 +395,12 @@ decimal_convert (const gdb_byte *from, i
int len_to)
{
decNumber number;
+ gdb_byte dec[16];
- decimal_to_number (from, len_from, &number);
- decimal_from_number (&number, to, len_to);
+ match_endianness (from, len_from, dec);
+
+ decimal_to_number (dec, len_from, &number);
+ decimal_from_number (&number, dec, len_to);
+
+ match_endianness (dec, len_to, to);
}
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fix cross-endian DFP for GDB
2008-06-27 17:57 Fix cross-endian DFP for GDB Joseph S. Myers
@ 2008-06-27 18:18 ` Daniel Jacobowitz
2008-06-27 20:45 ` Joseph S. Myers
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-06-27 18:18 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: gdb-patches
On Fri, Jun 27, 2008 at 05:40:45PM +0000, Joseph S. Myers wrote:
> 2008-06-27 Joseph Myers <joseph@codesourcery.com>
>
> * dfp.c (decimal_convert): Call match_endianness before and after
> conversion.
Does promote_decimal have the same problem?
I'm wondering why the calls can't go in decimal_to_number /
decimal_from_number... (resp. decimal_to_string).
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fix cross-endian DFP for GDB
2008-06-27 18:18 ` Daniel Jacobowitz
@ 2008-06-27 20:45 ` Joseph S. Myers
2008-06-27 20:47 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Joseph S. Myers @ 2008-06-27 20:45 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
On Fri, 27 Jun 2008, Daniel Jacobowitz wrote:
> On Fri, Jun 27, 2008 at 05:40:45PM +0000, Joseph S. Myers wrote:
> > 2008-06-27 Joseph Myers <joseph@codesourcery.com>
> >
> > * dfp.c (decimal_convert): Call match_endianness before and after
> > conversion.
>
> Does promote_decimal have the same problem?
Both callers of promote_decimal call match_endianness beforehand. Thus
the promote_decimal interface is that it uses host endianness.
> I'm wondering why the calls can't go in decimal_to_number /
> decimal_from_number... (resp. decimal_to_string).
I imagine almost any choice of which set of functions use host endianness
and which use target endianness would work. Given that which use which
endianness isn't documented, and nor is an underlying design, I kept the
existing interface for what is passed to/from each function and did the
minimal change to make it work.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fix cross-endian DFP for GDB
2008-06-27 20:45 ` Joseph S. Myers
@ 2008-06-27 20:47 ` Daniel Jacobowitz
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-06-27 20:47 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: gdb-patches
On Fri, Jun 27, 2008 at 07:57:34PM +0000, Joseph S. Myers wrote:
> On Fri, 27 Jun 2008, Daniel Jacobowitz wrote:
>
> > On Fri, Jun 27, 2008 at 05:40:45PM +0000, Joseph S. Myers wrote:
> > > 2008-06-27 Joseph Myers <joseph@codesourcery.com>
> > >
> > > * dfp.c (decimal_convert): Call match_endianness before and after
> > > conversion.
> >
> > Does promote_decimal have the same problem?
>
> Both callers of promote_decimal call match_endianness beforehand. Thus
> the promote_decimal interface is that it uses host endianness.
Patch is OK then.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-06-27 20:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-27 17:57 Fix cross-endian DFP for GDB Joseph S. Myers
2008-06-27 18:18 ` Daniel Jacobowitz
2008-06-27 20:45 ` Joseph S. Myers
2008-06-27 20:47 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox