Add an UNSPEC_PROLOGUE_USE to prevent the link register from being considered dead.
[official-gcc.git] / gcc / ada / debug.adb
blobd883e2d0251eb9cad889764b03846cfeaaeb8729
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- D E B U G --
6 -- --
7 -- B o d y --
8 -- --
9 -- --
10 -- Copyright (C) 1992-2002 Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
29 -- --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 -- --
33 ------------------------------------------------------------------------------
35 package body Debug is
37 ---------------------------------
38 -- Summary of Debug Flag Usage --
39 ---------------------------------
41 -- Debug flags for compiler (GNAT1 and GNATF)
43 -- da Generate messages tracking semantic analyzer progress
44 -- db Show encoding of type names for debug output
45 -- dc List names of units as they are compiled
46 -- dd Dynamic allocation of tables messages generated
47 -- de List the entity table
48 -- df Full tree/source print (includes withed units)
49 -- dg Print source from tree (generated code only)
50 -- dh Generate listing showing loading of name table hash chains
51 -- di Generate messages for visibility linking/delinking
52 -- dj Suppress "junk null check" for access parameter values
53 -- dk Generate GNATBUG message on abort, even if previous errors
54 -- dl Generate unit load trace messages
55 -- dm Allow VMS features even if not OpenVMS version
56 -- dn Generate messages for node/list allocation
57 -- do Print source from tree (original code only)
58 -- dp Generate messages for parser scope stack push/pops
59 -- dq No auto-alignment of small records
60 -- dr Generate parser resynchronization messages
61 -- ds Print source from tree (including original and generated stuff)
62 -- dt Print full tree
63 -- du Uncheck categorization pragmas
64 -- dv Output trace of overload resolution
65 -- dw Print trace of semantic scope stack
66 -- dx Force expansion on, even if no code being generated
67 -- dy Print tree of package Standard
68 -- dz Print source of package Standard
70 -- dA All entities included in representation information output
71 -- dB Output debug encoding of type names and variants
72 -- dC
73 -- dD Delete elaboration checks in inner level routines
74 -- dE Apply elaboration checks to predefined units
75 -- dF Front end data layout enabled.
76 -- dG
77 -- dH Hold (kill) call to gigi
78 -- dI Inhibit internal name numbering in gnatG listing
79 -- dJ Output debugging trace info for JGNAT (Java VM version of GNAT)
80 -- dK Kill all error messages
81 -- dL Output trace information on elaboration checking
82 -- dM
83 -- dN Do not generate file/line exception messages
84 -- dO Output immediate error messages
85 -- dP Do not check for controlled objects in preelaborable packages
86 -- dQ
87 -- dR Bypass check for correct version of s-rpc
88 -- dS Never convert numbers to machine numbers in Sem_Eval
89 -- dT Convert to machine numbers only for constant declarations
90 -- dU Enable garbage collection of unreachable entities
91 -- dV Enable viewing of all symbols in debugger
92 -- dW
93 -- dX Enable Frontend ZCX even when it is not supported
94 -- dY
95 -- dZ
97 -- d1 Error msgs have node numbers where possible
98 -- d2 Eliminate error flags in verbose form error messages
99 -- d3 Dump bad node in Comperr on an abort
100 -- d4 Inhibit automatic krunch of predefined library unit files
101 -- d5 Debug output for tree read/write
102 -- d6 Default access unconstrained to thin pointers
103 -- d7 Do not output version & file time stamp in -gnatv or -gnatl mode
104 -- d8 Force opposite endianness in packed stuff
105 -- d9
107 -- Debug flags for binder (GNATBIND)
109 -- da
110 -- db
111 -- dc List units as they are chosen
112 -- dd
113 -- de Elaboration dependencies including system units
114 -- df
115 -- dg
116 -- dh
117 -- di
118 -- dj
119 -- dk
120 -- dl
121 -- dm
122 -- dn List details of manipulation of Num_Pred values
123 -- do
124 -- dp
125 -- dq
126 -- dr
127 -- ds
128 -- dt
129 -- du List units as they are acquired
130 -- dv
131 -- dw
132 -- dx
133 -- dy
134 -- dz
136 -- d1
137 -- d2
138 -- d3
139 -- d4
140 -- d5
141 -- d6
142 -- d7
143 -- d8
144 -- d9
146 -- Debug flags used in package Make and its clients (e.g. GNATMAKE)
148 -- da
149 -- db
150 -- dc
151 -- dd
152 -- de
153 -- df
154 -- dg
155 -- dh
156 -- di
157 -- dj
158 -- dk
159 -- dl
160 -- dm
161 -- dn
162 -- do
163 -- dp Prints the contents of the Q used by Make.Compile_Sources
164 -- dq Prints source files as they are enqueued and dequeued
165 -- dr
166 -- ds
167 -- dt
168 -- du List units as their ali files are acquired
169 -- dv
170 -- dw Prints the list of units withed by the unit currently explored
171 -- dx
172 -- dy
173 -- dz
175 -- d1
176 -- d2
177 -- d3
178 -- d4
179 -- d5
180 -- d6
181 -- d7
182 -- d8
183 -- d9
185 --------------------------------------------
186 -- Documentation for Compiler Debug Flags --
187 --------------------------------------------
189 -- da Generate messages tracking semantic analyzer progress. A message
190 -- is output showing each node as it gets analyzed, expanded,
191 -- resolved, or evaluated. This option is useful for finding out
192 -- exactly where a bomb during semantic analysis is occurring.
194 -- dA Normally the output from -gnatR excludes private types and all
195 -- internal entities. This debug flag causes representation info
196 -- for these entities to be output as well.
198 -- db In Exp_Dbug, certain type names are encoded to include debugging
199 -- information. This debug switch causes lines to be output showing
200 -- the encodings used.
202 -- dc List names of units as they are compiled. One line of output will
203 -- be generated at the start of compiling each unit (package or
204 -- subprogram).
206 -- dd Dynamic allocation of tables messages generated. Each time a
207 -- table is reallocated, a line is output indicating the expansion.
209 -- dD Delete new elaboration checks. This flag causes GNAT to return
210 -- to the 3.13a elaboration semantics, and to suppress the fixing
211 -- of two bugs. The first is in the context of inner routines in
212 -- dynamic elaboration mode, when the subprogram we are in was
213 -- called at elaboration time by a unit that was also compiled with
214 -- dynamic elaboration checks. In this case, if A calls B calls C,
215 -- and all are in different units, we need an elaboration check at
216 -- each call. These nested checks were only put in recently (see
217 -- version 1.80 of Sem_Elab) and we provide this debug flag to
218 -- revert to the previous behavior in case of regressions. The
219 -- other behavior reverted by this flag is the treatment of the
220 -- Elaborate_Body pragma in static elaboration mode. This used to
221 -- be treated as not needing elaboration checking, but in fact in
222 -- general Elaborate_All is still required because of nested calls.
224 -- de List the entity table
226 -- df Full tree/source print (includes withed units). Normally the tree
227 -- output (dt) or recreated source output (dg,do,ds) includes only
228 -- the main unit. If df is set, then the output in either case
229 -- includes all compiled units (see also dg,do,ds,dt). Note that to
230 -- be effective, this swich must be used in combination with one or
231 -- more of dt, dg, do or ds.
233 -- dF Front end data layout enabled. Normally front end data layout
234 -- is only enabled if the target parameter Backend_Layout is False.
235 -- This debugging switch enables it unconditionally.
237 -- dg Print the source recreated from the generated tree. In the case
238 -- where the tree has been rewritten this output includes only the
239 -- generated code, not the original code (see also df,do,ds,dz).
240 -- This flag differs from -gnatG in that the output also includes
241 -- non-source generated null statements, and freeze nodes, which
242 -- are normally omitted in -gnatG mode.
244 -- dh Generates a table at the end of a compilation showing how the hash
245 -- table chains built by the Namet package are loaded. This is useful
246 -- in ensuring that the hashing algorithm (in Namet.Hash) is working
247 -- effectively with typical sets of program identifiers.
249 -- dH Inhibit call to gigi. This is useful for testing front end data
250 -- layout, and may be useful in other debugging situations where
251 -- you do not want gigi to intefere with the testing.
253 -- di Generate messages for visibility linking/delinking
255 -- dj Suppress "junk null check" for access parameters. This flag permits
256 -- Ada programs to pass null parameters to access parameters, and to
257 -- explicitly check such access values against the null literal.
258 -- Neither of these is valid Ada, but both were allowed in versions of
259 -- GNAT before 3.10, so this switch can ease the transition process.
261 -- dJ Generate debugging trace output for the JGNAT back end. This
262 -- consists of symbolic Java Byte Code sequences for all generated
263 -- classes plus additional information to indicate local variables
264 -- and methods.
266 -- dk Immediate kill on abort. Normally on an abort (i.e. a call to
267 -- Comperr.Compiler_Abort), the GNATBUG message is not given if
268 -- there is a previous error. This debug switch bypasses this test
269 -- and gives the message unconditionally (useful for debugging).
271 -- dK Kill all error messages. This debug flag suppresses the output
272 -- of all error messages. It is used in regression tests where the
273 -- error messages are target dependent and irrelevant.
275 -- dl Generate unit load trace messages. A line of traceback output is
276 -- generated each time a request is made to the library manager to
277 -- load a new unit.
279 -- dm Some features are permitted only in OpenVMS ports of GNAT (e.g.
280 -- the specification of passing by descriptor). Normally any use
281 -- of these features will be flagged as an error, but this debug
282 -- flag allows acceptance of these features in non OpenVMS ports.
283 -- Of course they may not have any useful effect, and in particular
284 -- attempting to generate code with this flag set may blow up.
285 -- The flag also forces the use of 64-bits for Long_Integer.
287 -- dn Generate messages for node/list allocation. Each time a node or
288 -- list header is allocated, a line of output is generated. Certain
289 -- other basic tree operations also cause a line of output to be
290 -- generated. This option is useful in seeing where the parser is
291 -- blowing up.;
293 -- dN Do not generate file/line exception messages. Normally we do the
294 -- explicit generation of these messages, but since these can only
295 -- be disabled using pragma Discard_Names, this switch may be useful.
297 -- do Print the source recreated from the generated tree. In the case
298 -- where the tree has been rewritten, this output includes only the
299 -- original code, not the generated code (see also df,dg,ds,dz).
301 -- dp Generate messages for parser scope stack push/pops. A line of
302 -- output by the parser each time the parser scope stack is either
303 -- pushed or popped. Useful in debugging situations where the
304 -- parser scope stack ends up incorrectly synchronized
306 -- dq In layout version 1.38, 2002/01/12, a circuit was implemented
307 -- to give decent default alignment to short records that had no
308 -- specific alignment set. This debug option restores the previous
309 -- behavior of giving such records poor alignments, typically 1.
310 -- This may be useful in dealing with transition.
312 -- dr Generate parser resynchronization messages. Normally the parser
313 -- resynchronizes quietly. With this debug option, two messages
314 -- are generated, one when the parser starts a resynchronization
315 -- skip, and another when it resumes parsing. Useful in debugging
316 -- inadequate error recovery situations.
318 -- ds Print the source recreated from the generated tree. In the case
319 -- where the tree has been rewritten this output includes both the
320 -- generated code and the original code with the generated code
321 -- being enlosed in curly brackets (see also df,do,ds,dz)
323 -- dt Print full tree. The generated tree is output (see also df,dy)
325 -- du Uncheck categorization pragmas. This debug switch causes the
326 -- categorization pragmas (Pure, Preelaborate etc) to be ignored
327 -- so that normal checks are not made (this is particularly useful
328 -- for adding temporary debugging code to units that have pragmas
329 -- that are inconsistent with the debugging code added.
331 -- dw Write semantic scope stack messages. Each time a scope is created
332 -- or removed, a message is output (see the Sem_Ch8.New_Scope and
333 -- Sem_Ch8.Pop_Scope subprograms).
335 -- dx Force expansion on, even if no code being generated. Normally the
336 -- expander is inhibited if no code is generated. This switch forces
337 -- expansion to proceed normally even if the backend is not being
338 -- called. This is particularly useful for debugging purposes when
339 -- using the front-end only version of the compiler (which normally
340 -- would never do any expansion).
342 -- dy Print tree of package Standard. Normally the tree print out does
343 -- not include package Standard, even if the -df switch is set. This
344 -- switch forces output of the internal tree built for Standard.
346 -- dz Print source of package Standard. Normally the source print out
347 -- does not include package Standard, even if the -df switch is set.
348 -- This switch forces output of the source recreated from the internal
349 -- tree built for Standard.
351 -- dA Forces output of representation information, including full
352 -- information for all internal type and object entities, as well
353 -- as all user defined type and object entities.
355 -- dB Output debug encodings for types and variants. See Exp_Dbug for
356 -- exact form of the generated output.
358 -- dE Apply compile time elaboration checking for with relations between
359 -- predefined units. Normally no checks are made (it seems that at
360 -- least on the SGI, such checks run into trouble).
362 -- dI Inhibit internal name numbering in gnatDG listing. For internal
363 -- names of the form <uppercase-letters><digits><suffix>, the output
364 -- will be modified to <uppercase-letters>...<suffix>. This is used
365 -- in the fixed bugs run to minimize system and version dependency
366 -- in filed -gnatDG output.
368 -- dL Output trace information on elaboration checking. This debug
369 -- switch causes output to be generated showing each call or
370 -- instantiation as it is checked, and the progress of the recursive
371 -- trace through calls at elaboration time.
373 -- dO Output immediate error messages. This causes error messages to
374 -- be output as soon as they are generated (disconnecting several
375 -- circuits for improvement of messages, deletion of duplicate
376 -- messages etc). Useful to diagnose compiler bombs caused by
377 -- erroneous handling of error situations
379 -- dP Do not check for controlled objects in preelaborable packages.
380 -- RM 10.2.1(9) forbids the use of library level controlled objects
381 -- in preelaborable packages, but this restriction is a huge pain,
382 -- especially in the predefined library units.
384 -- dR Bypass the check for a proper version of s-rpc being present
385 -- to use the -gnatz? switch. This allows debugging of the use
386 -- of stubs generation without needing to have GLADE (or some
387 -- other PCS installed).
389 -- dS Omit conversion of fpt numbers to exact machine numbers in
390 -- non-static evaluation contexts (see Check_Non_Static_Context).
391 -- This is intended for testing out timing problems with this
392 -- conversion circuit.
394 -- dT Similar to dS, but omits the conversions only in the case where
395 -- the parent is not a constant declaration.
397 -- dU Enable garbage collection of unreachable entities. This enables
398 -- both the reachability analysis and changing the Is_Public and
399 -- Is_Eliminated flags.
401 -- dV Enable viewing of all symbols in debugger. Causes debug information
402 -- to be generated for all symbols, including internal symbols. This
403 -- is enabled by default for -gnatD, but this switch allows this to
404 -- be enabled without generating modified source files. Note that the
405 -- use of -gnatdV ensures in the dwarf/elf case that all symbols that
406 -- are present in the elf tables are also in the dwarf tables (which
407 -- seems to be required by some tools).
409 -- dX Enable frontend ZCX even when it is not supported. Equivalent to
410 -- -gnatZ but without verifying that System.Front_End_ZCX_Support
411 -- is set. This causes the front end to generate suitable tables
412 -- for ZCX handling even when the runtime cannot handle ZCX. This
413 -- is used for testing the front end for correct ZCX operation, and
414 -- in particular is useful for multi-target testing.
416 -- d1 Error msgs have node numbers where possible. Normally error
417 -- messages have only source locations. This option is useful when
418 -- debugging errors caused by expanded code, where the source location
419 -- does not give enough information.
421 -- d2 Suppress output of the error position flags for verbose form error
422 -- messages. The messages are still interspersed in the listing, but
423 -- without any error flags or extra blank lines. Also causes an extra
424 -- <<< to be output at the right margin. This is intended to be the
425 -- easiest format for checking conformance of ACVC B tests.
427 -- d3 Causes Comperr to dump the contents of the node for which an abort
428 -- was detected (normally only the Node_Id of the node is output).
430 -- d4 Inhibits automatic krunching of predefined library unit file names.
431 -- Normally, as described in the spec of package Krunch, such files
432 -- are automatically krunched to 8 characters, with special treatment
433 -- of the prefixes Ada, System, and Interfaces. Setting this debug
434 -- switch disables this special treatment.
436 -- d6 Normally access-to-unconstrained-array types are represented
437 -- using fat (double) pointers. Using this debug flag causes them
438 -- to default to thin. This can be used to test the performance
439 -- implications of using thin pointers, and also to test that the
440 -- compiler functions correctly with this choice.
442 -- d7 Normally a -gnatl or -gnatv listing includes the time stamp
443 -- of the source file. This debug flag suppresses this output,
444 -- and also suppresses the message with the version number.
445 -- This is useful in certain regression tests.
447 -- d8 This forces the packed stuff to generate code assuming the
448 -- opposite endianness from the actual correct value. Useful in
449 -- testing out code generation from the packed routines.
451 ------------------------------------------
452 -- Documentation for Binder Debug Flags --
453 ------------------------------------------
455 -- dc List units as they are chosen. As units are selected for addition to
456 -- the elaboration order, a line of output is generated showing which
457 -- unit has been selected.
459 -- de Similar to the effect of -e (output complete list of elaboration
460 -- dependencies) except that internal units are included in the
461 -- listing.
463 -- dn List details of manipulation of Num_Pred values during execution of
464 -- the algorithm used to determine a correct order of elaboration. This
465 -- is useful in diagnosing any problems in its behavior.
467 -- du List unit name and file name for each unit as it is read in
469 ------------------------------------------------------------
470 -- Documentation for the Debug Flags used in package Make --
471 ------------------------------------------------------------
473 -- Please note that such flags apply to all of Make clients,
474 -- such as gnatmake.
476 -- dp Prints the Q used by routine Make.Compile_Sources every time
477 -- we go around the main compile loop of Make.Compile_Sources
479 -- dq Prints source files as they are enqueued and dequeued in the Q
480 -- used by routine Make.Compile_Sources. Useful to figure out the
481 -- order in which sources are recompiled.
483 -- dw Prints the list of units withed by the unit currently explored
484 -- during the main loop of Make.Compile_Sources.
486 ----------------------
487 -- Get_Debug_Flag_K --
488 ----------------------
490 function Get_Debug_Flag_K return Boolean is
491 begin
492 return Debug_Flag_K;
493 end Get_Debug_Flag_K;
495 --------------------
496 -- Set_Debug_Flag --
497 --------------------
499 procedure Set_Debug_Flag (C : Character; Val : Boolean := True) is
500 subtype Dig is Character range '1' .. '9';
501 subtype LLet is Character range 'a' .. 'z';
502 subtype ULet is Character range 'A' .. 'Z';
504 begin
505 if C in Dig then
506 case Dig (C) is
507 when '1' => Debug_Flag_1 := Val;
508 when '2' => Debug_Flag_2 := Val;
509 when '3' => Debug_Flag_3 := Val;
510 when '4' => Debug_Flag_4 := Val;
511 when '5' => Debug_Flag_5 := Val;
512 when '6' => Debug_Flag_6 := Val;
513 when '7' => Debug_Flag_7 := Val;
514 when '8' => Debug_Flag_8 := Val;
515 when '9' => Debug_Flag_9 := Val;
516 end case;
518 elsif C in ULet then
519 case ULet (C) is
520 when 'A' => Debug_Flag_AA := Val;
521 when 'B' => Debug_Flag_BB := Val;
522 when 'C' => Debug_Flag_CC := Val;
523 when 'D' => Debug_Flag_DD := Val;
524 when 'E' => Debug_Flag_EE := Val;
525 when 'F' => Debug_Flag_FF := Val;
526 when 'G' => Debug_Flag_GG := Val;
527 when 'H' => Debug_Flag_HH := Val;
528 when 'I' => Debug_Flag_II := Val;
529 when 'J' => Debug_Flag_JJ := Val;
530 when 'K' => Debug_Flag_KK := Val;
531 when 'L' => Debug_Flag_LL := Val;
532 when 'M' => Debug_Flag_MM := Val;
533 when 'N' => Debug_Flag_NN := Val;
534 when 'O' => Debug_Flag_OO := Val;
535 when 'P' => Debug_Flag_PP := Val;
536 when 'Q' => Debug_Flag_QQ := Val;
537 when 'R' => Debug_Flag_RR := Val;
538 when 'S' => Debug_Flag_SS := Val;
539 when 'T' => Debug_Flag_TT := Val;
540 when 'U' => Debug_Flag_UU := Val;
541 when 'V' => Debug_Flag_VV := Val;
542 when 'W' => Debug_Flag_WW := Val;
543 when 'X' => Debug_Flag_XX := Val;
544 when 'Y' => Debug_Flag_YY := Val;
545 when 'Z' => Debug_Flag_ZZ := Val;
546 end case;
548 else
549 case LLet (C) is
550 when 'a' => Debug_Flag_A := Val;
551 when 'b' => Debug_Flag_B := Val;
552 when 'c' => Debug_Flag_C := Val;
553 when 'd' => Debug_Flag_D := Val;
554 when 'e' => Debug_Flag_E := Val;
555 when 'f' => Debug_Flag_F := Val;
556 when 'g' => Debug_Flag_G := Val;
557 when 'h' => Debug_Flag_H := Val;
558 when 'i' => Debug_Flag_I := Val;
559 when 'j' => Debug_Flag_J := Val;
560 when 'k' => Debug_Flag_K := Val;
561 when 'l' => Debug_Flag_L := Val;
562 when 'm' => Debug_Flag_M := Val;
563 when 'n' => Debug_Flag_N := Val;
564 when 'o' => Debug_Flag_O := Val;
565 when 'p' => Debug_Flag_P := Val;
566 when 'q' => Debug_Flag_Q := Val;
567 when 'r' => Debug_Flag_R := Val;
568 when 's' => Debug_Flag_S := Val;
569 when 't' => Debug_Flag_T := Val;
570 when 'u' => Debug_Flag_U := Val;
571 when 'v' => Debug_Flag_V := Val;
572 when 'w' => Debug_Flag_W := Val;
573 when 'x' => Debug_Flag_X := Val;
574 when 'y' => Debug_Flag_Y := Val;
575 when 'z' => Debug_Flag_Z := Val;
576 end case;
577 end if;
578 end Set_Debug_Flag;
580 end Debug;