Next: Units to Sources Mapping Files, Previous: Debugging Control, Up: Switches for gcc
GNAT uses two methods for handling exceptions at run-time. The
setjmp/longjmp
method saves the context when entering
a frame with an exception handler. Then when an exception is
raised, the context can be restored immediately, without the
need for tracing stack frames. This method provides very fast
exception propagation, but introduces significant overhead for
the use of exception handlers, even if no exception is raised.
The other approach is called “zero cost” exception handling. With this method, the compiler builds static tables to describe the exception ranges. No dynamic code is required when entering a frame containing an exception handler. When an exception is raised, the tables are used to control a back trace of the subprogram invocation stack to locate the required exception handler. This method has considerably poorer performance for the propagation of exceptions, but there is no overhead for exception handlers if no exception is raised. Note that in this mode and in the context of mixed Ada and C/C++ programming, to propagate an exception through a C/C++ code, the C/C++ code must be compiled with the -funwind-tables GCC's option.
The following switches may be used to control which of the two exception handling methods is used.
The same option --RTS must be used both for gcc and gnatbind. Passing this option to gnatmake (see Switches for gnatmake) will ensure the required consistency through the compilation and binding steps.