Commit | Line | Data |
---|---|---|
4af6d502 RP |
1 | @c -*- Texinfo -*- |
2 | @c Copyright (c) 1990 1991 1992 1993 Free Software Foundation, Inc. | |
3 | @c This file is part of the source for the GDB manual. | |
4 | @c This text diverted to "Remote Debugging" section in general case; | |
5 | @c however, if we're doing a manual specifically for one of these, it | |
6 | @c belongs up front (in "Getting In and Out" chapter). | |
7 | ||
8 | @ifset REMOTESTUB | |
9 | @node Remote Serial | |
10 | @subsection The @value{GDBN} remote serial protocol | |
11 | ||
12 | @cindex remote serial debugging, overview | |
13 | To debug a program running on another machine (the debugging | |
14 | @dfn{target} machine), you must first arrange for all the usual | |
15 | prerequisites for the program to run by itself. For example, for a C | |
16 | program, you need | |
17 | ||
18 | @enumerate | |
19 | @item | |
20 | A startup routine to set up the C runtime environment; these usually | |
21 | have a name like @file{crt0}. The startup routine may be supplied by | |
22 | your hardware supplier, or you may have to write your own. | |
23 | ||
24 | @item | |
25 | You probably need a C subroutine library to support your program's | |
26 | subroutine calls, notably managing input and output. | |
27 | ||
28 | @item | |
29 | A way of getting your program to the other machine---for example, a | |
30 | download program. These are often supplied by the hardware | |
31 | manufacturer, but you may have to write your own from hardware | |
32 | documentation. | |
33 | @end enumerate | |
34 | ||
35 | The next step is to arrange for your program to use a serial port to | |
36 | communicate with the machine where @value{GDBN} is running (the @dfn{host} | |
37 | machine). In general terms, the scheme looks like this: | |
38 | ||
39 | @table @emph | |
40 | @item On the host, | |
41 | @value{GDBN} already understands how to use this protocol; when everything | |
42 | else is set up, you can simply use the @samp{target remote} command | |
43 | (@pxref{Targets,,Specifying a Debugging Target}). | |
44 | ||
45 | @item On the target, | |
46 | you must link with your program a few special-purpose subroutines that | |
47 | implement the @value{GDBN} remote serial protocol. The file containing these | |
48 | subroutines is called a @dfn{debugging stub}. | |
49 | ||
50 | @ifset GDBSERVER | |
51 | On certain remote targets, you can use an auxiliary program | |
52 | @code{gdbserver} instead of linking a stub into your program. | |
53 | @xref{Server,,Using the @code{gdbserver} program}, for details. | |
54 | @end ifset | |
55 | @end table | |
56 | ||
57 | The debugging stub is specific to the architecture of the remote | |
58 | machine; for example, use @file{sparc-stub.c} to debug programs on | |
59 | @sc{sparc} boards. | |
60 | ||
61 | @cindex remote serial stub list | |
62 | These working remote stubs are distributed with @value{GDBN}: | |
63 | ||
64 | @table @code | |
65 | @item sparc-stub.c | |
66 | @kindex sparc-stub.c | |
67 | For @sc{sparc} architectures. | |
68 | ||
69 | @item m68k-stub.c | |
70 | @kindex m68k-stub.c | |
6b51acad RP |
71 | @cindex Motorola 680x0 |
72 | @cindex 680x0 | |
4af6d502 RP |
73 | For Motorola 680x0 architectures. |
74 | ||
75 | @item i386-stub.c | |
76 | @kindex i386-stub.c | |
6b51acad RP |
77 | @cindex Intel |
78 | @cindex 386 | |
4af6d502 RP |
79 | For Intel 386 and compatible architectures. |
80 | @end table | |
81 | ||
82 | The @file{README} file in the @value{GDBN} distribution may list other | |
83 | recently added stubs. | |
84 | ||
85 | @menu | |
86 | * Stub Contents:: What the stub can do for you | |
87 | * Bootstrapping:: What you must do for the stub | |
88 | * Debug Session:: Putting it all together | |
89 | * Protocol:: Outline of the communication protocol | |
90 | @ifset GDBSERVER | |
91 | * Server:: Using the `gdbserver' program | |
92 | @end ifset | |
93 | @end menu | |
94 | ||
95 | @node Stub Contents | |
96 | @subsubsection What the stub can do for you | |
97 | ||
98 | @cindex remote serial stub | |
99 | The debugging stub for your architecture supplies these three | |
100 | subroutines: | |
101 | ||
102 | @table @code | |
103 | @item set_debug_traps | |
104 | @kindex set_debug_traps | |
105 | @cindex remote serial stub, initialization | |
106 | This routine arranges for @code{handle_exception} to run when your | |
107 | program stops. You must call this subroutine explicitly near the | |
108 | beginning of your program. | |
109 | ||
110 | @item handle_exception | |
111 | @kindex handle_exception | |
112 | @cindex remote serial stub, main routine | |
113 | This is the central workhorse, but your program never calls it | |
114 | explicitly---the setup code arranges for @code{handle_exception} to | |
115 | run when a trap is triggered. | |
116 | ||
117 | @code{handle_exception} takes control when your program stops during | |
118 | execution (for example, on a breakpoint), and mediates communications | |
119 | with @value{GDBN} on the host machine. This is where the communications | |
120 | protocol is implemented; @code{handle_exception} acts as the @value{GDBN} | |
121 | representative on the target machine; it begins by sending summary | |
122 | information on the state of your program, then continues to execute, | |
123 | retrieving and transmitting any information @value{GDBN} needs, until you | |
124 | execute a @value{GDBN} command that makes your program resume; at that point, | |
125 | @code{handle_exception} returns control to your own code on the target | |
126 | machine. | |
127 | ||
128 | @item breakpoint | |
129 | @cindex @code{breakpoint} subroutine, remote | |
130 | Use this auxiliary subroutine to make your program contain a | |
131 | breakpoint. Depending on the particular situation, this may be the only | |
132 | way for @value{GDBN} to get control. For instance, if your target | |
133 | machine has some sort of interrupt button, you won't need to call this; | |
134 | pressing the interrupt button will transfer control to | |
135 | @code{handle_exception}---in effect, to @value{GDBN}. On some machines, | |
136 | simply receiving characters on the serial port may also trigger a trap; | |
137 | again, in that situation, you don't need to call @code{breakpoint} from | |
138 | your own program---simply running @samp{target remote} from the host | |
139 | @value{GDBN} session will get control. | |
140 | ||
141 | Call @code{breakpoint} if none of these is true, or if you simply want | |
142 | to make certain your program stops at a predetermined point for the | |
143 | start of your debugging session. | |
144 | @end table | |
145 | ||
146 | @node Bootstrapping | |
147 | @subsubsection What you must do for the stub | |
148 | ||
149 | @cindex remote stub, support routines | |
150 | The debugging stubs that come with @value{GDBN} are set up for a particular | |
151 | chip architecture, but they have no information about the rest of your | |
152 | debugging target machine. To allow the stub to work, you must supply | |
153 | these special low-level subroutines: | |
154 | ||
155 | @table @code | |
156 | @item int getDebugChar() | |
157 | @kindex getDebugChar | |
158 | Write this subroutine to read a single character from the serial port. | |
159 | It may be identical to @code{getchar} for your target system; a | |
160 | different name is used to allow you to distinguish the two if you wish. | |
161 | ||
162 | @item void putDebugChar(int) | |
163 | @kindex putDebugChar | |
164 | Write this subroutine to write a single character to the serial port. | |
165 | It may be identical to @code{putchar} for your target system; a | |
166 | different name is used to allow you to distinguish the two if you wish. | |
167 | ||
168 | @item void exceptionHandler (int @var{exception_number}, void *@var{exception_address}) | |
8d8c5f39 | 169 | @kindex exceptionHandler |
4af6d502 RP |
170 | Write this function to install @var{exception_address} in the exception |
171 | handling tables. You need to do this because the stub does not have any | |
172 | way of knowing what the exception handling tables on your target system | |
173 | are like (for example, the processor's table might be in @sc{rom}, | |
174 | containing entries which point to a table in @sc{ram}). | |
175 | @var{exception_number} is the exception number which should be changed; | |
176 | its meaning is architecture-dependent (for example, different numbers | |
177 | might represent divide by zero, misaligned access, etc). When this | |
178 | exception occurs, control should be transferred directly to | |
179 | @var{exception_address}, and the processor state (stack, registers, | |
180 | etc.) should be just as it is when a processor exception occurs. So if | |
181 | you want to use a jump instruction to reach @var{exception_address}, it | |
182 | should be a simple jump, not a jump to subroutine. | |
183 | ||
4af6d502 | 184 | For the 386, @var{exception_address} should be installed as an interrupt |
8d8c5f39 JK |
185 | gate so that interrupts are masked while the handler runs. The gate |
186 | should be at privilege level 0 (the most privileged level). The | |
4af6d502 RP |
187 | @sc{sparc} and 68k stubs are able to mask interrupts themself without |
188 | help from @code{exceptionHandler}. | |
189 | ||
190 | @item void flush_i_cache() | |
191 | @kindex flush_i_cache | |
192 | Write this subroutine to flush the instruction cache, if any, on your | |
193 | target machine. If there is no instruction cache, this subroutine may | |
194 | be a no-op. | |
195 | ||
196 | On target machines that have instruction caches, @value{GDBN} requires this | |
197 | function to make certain that the state of your program is stable. | |
198 | @end table | |
199 | ||
200 | @noindent | |
201 | You must also make sure this library routine is available: | |
202 | ||
203 | @table @code | |
204 | @item void *memset(void *, int, int) | |
205 | @kindex memset | |
206 | This is the standard library function @code{memset} that sets an area of | |
207 | memory to a known value. If you have one of the free versions of | |
208 | @code{libc.a}, @code{memset} can be found there; otherwise, you must | |
209 | either obtain it from your hardware manufacturer, or write your own. | |
210 | @end table | |
211 | ||
212 | If you do not use the GNU C compiler, you may need other standard | |
213 | library subroutines as well; this will vary from one stub to another, | |
214 | but in general the stubs are likely to use any of the common library | |
215 | subroutines which @code{gcc} generates as inline code. | |
216 | ||
217 | ||
218 | @node Debug Session | |
219 | @subsubsection Putting it all together | |
220 | ||
221 | @cindex remote serial debugging summary | |
222 | In summary, when your program is ready to debug, you must follow these | |
223 | steps. | |
224 | ||
225 | @enumerate | |
226 | @item | |
227 | Make sure you have the supporting low-level routines | |
6b51acad | 228 | (@pxref{Bootstrapping,,What you must do for the stub}): |
4af6d502 RP |
229 | @display |
230 | @code{getDebugChar}, @code{putDebugChar}, | |
231 | @code{flush_i_cache}, @code{memset}, @code{exceptionHandler}. | |
232 | @end display | |
233 | ||
234 | @item | |
235 | Insert these lines near the top of your program: | |
236 | ||
237 | @example | |
238 | set_debug_traps(); | |
239 | breakpoint(); | |
240 | @end example | |
241 | ||
242 | @item | |
243 | For the 680x0 stub only, you need to provide a variable called | |
244 | @code{exceptionHook}. Normally you just use | |
245 | ||
246 | @example | |
247 | void (*exceptionHook)() = 0; | |
248 | @end example | |
249 | ||
250 | but if before calling @code{set_debug_traps}, you set it to point to a | |
251 | function in your program, that function is called when | |
252 | @code{@value{GDBN}} continues after stopping on a trap (for example, bus | |
253 | error). The function indicated by @code{exceptionHook} is called with | |
254 | one parameter: an @code{int} which is the exception number. | |
255 | ||
256 | @item | |
257 | Compile and link together: your program, the @value{GDBN} debugging stub for | |
258 | your target architecture, and the supporting subroutines. | |
259 | ||
260 | @item | |
261 | Make sure you have a serial connection between your target machine and | |
262 | the @value{GDBN} host, and identify the serial port used for this on the host. | |
263 | ||
264 | @item | |
265 | @c The "remote" target now provides a `load' command, so we should | |
266 | @c document that. FIXME. | |
267 | Download your program to your target machine (or get it there by | |
268 | whatever means the manufacturer provides), and start it. | |
269 | ||
270 | @item | |
271 | To start remote debugging, run @value{GDBN} on the host machine, and specify | |
272 | as an executable file the program that is running in the remote machine. | |
273 | This tells @value{GDBN} how to find your program's symbols and the contents | |
274 | of its pure text. | |
275 | ||
276 | @cindex serial line, @code{target remote} | |
277 | Then establish communication using the @code{target remote} command. | |
278 | Its argument specifies how to communicate with the target | |
279 | machine---either via a devicename attached to a direct serial line, or a | |
280 | TCP port (usually to a terminal server which in turn has a serial line | |
281 | to the target). For example, to use a serial line connected to the | |
282 | device named @file{/dev/ttyb}: | |
283 | ||
284 | @example | |
285 | target remote /dev/ttyb | |
286 | @end example | |
287 | ||
288 | @cindex TCP port, @code{target remote} | |
289 | To use a TCP connection, use an argument of the form | |
290 | @code{@var{host}:port}. For example, to connect to port 2828 on a | |
291 | terminal server named @code{manyfarms}: | |
292 | ||
293 | @example | |
294 | target remote manyfarms:2828 | |
295 | @end example | |
296 | @end enumerate | |
297 | ||
298 | Now you can use all the usual commands to examine and change data and to | |
299 | step and continue the remote program. | |
300 | ||
301 | To resume the remote program and stop debugging it, use the @code{detach} | |
302 | command. | |
303 | ||
304 | @cindex interrupting remote programs | |
305 | @cindex remote programs, interrupting | |
306 | Whenever @value{GDBN} is waiting for the remote program, if you type the | |
307 | interrupt character (often @key{C-C}), @value{GDBN} attempts to stop the | |
308 | program. This may or may not succeed, depending in part on the hardware | |
309 | and the serial drivers the remote system uses. If you type the | |
310 | interrupt character once again, @value{GDBN} displays this prompt: | |
311 | ||
312 | @example | |
313 | Interrupted while waiting for the program. | |
314 | Give up (and stop debugging it)? (y or n) | |
315 | @end example | |
316 | ||
317 | If you type @kbd{y}, @value{GDBN} abandons the remote debugging session. | |
318 | (If you decide you want to try again later, you can use @samp{target | |
319 | remote} again to connect once more.) If you type @kbd{n}, @value{GDBN} | |
320 | goes back to waiting. | |
321 | ||
322 | @node Protocol | |
323 | @subsubsection Outline of the communication protocol | |
324 | ||
325 | @cindex debugging stub, example | |
326 | @cindex remote stub, example | |
327 | @cindex stub example, remote debugging | |
328 | The stub files provided with @value{GDBN} implement the target side of the | |
329 | communication protocol, and the @value{GDBN} side is implemented in the | |
330 | @value{GDBN} source file @file{remote.c}. Normally, you can simply allow | |
331 | these subroutines to communicate, and ignore the details. (If you're | |
332 | implementing your own stub file, you can still ignore the details: start | |
333 | with one of the existing stub files. @file{sparc-stub.c} is the best | |
334 | organized, and therefore the easiest to read.) | |
335 | ||
336 | However, there may be occasions when you need to know something about | |
337 | the protocol---for example, if there is only one serial port to your | |
338 | target machine, you might want your program to do something special if | |
339 | it recognizes a packet meant for @value{GDBN}. | |
340 | ||
341 | @cindex protocol, @value{GDBN} remote serial | |
342 | @cindex serial protocol, @value{GDBN} remote | |
343 | @cindex remote serial protocol | |
344 | All @value{GDBN} commands and responses (other than acknowledgements, which | |
345 | are single characters) are sent as a packet which includes a | |
346 | checksum. A packet is introduced with the character @samp{$}, and ends | |
347 | with the character @samp{#} followed by a two-digit checksum: | |
348 | ||
349 | @example | |
350 | $@var{packet info}#@var{checksum} | |
351 | @end example | |
352 | ||
353 | @cindex checksum, for @value{GDBN} remote | |
354 | @noindent | |
355 | @var{checksum} is computed as the modulo 256 sum of the @var{packet | |
356 | info} characters. | |
357 | ||
358 | When either the host or the target machine receives a packet, the first | |
359 | response expected is an acknowledgement: a single character, either | |
360 | @samp{+} (to indicate the package was received correctly) or @samp{-} | |
361 | (to request retransmission). | |
362 | ||
363 | The host (@value{GDBN}) sends commands, and the target (the debugging stub | |
364 | incorporated in your program) sends data in response. The target also | |
365 | sends data when your program stops. | |
366 | ||
367 | Command packets are distinguished by their first character, which | |
368 | identifies the kind of command. | |
369 | ||
370 | These are the commands currently supported: | |
371 | ||
372 | @table @code | |
373 | @item g | |
374 | Requests the values of CPU registers. | |
375 | ||
376 | @item G | |
377 | Sets the values of CPU registers. | |
378 | ||
379 | @item m@var{addr},@var{count} | |
380 | Read @var{count} bytes at location @var{addr}. | |
381 | ||
382 | @item M@var{addr},@var{count}:@dots{} | |
383 | Write @var{count} bytes at location @var{addr}. | |
384 | ||
385 | @item c | |
386 | @itemx c@var{addr} | |
387 | Resume execution at the current address (or at @var{addr} if supplied). | |
388 | ||
389 | @item s | |
390 | @itemx s@var{addr} | |
391 | Step the target program for one instruction, from either the current | |
392 | program counter or from @var{addr} if supplied. | |
393 | ||
394 | @item k | |
395 | Kill the target program. | |
396 | ||
397 | @item ? | |
398 | Report the most recent signal. To allow you to take advantage of the | |
399 | @value{GDBN} signal handling commands, one of the functions of the debugging | |
400 | stub is to report CPU traps as the corresponding POSIX signal values. | |
401 | @end table | |
402 | ||
403 | @kindex set remotedebug | |
404 | @kindex show remotedebug | |
405 | @cindex packets, reporting on stdout | |
406 | @cindex serial connections, debugging | |
407 | If you have trouble with the serial connection, you can use the command | |
408 | @code{set remotedebug}. This makes @value{GDBN} report on all packets sent | |
409 | back and forth across the serial line to the remote machine. The | |
410 | packet-debugging information is printed on the @value{GDBN} standard output | |
411 | stream. @code{set remotedebug off} turns it off, and @code{show | |
412 | remotedebug} will show you its current state. | |
413 | ||
414 | @ifset GDBSERVER | |
415 | @node Server | |
416 | @subsubsection Using the @code{gdbserver} program | |
417 | ||
418 | @kindex gdbserver | |
419 | @cindex remote connection without stubs | |
420 | @code{gdbserver} is a control program for Unix-like systems, which | |
421 | allows you to connect your program with a remote @value{GDBN} via | |
422 | @code{target remote}---but without linking in the usual debugging stub. | |
423 | ||
424 | @code{gdbserver} is not a complete replacement for the debugging stubs, | |
425 | because it requires essentially the same operating-system facilities | |
426 | that @value{GDBN} itself does. In fact, a system that can run | |
427 | @code{gdbserver} to connect to a remote @value{GDBN} could also run | |
428 | @var{GDBN} locally! @code{gdbserver} is sometimes useful nevertheless, | |
429 | because it is a much smaller program than @value{GDBN} itself. It is | |
430 | also easier to port than all of @var{GDBN}, so you may be able to get | |
431 | started more quickly on a new system by using @code{gdbserver}. | |
432 | ||
433 | @value{GDBN} and @code{gdbserver} communicate via either a serial line | |
434 | or a TCP connection, using the standard @value{GDBN} remote serial | |
435 | protocol. | |
436 | ||
437 | @table @emph | |
438 | @item On the target, | |
439 | you need to have a copy of the program you want to debug. | |
440 | @code{gdbserver} does not need your program's symbol table, so you can | |
441 | strip the program if necessary to save space. @value{GDBN} on the host | |
442 | system does all the symbol handling. | |
443 | ||
444 | To use the server, you must tell it how to communicate with @value{GDB}; | |
445 | the name of your program; and the arguments for your program. The | |
446 | syntax is: | |
447 | ||
448 | @smallexample | |
449 | target> gdbserver @var{comm} @var{program} [ @var{args} @dots{} ] | |
450 | @end smallexample | |
451 | ||
452 | @var{comm} is either a device name (to use a serial line) or a TCP | |
453 | hostname and portnumber. For example, to debug emacs with the argument | |
454 | @samp{foo.txt} and communicate with @value{GDBN} over the serial port | |
455 | @file{/dev/com1}: | |
456 | ||
457 | @smallexample | |
458 | target> gdbserver /dev/com1 emacs foo.txt | |
459 | @end smallexample | |
460 | ||
461 | @code{gdbserver} waits passively for the host @value{GDBN} to communicate | |
462 | with it. | |
463 | ||
464 | To use a TCP connection instead of a serial line: | |
465 | ||
466 | @smallexample | |
467 | target> gdbserver host:2345 emacs foo.txt | |
468 | @end smallexample | |
469 | ||
470 | The only difference from the previous example is the first argument, | |
471 | specifying that you are communicating with the host @value{GDBN} via | |
472 | TCP. The @samp{host:2345} argument means that @code{gdbserver} is to | |
473 | expect a TCP connection from machine @samp{host} to local TCP port 2345. | |
474 | (Currently, the @samp{host} part is ignored.) You can choose any number | |
475 | you want for the port number as long as it does not conflict with any | |
476 | TCP ports already in use on the target system.@footnote{If you choose a | |
477 | port number that conflicts with another service, @code{gdbserver} prints | |
478 | an error message and exits.} You must use the same port number with the | |
479 | host @value{GDBN} @code{target remote} command. | |
480 | ||
481 | @item On the host, | |
482 | you need an unstripped copy of your program, since | |
483 | @value{GDBN} needs symbols and debugging information. Start up | |
484 | @value{GDBN} as usual, using the name of the local copy of your program | |
485 | as the first argument. (You may also need the | |
486 | @samp{--baud} option if the serial line is running at anything other than 9600 bps.) | |
487 | After that, use @code{target remote} to establish communications with @code{gdbserver}. Its argument is either | |
488 | a device name (usually a serial device, like @file{/dev/ttyb}), or a TCP | |
489 | port descriptof in the form @code{@var{host}:@var{PORT}}. For example: | |
490 | ||
491 | @smallexample | |
492 | (@value{GDBP}) target remote /dev/ttyb | |
493 | @end smallexample | |
494 | ||
495 | @noindent | |
496 | communicates with the server via serial line @file{/dev/ttyb}, and | |
497 | ||
498 | @smallexample | |
499 | (@value{GDBP}) target remote the-target:2345 | |
500 | @end smallexample | |
501 | ||
502 | @noindent | |
503 | communicates via a TCP connection to port 2345 on host @file{the-target}. | |
504 | For TCP connections, you must start up @code{gdbserver} prior to using | |
505 | the @code{target remote} command. Otherwise you may get an error whose | |
506 | text depends on the host system, but which usually looks something like | |
507 | @samp{Connection refused}. | |
508 | @end table | |
509 | @end ifset | |
510 | ||
511 | @end ifset | |
512 | ||
513 | @ifset I960 | |
514 | @node i960-Nindy Remote | |
515 | @subsection @value{GDBN} with a remote i960 (Nindy) | |
516 | ||
517 | @cindex Nindy | |
518 | @cindex i960 | |
519 | @dfn{Nindy} is a ROM Monitor program for Intel 960 target systems. When | |
520 | @value{GDBN} is configured to control a remote Intel 960 using Nindy, you can | |
521 | tell @value{GDBN} how to connect to the 960 in several ways: | |
522 | ||
523 | @itemize @bullet | |
524 | @item | |
525 | Through command line options specifying serial port, version of the | |
526 | Nindy protocol, and communications speed; | |
527 | ||
528 | @item | |
529 | By responding to a prompt on startup; | |
530 | ||
531 | @item | |
532 | By using the @code{target} command at any point during your @value{GDBN} | |
533 | session. @xref{Target Commands, ,Commands for managing targets}. | |
534 | ||
535 | @end itemize | |
536 | ||
537 | @menu | |
538 | * Nindy Startup:: Startup with Nindy | |
539 | * Nindy Options:: Options for Nindy | |
540 | * Nindy Reset:: Nindy reset command | |
541 | @end menu | |
542 | ||
543 | @node Nindy Startup | |
544 | @subsubsection Startup with Nindy | |
545 | ||
546 | If you simply start @code{@value{GDBP}} without using any command-line | |
547 | options, you are prompted for what serial port to use, @emph{before} you | |
548 | reach the ordinary @value{GDBN} prompt: | |
549 | ||
550 | @example | |
551 | Attach /dev/ttyNN -- specify NN, or "quit" to quit: | |
552 | @end example | |
553 | ||
554 | @noindent | |
555 | Respond to the prompt with whatever suffix (after @samp{/dev/tty}) | |
556 | identifies the serial port you want to use. You can, if you choose, | |
557 | simply start up with no Nindy connection by responding to the prompt | |
558 | with an empty line. If you do this and later wish to attach to Nindy, | |
559 | use @code{target} (@pxref{Target Commands, ,Commands for managing targets}). | |
560 | ||
561 | @node Nindy Options | |
562 | @subsubsection Options for Nindy | |
563 | ||
564 | These are the startup options for beginning your @value{GDBN} session with a | |
565 | Nindy-960 board attached: | |
566 | ||
567 | @table @code | |
568 | @item -r @var{port} | |
569 | Specify the serial port name of a serial interface to be used to connect | |
570 | to the target system. This option is only available when @value{GDBN} is | |
571 | configured for the Intel 960 target architecture. You may specify | |
572 | @var{port} as any of: a full pathname (e.g. @samp{-r /dev/ttya}), a | |
573 | device name in @file{/dev} (e.g. @samp{-r ttya}), or simply the unique | |
574 | suffix for a specific @code{tty} (e.g. @samp{-r a}). | |
575 | ||
576 | @item -O | |
577 | (An uppercase letter ``O'', not a zero.) Specify that @value{GDBN} should use | |
578 | the ``old'' Nindy monitor protocol to connect to the target system. | |
579 | This option is only available when @value{GDBN} is configured for the Intel 960 | |
580 | target architecture. | |
581 | ||
582 | @quotation | |
583 | @emph{Warning:} if you specify @samp{-O}, but are actually trying to | |
584 | connect to a target system that expects the newer protocol, the connection | |
585 | fails, appearing to be a speed mismatch. @value{GDBN} repeatedly | |
586 | attempts to reconnect at several different line speeds. You can abort | |
587 | this process with an interrupt. | |
588 | @end quotation | |
589 | ||
590 | @item -brk | |
591 | Specify that @value{GDBN} should first send a @code{BREAK} signal to the target | |
592 | system, in an attempt to reset it, before connecting to a Nindy target. | |
593 | ||
594 | @quotation | |
595 | @emph{Warning:} Many target systems do not have the hardware that this | |
596 | requires; it only works with a few boards. | |
597 | @end quotation | |
598 | @end table | |
599 | ||
600 | The standard @samp{-b} option controls the line speed used on the serial | |
601 | port. | |
602 | ||
603 | @c @group | |
604 | @node Nindy Reset | |
605 | @subsubsection Nindy reset command | |
606 | ||
607 | @table @code | |
608 | @item reset | |
609 | @kindex reset | |
610 | For a Nindy target, this command sends a ``break'' to the remote target | |
611 | system; this is only useful if the target has been equipped with a | |
612 | circuit to perform a hard reset (or some other interesting action) when | |
613 | a break is detected. | |
614 | @end table | |
615 | @c @end group | |
616 | @end ifset | |
617 | ||
618 | @ifset AMD29K | |
619 | @node UDI29K Remote | |
620 | @subsection @value{GDBN} and the UDI protocol for AMD29K | |
621 | ||
622 | @cindex UDI | |
623 | @cindex AMD29K via UDI | |
624 | @value{GDBN} supports AMD's UDI (``Universal Debugger Interface'') | |
625 | protocol for debugging the a29k processor family. To use this | |
626 | configuration with AMD targets running the MiniMON monitor, you need the | |
627 | program @code{MONTIP}, available from AMD at no charge. You can also | |
628 | use @value{GDBN} with the UDI conformant a29k simulator program | |
629 | @code{ISSTIP}, also available from AMD. | |
630 | ||
631 | @table @code | |
632 | @item target udi @var{keyword} | |
633 | @kindex udi | |
634 | Select the UDI interface to a remote a29k board or simulator, where | |
635 | @var{keyword} is an entry in the AMD configuration file @file{udi_soc}. | |
636 | This file contains keyword entries which specify parameters used to | |
637 | connect to a29k targets. If the @file{udi_soc} file is not in your | |
638 | working directory, you must set the environment variable @samp{UDICONF} | |
639 | to its pathname. | |
640 | @end table | |
641 | ||
642 | @node EB29K Remote | |
643 | @subsection @value{GDBN} and the EBMON protocol for AMD29K | |
644 | ||
645 | @cindex EB29K board | |
646 | @cindex running 29K programs | |
647 | ||
648 | AMD distributes a 29K development board meant to fit in a PC, together | |
649 | with a DOS-hosted monitor program called @code{EBMON}. As a shorthand | |
650 | term, this development system is called the ``EB29K''. To use | |
651 | @value{GDBN} from a Unix system to run programs on the EB29K board, you | |
652 | must first connect a serial cable between the PC (which hosts the EB29K | |
653 | board) and a serial port on the Unix system. In the following, we | |
654 | assume you've hooked the cable between the PC's @file{COM1} port and | |
655 | @file{/dev/ttya} on the Unix system. | |
656 | ||
657 | @menu | |
658 | * Comms (EB29K):: Communications setup | |
659 | * gdb-EB29K:: EB29K cross-debugging | |
660 | * Remote Log:: Remote log | |
661 | @end menu | |
662 | ||
663 | @node Comms (EB29K) | |
664 | @subsubsection Communications setup | |
665 | ||
666 | The next step is to set up the PC's port, by doing something like this | |
667 | in DOS on the PC: | |
668 | ||
669 | @example | |
670 | C:\> MODE com1:9600,n,8,1,none | |
671 | @end example | |
672 | ||
673 | @noindent | |
674 | This example---run on an MS DOS 4.0 system---sets the PC port to 9600 | |
675 | bps, no parity, eight data bits, one stop bit, and no ``retry'' action; | |
676 | you must match the communications parameters when establishing the Unix | |
677 | end of the connection as well. | |
678 | @c FIXME: Who knows what this "no retry action" crud from the DOS manual may | |
679 | @c mean? It's optional; leave it out? ---pesch@cygnus.com, 25feb91 | |
680 | ||
681 | To give control of the PC to the Unix side of the serial line, type | |
682 | the following at the DOS console: | |
683 | ||
684 | @example | |
685 | C:\> CTTY com1 | |
686 | @end example | |
687 | ||
688 | @noindent | |
689 | (Later, if you wish to return control to the DOS console, you can use | |
690 | the command @code{CTTY con}---but you must send it over the device that | |
691 | had control, in our example over the @file{COM1} serial line). | |
692 | ||
693 | From the Unix host, use a communications program such as @code{tip} or | |
694 | @code{cu} to communicate with the PC; for example, | |
695 | ||
696 | @example | |
697 | cu -s 9600 -l /dev/ttya | |
698 | @end example | |
699 | ||
700 | @noindent | |
701 | The @code{cu} options shown specify, respectively, the linespeed and the | |
702 | serial port to use. If you use @code{tip} instead, your command line | |
703 | may look something like the following: | |
704 | ||
705 | @example | |
706 | tip -9600 /dev/ttya | |
707 | @end example | |
708 | ||
709 | @noindent | |
710 | Your system may require a different name where we show | |
711 | @file{/dev/ttya} as the argument to @code{tip}. The communications | |
712 | parameters, including which port to use, are associated with the | |
713 | @code{tip} argument in the ``remote'' descriptions file---normally the | |
714 | system table @file{/etc/remote}. | |
715 | @c FIXME: What if anything needs doing to match the "n,8,1,none" part of | |
716 | @c the DOS side's comms setup? cu can support -o (odd | |
717 | @c parity), -e (even parity)---apparently no settings for no parity or | |
718 | @c for character size. Taken from stty maybe...? John points out tip | |
719 | @c can set these as internal variables, eg ~s parity=none; man stty | |
720 | @c suggests that it *might* work to stty these options with stdin or | |
721 | @c stdout redirected... ---pesch@cygnus.com, 25feb91 | |
722 | ||
723 | @kindex EBMON | |
724 | Using the @code{tip} or @code{cu} connection, change the DOS working | |
725 | directory to the directory containing a copy of your 29K program, then | |
726 | start the PC program @code{EBMON} (an EB29K control program supplied | |
727 | with your board by AMD). You should see an initial display from | |
728 | @code{EBMON} similar to the one that follows, ending with the | |
729 | @code{EBMON} prompt @samp{#}--- | |
730 | ||
731 | @example | |
732 | C:\> G: | |
733 | ||
734 | G:\> CD \usr\joe\work29k | |
735 | ||
736 | G:\USR\JOE\WORK29K> EBMON | |
737 | Am29000 PC Coprocessor Board Monitor, version 3.0-18 | |
738 | Copyright 1990 Advanced Micro Devices, Inc. | |
739 | Written by Gibbons and Associates, Inc. | |
740 | ||
741 | Enter '?' or 'H' for help | |
742 | ||
743 | PC Coprocessor Type = EB29K | |
744 | I/O Base = 0x208 | |
745 | Memory Base = 0xd0000 | |
746 | ||
747 | Data Memory Size = 2048KB | |
748 | Available I-RAM Range = 0x8000 to 0x1fffff | |
749 | Available D-RAM Range = 0x80002000 to 0x801fffff | |
750 | ||
751 | PageSize = 0x400 | |
752 | Register Stack Size = 0x800 | |
753 | Memory Stack Size = 0x1800 | |
754 | ||
755 | CPU PRL = 0x3 | |
756 | Am29027 Available = No | |
757 | Byte Write Available = Yes | |
758 | ||
759 | # ~. | |
760 | @end example | |
761 | ||
762 | Then exit the @code{cu} or @code{tip} program (done in the example by | |
763 | typing @code{~.} at the @code{EBMON} prompt). @code{EBMON} will keep | |
764 | running, ready for @value{GDBN} to take over. | |
765 | ||
766 | For this example, we've assumed what is probably the most convenient | |
767 | way to make sure the same 29K program is on both the PC and the Unix | |
768 | system: a PC/NFS connection that establishes ``drive @code{G:}'' on the | |
769 | PC as a file system on the Unix host. If you do not have PC/NFS or | |
770 | something similar connecting the two systems, you must arrange some | |
771 | other way---perhaps floppy-disk transfer---of getting the 29K program | |
772 | from the Unix system to the PC; @value{GDBN} will @emph{not} download it over the | |
773 | serial line. | |
774 | ||
775 | @node gdb-EB29K | |
776 | @subsubsection EB29K cross-debugging | |
777 | ||
778 | Finally, @code{cd} to the directory containing an image of your 29K | |
779 | program on the Unix system, and start @value{GDBN}---specifying as argument the | |
780 | name of your 29K program: | |
781 | ||
782 | @example | |
783 | cd /usr/joe/work29k | |
784 | @value{GDBP} myfoo | |
785 | @end example | |
786 | ||
787 | Now you can use the @code{target} command: | |
788 | ||
789 | @example | |
790 | target amd-eb /dev/ttya 9600 MYFOO | |
791 | @c FIXME: test above 'target amd-eb' as spelled, with caps! caps are meant to | |
792 | @c emphasize that this is the name as seen by DOS (since I think DOS is | |
793 | @c single-minded about case of letters). ---pesch@cygnus.com, 25feb91 | |
794 | @end example | |
795 | ||
796 | @noindent | |
797 | In this example, we've assumed your program is in a file called | |
798 | @file{myfoo}. Note that the filename given as the last argument to | |
799 | @code{target amd-eb} should be the name of the program as it appears to DOS. | |
800 | In our example this is simply @code{MYFOO}, but in general it can include | |
801 | a DOS path, and depending on your transfer mechanism may not resemble | |
802 | the name on the Unix side. | |
803 | ||
804 | At this point, you can set any breakpoints you wish; when you are ready | |
805 | to see your program run on the 29K board, use the @value{GDBN} command | |
806 | @code{run}. | |
807 | ||
808 | To stop debugging the remote program, use the @value{GDBN} @code{detach} | |
809 | command. | |
810 | ||
811 | To return control of the PC to its console, use @code{tip} or @code{cu} | |
812 | once again, after your @value{GDBN} session has concluded, to attach to | |
813 | @code{EBMON}. You can then type the command @code{q} to shut down | |
814 | @code{EBMON}, returning control to the DOS command-line interpreter. | |
815 | Type @code{CTTY con} to return command input to the main DOS console, | |
816 | and type @kbd{~.} to leave @code{tip} or @code{cu}. | |
817 | ||
818 | @node Remote Log | |
819 | @subsubsection Remote log | |
820 | @kindex eb.log | |
821 | @cindex log file for EB29K | |
822 | ||
823 | The @code{target amd-eb} command creates a file @file{eb.log} in the | |
824 | current working directory, to help debug problems with the connection. | |
825 | @file{eb.log} records all the output from @code{EBMON}, including echoes | |
826 | of the commands sent to it. Running @samp{tail -f} on this file in | |
827 | another window often helps to understand trouble with @code{EBMON}, or | |
828 | unexpected events on the PC side of the connection. | |
829 | ||
830 | @end ifset | |
831 | ||
832 | @ifset ST2000 | |
833 | @node ST2000 Remote | |
834 | @subsection @value{GDBN} with a Tandem ST2000 | |
835 | ||
836 | To connect your ST2000 to the host system, see the manufacturer's | |
837 | manual. Once the ST2000 is physically attached, you can run | |
838 | ||
839 | @example | |
840 | target st2000 @var{dev} @var{speed} | |
841 | @end example | |
842 | ||
843 | @noindent | |
844 | to establish it as your debugging environment. @var{dev} is normally | |
845 | the name of a serial device, such as @file{/dev/ttya}, connected to the | |
846 | ST2000 via a serial line. You can instead specify @var{dev} as a TCP | |
847 | connection (for example, to a serial line attached via a terminal | |
848 | concentrator) using the syntax @code{@var{hostname}:@var{portnumber}}. | |
849 | ||
850 | The @code{load} and @code{attach} commands are @emph{not} defined for | |
851 | this target; you must load your program into the ST2000 as you normally | |
852 | would for standalone operation. @value{GDBN} will read debugging information | |
853 | (such as symbols) from a separate, debugging version of the program | |
854 | available on your host computer. | |
855 | @c FIXME!! This is terribly vague; what little content is here is | |
856 | @c basically hearsay. | |
857 | ||
858 | @cindex ST2000 auxiliary commands | |
859 | These auxiliary @value{GDBN} commands are available to help you with the ST2000 | |
860 | environment: | |
861 | ||
862 | @table @code | |
863 | @item st2000 @var{command} | |
864 | @kindex st2000 @var{cmd} | |
865 | @cindex STDBUG commands (ST2000) | |
866 | @cindex commands to STDBUG (ST2000) | |
867 | Send a @var{command} to the STDBUG monitor. See the manufacturer's | |
868 | manual for available commands. | |
869 | ||
870 | @item connect | |
871 | @cindex connect (to STDBUG) | |
872 | Connect the controlling terminal to the STDBUG command monitor. When | |
873 | you are done interacting with STDBUG, typing either of two character | |
874 | sequences will get you back to the @value{GDBN} command prompt: | |
875 | @kbd{@key{RET}~.} (Return, followed by tilde and period) or | |
876 | @kbd{@key{RET}~@key{C-d}} (Return, followed by tilde and control-D). | |
877 | @end table | |
878 | @end ifset | |
879 | ||
880 | @ifset VXWORKS | |
881 | @node VxWorks Remote | |
882 | @subsection @value{GDBN} and VxWorks | |
883 | @cindex VxWorks | |
884 | ||
885 | @value{GDBN} enables developers to spawn and debug tasks running on networked | |
886 | VxWorks targets from a Unix host. Already-running tasks spawned from | |
887 | the VxWorks shell can also be debugged. @value{GDBN} uses code that runs on | |
6b51acad RP |
888 | both the Unix host and on the VxWorks target. The program |
889 | @code{gdb} is installed and executed on the Unix host. (It may be | |
4af6d502 RP |
890 | installed with the name @code{vxgdb}, to distinguish it from a |
891 | @value{GDBN} for debugging programs on the host itself.) | |
892 | ||
893 | The following information on connecting to VxWorks was current when | |
894 | this manual was produced; newer releases of VxWorks may use revised | |
895 | procedures. | |
896 | ||
897 | The remote debugging interface (RDB) routines are installed and executed | |
898 | on the VxWorks target. These routines are included in the VxWorks library | |
899 | @file{rdb.a} and are incorporated into the system image when source-level | |
900 | debugging is enabled in the VxWorks configuration. | |
901 | ||
902 | @kindex INCLUDE_RDB | |
903 | If you wish, you can define @code{INCLUDE_RDB} in the VxWorks | |
904 | configuration file @file{configAll.h} to include the RDB interface | |
905 | routines and spawn the source debugging task @code{tRdbTask} when | |
906 | VxWorks is booted. For more information on configuring and remaking | |
907 | VxWorks, see the manufacturer's manual. | |
908 | @c VxWorks, see the @cite{VxWorks Programmer's Guide}. | |
909 | ||
910 | Once you have included the RDB interface in your VxWorks system image | |
911 | and set your Unix execution search path to find @value{GDBN}, you are ready | |
6b51acad | 912 | to run @value{GDBN}. From your Unix host, run @code{gdb} (or |
4af6d502 RP |
913 | @code{vxgdb}, depending on your installation). |
914 | ||
915 | @value{GDBN} comes up showing the prompt: | |
916 | ||
917 | @example | |
918 | (vxgdb) | |
919 | @end example | |
920 | ||
921 | @menu | |
922 | * VxWorks Connection:: Connecting to VxWorks | |
923 | * VxWorks Download:: VxWorks download | |
924 | * VxWorks Attach:: Running tasks | |
925 | @end menu | |
926 | ||
927 | @node VxWorks Connection | |
928 | @subsubsection Connecting to VxWorks | |
929 | ||
930 | The @value{GDBN} command @code{target} lets you connect to a VxWorks target on the | |
931 | network. To connect to a target whose host name is ``@code{tt}'', type: | |
932 | ||
933 | @example | |
934 | (vxgdb) target vxworks tt | |
935 | @end example | |
936 | ||
937 | @value{GDBN} displays messages like these: | |
938 | ||
939 | @smallexample | |
940 | Attaching remote machine across net... | |
941 | Connected to tt. | |
942 | @end smallexample | |
943 | ||
944 | @value{GDBN} then attempts to read the symbol tables of any object modules | |
945 | loaded into the VxWorks target since it was last booted. @value{GDBN} locates | |
946 | these files by searching the directories listed in the command search | |
947 | path (@pxref{Environment, ,Your program's environment}); if it fails | |
948 | to find an object file, it displays a message such as: | |
949 | ||
950 | @example | |
951 | prog.o: No such file or directory. | |
952 | @end example | |
953 | ||
954 | When this happens, add the appropriate directory to the search path with | |
955 | the @value{GDBN} command @code{path}, and execute the @code{target} | |
956 | command again. | |
957 | ||
958 | @node VxWorks Download | |
959 | @subsubsection VxWorks download | |
960 | ||
961 | @cindex download to VxWorks | |
962 | If you have connected to the VxWorks target and you want to debug an | |
963 | object that has not yet been loaded, you can use the @value{GDBN} | |
6b51acad | 964 | @code{load} command to download a file from Unix to VxWorks |
4af6d502 RP |
965 | incrementally. The object file given as an argument to the @code{load} |
966 | command is actually opened twice: first by the VxWorks target in order | |
967 | to download the code, then by @value{GDBN} in order to read the symbol | |
968 | table. This can lead to problems if the current working directories on | |
969 | the two systems differ. If both systems have NFS mounted the same | |
970 | filesystems, you can avoid these problems by using absolute paths. | |
971 | Otherwise, it is simplest to set the working directory on both systems | |
972 | to the directory in which the object file resides, and then to reference | |
973 | the file by its name, without any path. For instance, a program | |
974 | @file{prog.o} may reside in @file{@var{vxpath}/vw/demo/rdb} in VxWorks | |
975 | and in @file{@var{hostpath}/vw/demo/rdb} on the host. To load this | |
976 | program, type this on VxWorks: | |
977 | ||
978 | @example | |
979 | -> cd "@var{vxpath}/vw/demo/rdb" | |
980 | @end example | |
981 | ||
982 | Then, in @value{GDBN}, type: | |
983 | ||
984 | @example | |
985 | (vxgdb) cd @var{hostpath}/vw/demo/rdb | |
986 | (vxgdb) load prog.o | |
987 | @end example | |
988 | ||
989 | @value{GDBN} displays a response similar to this: | |
990 | ||
991 | @smallexample | |
992 | Reading symbol data from wherever/vw/demo/rdb/prog.o... done. | |
993 | @end smallexample | |
994 | ||
995 | You can also use the @code{load} command to reload an object module | |
996 | after editing and recompiling the corresponding source file. Note that | |
997 | this will cause @value{GDBN} to delete all currently-defined breakpoints, | |
998 | auto-displays, and convenience variables, and to clear the value | |
999 | history. (This is necessary in order to preserve the integrity of | |
1000 | debugger data structures that reference the target system's symbol | |
1001 | table.) | |
1002 | ||
1003 | @node VxWorks Attach | |
1004 | @subsubsection Running tasks | |
1005 | ||
1006 | @cindex running VxWorks tasks | |
1007 | You can also attach to an existing task using the @code{attach} command as | |
1008 | follows: | |
1009 | ||
1010 | @example | |
1011 | (vxgdb) attach @var{task} | |
1012 | @end example | |
1013 | ||
1014 | @noindent | |
1015 | where @var{task} is the VxWorks hexadecimal task ID. The task can be running | |
1016 | or suspended when you attach to it. If running, it will be suspended at | |
1017 | the time of attachment. | |
1018 | @end ifset | |
1019 | ||
1020 | @ifset H8 | |
1021 | @node Hitachi Remote | |
1022 | @subsection @value{GDBN} and Hitachi Microprocessors | |
1023 | @value{GDBN} needs to know these things to talk to your | |
1024 | Hitachi SH, H8/300, or H8/500: | |
1025 | ||
1026 | @enumerate | |
1027 | @item | |
1028 | that you want to use @samp{target hms}, the remote debugging interface | |
1029 | for Hitachi microprocessors (this is the default when GDB is configured | |
1030 | specifically for the Hitachi SH, H8/300, or H8/500); | |
1031 | ||
1032 | @item | |
1033 | what serial device connects your host to your Hitachi board (the first | |
1034 | serial device available on your host is the default); | |
1035 | ||
1036 | @ignore | |
1037 | @c this is only for Unix hosts, not currently of interest. | |
1038 | @item | |
1039 | what speed to use over the serial device. | |
1040 | @end ignore | |
1041 | @end enumerate | |
1042 | ||
1043 | @ifclear H8EXCLUSIVE | |
1044 | @c only for Unix hosts | |
1045 | @kindex device | |
1046 | @cindex serial device, Hitachi micros | |
1047 | Use the special @code{@value{GDBP}} command @samp{device @var{port}} if you | |
1048 | need to explicitly set the serial device. The default @var{port} is the | |
1049 | first available port on your host. This is only necessary on Unix | |
1050 | hosts, where it is typically something like @file{/dev/ttya}. | |
1051 | ||
1052 | @kindex speed | |
1053 | @cindex serial line speed, Hitachi micros | |
1054 | @code{@value{GDBP}} has another special command to set the communications | |
1055 | speed: @samp{speed @var{bps}}. This command also is only used from Unix | |
1056 | hosts; on DOS hosts, set the line speed as usual from outside GDB with | |
1057 | the DOS @kbd{mode} command (for instance, @w{@samp{mode | |
1058 | com2:9600,n,8,1,p}} for a 9600 bps connection). | |
1059 | ||
1060 | The @samp{device} and @samp{speed} commands are available only when you | |
1061 | use a Unix host to debug your Hitachi microprocessor programs. If you | |
1062 | use a DOS host, | |
1063 | @end ifclear | |
1064 | @value{GDBN} depends on an auxiliary terminate-and-stay-resident program | |
1065 | called @code{asynctsr} to communicate with the development board | |
1066 | through a PC serial port. You must also use the DOS @code{mode} command | |
1067 | to set up the serial port on the DOS side. | |
1068 | ||
1069 | @ifset DOSHOST | |
1070 | The following sample session illustrates the steps needed to start a | |
1071 | program under @value{GDBN} control on an H8/300. The example uses a | |
1072 | sample H8/300 program called @file{t.x}. The procedure is the same for | |
1073 | the Hitachi SH and the H8/500. | |
1074 | ||
1075 | First hook up your development board. In this example, we use a | |
1076 | board attached to serial port @code{COM2}; if you use a different serial | |
1077 | port, substitute its name in the argument of the @code{mode} command. | |
1078 | When you call @code{asynctsr}, the auxiliary comms program used by the | |
1079 | degugger, you give it just the numeric part of the serial port's name; | |
1080 | for example, @samp{asyncstr 2} below runs @code{asyncstr} on | |
1081 | @code{COM2}. | |
1082 | ||
1083 | @example | |
1084 | (eg-C:\H8300\TEST) mode com2:9600,n,8,1,p | |
1085 | ||
1086 | Resident portion of MODE loaded | |
1087 | ||
1088 | COM2: 9600, n, 8, 1, p | |
1089 | ||
1090 | (eg-C:\H8300\TEST) asynctsr 2 | |
1091 | @end example | |
1092 | ||
1093 | @quotation | |
1094 | @emph{Warning:} We have noticed a bug in PC-NFS that conflicts with | |
1095 | @code{asynctsr}. If you also run PC-NFS on your DOS host, you may need to | |
1096 | disable it, or even boot without it, to use @code{asynctsr} to control | |
1097 | your development board. | |
1098 | @end quotation | |
1099 | ||
1100 | @kindex target hms | |
1101 | Now that serial communications are set up, and the development board is | |
1102 | connected, you can start up @value{GDBN}. Call @code{@value{GDBP}} with | |
1103 | the name of your program as the argument. @code{@value{GDBP}} prompts | |
1104 | you, as usual, with the prompt @samp{(@value{GDBP})}. Use two special | |
1105 | commands to begin your debugging session: @samp{target hms} to specify | |
1106 | cross-debugging to the Hitachi board, and the @code{load} command to | |
1107 | download your program to the board. @code{load} displays the names of | |
1108 | the program's sections, and a @samp{*} for each 2K of data downloaded. | |
1109 | (If you want to refresh @value{GDBN} data on symbols or on the | |
1110 | executable file without downloading, use the @value{GDBN} commands | |
1111 | @code{file} or @code{symbol-file}. These commands, and @code{load} | |
1112 | itself, are described in @ref{Files,,Commands to specify files}.) | |
1113 | ||
1114 | @smallexample | |
1115 | (eg-C:\H8300\TEST) @value{GDBP} t.x | |
1116 | GDB is free software and you are welcome to distribute copies | |
1117 | of it under certain conditions; type "show copying" to see | |
1118 | the conditions. | |
1119 | There is absolutely no warranty for GDB; type "show warranty" | |
1120 | for details. | |
1121 | GDB @value{GDBVN}, Copyright 1992 Free Software Foundation, Inc... | |
1122 | (gdb) target hms | |
1123 | Connected to remote H8/300 HMS system. | |
1124 | (gdb) load t.x | |
1125 | .text : 0x8000 .. 0xabde *********** | |
1126 | .data : 0xabde .. 0xad30 * | |
1127 | .stack : 0xf000 .. 0xf014 * | |
1128 | @end smallexample | |
1129 | ||
1130 | At this point, you're ready to run or debug your program. From here on, | |
1131 | you can use all the usual @value{GDBN} commands. The @code{break} command | |
1132 | sets breakpoints; the @code{run} command starts your program; | |
1133 | @code{print} or @code{x} display data; the @code{continue} command | |
1134 | resumes execution after stopping at a breakpoint. You can use the | |
1135 | @code{help} command at any time to find out more about @value{GDBN} commands. | |
1136 | ||
1137 | Remember, however, that @emph{operating system} facilities aren't | |
1138 | available on your development board; for example, if your program hangs, | |
1139 | you can't send an interrupt---but you can press the @sc{reset} switch! | |
1140 | ||
1141 | Use the @sc{reset} button on the development board | |
1142 | @itemize @bullet | |
1143 | @item | |
1144 | to interrupt your program (don't use @kbd{ctl-C} on the DOS host---it has | |
1145 | no way to pass an interrupt signal to the development board); and | |
1146 | ||
1147 | @item | |
1148 | to return to the @value{GDBN} command prompt after your program finishes | |
1149 | normally. The communications protocol provides no other way for @value{GDBN} | |
1150 | to detect program completion. | |
1151 | @end itemize | |
1152 | ||
1153 | In either case, @value{GDBN} will see the effect of a @sc{reset} on the | |
1154 | development board as a ``normal exit'' of your program. | |
1155 | @end ifset | |
1156 | @end ifset | |
1157 | ||
1158 | @ifset MIPS | |
1159 | @node MIPS Remote | |
1160 | @subsection @value{GDBN} and remote MIPS boards | |
1161 | ||
1162 | @cindex MIPS boards | |
1163 | @value{GDBN} can use the MIPS remote debugging protocol to talk to a | |
1164 | MIPS board attached to a serial line. This is available when | |
1165 | you configure @value{GDBN} with @samp{--target=mips-idt-ecoff}. | |
1166 | ||
1167 | @kindex target mips @var{port} | |
1168 | To run a program on the board, start up @code{@value{GDBP}} with the | |
1169 | name of your program as the argument. To connect to the board, use the | |
1170 | command @samp{target mips @var{port}}, where @var{port} is the name of | |
1171 | the serial port connected to the board. If the program has not already | |
1172 | been downloaded to the board, you may use the @code{load} command to | |
1173 | download it. You can then use all the usual @value{GDBN} commands. | |
1174 | ||
1175 | You can also specify @var{port} as a TCP connection (for instance, to a | |
1176 | serial line managed by a terminal concentrator), using the syntax | |
1177 | @code{@var{hostname}:@var{portnumber}}. | |
1178 | ||
1179 | @cindex @code{remotedebug}, MIPS protocol | |
1180 | @c FIXME! For this to be useful, you must know something about the MIPS | |
1181 | @c FIXME...protocol. Where is it described? | |
1182 | You can see some debugging information about communications with the board | |
1183 | by setting the @code{remotedebug} variable. If you set it to 1 using | |
1184 | @samp{set remotedebug 1} every packet will be displayed. If you set it | |
1185 | to 2 every character will be displayed. You can check the current value | |
1186 | at any time with the command @samp{show remotedebug}. | |
1187 | ||
1188 | @cindex @code{timeout}, MIPS protocol | |
1189 | @cindex @code{retransmit-timeout}, MIPS protocol | |
f21c5362 RP |
1190 | @kindex set timeout |
1191 | @kindex show timeout | |
1192 | @kindex set retransmit-timeout | |
1193 | @kindex show retransmit-timeout | |
1194 | You can control the timeout used while waiting for a packet, in the MIPS | |
1195 | remote protocol, with the @code{set timeout @var{seconds}} command. The | |
1196 | default is 5 seconds. Similarly, you can control the timeout used while | |
1197 | waiting for an acknowledgement of a packet with the @code{set | |
1198 | retransmit-timeout @var{seconds}} command. The default is 3 seconds. | |
1199 | You can inspect both values with @code{show timeout} and @code{show | |
1200 | retransmit-timeout}. (These commands are @emph{only} available when | |
1201 | @value{GDBN} is configured for @samp{--target=mips-idt-ecoff}.) | |
4af6d502 RP |
1202 | |
1203 | @kindex set mipsfpu off | |
1204 | @cindex MIPS remote floating point | |
1205 | @cindex floating point, MIPS remote | |
1206 | If your target board does not support the MIPS floating point | |
6b51acad RP |
1207 | coprocessor, you should use the command @samp{set mipsfpu off} (you may |
1208 | wish to put this in your @value{GDBINIT} file). This tells @value{GDBN} | |
1209 | how to find the return value of functions which return floating point | |
1210 | values. It also allows @value{GDBN} to avoid saving the floating point | |
1211 | registers when calling functions on the board. | |
4af6d502 RP |
1212 | @end ifset |
1213 | ||
1214 | @ifset SIMS | |
1215 | @node Simulator | |
1216 | @subsection Simulated CPU target | |
1217 | ||
1218 | @ifset GENERIC | |
1219 | @cindex simulator | |
1220 | @cindex simulator, Z8000 | |
1221 | @cindex Z8000 simulator | |
1222 | @cindex simulator, H8/300 or H8/500 | |
1223 | @cindex H8/300 or H8/500 simulator | |
1224 | @cindex simulator, Hitachi SH | |
1225 | @cindex Hitachi SH simulator | |
1226 | @cindex CPU simulator | |
1227 | For some configurations, @value{GDBN} includes a CPU simulator that you | |
1228 | can use instead of a hardware CPU to debug your programs. Currently, | |
1229 | a simulator is available when @value{GDBN} is configured to debug Zilog | |
1230 | Z8000 or Hitachi microprocessor targets. | |
1231 | @end ifset | |
1232 | ||
1233 | @ifclear GENERIC | |
1234 | @ifset H8 | |
1235 | @cindex simulator, H8/300 or H8/500 | |
1236 | @cindex Hitachi H8/300 or H8/500 simulator | |
1237 | @cindex simulator, Hitachi SH | |
1238 | @cindex Hitachi SH simulator | |
1239 | When configured for debugging Hitachi microprocessor targets, | |
1240 | @value{GDBN} includes a CPU simulator for the target chip (a Hitachi SH, | |
1241 | H8/300, or H8/500). | |
1242 | @end ifset | |
1243 | ||
1244 | @ifset Z8K | |
1245 | @cindex simulator, Z8000 | |
1246 | @cindex Zilog Z8000 simulator | |
1247 | When configured for debugging Zilog Z8000 targets, @value{GDBN} includes | |
1248 | a Z8000 simulator. | |
1249 | @end ifset | |
1250 | @end ifclear | |
1251 | ||
1252 | @ifset Z8K | |
1253 | For the Z8000 family, @samp{target sim} simulates either the Z8002 (the | |
1254 | unsegmented variant of the Z8000 architecture) or the Z8001 (the | |
1255 | segmented variant). The simulator recognizes which architecture is | |
1256 | appropriate by inspecting the object code. | |
1257 | @end ifset | |
1258 | ||
1259 | @table @code | |
1260 | @item target sim | |
1261 | @kindex sim | |
1262 | @kindex target sim | |
1263 | Debug programs on a simulated CPU | |
1264 | @ifset GENERIC | |
1265 | (which CPU depends on the @value{GDBN} configuration) | |
1266 | @end ifset | |
1267 | @end table | |
1268 | ||
1269 | @noindent | |
1270 | After specifying this target, you can debug programs for the simulated | |
1271 | CPU in the same style as programs for your host computer; use the | |
1272 | @code{file} command to load a new program image, the @code{run} command | |
1273 | to run your program, and so on. | |
1274 | ||
1275 | As well as making available all the usual machine registers (see | |
1276 | @code{info reg}), this debugging target provides three additional items | |
1277 | of information as specially named registers: | |
1278 | ||
1279 | @table @code | |
1280 | @item cycles | |
1281 | Counts clock-ticks in the simulator. | |
1282 | ||
1283 | @item insts | |
1284 | Counts instructions run in the simulator. | |
1285 | ||
1286 | @item time | |
1287 | Execution time in 60ths of a second. | |
1288 | @end table | |
1289 | ||
1290 | You can refer to these values in @value{GDBN} expressions with the usual | |
1291 | conventions; for example, @w{@samp{b fputc if $cycles>5000}} sets a | |
1292 | conditional breakpoint that will suspend only after at least 5000 | |
1293 | simulated clock ticks. | |
1294 | @end ifset |