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 | |
af215b1a | 16 | program, you need: |
4af6d502 RP |
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 | |
42d0ec72 SS |
65 | |
66 | @item i386-stub.c | |
67 | @kindex i386-stub.c | |
68 | @cindex Intel | |
69 | @cindex i386 | |
70 | For Intel 386 and compatible architectures. | |
4af6d502 RP |
71 | |
72 | @item m68k-stub.c | |
73 | @kindex m68k-stub.c | |
6b51acad | 74 | @cindex Motorola 680x0 |
02f868b1 | 75 | @cindex m680x0 |
4af6d502 RP |
76 | For Motorola 680x0 architectures. |
77 | ||
42d0ec72 SS |
78 | @item sh-stub.c |
79 | @kindex sh-stub.c | |
80 | @cindex Hitachi | |
81 | @cindex SH | |
82 | For Hitachi SH architectures. | |
83 | ||
84 | @item sparc-stub.c | |
85 | @kindex sparc-stub.c | |
86 | @cindex Sparc | |
87 | For @sc{sparc} architectures. | |
88 | ||
89 | @item sparcl-stub.c | |
90 | @kindex sparcl-stub.c | |
91 | @cindex Fujitsu | |
92 | @cindex SparcLite | |
93 | For Fujitsu @sc{sparclite} architectures. | |
94 | ||
4af6d502 RP |
95 | @end table |
96 | ||
97 | The @file{README} file in the @value{GDBN} distribution may list other | |
98 | recently added stubs. | |
99 | ||
100 | @menu | |
101 | * Stub Contents:: What the stub can do for you | |
102 | * Bootstrapping:: What you must do for the stub | |
103 | * Debug Session:: Putting it all together | |
104 | * Protocol:: Outline of the communication protocol | |
105 | @ifset GDBSERVER | |
106 | * Server:: Using the `gdbserver' program | |
107 | @end ifset | |
07dff010 C |
108 | @ifset GDBSERVE |
109 | * NetWare:: Using the `gdbserve.nlm' program | |
110 | @end ifset | |
4af6d502 RP |
111 | @end menu |
112 | ||
113 | @node Stub Contents | |
114 | @subsubsection What the stub can do for you | |
115 | ||
116 | @cindex remote serial stub | |
117 | The debugging stub for your architecture supplies these three | |
118 | subroutines: | |
119 | ||
120 | @table @code | |
121 | @item set_debug_traps | |
122 | @kindex set_debug_traps | |
123 | @cindex remote serial stub, initialization | |
124 | This routine arranges for @code{handle_exception} to run when your | |
125 | program stops. You must call this subroutine explicitly near the | |
126 | beginning of your program. | |
127 | ||
128 | @item handle_exception | |
129 | @kindex handle_exception | |
130 | @cindex remote serial stub, main routine | |
131 | This is the central workhorse, but your program never calls it | |
132 | explicitly---the setup code arranges for @code{handle_exception} to | |
133 | run when a trap is triggered. | |
134 | ||
135 | @code{handle_exception} takes control when your program stops during | |
136 | execution (for example, on a breakpoint), and mediates communications | |
137 | with @value{GDBN} on the host machine. This is where the communications | |
138 | protocol is implemented; @code{handle_exception} acts as the @value{GDBN} | |
139 | representative on the target machine; it begins by sending summary | |
140 | information on the state of your program, then continues to execute, | |
141 | retrieving and transmitting any information @value{GDBN} needs, until you | |
142 | execute a @value{GDBN} command that makes your program resume; at that point, | |
143 | @code{handle_exception} returns control to your own code on the target | |
144 | machine. | |
145 | ||
146 | @item breakpoint | |
147 | @cindex @code{breakpoint} subroutine, remote | |
148 | Use this auxiliary subroutine to make your program contain a | |
149 | breakpoint. Depending on the particular situation, this may be the only | |
150 | way for @value{GDBN} to get control. For instance, if your target | |
151 | machine has some sort of interrupt button, you won't need to call this; | |
9a27b06e | 152 | pressing the interrupt button transfers control to |
4af6d502 RP |
153 | @code{handle_exception}---in effect, to @value{GDBN}. On some machines, |
154 | simply receiving characters on the serial port may also trigger a trap; | |
155 | again, in that situation, you don't need to call @code{breakpoint} from | |
156 | your own program---simply running @samp{target remote} from the host | |
9a27b06e | 157 | @value{GDBN} session gets control. |
4af6d502 RP |
158 | |
159 | Call @code{breakpoint} if none of these is true, or if you simply want | |
160 | to make certain your program stops at a predetermined point for the | |
161 | start of your debugging session. | |
162 | @end table | |
163 | ||
164 | @node Bootstrapping | |
165 | @subsubsection What you must do for the stub | |
166 | ||
167 | @cindex remote stub, support routines | |
168 | The debugging stubs that come with @value{GDBN} are set up for a particular | |
169 | chip architecture, but they have no information about the rest of your | |
e3b9a485 JK |
170 | debugging target machine. |
171 | ||
172 | First of all you need to tell the stub how to communicate with the | |
173 | serial port. | |
4af6d502 RP |
174 | |
175 | @table @code | |
176 | @item int getDebugChar() | |
177 | @kindex getDebugChar | |
178 | Write this subroutine to read a single character from the serial port. | |
179 | It may be identical to @code{getchar} for your target system; a | |
180 | different name is used to allow you to distinguish the two if you wish. | |
181 | ||
182 | @item void putDebugChar(int) | |
183 | @kindex putDebugChar | |
184 | Write this subroutine to write a single character to the serial port. | |
185 | It may be identical to @code{putchar} for your target system; a | |
186 | different name is used to allow you to distinguish the two if you wish. | |
e3b9a485 JK |
187 | @end table |
188 | ||
22b5dba5 RP |
189 | @cindex control C, and remote debugging |
190 | @cindex interrupting remote targets | |
e3b9a485 JK |
191 | If you want @value{GDBN} to be able to stop your program while it is |
192 | running, you need to use an interrupt-driven serial driver, and arrange | |
22b5dba5 RP |
193 | for it to stop when it receives a @code{^C} (@samp{\003}, the control-C |
194 | character). That is the character which @value{GDBN} uses to tell the | |
195 | remote system to stop. | |
196 | ||
197 | Getting the debugging target to return the proper status to @value{GDBN} | |
198 | probably requires changes to the standard stub; one quick and dirty way | |
199 | is to just execute a breakpoint instruction (the ``dirty'' part is that | |
200 | @value{GDBN} reports a @code{SIGTRAP} instead of a @code{SIGINT}). | |
4af6d502 | 201 | |
e3b9a485 JK |
202 | Other routines you need to supply are: |
203 | ||
204 | @table @code | |
4af6d502 | 205 | @item void exceptionHandler (int @var{exception_number}, void *@var{exception_address}) |
8d8c5f39 | 206 | @kindex exceptionHandler |
4af6d502 RP |
207 | Write this function to install @var{exception_address} in the exception |
208 | handling tables. You need to do this because the stub does not have any | |
209 | way of knowing what the exception handling tables on your target system | |
210 | are like (for example, the processor's table might be in @sc{rom}, | |
211 | containing entries which point to a table in @sc{ram}). | |
212 | @var{exception_number} is the exception number which should be changed; | |
213 | its meaning is architecture-dependent (for example, different numbers | |
214 | might represent divide by zero, misaligned access, etc). When this | |
215 | exception occurs, control should be transferred directly to | |
216 | @var{exception_address}, and the processor state (stack, registers, | |
b1955f0b | 217 | and so on) should be just as it is when a processor exception occurs. So if |
4af6d502 RP |
218 | you want to use a jump instruction to reach @var{exception_address}, it |
219 | should be a simple jump, not a jump to subroutine. | |
220 | ||
4af6d502 | 221 | For the 386, @var{exception_address} should be installed as an interrupt |
8d8c5f39 JK |
222 | gate so that interrupts are masked while the handler runs. The gate |
223 | should be at privilege level 0 (the most privileged level). The | |
af215b1a | 224 | @sc{sparc} and 68k stubs are able to mask interrup themselves without |
4af6d502 RP |
225 | help from @code{exceptionHandler}. |
226 | ||
227 | @item void flush_i_cache() | |
228 | @kindex flush_i_cache | |
0f6bb717 JK |
229 | (sparc and sparclite only) Write this subroutine to flush the |
230 | instruction cache, if any, on your target machine. If there is no | |
231 | instruction cache, this subroutine may be a no-op. | |
4af6d502 RP |
232 | |
233 | On target machines that have instruction caches, @value{GDBN} requires this | |
234 | function to make certain that the state of your program is stable. | |
235 | @end table | |
236 | ||
237 | @noindent | |
238 | You must also make sure this library routine is available: | |
239 | ||
240 | @table @code | |
241 | @item void *memset(void *, int, int) | |
242 | @kindex memset | |
243 | This is the standard library function @code{memset} that sets an area of | |
244 | memory to a known value. If you have one of the free versions of | |
245 | @code{libc.a}, @code{memset} can be found there; otherwise, you must | |
246 | either obtain it from your hardware manufacturer, or write your own. | |
247 | @end table | |
248 | ||
249 | If you do not use the GNU C compiler, you may need other standard | |
9a27b06e | 250 | library subroutines as well; this varies from one stub to another, |
4af6d502 RP |
251 | but in general the stubs are likely to use any of the common library |
252 | subroutines which @code{gcc} generates as inline code. | |
253 | ||
254 | ||
255 | @node Debug Session | |
256 | @subsubsection Putting it all together | |
257 | ||
258 | @cindex remote serial debugging summary | |
259 | In summary, when your program is ready to debug, you must follow these | |
260 | steps. | |
261 | ||
262 | @enumerate | |
263 | @item | |
264 | Make sure you have the supporting low-level routines | |
6b51acad | 265 | (@pxref{Bootstrapping,,What you must do for the stub}): |
4af6d502 RP |
266 | @display |
267 | @code{getDebugChar}, @code{putDebugChar}, | |
268 | @code{flush_i_cache}, @code{memset}, @code{exceptionHandler}. | |
269 | @end display | |
270 | ||
271 | @item | |
272 | Insert these lines near the top of your program: | |
273 | ||
274 | @example | |
275 | set_debug_traps(); | |
276 | breakpoint(); | |
277 | @end example | |
278 | ||
279 | @item | |
280 | For the 680x0 stub only, you need to provide a variable called | |
af215b1a | 281 | @code{exceptionHook}. Normally you just use: |
4af6d502 RP |
282 | |
283 | @example | |
284 | void (*exceptionHook)() = 0; | |
285 | @end example | |
286 | ||
287 | but if before calling @code{set_debug_traps}, you set it to point to a | |
288 | function in your program, that function is called when | |
289 | @code{@value{GDBN}} continues after stopping on a trap (for example, bus | |
290 | error). The function indicated by @code{exceptionHook} is called with | |
291 | one parameter: an @code{int} which is the exception number. | |
292 | ||
293 | @item | |
294 | Compile and link together: your program, the @value{GDBN} debugging stub for | |
295 | your target architecture, and the supporting subroutines. | |
296 | ||
297 | @item | |
298 | Make sure you have a serial connection between your target machine and | |
af215b1a | 299 | the @value{GDBN} host, and identify the serial port on the host. |
4af6d502 RP |
300 | |
301 | @item | |
302 | @c The "remote" target now provides a `load' command, so we should | |
303 | @c document that. FIXME. | |
304 | Download your program to your target machine (or get it there by | |
305 | whatever means the manufacturer provides), and start it. | |
306 | ||
307 | @item | |
308 | To start remote debugging, run @value{GDBN} on the host machine, and specify | |
309 | as an executable file the program that is running in the remote machine. | |
310 | This tells @value{GDBN} how to find your program's symbols and the contents | |
311 | of its pure text. | |
312 | ||
313 | @cindex serial line, @code{target remote} | |
314 | Then establish communication using the @code{target remote} command. | |
315 | Its argument specifies how to communicate with the target | |
316 | machine---either via a devicename attached to a direct serial line, or a | |
317 | TCP port (usually to a terminal server which in turn has a serial line | |
318 | to the target). For example, to use a serial line connected to the | |
319 | device named @file{/dev/ttyb}: | |
320 | ||
321 | @example | |
322 | target remote /dev/ttyb | |
323 | @end example | |
324 | ||
325 | @cindex TCP port, @code{target remote} | |
326 | To use a TCP connection, use an argument of the form | |
327 | @code{@var{host}:port}. For example, to connect to port 2828 on a | |
328 | terminal server named @code{manyfarms}: | |
329 | ||
330 | @example | |
331 | target remote manyfarms:2828 | |
332 | @end example | |
333 | @end enumerate | |
334 | ||
335 | Now you can use all the usual commands to examine and change data and to | |
336 | step and continue the remote program. | |
337 | ||
338 | To resume the remote program and stop debugging it, use the @code{detach} | |
339 | command. | |
340 | ||
341 | @cindex interrupting remote programs | |
342 | @cindex remote programs, interrupting | |
343 | Whenever @value{GDBN} is waiting for the remote program, if you type the | |
344 | interrupt character (often @key{C-C}), @value{GDBN} attempts to stop the | |
345 | program. This may or may not succeed, depending in part on the hardware | |
346 | and the serial drivers the remote system uses. If you type the | |
347 | interrupt character once again, @value{GDBN} displays this prompt: | |
348 | ||
349 | @example | |
350 | Interrupted while waiting for the program. | |
351 | Give up (and stop debugging it)? (y or n) | |
352 | @end example | |
353 | ||
354 | If you type @kbd{y}, @value{GDBN} abandons the remote debugging session. | |
355 | (If you decide you want to try again later, you can use @samp{target | |
356 | remote} again to connect once more.) If you type @kbd{n}, @value{GDBN} | |
357 | goes back to waiting. | |
358 | ||
359 | @node Protocol | |
b1955f0b | 360 | @subsubsection Communication protocol |
4af6d502 RP |
361 | |
362 | @cindex debugging stub, example | |
363 | @cindex remote stub, example | |
364 | @cindex stub example, remote debugging | |
365 | The stub files provided with @value{GDBN} implement the target side of the | |
366 | communication protocol, and the @value{GDBN} side is implemented in the | |
367 | @value{GDBN} source file @file{remote.c}. Normally, you can simply allow | |
368 | these subroutines to communicate, and ignore the details. (If you're | |
369 | implementing your own stub file, you can still ignore the details: start | |
370 | with one of the existing stub files. @file{sparc-stub.c} is the best | |
371 | organized, and therefore the easiest to read.) | |
372 | ||
373 | However, there may be occasions when you need to know something about | |
374 | the protocol---for example, if there is only one serial port to your | |
375 | target machine, you might want your program to do something special if | |
376 | it recognizes a packet meant for @value{GDBN}. | |
377 | ||
378 | @cindex protocol, @value{GDBN} remote serial | |
379 | @cindex serial protocol, @value{GDBN} remote | |
380 | @cindex remote serial protocol | |
381 | All @value{GDBN} commands and responses (other than acknowledgements, which | |
382 | are single characters) are sent as a packet which includes a | |
383 | checksum. A packet is introduced with the character @samp{$}, and ends | |
384 | with the character @samp{#} followed by a two-digit checksum: | |
385 | ||
386 | @example | |
387 | $@var{packet info}#@var{checksum} | |
388 | @end example | |
389 | ||
390 | @cindex checksum, for @value{GDBN} remote | |
391 | @noindent | |
392 | @var{checksum} is computed as the modulo 256 sum of the @var{packet | |
393 | info} characters. | |
394 | ||
395 | When either the host or the target machine receives a packet, the first | |
396 | response expected is an acknowledgement: a single character, either | |
397 | @samp{+} (to indicate the package was received correctly) or @samp{-} | |
398 | (to request retransmission). | |
399 | ||
400 | The host (@value{GDBN}) sends commands, and the target (the debugging stub | |
401 | incorporated in your program) sends data in response. The target also | |
402 | sends data when your program stops. | |
403 | ||
404 | Command packets are distinguished by their first character, which | |
405 | identifies the kind of command. | |
406 | ||
af215b1a VM |
407 | These are some of the commands currently supported (for a complete list of |
408 | commands, look in @file{gdb/remote.c.}): | |
4af6d502 RP |
409 | |
410 | @table @code | |
411 | @item g | |
412 | Requests the values of CPU registers. | |
413 | ||
414 | @item G | |
415 | Sets the values of CPU registers. | |
416 | ||
417 | @item m@var{addr},@var{count} | |
418 | Read @var{count} bytes at location @var{addr}. | |
419 | ||
420 | @item M@var{addr},@var{count}:@dots{} | |
421 | Write @var{count} bytes at location @var{addr}. | |
422 | ||
b1955f0b | 423 | @need 500 |
4af6d502 RP |
424 | @item c |
425 | @itemx c@var{addr} | |
426 | Resume execution at the current address (or at @var{addr} if supplied). | |
427 | ||
b1955f0b | 428 | @need 500 |
4af6d502 RP |
429 | @item s |
430 | @itemx s@var{addr} | |
431 | Step the target program for one instruction, from either the current | |
432 | program counter or from @var{addr} if supplied. | |
433 | ||
434 | @item k | |
435 | Kill the target program. | |
436 | ||
437 | @item ? | |
438 | Report the most recent signal. To allow you to take advantage of the | |
439 | @value{GDBN} signal handling commands, one of the functions of the debugging | |
440 | stub is to report CPU traps as the corresponding POSIX signal values. | |
af215b1a VM |
441 | |
442 | @item T | |
443 | Allows the remote stub to send only the registers that @value{GDBN} needs | |
444 | to make a quick decision about single-stepping or conditional breakpoints. | |
445 | This eliminates the need to fetch the entire register set for each instruction | |
446 | being stepped through. | |
447 | ||
448 | The @value{GDBN} remote serial protocol now implements a write-through | |
449 | cache for registers. @value{GDBN} only re-reads the registers if the | |
450 | target has run. | |
4af6d502 RP |
451 | @end table |
452 | ||
453 | @kindex set remotedebug | |
454 | @kindex show remotedebug | |
455 | @cindex packets, reporting on stdout | |
456 | @cindex serial connections, debugging | |
457 | If you have trouble with the serial connection, you can use the command | |
458 | @code{set remotedebug}. This makes @value{GDBN} report on all packets sent | |
459 | back and forth across the serial line to the remote machine. The | |
460 | packet-debugging information is printed on the @value{GDBN} standard output | |
461 | stream. @code{set remotedebug off} turns it off, and @code{show | |
9a27b06e | 462 | remotedebug} shows you its current state. |
4af6d502 RP |
463 | |
464 | @ifset GDBSERVER | |
465 | @node Server | |
466 | @subsubsection Using the @code{gdbserver} program | |
467 | ||
468 | @kindex gdbserver | |
469 | @cindex remote connection without stubs | |
470 | @code{gdbserver} is a control program for Unix-like systems, which | |
471 | allows you to connect your program with a remote @value{GDBN} via | |
472 | @code{target remote}---but without linking in the usual debugging stub. | |
473 | ||
474 | @code{gdbserver} is not a complete replacement for the debugging stubs, | |
475 | because it requires essentially the same operating-system facilities | |
476 | that @value{GDBN} itself does. In fact, a system that can run | |
477 | @code{gdbserver} to connect to a remote @value{GDBN} could also run | |
c79890ee | 478 | @value{GDBN} locally! @code{gdbserver} is sometimes useful nevertheless, |
4af6d502 | 479 | because it is a much smaller program than @value{GDBN} itself. It is |
c79890ee | 480 | also easier to port than all of @value{GDBN}, so you may be able to get |
4af6d502 | 481 | started more quickly on a new system by using @code{gdbserver}. |
22b5dba5 RP |
482 | Finally, if you develop code for real-time systems, you may find that |
483 | the tradeoffs involved in real-time operation make it more convenient to | |
484 | do as much development work as possible on another system, for example | |
485 | by cross-compiling. You can use @code{gdbserver} to make a similar | |
486 | choice for debugging. | |
4af6d502 RP |
487 | |
488 | @value{GDBN} and @code{gdbserver} communicate via either a serial line | |
489 | or a TCP connection, using the standard @value{GDBN} remote serial | |
490 | protocol. | |
491 | ||
492 | @table @emph | |
22b5dba5 | 493 | @item On the target machine, |
4af6d502 RP |
494 | you need to have a copy of the program you want to debug. |
495 | @code{gdbserver} does not need your program's symbol table, so you can | |
496 | strip the program if necessary to save space. @value{GDBN} on the host | |
497 | system does all the symbol handling. | |
498 | ||
22b5dba5 | 499 | To use the server, you must tell it how to communicate with @value{GDBN}; |
4af6d502 RP |
500 | the name of your program; and the arguments for your program. The |
501 | syntax is: | |
502 | ||
503 | @smallexample | |
504 | target> gdbserver @var{comm} @var{program} [ @var{args} @dots{} ] | |
505 | @end smallexample | |
506 | ||
507 | @var{comm} is either a device name (to use a serial line) or a TCP | |
22b5dba5 | 508 | hostname and portnumber. For example, to debug Emacs with the argument |
4af6d502 RP |
509 | @samp{foo.txt} and communicate with @value{GDBN} over the serial port |
510 | @file{/dev/com1}: | |
511 | ||
512 | @smallexample | |
513 | target> gdbserver /dev/com1 emacs foo.txt | |
514 | @end smallexample | |
515 | ||
516 | @code{gdbserver} waits passively for the host @value{GDBN} to communicate | |
517 | with it. | |
518 | ||
519 | To use a TCP connection instead of a serial line: | |
520 | ||
521 | @smallexample | |
522 | target> gdbserver host:2345 emacs foo.txt | |
523 | @end smallexample | |
524 | ||
525 | The only difference from the previous example is the first argument, | |
526 | specifying that you are communicating with the host @value{GDBN} via | |
527 | TCP. The @samp{host:2345} argument means that @code{gdbserver} is to | |
528 | expect a TCP connection from machine @samp{host} to local TCP port 2345. | |
529 | (Currently, the @samp{host} part is ignored.) You can choose any number | |
530 | you want for the port number as long as it does not conflict with any | |
22b5dba5 RP |
531 | TCP ports already in use on the target system (for example, @code{23} is |
532 | reserved for @code{telnet}).@footnote{If you choose a port number that | |
533 | conflicts with another service, @code{gdbserver} prints an error message | |
534 | and exits.} You must use the same port number with the host @value{GDBN} | |
535 | @code{target remote} command. | |
536 | ||
537 | @item On the @value{GDBN} host machine, | |
538 | you need an unstripped copy of your program, since @value{GDBN} needs | |
539 | symbols and debugging information. Start up @value{GDBN} as usual, | |
540 | using the name of the local copy of your program as the first argument. | |
541 | (You may also need the @w{@samp{--baud}} option if the serial line is | |
542 | running at anything other than 9600 bps.) After that, use @code{target | |
543 | remote} to establish communications with @code{gdbserver}. Its argument | |
544 | is either a device name (usually a serial device, like | |
545 | @file{/dev/ttyb}), or a TCP port descriptor in the form | |
546 | @code{@var{host}:@var{PORT}}. For example: | |
4af6d502 RP |
547 | |
548 | @smallexample | |
549 | (@value{GDBP}) target remote /dev/ttyb | |
550 | @end smallexample | |
551 | ||
552 | @noindent | |
553 | communicates with the server via serial line @file{/dev/ttyb}, and | |
554 | ||
555 | @smallexample | |
556 | (@value{GDBP}) target remote the-target:2345 | |
557 | @end smallexample | |
558 | ||
559 | @noindent | |
22b5dba5 | 560 | communicates via a TCP connection to port 2345 on host @w{@file{the-target}}. |
4af6d502 RP |
561 | For TCP connections, you must start up @code{gdbserver} prior to using |
562 | the @code{target remote} command. Otherwise you may get an error whose | |
563 | text depends on the host system, but which usually looks something like | |
564 | @samp{Connection refused}. | |
565 | @end table | |
566 | @end ifset | |
567 | ||
07dff010 C |
568 | @ifset GDBSERVE |
569 | @node NetWare | |
570 | @subsubsection Using the @code{gdbserve.nlm} program | |
571 | ||
572 | @kindex gdbserve.nlm | |
573 | @code{gdbserve.nlm} is a control program for NetWare systems, which | |
574 | allows you to connect your program with a remote @value{GDBN} via | |
575 | @code{target remote}. | |
576 | ||
577 | @value{GDBN} and @code{gdbserve.nlm} communicate via a serial line, | |
578 | using the standard @value{GDBN} remote serial protocol. | |
579 | ||
580 | @table @emph | |
581 | @item On the target machine, | |
582 | you need to have a copy of the program you want to debug. | |
583 | @code{gdbserve.nlm} does not need your program's symbol table, so you | |
584 | can strip the program if necessary to save space. @value{GDBN} on the | |
585 | host system does all the symbol handling. | |
586 | ||
587 | To use the server, you must tell it how to communicate with | |
588 | @value{GDBN}; the name of your program; and the arguments for your | |
589 | program. The syntax is: | |
590 | ||
591 | @smallexample | |
af215b1a VM |
592 | load gdbserve [ BOARD=@var{board} ] [ PORT=@var{port} ] |
593 | [ BAUD=@var{baud} ] @var{program} [ @var{args} @dots{} ] | |
07dff010 C |
594 | @end smallexample |
595 | ||
7d777b91 | 596 | @var{board} and @var{port} specify the serial line; @var{baud} specifies |
07dff010 C |
597 | the baud rate used by the connection. @var{port} and @var{node} default |
598 | to 0, @var{baud} defaults to 9600 bps. | |
599 | ||
600 | For example, to debug Emacs with the argument @samp{foo.txt}and | |
7d777b91 C |
601 | communicate with @value{GDBN} over serial port number 2 or board 1 |
602 | using a 19200 bps connection: | |
07dff010 C |
603 | |
604 | @smallexample | |
7d777b91 | 605 | load gdbserve BOARD=1 PORT=2 BAUD=19200 emacs foo.txt |
07dff010 C |
606 | @end smallexample |
607 | ||
608 | @item On the @value{GDBN} host machine, | |
609 | you need an unstripped copy of your program, since @value{GDBN} needs | |
610 | symbols and debugging information. Start up @value{GDBN} as usual, | |
611 | using the name of the local copy of your program as the first argument. | |
612 | (You may also need the @w{@samp{--baud}} option if the serial line is | |
613 | running at anything other than 9600 bps. After that, use @code{target | |
614 | remote} to establish communications with @code{gdbserve.nlm}. Its | |
615 | argument is a device name (usually a serial device, like | |
616 | @file{/dev/ttyb}). For example: | |
617 | ||
618 | @smallexample | |
619 | (@value{GDBP}) target remote /dev/ttyb | |
620 | @end smallexample | |
621 | ||
622 | @noindent | |
623 | communications with the server via serial line @file{/dev/ttyb}. | |
624 | @end table | |
625 | @end ifset | |
626 | ||
4af6d502 RP |
627 | @end ifset |
628 | ||
629 | @ifset I960 | |
630 | @node i960-Nindy Remote | |
631 | @subsection @value{GDBN} with a remote i960 (Nindy) | |
632 | ||
633 | @cindex Nindy | |
634 | @cindex i960 | |
635 | @dfn{Nindy} is a ROM Monitor program for Intel 960 target systems. When | |
636 | @value{GDBN} is configured to control a remote Intel 960 using Nindy, you can | |
637 | tell @value{GDBN} how to connect to the 960 in several ways: | |
638 | ||
639 | @itemize @bullet | |
640 | @item | |
641 | Through command line options specifying serial port, version of the | |
642 | Nindy protocol, and communications speed; | |
643 | ||
644 | @item | |
645 | By responding to a prompt on startup; | |
646 | ||
647 | @item | |
648 | By using the @code{target} command at any point during your @value{GDBN} | |
649 | session. @xref{Target Commands, ,Commands for managing targets}. | |
650 | ||
651 | @end itemize | |
652 | ||
653 | @menu | |
654 | * Nindy Startup:: Startup with Nindy | |
655 | * Nindy Options:: Options for Nindy | |
656 | * Nindy Reset:: Nindy reset command | |
657 | @end menu | |
658 | ||
659 | @node Nindy Startup | |
660 | @subsubsection Startup with Nindy | |
661 | ||
662 | If you simply start @code{@value{GDBP}} without using any command-line | |
663 | options, you are prompted for what serial port to use, @emph{before} you | |
664 | reach the ordinary @value{GDBN} prompt: | |
665 | ||
666 | @example | |
667 | Attach /dev/ttyNN -- specify NN, or "quit" to quit: | |
668 | @end example | |
669 | ||
670 | @noindent | |
671 | Respond to the prompt with whatever suffix (after @samp{/dev/tty}) | |
672 | identifies the serial port you want to use. You can, if you choose, | |
673 | simply start up with no Nindy connection by responding to the prompt | |
674 | with an empty line. If you do this and later wish to attach to Nindy, | |
675 | use @code{target} (@pxref{Target Commands, ,Commands for managing targets}). | |
676 | ||
677 | @node Nindy Options | |
678 | @subsubsection Options for Nindy | |
679 | ||
680 | These are the startup options for beginning your @value{GDBN} session with a | |
681 | Nindy-960 board attached: | |
682 | ||
683 | @table @code | |
684 | @item -r @var{port} | |
685 | Specify the serial port name of a serial interface to be used to connect | |
686 | to the target system. This option is only available when @value{GDBN} is | |
687 | configured for the Intel 960 target architecture. You may specify | |
688 | @var{port} as any of: a full pathname (e.g. @samp{-r /dev/ttya}), a | |
689 | device name in @file{/dev} (e.g. @samp{-r ttya}), or simply the unique | |
690 | suffix for a specific @code{tty} (e.g. @samp{-r a}). | |
691 | ||
692 | @item -O | |
693 | (An uppercase letter ``O'', not a zero.) Specify that @value{GDBN} should use | |
694 | the ``old'' Nindy monitor protocol to connect to the target system. | |
695 | This option is only available when @value{GDBN} is configured for the Intel 960 | |
696 | target architecture. | |
697 | ||
698 | @quotation | |
699 | @emph{Warning:} if you specify @samp{-O}, but are actually trying to | |
700 | connect to a target system that expects the newer protocol, the connection | |
701 | fails, appearing to be a speed mismatch. @value{GDBN} repeatedly | |
702 | attempts to reconnect at several different line speeds. You can abort | |
703 | this process with an interrupt. | |
704 | @end quotation | |
705 | ||
706 | @item -brk | |
707 | Specify that @value{GDBN} should first send a @code{BREAK} signal to the target | |
708 | system, in an attempt to reset it, before connecting to a Nindy target. | |
709 | ||
710 | @quotation | |
711 | @emph{Warning:} Many target systems do not have the hardware that this | |
712 | requires; it only works with a few boards. | |
713 | @end quotation | |
714 | @end table | |
715 | ||
716 | The standard @samp{-b} option controls the line speed used on the serial | |
717 | port. | |
718 | ||
719 | @c @group | |
720 | @node Nindy Reset | |
721 | @subsubsection Nindy reset command | |
722 | ||
723 | @table @code | |
724 | @item reset | |
725 | @kindex reset | |
726 | For a Nindy target, this command sends a ``break'' to the remote target | |
727 | system; this is only useful if the target has been equipped with a | |
728 | circuit to perform a hard reset (or some other interesting action) when | |
729 | a break is detected. | |
730 | @end table | |
731 | @c @end group | |
732 | @end ifset | |
733 | ||
734 | @ifset AMD29K | |
735 | @node UDI29K Remote | |
b1955f0b | 736 | @subsection The UDI protocol for AMD29K |
4af6d502 RP |
737 | |
738 | @cindex UDI | |
739 | @cindex AMD29K via UDI | |
740 | @value{GDBN} supports AMD's UDI (``Universal Debugger Interface'') | |
741 | protocol for debugging the a29k processor family. To use this | |
742 | configuration with AMD targets running the MiniMON monitor, you need the | |
743 | program @code{MONTIP}, available from AMD at no charge. You can also | |
af215b1a | 744 | use @value{GDBN} with the UDI-conformant a29k simulator program |
4af6d502 RP |
745 | @code{ISSTIP}, also available from AMD. |
746 | ||
747 | @table @code | |
748 | @item target udi @var{keyword} | |
749 | @kindex udi | |
750 | Select the UDI interface to a remote a29k board or simulator, where | |
751 | @var{keyword} is an entry in the AMD configuration file @file{udi_soc}. | |
752 | This file contains keyword entries which specify parameters used to | |
753 | connect to a29k targets. If the @file{udi_soc} file is not in your | |
754 | working directory, you must set the environment variable @samp{UDICONF} | |
755 | to its pathname. | |
756 | @end table | |
757 | ||
758 | @node EB29K Remote | |
b1955f0b | 759 | @subsection The EBMON protocol for AMD29K |
4af6d502 RP |
760 | |
761 | @cindex EB29K board | |
762 | @cindex running 29K programs | |
763 | ||
764 | AMD distributes a 29K development board meant to fit in a PC, together | |
765 | with a DOS-hosted monitor program called @code{EBMON}. As a shorthand | |
766 | term, this development system is called the ``EB29K''. To use | |
767 | @value{GDBN} from a Unix system to run programs on the EB29K board, you | |
768 | must first connect a serial cable between the PC (which hosts the EB29K | |
769 | board) and a serial port on the Unix system. In the following, we | |
770 | assume you've hooked the cable between the PC's @file{COM1} port and | |
771 | @file{/dev/ttya} on the Unix system. | |
772 | ||
773 | @menu | |
774 | * Comms (EB29K):: Communications setup | |
775 | * gdb-EB29K:: EB29K cross-debugging | |
776 | * Remote Log:: Remote log | |
777 | @end menu | |
778 | ||
779 | @node Comms (EB29K) | |
780 | @subsubsection Communications setup | |
781 | ||
782 | The next step is to set up the PC's port, by doing something like this | |
783 | in DOS on the PC: | |
784 | ||
785 | @example | |
786 | C:\> MODE com1:9600,n,8,1,none | |
787 | @end example | |
788 | ||
789 | @noindent | |
790 | This example---run on an MS DOS 4.0 system---sets the PC port to 9600 | |
791 | bps, no parity, eight data bits, one stop bit, and no ``retry'' action; | |
792 | you must match the communications parameters when establishing the Unix | |
793 | end of the connection as well. | |
794 | @c FIXME: Who knows what this "no retry action" crud from the DOS manual may | |
e0d3ace2 | 795 | @c mean? It's optional; leave it out? ---doc@cygnus.com, 25feb91 |
4af6d502 RP |
796 | |
797 | To give control of the PC to the Unix side of the serial line, type | |
798 | the following at the DOS console: | |
799 | ||
800 | @example | |
801 | C:\> CTTY com1 | |
802 | @end example | |
803 | ||
804 | @noindent | |
805 | (Later, if you wish to return control to the DOS console, you can use | |
806 | the command @code{CTTY con}---but you must send it over the device that | |
807 | had control, in our example over the @file{COM1} serial line). | |
808 | ||
809 | From the Unix host, use a communications program such as @code{tip} or | |
810 | @code{cu} to communicate with the PC; for example, | |
811 | ||
812 | @example | |
813 | cu -s 9600 -l /dev/ttya | |
814 | @end example | |
815 | ||
816 | @noindent | |
817 | The @code{cu} options shown specify, respectively, the linespeed and the | |
818 | serial port to use. If you use @code{tip} instead, your command line | |
819 | may look something like the following: | |
820 | ||
821 | @example | |
822 | tip -9600 /dev/ttya | |
823 | @end example | |
824 | ||
825 | @noindent | |
826 | Your system may require a different name where we show | |
827 | @file{/dev/ttya} as the argument to @code{tip}. The communications | |
828 | parameters, including which port to use, are associated with the | |
829 | @code{tip} argument in the ``remote'' descriptions file---normally the | |
830 | system table @file{/etc/remote}. | |
831 | @c FIXME: What if anything needs doing to match the "n,8,1,none" part of | |
832 | @c the DOS side's comms setup? cu can support -o (odd | |
833 | @c parity), -e (even parity)---apparently no settings for no parity or | |
834 | @c for character size. Taken from stty maybe...? John points out tip | |
835 | @c can set these as internal variables, eg ~s parity=none; man stty | |
836 | @c suggests that it *might* work to stty these options with stdin or | |
e0d3ace2 | 837 | @c stdout redirected... ---doc@cygnus.com, 25feb91 |
4af6d502 RP |
838 | |
839 | @kindex EBMON | |
840 | Using the @code{tip} or @code{cu} connection, change the DOS working | |
841 | directory to the directory containing a copy of your 29K program, then | |
842 | start the PC program @code{EBMON} (an EB29K control program supplied | |
843 | with your board by AMD). You should see an initial display from | |
844 | @code{EBMON} similar to the one that follows, ending with the | |
845 | @code{EBMON} prompt @samp{#}--- | |
846 | ||
847 | @example | |
848 | C:\> G: | |
849 | ||
850 | G:\> CD \usr\joe\work29k | |
851 | ||
852 | G:\USR\JOE\WORK29K> EBMON | |
853 | Am29000 PC Coprocessor Board Monitor, version 3.0-18 | |
854 | Copyright 1990 Advanced Micro Devices, Inc. | |
855 | Written by Gibbons and Associates, Inc. | |
856 | ||
857 | Enter '?' or 'H' for help | |
858 | ||
859 | PC Coprocessor Type = EB29K | |
860 | I/O Base = 0x208 | |
861 | Memory Base = 0xd0000 | |
862 | ||
863 | Data Memory Size = 2048KB | |
864 | Available I-RAM Range = 0x8000 to 0x1fffff | |
865 | Available D-RAM Range = 0x80002000 to 0x801fffff | |
866 | ||
867 | PageSize = 0x400 | |
868 | Register Stack Size = 0x800 | |
869 | Memory Stack Size = 0x1800 | |
870 | ||
871 | CPU PRL = 0x3 | |
872 | Am29027 Available = No | |
873 | Byte Write Available = Yes | |
874 | ||
875 | # ~. | |
876 | @end example | |
877 | ||
878 | Then exit the @code{cu} or @code{tip} program (done in the example by | |
9a27b06e | 879 | typing @code{~.} at the @code{EBMON} prompt). @code{EBMON} keeps |
4af6d502 RP |
880 | running, ready for @value{GDBN} to take over. |
881 | ||
882 | For this example, we've assumed what is probably the most convenient | |
883 | way to make sure the same 29K program is on both the PC and the Unix | |
884 | system: a PC/NFS connection that establishes ``drive @code{G:}'' on the | |
885 | PC as a file system on the Unix host. If you do not have PC/NFS or | |
886 | something similar connecting the two systems, you must arrange some | |
887 | other way---perhaps floppy-disk transfer---of getting the 29K program | |
9a27b06e | 888 | from the Unix system to the PC; @value{GDBN} does @emph{not} download it over the |
4af6d502 RP |
889 | serial line. |
890 | ||
891 | @node gdb-EB29K | |
892 | @subsubsection EB29K cross-debugging | |
893 | ||
894 | Finally, @code{cd} to the directory containing an image of your 29K | |
895 | program on the Unix system, and start @value{GDBN}---specifying as argument the | |
896 | name of your 29K program: | |
897 | ||
898 | @example | |
899 | cd /usr/joe/work29k | |
900 | @value{GDBP} myfoo | |
901 | @end example | |
902 | ||
b1955f0b | 903 | @need 500 |
4af6d502 RP |
904 | Now you can use the @code{target} command: |
905 | ||
906 | @example | |
907 | target amd-eb /dev/ttya 9600 MYFOO | |
908 | @c FIXME: test above 'target amd-eb' as spelled, with caps! caps are meant to | |
909 | @c emphasize that this is the name as seen by DOS (since I think DOS is | |
e0d3ace2 | 910 | @c single-minded about case of letters). ---doc@cygnus.com, 25feb91 |
4af6d502 RP |
911 | @end example |
912 | ||
913 | @noindent | |
914 | In this example, we've assumed your program is in a file called | |
915 | @file{myfoo}. Note that the filename given as the last argument to | |
916 | @code{target amd-eb} should be the name of the program as it appears to DOS. | |
917 | In our example this is simply @code{MYFOO}, but in general it can include | |
918 | a DOS path, and depending on your transfer mechanism may not resemble | |
919 | the name on the Unix side. | |
920 | ||
921 | At this point, you can set any breakpoints you wish; when you are ready | |
922 | to see your program run on the 29K board, use the @value{GDBN} command | |
923 | @code{run}. | |
924 | ||
925 | To stop debugging the remote program, use the @value{GDBN} @code{detach} | |
926 | command. | |
927 | ||
928 | To return control of the PC to its console, use @code{tip} or @code{cu} | |
929 | once again, after your @value{GDBN} session has concluded, to attach to | |
930 | @code{EBMON}. You can then type the command @code{q} to shut down | |
931 | @code{EBMON}, returning control to the DOS command-line interpreter. | |
932 | Type @code{CTTY con} to return command input to the main DOS console, | |
933 | and type @kbd{~.} to leave @code{tip} or @code{cu}. | |
934 | ||
935 | @node Remote Log | |
936 | @subsubsection Remote log | |
937 | @kindex eb.log | |
938 | @cindex log file for EB29K | |
939 | ||
940 | The @code{target amd-eb} command creates a file @file{eb.log} in the | |
941 | current working directory, to help debug problems with the connection. | |
942 | @file{eb.log} records all the output from @code{EBMON}, including echoes | |
943 | of the commands sent to it. Running @samp{tail -f} on this file in | |
944 | another window often helps to understand trouble with @code{EBMON}, or | |
945 | unexpected events on the PC side of the connection. | |
946 | ||
947 | @end ifset | |
948 | ||
949 | @ifset ST2000 | |
950 | @node ST2000 Remote | |
951 | @subsection @value{GDBN} with a Tandem ST2000 | |
952 | ||
953 | To connect your ST2000 to the host system, see the manufacturer's | |
af215b1a | 954 | manual. Once the ST2000 is physically attached, you can run: |
4af6d502 RP |
955 | |
956 | @example | |
957 | target st2000 @var{dev} @var{speed} | |
958 | @end example | |
959 | ||
960 | @noindent | |
961 | to establish it as your debugging environment. @var{dev} is normally | |
962 | the name of a serial device, such as @file{/dev/ttya}, connected to the | |
963 | ST2000 via a serial line. You can instead specify @var{dev} as a TCP | |
964 | connection (for example, to a serial line attached via a terminal | |
965 | concentrator) using the syntax @code{@var{hostname}:@var{portnumber}}. | |
966 | ||
967 | The @code{load} and @code{attach} commands are @emph{not} defined for | |
968 | this target; you must load your program into the ST2000 as you normally | |
9a27b06e | 969 | would for standalone operation. @value{GDBN} reads debugging information |
4af6d502 RP |
970 | (such as symbols) from a separate, debugging version of the program |
971 | available on your host computer. | |
972 | @c FIXME!! This is terribly vague; what little content is here is | |
973 | @c basically hearsay. | |
974 | ||
975 | @cindex ST2000 auxiliary commands | |
976 | These auxiliary @value{GDBN} commands are available to help you with the ST2000 | |
977 | environment: | |
978 | ||
979 | @table @code | |
980 | @item st2000 @var{command} | |
981 | @kindex st2000 @var{cmd} | |
982 | @cindex STDBUG commands (ST2000) | |
983 | @cindex commands to STDBUG (ST2000) | |
984 | Send a @var{command} to the STDBUG monitor. See the manufacturer's | |
985 | manual for available commands. | |
986 | ||
987 | @item connect | |
988 | @cindex connect (to STDBUG) | |
989 | Connect the controlling terminal to the STDBUG command monitor. When | |
990 | you are done interacting with STDBUG, typing either of two character | |
9a27b06e | 991 | sequences gets you back to the @value{GDBN} command prompt: |
4af6d502 RP |
992 | @kbd{@key{RET}~.} (Return, followed by tilde and period) or |
993 | @kbd{@key{RET}~@key{C-d}} (Return, followed by tilde and control-D). | |
994 | @end table | |
995 | @end ifset | |
996 | ||
997 | @ifset VXWORKS | |
146ff252 DE |
998 | @node VxWorks Remote |
999 | @subsection @value{GDBN} and VxWorks | |
1000 | @cindex VxWorks | |
4af6d502 RP |
1001 | |
1002 | @value{GDBN} enables developers to spawn and debug tasks running on networked | |
146ff252 DE |
1003 | VxWorks targets from a Unix host. Already-running tasks spawned from |
1004 | the VxWorks shell can also be debugged. @value{GDBN} uses code that runs on | |
1005 | both the Unix host and on the VxWorks target. The program | |
6b51acad | 1006 | @code{gdb} is installed and executed on the Unix host. (It may be |
4af6d502 RP |
1007 | installed with the name @code{vxgdb}, to distinguish it from a |
1008 | @value{GDBN} for debugging programs on the host itself.) | |
1009 | ||
af215b1a | 1010 | @table @code |
146ff252 | 1011 | @item VxWorks-timeout @var{args} |
af215b1a | 1012 | @kindex vxworks-timeout |
146ff252 | 1013 | All VxWorks-based targets now support the option @code{vxworks-timeout}. |
af215b1a VM |
1014 | This option is set by the user, and @var{args} represents the number of |
1015 | seconds @value{GDBN} waits for responses to rpc's. You might use this if | |
146ff252 | 1016 | your VxWorks target is a slow software simulator or is on the far side |
af215b1a VM |
1017 | of a thin network line. |
1018 | @end table | |
1019 | ||
146ff252 DE |
1020 | The following information on connecting to VxWorks was current when |
1021 | this manual was produced; newer releases of VxWorks may use revised | |
4af6d502 RP |
1022 | procedures. |
1023 | ||
4af6d502 | 1024 | @kindex INCLUDE_RDB |
146ff252 DE |
1025 | To use @value{GDBN} with VxWorks, you must rebuild your VxWorks kernel |
1026 | to include the remote debugging interface routines in the VxWorks | |
ffbfe250 | 1027 | library @file{rdb.a}. To do this, define @code{INCLUDE_RDB} in the |
146ff252 | 1028 | VxWorks configuration file @file{configAll.h} and rebuild your VxWorks |
9a27b06e | 1029 | kernel. The resulting kernel contains @file{rdb.a}, and spawns the |
146ff252 DE |
1030 | source debugging task @code{tRdbTask} when VxWorks is booted. For more |
1031 | information on configuring and remaking VxWorks, see the manufacturer's | |
ffbfe250 | 1032 | manual. |
146ff252 | 1033 | @c VxWorks, see the @cite{VxWorks Programmer's Guide}. |
4af6d502 | 1034 | |
146ff252 | 1035 | Once you have included @file{rdb.a} in your VxWorks system image and set |
ffbfe250 JK |
1036 | your Unix execution search path to find @value{GDBN}, you are ready to |
1037 | run @value{GDBN}. From your Unix host, run @code{gdb} (or @code{vxgdb}, | |
1038 | depending on your installation). | |
4af6d502 RP |
1039 | |
1040 | @value{GDBN} comes up showing the prompt: | |
1041 | ||
1042 | @example | |
1043 | (vxgdb) | |
1044 | @end example | |
1045 | ||
1046 | @menu | |
146ff252 DE |
1047 | * VxWorks Connection:: Connecting to VxWorks |
1048 | * VxWorks Download:: VxWorks download | |
1049 | * VxWorks Attach:: Running tasks | |
4af6d502 RP |
1050 | @end menu |
1051 | ||
146ff252 DE |
1052 | @node VxWorks Connection |
1053 | @subsubsection Connecting to VxWorks | |
4af6d502 | 1054 | |
146ff252 | 1055 | The @value{GDBN} command @code{target} lets you connect to a VxWorks target on the |
4af6d502 RP |
1056 | network. To connect to a target whose host name is ``@code{tt}'', type: |
1057 | ||
1058 | @example | |
1059 | (vxgdb) target vxworks tt | |
1060 | @end example | |
1061 | ||
b1955f0b | 1062 | @need 750 |
4af6d502 RP |
1063 | @value{GDBN} displays messages like these: |
1064 | ||
1065 | @smallexample | |
1066 | Attaching remote machine across net... | |
1067 | Connected to tt. | |
1068 | @end smallexample | |
1069 | ||
b1955f0b | 1070 | @need 1000 |
4af6d502 | 1071 | @value{GDBN} then attempts to read the symbol tables of any object modules |
146ff252 | 1072 | loaded into the VxWorks target since it was last booted. @value{GDBN} locates |
4af6d502 RP |
1073 | these files by searching the directories listed in the command search |
1074 | path (@pxref{Environment, ,Your program's environment}); if it fails | |
1075 | to find an object file, it displays a message such as: | |
1076 | ||
1077 | @example | |
1078 | prog.o: No such file or directory. | |
1079 | @end example | |
1080 | ||
1081 | When this happens, add the appropriate directory to the search path with | |
1082 | the @value{GDBN} command @code{path}, and execute the @code{target} | |
1083 | command again. | |
1084 | ||
146ff252 DE |
1085 | @node VxWorks Download |
1086 | @subsubsection VxWorks download | |
4af6d502 | 1087 | |
146ff252 DE |
1088 | @cindex download to VxWorks |
1089 | If you have connected to the VxWorks target and you want to debug an | |
4af6d502 | 1090 | object that has not yet been loaded, you can use the @value{GDBN} |
146ff252 | 1091 | @code{load} command to download a file from Unix to VxWorks |
4af6d502 | 1092 | incrementally. The object file given as an argument to the @code{load} |
146ff252 | 1093 | command is actually opened twice: first by the VxWorks target in order |
4af6d502 RP |
1094 | to download the code, then by @value{GDBN} in order to read the symbol |
1095 | table. This can lead to problems if the current working directories on | |
1096 | the two systems differ. If both systems have NFS mounted the same | |
1097 | filesystems, you can avoid these problems by using absolute paths. | |
1098 | Otherwise, it is simplest to set the working directory on both systems | |
1099 | to the directory in which the object file resides, and then to reference | |
1100 | the file by its name, without any path. For instance, a program | |
146ff252 | 1101 | @file{prog.o} may reside in @file{@var{vxpath}/vw/demo/rdb} in VxWorks |
4af6d502 | 1102 | and in @file{@var{hostpath}/vw/demo/rdb} on the host. To load this |
146ff252 | 1103 | program, type this on VxWorks: |
4af6d502 RP |
1104 | |
1105 | @example | |
1106 | -> cd "@var{vxpath}/vw/demo/rdb" | |
1107 | @end example | |
af215b1a | 1108 | v |
4af6d502 RP |
1109 | Then, in @value{GDBN}, type: |
1110 | ||
1111 | @example | |
1112 | (vxgdb) cd @var{hostpath}/vw/demo/rdb | |
1113 | (vxgdb) load prog.o | |
1114 | @end example | |
1115 | ||
1116 | @value{GDBN} displays a response similar to this: | |
1117 | ||
1118 | @smallexample | |
1119 | Reading symbol data from wherever/vw/demo/rdb/prog.o... done. | |
1120 | @end smallexample | |
1121 | ||
1122 | You can also use the @code{load} command to reload an object module | |
1123 | after editing and recompiling the corresponding source file. Note that | |
9a27b06e | 1124 | this makes @value{GDBN} delete all currently-defined breakpoints, |
4af6d502 RP |
1125 | auto-displays, and convenience variables, and to clear the value |
1126 | history. (This is necessary in order to preserve the integrity of | |
1127 | debugger data structures that reference the target system's symbol | |
1128 | table.) | |
1129 | ||
146ff252 | 1130 | @node VxWorks Attach |
4af6d502 RP |
1131 | @subsubsection Running tasks |
1132 | ||
146ff252 | 1133 | @cindex running VxWorks tasks |
4af6d502 RP |
1134 | You can also attach to an existing task using the @code{attach} command as |
1135 | follows: | |
1136 | ||
1137 | @example | |
1138 | (vxgdb) attach @var{task} | |
1139 | @end example | |
1140 | ||
1141 | @noindent | |
146ff252 | 1142 | where @var{task} is the VxWorks hexadecimal task ID. The task can be running |
9a27b06e | 1143 | or suspended when you attach to it. Running tasks are suspended at |
4af6d502 RP |
1144 | the time of attachment. |
1145 | @end ifset | |
1146 | ||
6905de28 DP |
1147 | @ifset SPARCLET |
1148 | @node Sparclet Remote | |
1149 | @subsection @value{GDBN} and Sparclet | |
1150 | @cindex Sparclet | |
1151 | ||
1152 | @value{GDBN} enables developers to debug tasks running on | |
1153 | Sparclet targets from a Unix host. | |
1154 | @value{GDBN} uses code that runs on | |
1155 | both the Unix host and on the Sparclet target. The program | |
1156 | @code{gdb} is installed and executed on the Unix host. | |
1157 | ||
1158 | @table @code | |
1159 | @item timeout @var{args} | |
1160 | @kindex remotetimeout | |
1161 | @value{GDBN} now supports the option @code{remotetimeout}. | |
1162 | This option is set by the user, and @var{args} represents the number of | |
1163 | seconds @value{GDBN} waits for responses. | |
1164 | @end table | |
1165 | ||
1166 | @kindex Compiling | |
1167 | When compiling for debugging, include the options "-g" to get debug | |
1168 | information and "-Ttext" to relocate the program to where you wish to | |
1169 | load it on the target. You may also want to add the options "-n" or | |
1170 | "-N" in order to reduce the size of the sections. | |
1171 | ||
1172 | @example | |
1173 | sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N | |
1174 | @end example | |
1175 | ||
1176 | You can use objdump to verify that the addresses are what you intended. | |
1177 | ||
1178 | @example | |
1179 | sparclet-aout-objdump --headers --syms prog | |
1180 | @end example | |
1181 | ||
1182 | @kindex Running | |
1183 | Once you have set | |
1184 | your Unix execution search path to find @value{GDBN}, you are ready to | |
1185 | run @value{GDBN}. From your Unix host, run @code{gdb} | |
1186 | (or @code{sparclet-aout-gdb}, depending on your installation). | |
1187 | ||
1188 | @value{GDBN} comes up showing the prompt: | |
1189 | ||
1190 | @example | |
1191 | (gdbslet) | |
1192 | @end example | |
1193 | ||
1194 | @menu | |
1195 | * Sparclet File:: Setting the file to debug | |
1196 | * Sparclet Connection:: Connecting to Sparclet | |
1197 | * Sparclet Download:: Sparclet download | |
1198 | * Sparclet Execution:: Running and debugging | |
1199 | @end menu | |
1200 | ||
1201 | @node Sparclet File | |
1202 | @subsubsection Setting file to debug | |
1203 | ||
146ff252 | 1204 | The @value{GDBN} command @code{file} lets you choose with program to debug. |
6905de28 DP |
1205 | |
1206 | @example | |
1207 | (gdbslet) file prog | |
1208 | @end example | |
1209 | ||
1210 | @need 1000 | |
1211 | @value{GDBN} then attempts to read the symbol table of @file{prog}. | |
1212 | @value{GDBN} locates | |
1213 | the file by searching the directories listed in the command search | |
1214 | path. | |
1215 | If the file was compiled with debug information (option "-g"), source | |
1216 | files will be searched as well. | |
1217 | @value{GDBN} locates | |
1218 | the source files by searching the directories listed in the directory search | |
1219 | path (@pxref{Environment, ,Your program's environment}). | |
1220 | If it fails | |
1221 | to find a file, it displays a message such as: | |
1222 | ||
1223 | @example | |
1224 | prog: No such file or directory. | |
1225 | @end example | |
1226 | ||
1227 | When this happens, add the appropriate directories to the search paths with | |
1228 | the @value{GDBN} commands @code{path} and @code{dir}, and execute the | |
1229 | @code{target} command again. | |
1230 | ||
1231 | @node Sparclet Connection | |
1232 | @subsubsection Connecting to Sparclet | |
1233 | ||
1234 | The @value{GDBN} command @code{target} lets you connect to a Sparclet target. | |
1235 | To connect to a target on serial port ``@code{ttya}'', type: | |
1236 | ||
1237 | @example | |
1238 | (gdbslet) target sparclet /dev/ttya | |
1239 | Remote target sparclet connected to /dev/ttya | |
1240 | main () at ../prog.c:3 | |
1241 | @end example | |
1242 | ||
1243 | @need 750 | |
1244 | @value{GDBN} displays messages like these: | |
1245 | ||
1246 | @smallexample | |
1247 | Connected to ttya. | |
1248 | @end smallexample | |
1249 | ||
1250 | @node Sparclet Download | |
1251 | @subsubsection Sparclet download | |
1252 | ||
1253 | @cindex download to Sparclet | |
1254 | Once connected to the Sparclet target, | |
1255 | you can use the @value{GDBN} | |
1256 | @code{load} command to download the file from the host to the target. | |
1257 | The file name and load offset should be given as arguments to the @code{load} | |
1258 | command. | |
1259 | Since the file format is aout, the program must be loaded to the starting | |
1260 | address. You can use objdump to find out what this value is. The load | |
1261 | offset is an offset which is added to the VMA (virtual memory address) | |
1262 | of each of the file's sections. | |
1263 | For instance, if the program | |
1264 | @file{prog} was linked to text address 0x1201000, with data at 0x12010160 | |
1265 | and bss at 0x12010170, in @value{GDBN}, type: | |
1266 | ||
1267 | @example | |
1268 | (gdbslet) load prog 0x12010000 | |
1269 | Loading section .text, size 0xdb0 vma 0x12010000 | |
1270 | @end example | |
1271 | ||
146ff252 | 1272 | If the code is loaded at a different address then what the program was linked |
6905de28 DP |
1273 | to, you may need to use the @code{section} and @code{add-symbol-file} commands |
1274 | to tell @value{GDBN} where to map the symbol table. | |
1275 | ||
1276 | @node Sparclet Execution | |
1277 | @subsubsection Running and debugging | |
1278 | ||
1279 | @cindex running and debugging Sparclet programs | |
1280 | You can now begin debugging the task using @value{GDBN}'s execution control | |
1281 | commands, @code{b}, @code{step}, @code{run}, etc. See the @value{GDBN} | |
1282 | manual for the list of commands. | |
1283 | ||
1284 | @example | |
1285 | (gdbslet) b main | |
1286 | Breakpoint 1 at 0x12010000: file prog.c, line 3. | |
1287 | (gdbslet) run | |
1288 | Starting program: prog | |
1289 | Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3 | |
1290 | 3 char *symarg = 0; | |
1291 | (gdbslet) step | |
1292 | 4 char *execarg = "hello!"; | |
1293 | (gdbslet) | |
1294 | @end example | |
1295 | ||
1296 | @end ifset | |
1297 | ||
4af6d502 RP |
1298 | @ifset H8 |
1299 | @node Hitachi Remote | |
2ded09f5 | 1300 | @subsection @value{GDBN} and Hitachi microprocessors |
4af6d502 RP |
1301 | @value{GDBN} needs to know these things to talk to your |
1302 | Hitachi SH, H8/300, or H8/500: | |
1303 | ||
1304 | @enumerate | |
1305 | @item | |
1306 | that you want to use @samp{target hms}, the remote debugging interface | |
2ded09f5 RP |
1307 | for Hitachi microprocessors, or @samp{target e7000}, the in-circuit |
1308 | emulator for the Hitachi SH and the Hitachi 300H. (@samp{target hms} is | |
1309 | the default when GDB is configured specifically for the Hitachi SH, | |
1310 | H8/300, or H8/500.) | |
4af6d502 RP |
1311 | |
1312 | @item | |
1313 | what serial device connects your host to your Hitachi board (the first | |
2ded09f5 | 1314 | serial device available on your host is the default). |
4af6d502 | 1315 | |
2ded09f5 RP |
1316 | @ifclear H8EXCLUSIVE |
1317 | @c this is only for Unix hosts, not of interest to Hitachi | |
4af6d502 RP |
1318 | @item |
1319 | what speed to use over the serial device. | |
2ded09f5 | 1320 | @end ifclear |
4af6d502 RP |
1321 | @end enumerate |
1322 | ||
2ded09f5 | 1323 | @menu |
009ed681 RP |
1324 | * Hitachi Boards:: Connecting to Hitachi boards. |
1325 | * Hitachi ICE:: Using the E7000 In-Circuit Emulator. | |
1326 | * Hitachi Special:: Special @value{GDBN} commands for Hitachi micros. | |
2ded09f5 RP |
1327 | @end menu |
1328 | ||
1329 | @node Hitachi Boards | |
1330 | @subsubsection Connecting to Hitachi boards | |
1331 | ||
4af6d502 RP |
1332 | @ifclear H8EXCLUSIVE |
1333 | @c only for Unix hosts | |
1334 | @kindex device | |
1335 | @cindex serial device, Hitachi micros | |
1336 | Use the special @code{@value{GDBP}} command @samp{device @var{port}} if you | |
1337 | need to explicitly set the serial device. The default @var{port} is the | |
1338 | first available port on your host. This is only necessary on Unix | |
1339 | hosts, where it is typically something like @file{/dev/ttya}. | |
1340 | ||
1341 | @kindex speed | |
1342 | @cindex serial line speed, Hitachi micros | |
1343 | @code{@value{GDBP}} has another special command to set the communications | |
1344 | speed: @samp{speed @var{bps}}. This command also is only used from Unix | |
1345 | hosts; on DOS hosts, set the line speed as usual from outside GDB with | |
1346 | the DOS @kbd{mode} command (for instance, @w{@samp{mode | |
1347 | com2:9600,n,8,1,p}} for a 9600 bps connection). | |
1348 | ||
1349 | The @samp{device} and @samp{speed} commands are available only when you | |
1350 | use a Unix host to debug your Hitachi microprocessor programs. If you | |
1351 | use a DOS host, | |
1352 | @end ifclear | |
1353 | @value{GDBN} depends on an auxiliary terminate-and-stay-resident program | |
1354 | called @code{asynctsr} to communicate with the development board | |
1355 | through a PC serial port. You must also use the DOS @code{mode} command | |
1356 | to set up the serial port on the DOS side. | |
1357 | ||
1358 | @ifset DOSHOST | |
1359 | The following sample session illustrates the steps needed to start a | |
1360 | program under @value{GDBN} control on an H8/300. The example uses a | |
1361 | sample H8/300 program called @file{t.x}. The procedure is the same for | |
1362 | the Hitachi SH and the H8/500. | |
1363 | ||
1364 | First hook up your development board. In this example, we use a | |
1365 | board attached to serial port @code{COM2}; if you use a different serial | |
1366 | port, substitute its name in the argument of the @code{mode} command. | |
1367 | When you call @code{asynctsr}, the auxiliary comms program used by the | |
1368 | degugger, you give it just the numeric part of the serial port's name; | |
1369 | for example, @samp{asyncstr 2} below runs @code{asyncstr} on | |
1370 | @code{COM2}. | |
1371 | ||
1372 | @example | |
e3a58c92 JO |
1373 | C:\H8300\TEST> asynctsr 2 |
1374 | C:\H8300\TEST> mode com2:9600,n,8,1,p | |
4af6d502 RP |
1375 | |
1376 | Resident portion of MODE loaded | |
1377 | ||
1378 | COM2: 9600, n, 8, 1, p | |
1379 | ||
4af6d502 RP |
1380 | @end example |
1381 | ||
1382 | @quotation | |
1383 | @emph{Warning:} We have noticed a bug in PC-NFS that conflicts with | |
1384 | @code{asynctsr}. If you also run PC-NFS on your DOS host, you may need to | |
1385 | disable it, or even boot without it, to use @code{asynctsr} to control | |
1386 | your development board. | |
1387 | @end quotation | |
1388 | ||
1389 | @kindex target hms | |
1390 | Now that serial communications are set up, and the development board is | |
1391 | connected, you can start up @value{GDBN}. Call @code{@value{GDBP}} with | |
1392 | the name of your program as the argument. @code{@value{GDBP}} prompts | |
1393 | you, as usual, with the prompt @samp{(@value{GDBP})}. Use two special | |
1394 | commands to begin your debugging session: @samp{target hms} to specify | |
1395 | cross-debugging to the Hitachi board, and the @code{load} command to | |
1396 | download your program to the board. @code{load} displays the names of | |
1397 | the program's sections, and a @samp{*} for each 2K of data downloaded. | |
1398 | (If you want to refresh @value{GDBN} data on symbols or on the | |
1399 | executable file without downloading, use the @value{GDBN} commands | |
1400 | @code{file} or @code{symbol-file}. These commands, and @code{load} | |
1401 | itself, are described in @ref{Files,,Commands to specify files}.) | |
1402 | ||
1403 | @smallexample | |
1404 | (eg-C:\H8300\TEST) @value{GDBP} t.x | |
1405 | GDB is free software and you are welcome to distribute copies | |
1406 | of it under certain conditions; type "show copying" to see | |
1407 | the conditions. | |
1408 | There is absolutely no warranty for GDB; type "show warranty" | |
1409 | for details. | |
1410 | GDB @value{GDBVN}, Copyright 1992 Free Software Foundation, Inc... | |
1411 | (gdb) target hms | |
1412 | Connected to remote H8/300 HMS system. | |
1413 | (gdb) load t.x | |
1414 | .text : 0x8000 .. 0xabde *********** | |
1415 | .data : 0xabde .. 0xad30 * | |
1416 | .stack : 0xf000 .. 0xf014 * | |
1417 | @end smallexample | |
1418 | ||
1419 | At this point, you're ready to run or debug your program. From here on, | |
1420 | you can use all the usual @value{GDBN} commands. The @code{break} command | |
1421 | sets breakpoints; the @code{run} command starts your program; | |
1422 | @code{print} or @code{x} display data; the @code{continue} command | |
1423 | resumes execution after stopping at a breakpoint. You can use the | |
1424 | @code{help} command at any time to find out more about @value{GDBN} commands. | |
1425 | ||
1426 | Remember, however, that @emph{operating system} facilities aren't | |
1427 | available on your development board; for example, if your program hangs, | |
1428 | you can't send an interrupt---but you can press the @sc{reset} switch! | |
1429 | ||
1430 | Use the @sc{reset} button on the development board | |
1431 | @itemize @bullet | |
1432 | @item | |
1433 | to interrupt your program (don't use @kbd{ctl-C} on the DOS host---it has | |
1434 | no way to pass an interrupt signal to the development board); and | |
1435 | ||
1436 | @item | |
1437 | to return to the @value{GDBN} command prompt after your program finishes | |
1438 | normally. The communications protocol provides no other way for @value{GDBN} | |
1439 | to detect program completion. | |
1440 | @end itemize | |
1441 | ||
9a27b06e | 1442 | In either case, @value{GDBN} sees the effect of a @sc{reset} on the |
4af6d502 | 1443 | development board as a ``normal exit'' of your program. |
009ed681 | 1444 | @end ifset |
2ded09f5 RP |
1445 | |
1446 | @node Hitachi ICE | |
1447 | @subsubsection Using the E7000 in-circuit emulator | |
1448 | ||
1449 | @kindex target e7000 | |
1450 | You can use the E7000 in-circuit emulator to develop code for either the | |
1451 | Hitachi SH or the H8/300H. Use one of these forms of the @samp{target | |
1452 | e7000} command to connect @value{GDBN} to your E7000: | |
1453 | ||
1454 | @table @code | |
1455 | @item target e7000 @var{port} @var{speed} | |
1456 | Use this form if your E7000 is connected to a serial port. The | |
1457 | @var{port} argument identifies what serial port to use (for example, | |
1458 | @samp{com2}). The third argument is the line speed in bits per second | |
1459 | (for example, @samp{9600}). | |
1460 | ||
1461 | @item target e7000 @var{hostname} | |
1462 | If your E7000 is installed as a host on a TCP/IP network, you can just | |
1463 | specify its hostname; @value{GDBN} uses @code{telnet} to connect. | |
1464 | @end table | |
1465 | ||
1466 | @node Hitachi Special | |
1467 | @subsubsection Special @value{GDBN} commands for Hitachi micros | |
1468 | ||
1469 | Some @value{GDBN} commands are available only on the H8/300 or the | |
1470 | H8/500 configurations: | |
1471 | ||
1472 | @table @code | |
1473 | @kindex set machine | |
1474 | @kindex show machine | |
1475 | @item set machine h8300 | |
1476 | @itemx set machine h8300h | |
1477 | Condition @value{GDBN} for one of the two variants of the H8/300 | |
1478 | architecture with @samp{set machine}. You can use @samp{show machine} | |
1479 | to check which variant is currently in effect. | |
1480 | ||
1481 | @kindex set memory @var{mod} | |
1482 | @cindex memory models, H8/500 | |
1483 | @item set memory @var{mod} | |
1484 | @itemx show memory | |
1485 | Specify which H8/500 memory model (@var{mod}) you are using with | |
1486 | @samp{set memory}; check which memory model is in effect with @samp{show | |
1487 | memory}. The accepted values for @var{mod} are @code{small}, | |
1488 | @code{big}, @code{medium}, and @code{compact}. | |
1489 | @end table | |
1490 | ||
4af6d502 RP |
1491 | @end ifset |
1492 | ||
1493 | @ifset MIPS | |
1494 | @node MIPS Remote | |
1495 | @subsection @value{GDBN} and remote MIPS boards | |
1496 | ||
1497 | @cindex MIPS boards | |
1498 | @value{GDBN} can use the MIPS remote debugging protocol to talk to a | |
1499 | MIPS board attached to a serial line. This is available when | |
1500 | you configure @value{GDBN} with @samp{--target=mips-idt-ecoff}. | |
1501 | ||
b1955f0b | 1502 | @need 1000 |
22b5dba5 RP |
1503 | Use these @value{GDBN} commands to specify the connection to your target board: |
1504 | ||
1505 | @table @code | |
1506 | @item target mips @var{port} | |
4af6d502 RP |
1507 | @kindex target mips @var{port} |
1508 | To run a program on the board, start up @code{@value{GDBP}} with the | |
1509 | name of your program as the argument. To connect to the board, use the | |
1510 | command @samp{target mips @var{port}}, where @var{port} is the name of | |
1511 | the serial port connected to the board. If the program has not already | |
1512 | been downloaded to the board, you may use the @code{load} command to | |
1513 | download it. You can then use all the usual @value{GDBN} commands. | |
1514 | ||
22b5dba5 RP |
1515 | For example, this sequence connects to the target board through a serial |
1516 | port, and loads and runs a program called @var{prog} through the | |
1517 | debugger: | |
1518 | ||
1519 | @example | |
1520 | host$ @value{GDBP} @var{prog} | |
1521 | GDB is free software and @dots{} | |
1522 | (gdb) target mips /dev/ttyb | |
1523 | (gdb) load @var{prog} | |
1524 | (gdb) run | |
1525 | @end example | |
1526 | ||
1527 | @item target mips @var{hostname}:@var{portnumber} | |
1528 | On some @value{GDBN} host configurations, you can specify a TCP | |
1529 | connection (for instance, to a serial line managed by a terminal | |
1530 | concentrator) instead of a serial port, using the syntax | |
1531 | @samp{@var{hostname}:@var{portnumber}}. | |
1532 | @end table | |
1533 | ||
1534 | @noindent | |
1535 | @value{GDBN} also supports these special commands for MIPS targets: | |
4af6d502 | 1536 | |
22b5dba5 | 1537 | @table @code |
af215b1a VM |
1538 | @item set processor @var{args} |
1539 | @itemx show processor | |
1540 | @kindex set processor @var{args} | |
1541 | @kindex show processor | |
1542 | Use the @code{set processor} command to set the type of MIPS | |
1543 | processor when you want to access processor-type-specific registers. | |
1544 | For example, @code{set processor @var{r3041}} tells @value{GDBN} | |
1545 | to use the CPO registers appropriate for the 3041 chip. | |
1546 | Use the @code{show processor} command to see what MIPS processor @value{GDBN} | |
1547 | is using. Use the @code{info reg} command to see what registers | |
1548 | @value{GDBN} is using. | |
1549 | ||
89dd4786 ILT |
1550 | @item set mipsfpu double |
1551 | @itemx set mipsfpu single | |
1552 | @itemx set mipsfpu none | |
22b5dba5 | 1553 | @itemx show mipsfpu |
89dd4786 | 1554 | @kindex set mipsfpu |
22b5dba5 RP |
1555 | @kindex show mipsfpu |
1556 | @cindex MIPS remote floating point | |
1557 | @cindex floating point, MIPS remote | |
1558 | If your target board does not support the MIPS floating point | |
89dd4786 | 1559 | coprocessor, you should use the command @samp{set mipsfpu none} (if you |
22b5dba5 RP |
1560 | need this, you may wish to put the command in your @value{GDBINIT} |
1561 | file). This tells @value{GDBN} how to find the return value of | |
1562 | functions which return floating point values. It also allows | |
1563 | @value{GDBN} to avoid saving the floating point registers when calling | |
89dd4786 ILT |
1564 | functions on the board. If you are using a floating point coprocessor |
1565 | with only single precision floating point support, as on the @sc{r4650} | |
1566 | processor, use the command @samp{set mipsfpu single}. The default | |
1567 | double precision floating point coprocessor may be selected using | |
1568 | @samp{set mipsfpu double}. | |
1569 | ||
1570 | In previous versions the only choices were double precision or no | |
1571 | floating point, so @samp{set mipsfpu on} will select double precision | |
1572 | and @samp{set mipsfpu off} will select no floating point. | |
1573 | ||
1574 | As usual, you can inquire about the @code{mipsfpu} variable with | |
1575 | @samp{show mipsfpu}. | |
22b5dba5 RP |
1576 | |
1577 | @item set remotedebug @var{n} | |
1578 | @itemx show remotedebug | |
1579 | @kindex set remotedebug | |
1580 | @kindex show remotedebug | |
4af6d502 | 1581 | @cindex @code{remotedebug}, MIPS protocol |
22b5dba5 | 1582 | @cindex MIPS @code{remotedebug} protocol |
4af6d502 RP |
1583 | @c FIXME! For this to be useful, you must know something about the MIPS |
1584 | @c FIXME...protocol. Where is it described? | |
1585 | You can see some debugging information about communications with the board | |
22b5dba5 RP |
1586 | by setting the @code{remotedebug} variable. If you set it to @code{1} using |
1587 | @samp{set remotedebug 1}, every packet is displayed. If you set it | |
1588 | to @code{2}, every character is displayed. You can check the current value | |
4af6d502 RP |
1589 | at any time with the command @samp{show remotedebug}. |
1590 | ||
22b5dba5 RP |
1591 | @item set timeout @var{seconds} |
1592 | @itemx set retransmit-timeout @var{seconds} | |
1593 | @itemx show timeout | |
1594 | @itemx show retransmit-timeout | |
4af6d502 RP |
1595 | @cindex @code{timeout}, MIPS protocol |
1596 | @cindex @code{retransmit-timeout}, MIPS protocol | |
f21c5362 RP |
1597 | @kindex set timeout |
1598 | @kindex show timeout | |
1599 | @kindex set retransmit-timeout | |
1600 | @kindex show retransmit-timeout | |
1601 | You can control the timeout used while waiting for a packet, in the MIPS | |
1602 | remote protocol, with the @code{set timeout @var{seconds}} command. The | |
1603 | default is 5 seconds. Similarly, you can control the timeout used while | |
1604 | waiting for an acknowledgement of a packet with the @code{set | |
1605 | retransmit-timeout @var{seconds}} command. The default is 3 seconds. | |
1606 | You can inspect both values with @code{show timeout} and @code{show | |
1607 | retransmit-timeout}. (These commands are @emph{only} available when | |
1608 | @value{GDBN} is configured for @samp{--target=mips-idt-ecoff}.) | |
5940bfd9 JK |
1609 | |
1610 | The timeout set by @code{set timeout} does not apply when @value{GDBN} | |
1611 | is waiting for your program to stop. In that case, @value{GDBN} waits | |
1612 | forever because it has no way of knowing how long the program is going | |
1613 | to run before stopping. | |
22b5dba5 | 1614 | @end table |
4af6d502 RP |
1615 | @end ifset |
1616 | ||
1617 | @ifset SIMS | |
1618 | @node Simulator | |
1619 | @subsection Simulated CPU target | |
1620 | ||
1621 | @ifset GENERIC | |
1622 | @cindex simulator | |
1623 | @cindex simulator, Z8000 | |
1624 | @cindex Z8000 simulator | |
1625 | @cindex simulator, H8/300 or H8/500 | |
1626 | @cindex H8/300 or H8/500 simulator | |
1627 | @cindex simulator, Hitachi SH | |
1628 | @cindex Hitachi SH simulator | |
1629 | @cindex CPU simulator | |
1630 | For some configurations, @value{GDBN} includes a CPU simulator that you | |
1631 | can use instead of a hardware CPU to debug your programs. Currently, | |
1632 | a simulator is available when @value{GDBN} is configured to debug Zilog | |
1633 | Z8000 or Hitachi microprocessor targets. | |
1634 | @end ifset | |
1635 | ||
1636 | @ifclear GENERIC | |
1637 | @ifset H8 | |
1638 | @cindex simulator, H8/300 or H8/500 | |
1639 | @cindex Hitachi H8/300 or H8/500 simulator | |
1640 | @cindex simulator, Hitachi SH | |
1641 | @cindex Hitachi SH simulator | |
1642 | When configured for debugging Hitachi microprocessor targets, | |
1643 | @value{GDBN} includes a CPU simulator for the target chip (a Hitachi SH, | |
1644 | H8/300, or H8/500). | |
1645 | @end ifset | |
1646 | ||
1647 | @ifset Z8K | |
1648 | @cindex simulator, Z8000 | |
1649 | @cindex Zilog Z8000 simulator | |
1650 | When configured for debugging Zilog Z8000 targets, @value{GDBN} includes | |
1651 | a Z8000 simulator. | |
1652 | @end ifset | |
1653 | @end ifclear | |
1654 | ||
1655 | @ifset Z8K | |
1656 | For the Z8000 family, @samp{target sim} simulates either the Z8002 (the | |
1657 | unsegmented variant of the Z8000 architecture) or the Z8001 (the | |
1658 | segmented variant). The simulator recognizes which architecture is | |
1659 | appropriate by inspecting the object code. | |
1660 | @end ifset | |
1661 | ||
1662 | @table @code | |
1663 | @item target sim | |
1664 | @kindex sim | |
1665 | @kindex target sim | |
1666 | Debug programs on a simulated CPU | |
1667 | @ifset GENERIC | |
1668 | (which CPU depends on the @value{GDBN} configuration) | |
1669 | @end ifset | |
1670 | @end table | |
1671 | ||
1672 | @noindent | |
1673 | After specifying this target, you can debug programs for the simulated | |
1674 | CPU in the same style as programs for your host computer; use the | |
1675 | @code{file} command to load a new program image, the @code{run} command | |
1676 | to run your program, and so on. | |
1677 | ||
1678 | As well as making available all the usual machine registers (see | |
1679 | @code{info reg}), this debugging target provides three additional items | |
1680 | of information as specially named registers: | |
1681 | ||
1682 | @table @code | |
1683 | @item cycles | |
1684 | Counts clock-ticks in the simulator. | |
1685 | ||
1686 | @item insts | |
1687 | Counts instructions run in the simulator. | |
1688 | ||
1689 | @item time | |
1690 | Execution time in 60ths of a second. | |
1691 | @end table | |
1692 | ||
1693 | You can refer to these values in @value{GDBN} expressions with the usual | |
1694 | conventions; for example, @w{@samp{b fputc if $cycles>5000}} sets a | |
9a27b06e | 1695 | conditional breakpoint that suspends only after at least 5000 |
4af6d502 RP |
1696 | simulated clock ticks. |
1697 | @end ifset |