3.2.15 Debugging Control
- Activate internal debugging switches. x is a letter or digit, or
string of letters or digits, which specifies the type of debugging
outputs desired. Normally these are used only for internal development
or system debugging purposes. You can find full documentation for these
switches in the body of the
Debug unit in the compiler source
- This switch causes the compiler to generate auxiliary output containing
a pseudo-source listing of the generated expanded code. Like most Ada
compilers, GNAT works by first transforming the high level Ada code into
lower level constructs. For example, tasking operations are transformed
into calls to the tasking run-time routines. A unique capability of GNAT
is to list this expanded code in a form very close to normal Ada source.
This is very useful in understanding the implications of various Ada
usage on the efficiency of the generated code. There are many cases in
Ada (e.g. the use of controlled types), where simple Ada statements can
generate a lot of run-time code. By using -gnatG you can identify
these cases, and consider whether it may be desirable to modify the coding
approach to improve efficiency.
The format of the output is very similar to standard Ada source, and is
easily understood by an Ada programmer. The following special syntactic
additions correspond to low level features used in the generated code that
do not have any exact analogies in pure Ada source form. The following
is a partial list of these special constructions. See the specification
Sprint in file sprint.ads for a full list.
[storage_pool = yyy
- Shows the storage pool being used for an allocator.
at end procedure-name
- Shows the finalization (cleanup) procedure for a scope.
- Conditional expression equivalent to the
x?y:z construction in C.
- A conversion with floating-point truncation instead of rounding.
- A conversion that bypasses normal Ada semantic checking. In particular
enumeration types and fixed-point types are treated simply as integers.
- Combines the above two cases.
- A division or multiplication of fixed-point values which are treated as
integers without any kind of scaling.
[storage_pool = xxx
- Shows the storage pool associated with a
- Shows the point at which typename is frozen, with possible
associated actions to be performed at the freeze point.
- Reference (and hence definition) to internal type itype.
- Intrinsic function call.
- Declaration of label labelname.
... && expr
- A multiple concatenation (same effect as expr & expr &
expr, but handled more efficiently).
- Raise the
- A pointer to the result of evaluating expression.
- An unchecked conversion of source-expression to target-type.
- Used to represent internal real literals (that) have no exact
representation in base 2-16 (for example, the result of compile time
evaluation of the expression 1.0/27.0).
- When used in conjunction with -gnatG, this switch causes
the expanded source, as described above for
-gnatG to be written to files with names
xxx.dg, where xxx is the normal file name,
instead of to the standard ooutput file. For
example, if the source file name is hello.adb, then a file
hello.adb.dg will be written. The debugging
information generated by the gcc -g switch
will refer to the generated xxx.dg file. This allows
you to do source level debugging using the generated code which is
sometimes useful for complex code, for example to find out exactly
which part of a complex construction raised an exception. This switch
also suppress generation of cross-reference information (see
-gnatx) since otherwise the cross-reference information
would refer to the .dg file, which would cause
confusion since this is not the original source file.
Note that -gnatD actually implies -gnatG
automatically, so it is not necessary to give both options.
In other words -gnatD is equivalent to -gnatDG).
- This switch controls output from the compiler of a listing showing
representation information for declared types and objects. For
-gnatR0, no information is output (equivalent to omitting
the -gnatR switch). For -gnatR1 (which is the default,
so -gnatR with no parameter has the same effect), size and alignment
information is listed for declared array and record types. For
-gnatR2, size and alignment information is listed for all
expression information for values that are computed at run time for
variant records. These symbolic expressions have a mostly obvious
format with #n being used to represent the value of the n'th
discriminant. See source files repinfo.ads/adb in the
GNAT sources for full details on the format of -gnatR3
output. If the switch is followed by an s (e.g. -gnatR2s), then
the output is to a file with the name file.rep where
file is the name of the corresponding source file.
- The use of the switch -gnatS for an
Ada compilation will cause the compiler to output a
representation of package Standard in a form very
close to standard Ada. It is not quite possible to
do this entirely in standard Ada (since new
numeric base types cannot be created in standard
Ada), but the output is easily
readable to any Ada programmer, and is useful to
determine the characteristics of target dependent
types in package Standard.
- Normally the compiler generates full cross-referencing information in
the ALI file. This information is used by a number of tools,
gnatxref. The -gnatx switch
suppresses this information. This saves some space and may slightly
speed up compilation, but means that these tools cannot be used.