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