Debug

Debug options

The compiler option --debug can be used, especially during the development of your programs. It enables all run-time error checking, such as subscript boundary checks and numeric data checks, and leads to display of run-time errors with source locations. Exceptions may also be enabled/disabled separately. Debug switches.

Source Level Debugger

Compiling with -g enables several kinds of debug information, allowing you to run your programs with the system debugger. This allows you to step through the COBOL code and inspect the call stack, but direct access to the COBOL variables is not available. Different GDB frontends exist that provide access the COBOL variables directly.

Compiling with debug information also enables several tools to profile the code or test it, for example against memory violations.

Memory Dumps

Memory Dumps can be enabled/disabled at runtime and will by default be executed in case of runtime errors or handling of different signals.

They can also be requested via C interface.

Only modules that are explicit enabled for dump code will output their data.

Core Dumps

By default GnuCOBOL catches signals that normally may create core-dumps. To disable this or to even explicit raise SIGABRT on runtime errors or to directly generate core-dumps through libcob, see the runtime varialbes COB_CORE_ON_ERROR and COB_CORE_FILENAME. To inspecting the reason for the abort check the content of the variable runtime_err_str in the generated dump file. 1

Tracing execution

Tracing program execution, either in general or in specific parts can be enabled.

1

The usability of coredumps depends on your operating system.