From patchwork Thu May 12 12:40:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1630184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=AO6wquI3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KzX8z1f8Dz9sGJ for ; Thu, 12 May 2022 23:06:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0889B3839C43 for ; Thu, 12 May 2022 13:06:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0889B3839C43 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652360785; bh=PaMAu6sGAVo47opFEwRSSpXu0NmuBuevqlJuKladAJE=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=AO6wquI3yppIM+qvPJIx5A0LCKxPOkhOQrzsATiXEEmpV64PgrvQWtms87/TPPivg lQnJdpn80ysBnclrJil9mwOLlbYEHVZyp/4IC2Eq33vgJbDREf+NOgjxHl/44GB9T3 D9PHbEWw1ceLmKxi6l2mxrWaMqZnqKjU3XHQ/Sxw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 To: gcc-patches@gcc.gnu.org Subject: [Ada] Restore double quotes in debug printouts Message-ID: <20220512124015.GA781209@adacore.com> MIME-Version: 1.0 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-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Bob Duff Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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. 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;