This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC][00/19] Target FP: Precise target floating-point emulation


[RFC][00/19] Target FP: Precise target floating-point emulation

GDB currently performs all floating-point operations (arithmetic, conversion,
printing and scanning) using the largest standard host floating-point type
(typedef'd as DOUBLEST).

While this used to be mostly OK for typical native debugging sessions
(since the host DOUBLEST is large enough to faithfully represent all
target data types) -- except possibly for some rounding differences --,
this can cause serious issues if that assumption doesn't hold:

- When remote debugging a target that has a data type larger than
  the host DOUBLEST, e.g. "long double" on s390 is IEEE-128, which
  cannot be represented in a DOUBLEST on a x86 host.

- Even in native debugging, if there is some non-standard type that
  does not fit into "long double", e.g. __float128 on x86 and ppc64.

This patch series addresses this problem by converting GDB to perform
all floating-operations by precisely emulation target arithmetic,
using the MPFR library.

In general, the idea of the patch series is to completely eliminate
DOUBLEST from the GDB source base, and instead hold all floating-point
values always in target binary format in a byte buffer.  A new file
target-float.{c,h} then implements all required operations on those
byte buffers.

Note that this is very similar to how GDB today already handles
*decimal* floating-point values.  In fact, the new target-float
operations support both binary and decimal types with the same
interface, which will allow to consolidate most handling of BFP
and DFP throughout GDB into single FP code paths.

Once this refactoring is complete, the only remaining use of DOUBLEST
will be in target-float.c, where it can then be replaced by MPFR.
(Use of MPFR is still optional, with a fall-back to the old DOUBLEST
code if MPFR is not available.  We may want to re-think this and
make MPFR required --- it should be available everywhere where GDB
can be built today.)

The patch series is laid out as follows:

00-02: Some preliminary clean up of binary FP handling.
03:    Some preliminary clean up of decimal FP handling.
05-07: Simplify and fix binary FP printing.
08:    Remove DOUBLEST from expression parsing and binary FP scanning.
09-12: Introduce target-float.{c,h} and move operations there.
13-14: Remove some remaining uses of DOUBLEST in the code base.
15-17: Final (trival) clean up patches.
18:    Remove doublest.{c,h} and dfp.{c,h}.
19:    Switch target-float.c to use MPFR if present.

Any comments welcome, in particular from the affected target and
language maintainers!

Tested by building with --enable-targets=all and running the test
suite without regressions on x86_64-linux, powerpc64le-linux,
and s390x-linux.

Bye,
Ulrich


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]