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=
"Hitachi%20Boards">Hitachi Boards
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Hitachi-ICE.html#Hitachi%20ICE">Hitachi ICE
</a>,
14 Up:
<a rel=
"up" accesskey=
"u" href=
"H8-300.html#H8%2f300">H8/
300</a>
18 <h5 class=
"subsubsection">Connecting to Hitachi boards
</h5>
20 <p>Use the special
<code>GDB
</code> command
<code>device
</code><var>port
</var><code></code> if you
21 need to explicitly set the serial device. The default
<var>port
</var> is the
22 first available port on your host. This is only necessary on Unix
23 hosts, where it is typically something like
<code>/dev/ttya
</code>.
25 <p><code>GDB
</code> has another special command to set the communications
26 speed:
<code>speed
</code><var>bps
</var><code></code>. This command also is only used from Unix
27 hosts; on DOS hosts, set the line speed as usual from outside GDB with
28 the DOS
<code>mode
</code> command (for instance,
29 <kbd>mode
com2:
9600,n,
8,
1,p
</kbd> for a
9600bps connection).
31 <p>The
<code>device
</code> and
<code>speed
</code> commands are available only when you
32 use a Unix host to debug your Hitachi microprocessor programs. If you
34 GDB depends on an auxiliary terminate-and-stay-resident program
35 called
<code>asynctsr
</code> to communicate with the development board
36 through a PC serial port. You must also use the DOS
<code>mode
</code> command
37 to set up the serial port on the DOS side.
39 <p>The following sample session illustrates the steps needed to start a
40 program under GDB control on an H8/
300. The example uses a
41 sample H8/
300 program called
<code>t.x
</code>. The procedure is the same for
42 the Hitachi SH and the H8/
500.
44 <p>First hook up your development board. In this example, we use a
45 board attached to serial port
<code>COM2
</code>; if you use a different serial
46 port, substitute its name in the argument of the
<code>mode
</code> command.
47 When you call
<code>asynctsr
</code>, the auxiliary comms program used by the
48 debugger, you give it just the numeric part of the serial port's name;
49 for example,
<code>asyncstr
2</code> below runs
<code>asyncstr
</code> on
52 <pre class=
"example"> C:\H8300\TEST
> asynctsr
2
53 C:\H8300\TEST
> mode com2:
9600,n,
8,
1,p
55 Resident portion of MODE loaded
57 COM2:
9600, n,
8,
1, p
62 <em>Warning:
</em> We have noticed a bug in PC-NFS that conflicts with
63 <code>asynctsr
</code>. If you also run PC-NFS on your DOS host, you may need to
64 disable it, or even boot without it, to use
<code>asynctsr
</code> to control
65 your development board.
68 <p>Now that serial communications are set up, and the development board is
69 connected, you can start up GDB. Call
<code>gdb
</code> with
70 the name of your program as the argument.
<code>GDB
</code> prompts
71 you, as usual, with the prompt
<code>(gdb)
</code>. Use two special
72 commands to begin your debugging session:
<code>target hms
</code> to specify
73 cross-debugging to the Hitachi board, and the
<code>load
</code> command to
74 download your program to the board.
<code>load
</code> displays the names of
75 the program's sections, and a
<code>*
</code> for each
2K of data downloaded.
76 (If you want to refresh GDB data on symbols or on the
77 executable file without downloading, use the GDB commands
78 <code>file
</code> or
<code>symbol-file
</code>. These commands, and
<code>load
</code>
79 itself, are described in
<a href=
"Files.html#Files">Commands to specify files
</a>.)
81 <pre class=
"smallexample"> (eg-C:\H8300\TEST) gdb t.x
82 GDB is free software and you are welcome to distribute copies
83 of it under certain conditions; type
"show copying" to see
85 There is absolutely no warranty for GDB; type
"show warranty"
87 GDB
5.2.1, Copyright
1992 Free Software Foundation, Inc...
89 Connected to remote H8/
300 HMS system.
91 .text :
0x8000 ..
0xabde ***********
92 .data :
0xabde ..
0xad30 *
93 .stack :
0xf000 ..
0xf014 *
96 <p>At this point, you're ready to run or debug your program. From here on,
97 you can use all the usual GDB commands. The
<code>break
</code> command
98 sets breakpoints; the
<code>run
</code> command starts your program;
99 <code>print
</code> or
<code>x
</code> display data; the
<code>continue
</code> command
100 resumes execution after stopping at a breakpoint. You can use the
101 <code>help
</code> command at any time to find out more about GDB commands.
103 <p>Remember, however, that
<em>operating system
</em> facilities aren't
104 available on your development board; for example, if your program hangs,
105 you can't send an interrupt--but you can press the
<small>RESET
</small> switch!
107 <p>Use the
<small>RESET
</small> button on the development board
109 <li>to interrupt your program (don't use
<kbd>ctl-C
</kbd> on the DOS host--it has
110 no way to pass an interrupt signal to the development board); and
112 <li>to return to the GDB command prompt after your program finishes
113 normally. The communications protocol provides no other way for GDB
114 to detect program completion.
117 <p>In either case, GDB sees the effect of a
<small>RESET
</small> on the
118 development board as a
"normal exit" of your program.