public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add debug functions for REAL_VALUE_TYPE.
@ 2022-09-22 16:47 Aldy Hernandez
  2022-09-23  6:54 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Aldy Hernandez @ 2022-09-22 16:47 UTC (permalink / raw)
  To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez

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

OK for trunk?

gcc/ChangeLog:

	* real.cc (debug): New.
---
 gcc/real.cc | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gcc/real.cc b/gcc/real.cc
index 73bbac645d9..a31b256a47b 100644
--- a/gcc/real.cc
+++ b/gcc/real.cc
@@ -1900,6 +1900,22 @@ 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);
+}
+
+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,
-- 
2.37.1


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

* Re: [PATCH] Add debug functions for REAL_VALUE_TYPE.
  2022-09-22 16:47 [PATCH] Add debug functions for REAL_VALUE_TYPE Aldy Hernandez
@ 2022-09-23  6:54 ` Richard Biener
  2022-09-23  7:01   ` Aldy Hernandez
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2022-09-23  6:54 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: GCC patches

On Thu, Sep 22, 2022 at 6:48 PM Aldy Hernandez via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> 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
>
> OK for trunk?

I'd say the reference taking variant is enough (just remember to do
debug (*val)),
but OK (maybe simplify the pointer variant by forwarding instead of duplicating)

Richard.

>
> gcc/ChangeLog:
>
>         * real.cc (debug): New.
> ---
>  gcc/real.cc | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/gcc/real.cc b/gcc/real.cc
> index 73bbac645d9..a31b256a47b 100644
> --- a/gcc/real.cc
> +++ b/gcc/real.cc
> @@ -1900,6 +1900,22 @@ 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);
> +}
> +
> +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,
> --
> 2.37.1
>

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

* Re: [PATCH] Add debug functions for REAL_VALUE_TYPE.
  2022-09-23  6:54 ` Richard Biener
@ 2022-09-23  7:01   ` Aldy Hernandez
  0 siblings, 0 replies; 3+ messages in thread
From: Aldy Hernandez @ 2022-09-23  7:01 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC patches

On Fri, Sep 23, 2022 at 8:54 AM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Thu, Sep 22, 2022 at 6:48 PM Aldy Hernandez via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > 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
> >
> > OK for trunk?
>
> I'd say the reference taking variant is enough (just remember to do
> debug (*val)),

I added the pointer one because all of real.cc takes pointers
argument, but yeah...let's just nuke the pointer variant.  I hate that
we have various variants in VRP (my fault).

Thanks.
Aldy

> but OK (maybe simplify the pointer variant by forwarding instead of duplicating)
>
> Richard.
>
> >
> > gcc/ChangeLog:
> >
> >         * real.cc (debug): New.
> > ---
> >  gcc/real.cc | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> >
> > diff --git a/gcc/real.cc b/gcc/real.cc
> > index 73bbac645d9..a31b256a47b 100644
> > --- a/gcc/real.cc
> > +++ b/gcc/real.cc
> > @@ -1900,6 +1900,22 @@ 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);
> > +}
> > +
> > +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,
> > --
> > 2.37.1
> >
>


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

end of thread, other threads:[~2022-09-23  7:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22 16:47 [PATCH] Add debug functions for REAL_VALUE_TYPE Aldy Hernandez
2022-09-23  6:54 ` Richard Biener
2022-09-23  7:01   ` Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).