]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add debug functions for REAL_VALUE_TYPE.
authorAldy Hernandez <aldyh@redhat.com>
Thu, 22 Sep 2022 16:03:16 +0000 (18:03 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Fri, 23 Sep 2022 08:52:20 +0000 (10:52 +0200)
We currently have no way of dumping REAL_VALUE_TYPEs when debugging.

Tested on a gdb session examining the real value 10.0:

(gdb) p min
$9 = {cl = 1, decimal = 0, sign = 0, signalling = 0, canonical = 0, uexp = 4, sig = {0, 0, 11529215046068469760}}
(gdb) p debug (min)
0x0.ap+4

gcc/ChangeLog:

* real.cc (debug): New.

gcc/real.cc

index 73bbac645d9a8649056774b3eb99bcae4b080388..aae7c335d595e142fbb5988b5abf3b88033ba8c1 100644 (file)
@@ -1900,6 +1900,14 @@ real_to_decimal (char *str, const REAL_VALUE_TYPE *r_orig, size_t buf_size,
                            digits, crop_trailing_zeros, VOIDmode);
 }
 
+DEBUG_FUNCTION void
+debug (const REAL_VALUE_TYPE &r)
+{
+  char s[60];
+  real_to_hexadecimal (s, &r, sizeof (s), 0, 1);
+  fprintf (stderr, "%s\n", s);
+}
+
 /* Render R as a hexadecimal floating point constant.  Emit DIGITS
    significant digits in the result, bounded by BUF_SIZE.  If DIGITS is 0,
    choose the maximum for the representation.  If CROP_TRAILING_ZEROS,