3 <title>Debugging with GDB
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Debugging with GDB">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"Stub%20Contents">Stub Contents
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Bootstrapping.html#Bootstrapping">Bootstrapping
</a>,
14 Up:
<a rel=
"up" accesskey=
"u" href=
"remote-stub.html#remote%20stub">remote stub
</a>
18 <h4 class=
"subsection">What the stub can do for you
</h4>
20 <p>The debugging stub for your architecture supplies these three
24 <dt><code>set_debug_traps
</code>
25 <dd>This routine arranges for
<code>handle_exception
</code> to run when your
26 program stops. You must call this subroutine explicitly near the
27 beginning of your program.
29 <br><dt><code>handle_exception
</code>
30 <dd>This is the central workhorse, but your program never calls it
31 explicitly--the setup code arranges for
<code>handle_exception
</code> to
32 run when a trap is triggered.
34 <p><code>handle_exception
</code> takes control when your program stops during
35 execution (for example, on a breakpoint), and mediates communications
36 with GDB on the host machine. This is where the communications
37 protocol is implemented;
<code>handle_exception
</code> acts as the GDB
38 representative on the target machine. It begins by sending summary
39 information on the state of your program, then continues to execute,
40 retrieving and transmitting any information GDB needs, until you
41 execute a GDB command that makes your program resume; at that point,
42 <code>handle_exception
</code> returns control to your own code on the target
45 <br><dt><code>breakpoint
</code>
46 <dd>Use this auxiliary subroutine to make your program contain a
47 breakpoint. Depending on the particular situation, this may be the only
48 way for GDB to get control. For instance, if your target
49 machine has some sort of interrupt button, you won't need to call this;
50 pressing the interrupt button transfers control to
51 <code>handle_exception
</code>--in effect, to GDB. On some machines,
52 simply receiving characters on the serial port may also trigger a trap;
53 again, in that situation, you don't need to call
<code>breakpoint
</code> from
54 your own program--simply running
<code>target remote
</code> from the host
55 GDB session gets control.
57 <p>Call
<code>breakpoint
</code> if none of these is true, or if you simply want
58 to make certain your program stops at a predetermined point for the
59 start of your debugging session.