Message ID | 20220922164752.2566043-1-aldyh@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C58803857C42 for <patchwork@sourceware.org>; Thu, 22 Sep 2022 16:48:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C58803857C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663865310; bh=oMI2gsL997SbVYZRNEES1fJRDR5XnWvZ466Cy6gapQw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=pXLIxegJ7iA67VMkuPuapAie5XPVmViS8Pn61g5erR+/vRm7EFeSJbNtNPIs13vO+ /mO8VoP+UhIJ6a96AZ194ULPLua90TEcbHEZXvaK4BImg5IQOoC6EZcOfyiKhNxtcf ZV811SbQRIbNNXgTTd6UrpluEklVq1O41Bs5hryU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 5114B3858D38 for <gcc-patches@gcc.gnu.org>; Thu, 22 Sep 2022 16:48:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5114B3858D38 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-by_2NGM0MtivL8x2svMrAQ-1; Thu, 22 Sep 2022 12:47:59 -0400 X-MC-Unique: by_2NGM0MtivL8x2svMrAQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 78F411C13950 for <gcc-patches@gcc.gnu.org>; Thu, 22 Sep 2022 16:47:59 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.141]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 163282166B26; Thu, 22 Sep 2022 16:47:58 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 28MGlujP2566089 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 22 Sep 2022 18:47:56 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 28MGluvc2566088; Thu, 22 Sep 2022 18:47:56 +0200 To: GCC patches <gcc-patches@gcc.gnu.org> Subject: [PATCH] Add debug functions for REAL_VALUE_TYPE. Date: Thu, 22 Sep 2022 18:47:52 +0200 Message-Id: <20220922164752.2566043-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Aldy Hernandez <aldyh@redhat.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
Add debug functions for REAL_VALUE_TYPE.
|
|
Commit Message
Aldy Hernandez
Sept. 22, 2022, 4:47 p.m. UTC
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(+)
Comments
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 >
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 > > >
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,