Next: , Previous: Auxiliary Output Control, Up: Switches for gcc


3.2.15 Debugging Control

-gnatdx
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 file debug.adb.
-gnatG
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 of package Sprint in file sprint.ads for a full list.

new xxx [storage_pool = yyy]
Shows the storage pool being used for an allocator.
at end procedure-name;
Shows the finalization (cleanup) procedure for a scope.
(if expr then expr else expr)
Conditional expression equivalent to the x?y:z construction in C.
target^(source)
A conversion with floating-point truncation instead of rounding.
target?(source)
A conversion that bypasses normal Ada semantic checking. In particular enumeration types and fixed-point types are treated simply as integers.
target?^(source)
Combines the above two cases.
x #/ y
x #mod y
x #* y
x #rem y
A division or multiplication of fixed-point values which are treated as integers without any kind of scaling.
free expr [storage_pool = xxx]
Shows the storage pool associated with a free statement.
freeze typename [actions]
Shows the point at which typename is frozen, with possible associated actions to be performed at the freeze point.
reference itype
Reference (and hence definition) to internal type itype.
function-name! (arg, arg, arg)
Intrinsic function call.
labelname : label
Declaration of label labelname.
expr && expr && expr ... && expr
A multiple concatenation (same effect as expr & expr & expr, but handled more efficiently).
[constraint_error]
Raise the Constraint_Error exception.
expression'reference
A pointer to the result of evaluating expression.
target-type!(source-expression)
An unchecked conversion of source-expression to target-type.
[numerator/denominator]
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).

-gnatD
This switch is used in conjunction with -gnatG to cause the expanded source, as described above to be written to files with names xxx.dg, where xxx is the normal file name, 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).
-gnatR[0|1|2|3[s]]
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.
-gnatS
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 and remain entirely Standard (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.
-gnatx
Normally the compiler generates full cross-referencing information in the ALI file. This information is used by a number of tools, including gnatfind and 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.