From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 7CC0F383D815 for ; Thu, 12 May 2022 12:40:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7CC0F383D815 Received: by mail-wr1-x42a.google.com with SMTP id j25so6062002wrc.9 for ; Thu, 12 May 2022 05:40:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=PaMAu6sGAVo47opFEwRSSpXu0NmuBuevqlJuKladAJE=; b=q25XDtnnxfAdgm/gli9rXrBL4DxRXV1ibltwrdYS2YzSx0b83DRgp/SECGC51pXrNV tPrqmiHTcW0Kg1KOwlcdBVmMZfTKHsadoant2HdDpuP4QxkVIsTx0JBt/KslcAoAFIh8 rdyugMYi1EK6+aPKCH/kPboA8kRqh1ZYYI9Y/FP0NsQbI8/zBq8Bn+DVHhNBSBamBqLL 5rwDxDs469rbYoj55QyPm4dcf826AAsLj8+V7wSzUIZSXdS/dESJbGDgqmTDrFeKLOOp m3Vg03rnjwG0mdtxTImp9u+agU6OsK4PsTkBumdsqmDlDUNpEziSvG1F3ZKHr5pzIplY HhqA== X-Gm-Message-State: AOAM5303p4jzY8CDoXygK9+hIzNl0IYARPQsx5qQAhjH+HDLkRvWL09e +CWnqLfNgSfUtr5ReSQNqBKGxQRtWxUn7g== X-Google-Smtp-Source: ABdhPJz1R53KNy+2iGC16UZUD9QQqv6LlwDTLVPfbxIAmHBWIfCEC0MgEyFkDZVgF8KhiRv1CvETHQ== X-Received: by 2002:a5d:6f16:0:b0:20c:60f8:c17 with SMTP id ay22-20020a5d6f16000000b0020c60f80c17mr27796643wrb.322.1652359216942; Thu, 12 May 2022 05:40:16 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id o42-20020a05600c512a00b003942a244ed2sm3335751wms.23.2022.05.12.05.40.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 05:40:16 -0700 (PDT) Date: Thu, 12 May 2022 12:40:15 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Restore double quotes in debug printouts Message-ID: <20220512124015.GA781209@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="vkogqOf2sHV7VnPd" Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_QUOTING 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2022 12:40:19 -0000 --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline A previous change in "Make debug printouts more robust" accidentally removed double quotes around identifiers in debug printouts. This patch restores those. So for example, we have: Prev_Entity = Node #10 N_Defining_Identifier "foo" (Entity_Id=795) and not: Prev_Entity = Node #10 N_Defining_Identifier foo (Entity_Id=795) This affects the output of -gnatdt, and certain calls normally done from gdb. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * namet.ads, namet.adb (Write_Name_For_Debug): Add Quote parameter to allow conditional addition of quotes. Note that some calls to Write_Name_For_Debug, for example for file names, shouldn't have quotes, as in some_package.adb:123:45. * treepr.adb (Print_Name): Add double quotes around the name using the above Quote parameters. --vkogqOf2sHV7VnPd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/namet.adb b/gcc/ada/namet.adb --- a/gcc/ada/namet.adb +++ b/gcc/ada/namet.adb @@ -1570,9 +1570,11 @@ package body Namet is -- Write_Name_For_Debug -- -------------------------- - procedure Write_Name_For_Debug (Id : Name_Id) is + procedure Write_Name_For_Debug (Id : Name_Id; Quote : String := "") is begin if Is_Valid_Name (Id) then + Write_Str (Quote); + declare Buf : Bounded_String (Max_Length => Natural (Length_Of_Name (Id))); begin @@ -1580,6 +1582,8 @@ package body Namet is Write_Str (Buf.Chars (1 .. Buf.Length)); end; + Write_Str (Quote); + elsif Id = No_Name then Write_Str (""); diff --git a/gcc/ada/namet.ads b/gcc/ada/namet.ads --- a/gcc/ada/namet.ads +++ b/gcc/ada/namet.ads @@ -433,9 +433,9 @@ package Namet is -- Like Write_Name, except that the name written is the decoded name, as -- described for Append_Decoded. - procedure Write_Name_For_Debug (Id : Name_Id); + procedure Write_Name_For_Debug (Id : Name_Id; Quote : String := ""); -- Like Write_Name, except it tries to be robust in the presence of invalid - -- data. + -- data, and valid names are surrounded by Quote. function Name_Entries_Count return Nat; -- Return current number of entries in the names table diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb --- a/gcc/ada/treepr.adb +++ b/gcc/ada/treepr.adb @@ -1142,7 +1142,7 @@ package body Treepr is procedure Print_Name (N : Name_Id) is begin if Phase = Printing then - Write_Name_For_Debug (N); + Write_Name_For_Debug (N, Quote => """"); end if; end Print_Name; --vkogqOf2sHV7VnPd--