Go forward to Delete Breaks.
Go backward to Set Watchpoints.
Go up to Breakpoints.
Breakpoints and exceptions
--------------------------
Some languages, such as GNU C++, implement exception handling. You
can use GDB to examine what caused your program to raise an exception,
and to list the exceptions your program is prepared to handle at a
given point in time.
`catch EXCEPTIONS'
You can set breakpoints at active exception handlers by using the
`catch' command. EXCEPTIONS is a list of names of exceptions to
catch.
You can use `info catch' to list active exception handlers.
See Information about a frame: Frame Info.
There are currently some limitations to exception handling in GDB:
* If you call a function interactively, GDB normally returns control
to you when the function has finished executing. If the call
raises an exception, however, the call may bypass the mechanism
that returns control to you and cause your program to simply
continue running until it hits a breakpoint, catches a signal that
GDB is listening for, or exits.
* You cannot raise an exception interactively.
* You cannot install an exception handler interactively.
Sometimes `catch' is not the best way to debug exception handling:
if you need to know exactly where an exception is raised, it is better
to stop *before* the exception handler is called, since that way you
can see the stack before any unwinding takes place. If you set a
breakpoint in an exception handler instead, it may not be easy to find
out where the exception was raised.
To stop just before an exception handler is called, you need some
knowledge of the implementation. In the case of GNU C++, exceptions are
raised by calling a library function named `__raise_exception' which
has the following ANSI C interface:
/* ADDR is where the exception identifier is stored.
ID is the exception identifier. */
void __raise_exception (void **ADDR, void *ID);
To make the debugger catch all exceptions before any stack unwinding
takes place, set a breakpoint on `__raise_exception' (
see Breakpoints; watchpoints; and exceptions: Breakpoints.).
With a conditional breakpoint (see Break conditions: Conditions.)
that depends on the value of ID, you can stop your program when a
specific exception is raised. You can use multiple conditional
breakpoints to stop your program when any of a number of exceptions are
raised.