]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Restore double quotes in debug printouts
authorBob Duff <duff@adacore.com>
Mon, 14 Feb 2022 21:00:55 +0000 (16:00 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 12 May 2022 12:38:42 +0000 (12:38 +0000)
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.

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.

gcc/ada/namet.adb
gcc/ada/namet.ads
gcc/ada/treepr.adb

index 7eb2f0eeba2433cdbff5a6f4e2fbfdf087f452a6..50dc783322b90a5a162d3172b391eb2f7c5eec51 100644 (file)
@@ -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>");
 
index 5342e5d58261606925926d01c4a3662293e45b73..11c88ef3b2d2da65d748a77ef84ad74d8e976313 100644 (file)
@@ -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
index dda500dc69478c72b888dee817e8bcf5e9c31e9d..4fd082a0e612637751543b037249e6a1c326d57f 100644 (file)
@@ -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;