How to debug exceptions in C++ applications

Use this procedure to debug an exception in your C++ applications.

About this task

Specify one of the following options in the Manage Event Breakpoints dialog box of the z/TPF debugger. You can open the Manage Event Breakpoints dialog box by using the toolbar push button in the Breakpoints view.
SYSTEM ERROR
Specifies that the z/TPF debugger stops when an error is encountered and on occurrences of the assert function. The SYSTEM ERROR option is the default.
The following lists the exception options that are displayed when a system error is encountered:
  • Run
  • Examine
  • Step into handler.

See the IBM TPF Toolkit for information about using these exception options.

UNCAUGHT EXCEPTION
Specifies that the z/TPF debugger stops on all thrown exceptions for C++ applications that are not caught; that is, do not have an exception handler. The debug console displays the location from where the exception is thrown. If an exception is thrown from a NODEBUG segment, the z/TPF debugger displays the last address that can be debugged on the stack before the call to the NODEBUG segment that threw the exception. The UNCAUGHT EXCEPTION option is the default.

When an uncaught exception is encountered, the z/TPF debugger client displays the following message in a pop-up window and the debug console: Debugger stopped due to uncaught exception exception at location location, where exception is the exception that stopped the debugger and location is the address from which the exception is thrown.

CAUGHT EXCEPTION
Specifies that the z/TPF debugger stops on all thrown exceptions for C++ applications that do not originate from NODEBUG segments. The program stops processing when the exception is thrown so that you can step into an exception handler, if one exists. The z/TPF debugger displays the type of exception that is thrown.

When a caught exception is encountered, the z/TPF debugger client displays the following message in a pop-up window and the debug console: Debugger stopped due to exception exception, where exception is the exception that stopped the debugger.

Use the XCPTRAP debug console command to debug exceptions in your C++ applications and stop the debugger when a specified exception is thrown.

A list of specific exception breakpoints that stops the z/TPF debugger for the caught exceptions can be managed by using the XCPTRAP command.

When the CAUGHT EXCEPTION option is specified in the Manage Event Breakpoints dialog box, the debugger stops for all caught exceptions.

Note: The debug console LNIATAs are not required to issue the XCPTRAP command.
XCPTRAP
specify one of the following options:
ADD-exceptionname
Adds an exception name to the exceptions breakpoint list, where exceptionname is the name of the exception. Enter XCPTRAP ADD to set a breakpoint for an exception to stop the z/TPF debugger when the class name or primitive type matches the name of the exception that is specified in your C++ application. Do not specify the CAUGHT EXCEPTION option if you use this command to add exception names.
Note:
  • You can add exception names to the breakpoint list by using an asterisk (*) as the last character in a string to specify exception name patterns.
  • You can add an exception to a thread that is in the current debug session by using the debug view and specifying XCPTRAP ADD. This command uses the current thread by default.
DELete-exceptionname
Deletes an exception name from the exceptions breakpoint list, where exceptionname is the name of the exception.
Note:
  • Exception names can be deleted from the breakpoint list by using an asterisk (*) as the last character in a string to specify exception name patterns. All of the exceptions that are listed in the breakpoint list for the current thread are deleted if you specify only an *.
  • An exception can be deleted from a thread that is not in the current debug session by using the debug view and specifying XCPTRAP DEL.
DISPlay
Displays all existing exception breakpoints for the current debug session. You can specify the following values:
ALL
Displays all of the exception breakpoints from all of the threads in the same process.
STATus
Displays the types of the exceptions that stop the debugger.
ECBAddr
Displays the exception breakpoints for the system virtual address (SVA) address of an active entry control block (ECB). The currently selected ECB in the debug view is the default.
Note:
  • The exception breakpoints for all ECBs can be displayed by using an asterisk (*) when entering the XCPTRAP command with the DISP; for example, XCPTRAP DISP *.
  • You can display an exception for a thread that is in the current debug session by using the debug view and specifying XCPTRAP DISP.
HELP
Displays a detailed explanation of the XCPTRAP command.
NOSAve
Clears the exception breakpoint list from the registration entry.
SAVE
Saves the exception breakpoint list into the registration entry.

For more information about z/TPF debugger event breakpoint support, see the IBM TPF Toolkit online help.