Work around MinGW mangling of "host:/path"
[msysgit/historical-msysgit.git] / mingw / info / gdb / Bootstrapping.html
blob19e5c13fce5b9f143bbbadb53fa1e6ba6aab78dd
1 <html lang="en">
2 <head>
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">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="Bootstrapping">Bootstrapping</a>,
13 Next:<a rel="next" accesskey="n" href="Debug-Session.html#Debug%20Session">Debug Session</a>,
14 Previous:<a rel="previous" accesskey="p" href="Stub-Contents.html#Stub%20Contents">Stub Contents</a>,
15 Up:<a rel="up" accesskey="u" href="remote-stub.html#remote%20stub">remote stub</a>
16 <hr><br>
17 </div>
19 <h4 class="subsection">What you must do for the stub</h4>
21 <p>The debugging stubs that come with GDB are set up for a particular
22 chip architecture, but they have no information about the rest of your
23 debugging target machine.
25 <p>First of all you need to tell the stub how to communicate with the
26 serial port.
28 <dl>
29 <dt><code>int getDebugChar()</code>
30 <dd>Write this subroutine to read a single character from the serial port.
31 It may be identical to <code>getchar</code> for your target system; a
32 different name is used to allow you to distinguish the two if you wish.
34 <br><dt><code>void putDebugChar(int)</code>
35 <dd>Write this subroutine to write a single character to the serial port.
36 It may be identical to <code>putchar</code> for your target system; a
37 different name is used to allow you to distinguish the two if you wish.
38 </dl>
40 <p>If you want GDB to be able to stop your program while it is
41 running, you need to use an interrupt-driven serial driver, and arrange
42 for it to stop when it receives a <code>^C</code> (<code>\003</code>, the control-C
43 character). That is the character which GDB uses to tell the
44 remote system to stop.
46 <p>Getting the debugging target to return the proper status to GDB
47 probably requires changes to the standard stub; one quick and dirty way
48 is to just execute a breakpoint instruction (the "dirty" part is that
49 GDB reports a <code>SIGTRAP</code> instead of a <code>SIGINT</code>).
51 <p>Other routines you need to supply are:
53 <dl>
54 <dt><code>void exceptionHandler (int </code><var>exception_number</var><code>, void *</code><var>exception_address</var><code>)</code>
55 <dd>Write this function to install <var>exception_address</var> in the exception
56 handling tables. You need to do this because the stub does not have any
57 way of knowing what the exception handling tables on your target system
58 are like (for example, the processor's table might be in <small>ROM</small>,
59 containing entries which point to a table in <small>RAM</small>).
60 <var>exception_number</var> is the exception number which should be changed;
61 its meaning is architecture-dependent (for example, different numbers
62 might represent divide by zero, misaligned access, etc). When this
63 exception occurs, control should be transferred directly to
64 <var>exception_address</var>, and the processor state (stack, registers,
65 and so on) should be just as it is when a processor exception occurs. So if
66 you want to use a jump instruction to reach <var>exception_address</var>, it
67 should be a simple jump, not a jump to subroutine.
69 <p>For the 386, <var>exception_address</var> should be installed as an interrupt
70 gate so that interrupts are masked while the handler runs. The gate
71 should be at privilege level 0 (the most privileged level). The
72 <small>SPARC</small> and 68k stubs are able to mask interrupts themselves without
73 help from <code>exceptionHandler</code>.
75 <br><dt><code>void flush_i_cache()</code>
76 <dd>On <small>SPARC</small> and <small>SPARCLITE</small> only, write this subroutine to flush the
77 instruction cache, if any, on your target machine. If there is no
78 instruction cache, this subroutine may be a no-op.
80 <p>On target machines that have instruction caches, GDB requires this
81 function to make certain that the state of your program is stable.
82 </dl>
84 <p>You must also make sure this library routine is available:
86 <dl>
87 <dt><code>void *memset(void *, int, int)</code>
88 <dd>This is the standard library function <code>memset</code> that sets an area of
89 memory to a known value. If you have one of the free versions of
90 <code>libc.a</code>, <code>memset</code> can be found there; otherwise, you must
91 either obtain it from your hardware manufacturer, or write your own.
92 </dl>
94 <p>If you do not use the GNU C compiler, you may need other standard
95 library subroutines as well; this varies from one stub to another,
96 but in general the stubs are likely to use any of the common library
97 subroutines which <code>gcc</code> generates as inline code.
99 </body></html>