The debugging stub for your architecture supplies these three subroutines:
set_debug_traps
handle_exception
to run when your
program stops. You must call this subroutine explicitly in your
program's startup code.
handle_exception
handle_exception
to
run when a trap is triggered.
handle_exception
takes control when your program stops during
execution (for example, on a breakpoint), and mediates communications
with gdb on the host machine. This is where the communications
protocol is implemented; handle_exception
acts as the gdb
representative on the target machine. It begins by sending summary
information on the state of your program, then continues to execute,
retrieving and transmitting any information gdb needs, until you
execute a gdb command that makes your program resume; at that point,
handle_exception
returns control to your own code on the target
machine.
breakpoint
handle_exception
—in effect, to gdb. On some machines,
simply receiving characters on the serial port may also trigger a trap;
again, in that situation, you don't need to call breakpoint
from
your own program—simply running ‘target remote’ from the host
gdb session gets control.
Call breakpoint
if none of these is true, or if you simply want
to make certain your program stops at a predetermined point for the
start of your debugging session.