annotate gcc/ada/debug_a.adb @ 138:fc828634a951

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:17:14 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- D E B U G _ A --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 with Atree; use Atree;
kono
parents:
diff changeset
27 with Debug; use Debug;
kono
parents:
diff changeset
28 with Sinfo; use Sinfo;
kono
parents:
diff changeset
29 with Sinput; use Sinput;
kono
parents:
diff changeset
30 with Output; use Output;
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 package body Debug_A is
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 Debug_A_Depth : Natural := 0;
kono
parents:
diff changeset
35 -- Output for the debug A flag is preceded by a sequence of vertical bar
kono
parents:
diff changeset
36 -- characters corresponding to the recursion depth of the actions being
kono
parents:
diff changeset
37 -- recorded (analysis, expansion, resolution and evaluation of nodes)
kono
parents:
diff changeset
38 -- This variable records the depth.
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 Max_Node_Ids : constant := 200;
kono
parents:
diff changeset
41 -- Maximum number of Node_Id values that get stacked
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 Node_Ids : array (1 .. Max_Node_Ids) of Node_Id;
kono
parents:
diff changeset
44 -- A stack used to keep track of Node_Id values for setting the value of
kono
parents:
diff changeset
45 -- Current_Error_Node correctly. Note that if we have more than 200
kono
parents:
diff changeset
46 -- recursion levels, we just don't reset the right value on exit, which
kono
parents:
diff changeset
47 -- is not crucial, since this is only for debugging.
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 -----------------------
kono
parents:
diff changeset
50 -- Local Subprograms --
kono
parents:
diff changeset
51 -----------------------
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 procedure Debug_Output_Astring;
kono
parents:
diff changeset
54 -- Outputs Debug_A_Depth number of vertical bars, used to preface messages
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 -------------------
kono
parents:
diff changeset
57 -- Debug_A_Entry --
kono
parents:
diff changeset
58 -------------------
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 procedure Debug_A_Entry (S : String; N : Node_Id) is
kono
parents:
diff changeset
61 begin
kono
parents:
diff changeset
62 -- Output debugging information if -gnatda flag set
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 if Debug_Flag_A then
kono
parents:
diff changeset
65 Debug_Output_Astring;
kono
parents:
diff changeset
66 Write_Str (S);
kono
parents:
diff changeset
67 Write_Str ("Node_Id = ");
kono
parents:
diff changeset
68 Write_Int (Int (N));
kono
parents:
diff changeset
69 Write_Str (" ");
kono
parents:
diff changeset
70 Write_Location (Sloc (N));
kono
parents:
diff changeset
71 Write_Str (" ");
kono
parents:
diff changeset
72 Write_Str (Node_Kind'Image (Nkind (N)));
kono
parents:
diff changeset
73 Write_Eol;
kono
parents:
diff changeset
74 end if;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 -- Now push the new element
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 -- Why is this done unconditionally???
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 Debug_A_Depth := Debug_A_Depth + 1;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 if Debug_A_Depth <= Max_Node_Ids then
kono
parents:
diff changeset
83 Node_Ids (Debug_A_Depth) := N;
kono
parents:
diff changeset
84 end if;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 -- Set Current_Error_Node only if the new node has a decent Sloc
kono
parents:
diff changeset
87 -- value, since it is for the Sloc value that we set this anyway.
kono
parents:
diff changeset
88 -- If we don't have a decent Sloc value, we leave it unchanged.
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 if Sloc (N) > No_Location then
kono
parents:
diff changeset
91 Current_Error_Node := N;
kono
parents:
diff changeset
92 end if;
kono
parents:
diff changeset
93 end Debug_A_Entry;
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 ------------------
kono
parents:
diff changeset
96 -- Debug_A_Exit --
kono
parents:
diff changeset
97 ------------------
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 procedure Debug_A_Exit (S : String; N : Node_Id; Comment : String) is
kono
parents:
diff changeset
100 begin
kono
parents:
diff changeset
101 Debug_A_Depth := Debug_A_Depth - 1;
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 -- We look down the stack to find something with a decent Sloc. (If
kono
parents:
diff changeset
104 -- we find nothing, just leave it unchanged which is not so terrible)
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 -- This seems nasty overhead for the normal case ???
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 for J in reverse 1 .. Integer'Min (Max_Node_Ids, Debug_A_Depth) loop
kono
parents:
diff changeset
109 if Sloc (Node_Ids (J)) > No_Location then
kono
parents:
diff changeset
110 Current_Error_Node := Node_Ids (J);
kono
parents:
diff changeset
111 exit;
kono
parents:
diff changeset
112 end if;
kono
parents:
diff changeset
113 end loop;
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 -- Output debugging information if -gnatda flag set
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 if Debug_Flag_A then
kono
parents:
diff changeset
118 Debug_Output_Astring;
kono
parents:
diff changeset
119 Write_Str (S);
kono
parents:
diff changeset
120 Write_Str ("Node_Id = ");
kono
parents:
diff changeset
121 Write_Int (Int (N));
kono
parents:
diff changeset
122 Write_Str (Comment);
kono
parents:
diff changeset
123 Write_Eol;
kono
parents:
diff changeset
124 end if;
kono
parents:
diff changeset
125 end Debug_A_Exit;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 --------------------------
kono
parents:
diff changeset
128 -- Debug_Output_Astring --
kono
parents:
diff changeset
129 --------------------------
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 procedure Debug_Output_Astring is
kono
parents:
diff changeset
132 Vbars : constant String := "|||||||||||||||||||||||||";
kono
parents:
diff changeset
133 -- Should be constant, removed because of GNAT 1.78 bug ???
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 begin
kono
parents:
diff changeset
136 if Debug_A_Depth > Vbars'Length then
kono
parents:
diff changeset
137 for I in Vbars'Length .. Debug_A_Depth loop
kono
parents:
diff changeset
138 Write_Char ('|');
kono
parents:
diff changeset
139 end loop;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 Write_Str (Vbars);
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 else
kono
parents:
diff changeset
144 Write_Str (Vbars (1 .. Debug_A_Depth));
kono
parents:
diff changeset
145 end if;
kono
parents:
diff changeset
146 end Debug_Output_Astring;
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 end Debug_A;