Message ID | 20220922164752.2566043-1-aldyh@redhat.com |
---|---|
State | Accepted, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp291785wrt; Thu, 22 Sep 2022 09:48:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6np1ptO2k4+ZlPfXgyYZa1yLKBNR4fsK8yrv48j2+O0Lb0OxT57R9A65sLDkcd8QBHp6L9 X-Received: by 2002:a17:906:8466:b0:77b:43e9:48b5 with SMTP id hx6-20020a170906846600b0077b43e948b5mr3595931ejc.254.1663865325776; Thu, 22 Sep 2022 09:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663865325; cv=none; d=google.com; s=arc-20160816; b=tuH7BAT2OIrAnNcQLaNa/uFxHixWKz26EwItazF1N/0uZPXPEPVwDPoPj9XCtr0c0Q aZ0y8Q/J/TNfDCh4NztglsiwTrlTd9h53fANwVnCU9c3pahZDHUb8mosangjiNfXeLrH 2fNmEfm+LLqhxjkK/e+cg0RF8Kuj/flntEPl6GRp9fDC9q7aTE/penGKxyzktDWY7S5X TPxclF0IjuiEGZUGz6MzB/iOZ1bUi/Py/Ae3vSqdKlIvY+j5Q6oXY4jRezuPqB6rXdf6 gU4pYo7k5uhc3ytFkia3syK6i9bwT9p4wiv2Z0+4W78qazIIag0jFnbGANj9UzqDf9x/ 48cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=oMI2gsL997SbVYZRNEES1fJRDR5XnWvZ466Cy6gapQw=; b=zy3sQDHn3ghwCumkRHQPF0VkW5jX0SY/SCYyUgbUUmXaKJiWlUUUPI7xkrXqQhXdbY 7KXS4HbKPklRLO0EkSv7mdCOchbYCJORzUg/ZtmmHXeMQfsJdyi8cQXH2KY5ur0k+XIo vsgYUAfTATbv38g/ZiYPGgwo5Qrh8zKQz0BCCgGQn+YDRzJ5lA96QqesKR4dWElTNQeI fZ3PLIL39g5CdctN/WHv38kZ1xLW8IlXO5DqQ2xf3V5z0880zOOirAb9z5T7T6znTjki SzzKH5PhyzVrs4NqktdDlqAxzuQ1R6DwGgfRD/+RWX37EHMAktF65vBWGthMsRjIQcom 7u6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=NWffQrEK; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v6-20020a50d586000000b0045249bc17eesi4890229edi.589.2022.09.22.09.48.45 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 09:48:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=NWffQrEK; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A12BE3857C59 for <ouuuleilei@gmail.com>; Thu, 22 Sep 2022 16:48:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A12BE3857C59 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663865324; bh=oMI2gsL997SbVYZRNEES1fJRDR5XnWvZ466Cy6gapQw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=NWffQrEKoDI4VZxTpU9wkOrb+OxhFvLcMLxvAW179Md1r8n+SawYws7qV5opIMZVq S/HothJrpPtaw2h4eilgVqslJe2X28BNoytTFzSGCN8jTy2eUy4aq3CCwMkwNdAdht yHOxDJcva1i+lkJ7ZAOZWtKX7pYDMtmX7Uz6zS9Y= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744689248125274359?= X-GMAIL-MSGID: =?utf-8?q?1744689248125274359?= |
Series |
Add debug functions for REAL_VALUE_TYPE.
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patches-check | success | Github commit url |
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,