Determine Causes of System Exceptions
When an exception is raised in your program by operating
system or runtime library functions, you can use the Step
Exception command to step into the exception-handling code for
that exception. However, you cannot view source for this
exception-handling code, which makes debugging it difficult. It
is usually easier to determine which source statement caused the
exception, set a breakpoint on that statement, and run the
program again under debug control to examine the statement and
likely causes of the exception.
Follow these steps to determine which source statement caused
an exception:
- Disable the "All Breakpoints" breakpoint in the
Breakpoints view for the project.
- Find the Stack view in the Source page of the Process tab
for the process that caused the exception.
- In the Stack view, look down the list of stack frames to
the first one containing the name of a function within
your program. Set a breakpoint on this function.
- Terminate the process, start another debug process, and
run it. Make sure that you provide the same program
arguments and input as before. Execution should stop when
the function you set the breakpoint on is called. Use
Step Over commands to move through the function, until
the exception is thrown.
- Set a breakpoint on the statement causing the exception,
and remove the function breakpoint you set earlier.
- Terminate the process, start another debug process, and
run it. Execution stops at the statement that previously
caused the exception. From here you can examine the
context of the problem statement, to determine possible
reasons for the error. For example, you may be copying a
string to a null pointer or past the allocated bounds of
an array.

Handle Signals for User-Defined Exceptions
Debug Exception-Handling Code
Set a Function Breakpoint
Set a Statement Breakpoint