public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Restore double quotes in debug printouts
@ 2022-05-12 12:40 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-12 12:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bob Duff

[-- Attachment #1: Type: text/plain, Size: 817 bytes --]

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.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1736 bytes --]

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 ("<No_Name>");
 


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;
 



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-12 12:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 12:40 [Ada] Restore double quotes in debug printouts Pierre-Marie de Rodat

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).