Skip to content

Commit

Permalink
[Ada] Restore double quotes in debug printouts
Browse files Browse the repository at this point in the history
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 gcc-mirror#10 N_Defining_Identifier "foo" (Entity_Id=795)

and not:

       Prev_Entity = Node gcc-mirror#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.
  • Loading branch information
bobduff authored and pmderodat committed May 12, 2022
1 parent e280641 commit 0b46066
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion gcc/ada/namet.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1570,16 +1570,20 @@ 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
Append (Buf, Id);
Write_Str (Buf.Chars (1 .. Buf.Length));
end;

Write_Str (Quote);

elsif Id = No_Name then
Write_Str ("<No_Name>");

Expand Down
4 changes: 2 additions & 2 deletions gcc/ada/namet.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gcc/ada/treepr.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 0b46066

Please sign in to comment.