]>
Commit | Line | Data |
---|---|---|
c906108c SS |
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. | |
c906108c | 4 | |
c906108c SS |
5 | @node Remote Serial |
6 | @subsection The @value{GDBN} remote serial protocol | |
7 | ||
8 | @cindex remote serial debugging, overview | |
9 | To debug a program running on another machine (the debugging | |
10 | @dfn{target} machine), you must first arrange for all the usual | |
11 | prerequisites for the program to run by itself. For example, for a C | |
12 | program, you need: | |
13 | ||
14 | @enumerate | |
15 | @item | |
16 | A startup routine to set up the C runtime environment; these usually | |
17 | have a name like @file{crt0}. The startup routine may be supplied by | |
18 | your hardware supplier, or you may have to write your own. | |
19 | ||
20 | @item | |
21 | You probably need a C subroutine library to support your program's | |
22 | subroutine calls, notably managing input and output. | |
23 | ||
24 | @item | |
25 | A way of getting your program to the other machine---for example, a | |
26 | download program. These are often supplied by the hardware | |
27 | manufacturer, but you may have to write your own from hardware | |
28 | documentation. | |
29 | @end enumerate | |
30 | ||
31 | The next step is to arrange for your program to use a serial port to | |
32 | communicate with the machine where @value{GDBN} is running (the @dfn{host} | |
33 | machine). In general terms, the scheme looks like this: | |
34 | ||
35 | @table @emph | |
36 | @item On the host, | |
37 | @value{GDBN} already understands how to use this protocol; when everything | |
38 | else is set up, you can simply use the @samp{target remote} command | |
39 | (@pxref{Targets,,Specifying a Debugging Target}). | |
40 | ||
41 | @item On the target, | |
42 | you must link with your program a few special-purpose subroutines that | |
43 | implement the @value{GDBN} remote serial protocol. The file containing these | |
44 | subroutines is called a @dfn{debugging stub}. | |
45 | ||
c906108c SS |
46 | On certain remote targets, you can use an auxiliary program |
47 | @code{gdbserver} instead of linking a stub into your program. | |
48 | @xref{Server,,Using the @code{gdbserver} program}, for details. | |
c906108c SS |
49 | @end table |
50 | ||
51 | The debugging stub is specific to the architecture of the remote | |
52 | machine; for example, use @file{sparc-stub.c} to debug programs on | |
53 | @sc{sparc} boards. | |
54 | ||
55 | @cindex remote serial stub list | |
56 | These working remote stubs are distributed with @value{GDBN}: | |
57 | ||
58 | @table @code | |
59 | ||
60 | @item i386-stub.c | |
61 | @kindex i386-stub.c | |
62 | @cindex Intel | |
63 | @cindex i386 | |
64 | For Intel 386 and compatible architectures. | |
65 | ||
66 | @item m68k-stub.c | |
67 | @kindex m68k-stub.c | |
68 | @cindex Motorola 680x0 | |
69 | @cindex m680x0 | |
70 | For Motorola 680x0 architectures. | |
71 | ||
72 | @item sh-stub.c | |
73 | @kindex sh-stub.c | |
74 | @cindex Hitachi | |
75 | @cindex SH | |
76 | For Hitachi SH architectures. | |
77 | ||
78 | @item sparc-stub.c | |
79 | @kindex sparc-stub.c | |
80 | @cindex Sparc | |
81 | For @sc{sparc} architectures. | |
82 | ||
83 | @item sparcl-stub.c | |
84 | @kindex sparcl-stub.c | |
85 | @cindex Fujitsu | |
86 | @cindex SparcLite | |
87 | For Fujitsu @sc{sparclite} architectures. | |
88 | ||
89 | @end table | |
90 | ||
91 | The @file{README} file in the @value{GDBN} distribution may list other | |
92 | recently added stubs. | |
93 | ||
94 | @menu | |
95 | * Stub Contents:: What the stub can do for you | |
96 | * Bootstrapping:: What you must do for the stub | |
97 | * Debug Session:: Putting it all together | |
085dd6e6 | 98 | * Protocol:: Definition of the communication protocol |
c906108c | 99 | * Server:: Using the `gdbserver' program |
c906108c | 100 | * NetWare:: Using the `gdbserve.nlm' program |
c906108c SS |
101 | @end menu |
102 | ||
103 | @node Stub Contents | |
104 | @subsubsection What the stub can do for you | |
105 | ||
106 | @cindex remote serial stub | |
107 | The debugging stub for your architecture supplies these three | |
108 | subroutines: | |
109 | ||
110 | @table @code | |
111 | @item set_debug_traps | |
112 | @kindex set_debug_traps | |
113 | @cindex remote serial stub, initialization | |
114 | This routine arranges for @code{handle_exception} to run when your | |
115 | program stops. You must call this subroutine explicitly near the | |
116 | beginning of your program. | |
117 | ||
118 | @item handle_exception | |
119 | @kindex handle_exception | |
120 | @cindex remote serial stub, main routine | |
121 | This is the central workhorse, but your program never calls it | |
122 | explicitly---the setup code arranges for @code{handle_exception} to | |
123 | run when a trap is triggered. | |
124 | ||
125 | @code{handle_exception} takes control when your program stops during | |
126 | execution (for example, on a breakpoint), and mediates communications | |
127 | with @value{GDBN} on the host machine. This is where the communications | |
128 | protocol is implemented; @code{handle_exception} acts as the @value{GDBN} | |
129 | representative on the target machine; it begins by sending summary | |
130 | information on the state of your program, then continues to execute, | |
131 | retrieving and transmitting any information @value{GDBN} needs, until you | |
132 | execute a @value{GDBN} command that makes your program resume; at that point, | |
133 | @code{handle_exception} returns control to your own code on the target | |
134 | machine. | |
135 | ||
136 | @item breakpoint | |
137 | @cindex @code{breakpoint} subroutine, remote | |
138 | Use this auxiliary subroutine to make your program contain a | |
139 | breakpoint. Depending on the particular situation, this may be the only | |
140 | way for @value{GDBN} to get control. For instance, if your target | |
141 | machine has some sort of interrupt button, you won't need to call this; | |
142 | pressing the interrupt button transfers control to | |
143 | @code{handle_exception}---in effect, to @value{GDBN}. On some machines, | |
144 | simply receiving characters on the serial port may also trigger a trap; | |
145 | again, in that situation, you don't need to call @code{breakpoint} from | |
146 | your own program---simply running @samp{target remote} from the host | |
147 | @value{GDBN} session gets control. | |
148 | ||
149 | Call @code{breakpoint} if none of these is true, or if you simply want | |
150 | to make certain your program stops at a predetermined point for the | |
151 | start of your debugging session. | |
152 | @end table | |
153 | ||
154 | @node Bootstrapping | |
155 | @subsubsection What you must do for the stub | |
156 | ||
157 | @cindex remote stub, support routines | |
158 | The debugging stubs that come with @value{GDBN} are set up for a particular | |
159 | chip architecture, but they have no information about the rest of your | |
160 | debugging target machine. | |
161 | ||
162 | First of all you need to tell the stub how to communicate with the | |
163 | serial port. | |
164 | ||
165 | @table @code | |
166 | @item int getDebugChar() | |
167 | @kindex getDebugChar | |
168 | Write this subroutine to read a single character from the serial port. | |
169 | It may be identical to @code{getchar} for your target system; a | |
170 | different name is used to allow you to distinguish the two if you wish. | |
171 | ||
172 | @item void putDebugChar(int) | |
173 | @kindex putDebugChar | |
174 | Write this subroutine to write a single character to the serial port. | |
175 | It may be identical to @code{putchar} for your target system; a | |
176 | different name is used to allow you to distinguish the two if you wish. | |
177 | @end table | |
178 | ||
179 | @cindex control C, and remote debugging | |
180 | @cindex interrupting remote targets | |
181 | If you want @value{GDBN} to be able to stop your program while it is | |
182 | running, you need to use an interrupt-driven serial driver, and arrange | |
183 | for it to stop when it receives a @code{^C} (@samp{\003}, the control-C | |
184 | character). That is the character which @value{GDBN} uses to tell the | |
185 | remote system to stop. | |
186 | ||
187 | Getting the debugging target to return the proper status to @value{GDBN} | |
188 | probably requires changes to the standard stub; one quick and dirty way | |
189 | is to just execute a breakpoint instruction (the ``dirty'' part is that | |
190 | @value{GDBN} reports a @code{SIGTRAP} instead of a @code{SIGINT}). | |
191 | ||
192 | Other routines you need to supply are: | |
193 | ||
194 | @table @code | |
195 | @item void exceptionHandler (int @var{exception_number}, void *@var{exception_address}) | |
196 | @kindex exceptionHandler | |
197 | Write this function to install @var{exception_address} in the exception | |
198 | handling tables. You need to do this because the stub does not have any | |
199 | way of knowing what the exception handling tables on your target system | |
200 | are like (for example, the processor's table might be in @sc{rom}, | |
201 | containing entries which point to a table in @sc{ram}). | |
202 | @var{exception_number} is the exception number which should be changed; | |
203 | its meaning is architecture-dependent (for example, different numbers | |
204 | might represent divide by zero, misaligned access, etc). When this | |
205 | exception occurs, control should be transferred directly to | |
206 | @var{exception_address}, and the processor state (stack, registers, | |
207 | and so on) should be just as it is when a processor exception occurs. So if | |
208 | you want to use a jump instruction to reach @var{exception_address}, it | |
209 | should be a simple jump, not a jump to subroutine. | |
210 | ||
211 | For the 386, @var{exception_address} should be installed as an interrupt | |
212 | gate so that interrupts are masked while the handler runs. The gate | |
213 | should be at privilege level 0 (the most privileged level). The | |
7a292a7a | 214 | @sc{sparc} and 68k stubs are able to mask interrupts themselves without |
c906108c SS |
215 | help from @code{exceptionHandler}. |
216 | ||
217 | @item void flush_i_cache() | |
218 | @kindex flush_i_cache | |
219 | (sparc and sparclite only) Write this subroutine to flush the | |
220 | instruction cache, if any, on your target machine. If there is no | |
221 | instruction cache, this subroutine may be a no-op. | |
222 | ||
223 | On target machines that have instruction caches, @value{GDBN} requires this | |
224 | function to make certain that the state of your program is stable. | |
225 | @end table | |
226 | ||
227 | @noindent | |
228 | You must also make sure this library routine is available: | |
229 | ||
230 | @table @code | |
231 | @item void *memset(void *, int, int) | |
232 | @kindex memset | |
233 | This is the standard library function @code{memset} that sets an area of | |
234 | memory to a known value. If you have one of the free versions of | |
235 | @code{libc.a}, @code{memset} can be found there; otherwise, you must | |
236 | either obtain it from your hardware manufacturer, or write your own. | |
237 | @end table | |
238 | ||
239 | If you do not use the GNU C compiler, you may need other standard | |
240 | library subroutines as well; this varies from one stub to another, | |
241 | but in general the stubs are likely to use any of the common library | |
242 | subroutines which @code{gcc} generates as inline code. | |
243 | ||
244 | ||
245 | @node Debug Session | |
246 | @subsubsection Putting it all together | |
247 | ||
248 | @cindex remote serial debugging summary | |
249 | In summary, when your program is ready to debug, you must follow these | |
250 | steps. | |
251 | ||
252 | @enumerate | |
253 | @item | |
254 | Make sure you have the supporting low-level routines | |
255 | (@pxref{Bootstrapping,,What you must do for the stub}): | |
256 | @display | |
257 | @code{getDebugChar}, @code{putDebugChar}, | |
258 | @code{flush_i_cache}, @code{memset}, @code{exceptionHandler}. | |
259 | @end display | |
260 | ||
261 | @item | |
262 | Insert these lines near the top of your program: | |
263 | ||
264 | @example | |
265 | set_debug_traps(); | |
266 | breakpoint(); | |
267 | @end example | |
268 | ||
269 | @item | |
270 | For the 680x0 stub only, you need to provide a variable called | |
271 | @code{exceptionHook}. Normally you just use: | |
272 | ||
273 | @example | |
274 | void (*exceptionHook)() = 0; | |
275 | @end example | |
276 | ||
277 | but if before calling @code{set_debug_traps}, you set it to point to a | |
278 | function in your program, that function is called when | |
279 | @code{@value{GDBN}} continues after stopping on a trap (for example, bus | |
280 | error). The function indicated by @code{exceptionHook} is called with | |
281 | one parameter: an @code{int} which is the exception number. | |
282 | ||
283 | @item | |
284 | Compile and link together: your program, the @value{GDBN} debugging stub for | |
285 | your target architecture, and the supporting subroutines. | |
286 | ||
287 | @item | |
288 | Make sure you have a serial connection between your target machine and | |
289 | the @value{GDBN} host, and identify the serial port on the host. | |
290 | ||
291 | @item | |
292 | @c The "remote" target now provides a `load' command, so we should | |
293 | @c document that. FIXME. | |
294 | Download your program to your target machine (or get it there by | |
295 | whatever means the manufacturer provides), and start it. | |
296 | ||
297 | @item | |
298 | To start remote debugging, run @value{GDBN} on the host machine, and specify | |
299 | as an executable file the program that is running in the remote machine. | |
300 | This tells @value{GDBN} how to find your program's symbols and the contents | |
301 | of its pure text. | |
302 | ||
303 | @cindex serial line, @code{target remote} | |
304 | Then establish communication using the @code{target remote} command. | |
305 | Its argument specifies how to communicate with the target | |
306 | machine---either via a devicename attached to a direct serial line, or a | |
307 | TCP port (usually to a terminal server which in turn has a serial line | |
308 | to the target). For example, to use a serial line connected to the | |
309 | device named @file{/dev/ttyb}: | |
310 | ||
311 | @example | |
312 | target remote /dev/ttyb | |
313 | @end example | |
314 | ||
315 | @cindex TCP port, @code{target remote} | |
316 | To use a TCP connection, use an argument of the form | |
317 | @code{@var{host}:port}. For example, to connect to port 2828 on a | |
318 | terminal server named @code{manyfarms}: | |
319 | ||
320 | @example | |
321 | target remote manyfarms:2828 | |
322 | @end example | |
323 | @end enumerate | |
324 | ||
325 | Now you can use all the usual commands to examine and change data and to | |
326 | step and continue the remote program. | |
327 | ||
328 | To resume the remote program and stop debugging it, use the @code{detach} | |
329 | command. | |
330 | ||
331 | @cindex interrupting remote programs | |
332 | @cindex remote programs, interrupting | |
333 | Whenever @value{GDBN} is waiting for the remote program, if you type the | |
334 | interrupt character (often @key{C-C}), @value{GDBN} attempts to stop the | |
335 | program. This may or may not succeed, depending in part on the hardware | |
336 | and the serial drivers the remote system uses. If you type the | |
337 | interrupt character once again, @value{GDBN} displays this prompt: | |
338 | ||
339 | @example | |
340 | Interrupted while waiting for the program. | |
341 | Give up (and stop debugging it)? (y or n) | |
342 | @end example | |
343 | ||
344 | If you type @kbd{y}, @value{GDBN} abandons the remote debugging session. | |
345 | (If you decide you want to try again later, you can use @samp{target | |
346 | remote} again to connect once more.) If you type @kbd{n}, @value{GDBN} | |
347 | goes back to waiting. | |
348 | ||
349 | @node Protocol | |
350 | @subsubsection Communication protocol | |
351 | ||
352 | @cindex debugging stub, example | |
353 | @cindex remote stub, example | |
354 | @cindex stub example, remote debugging | |
355 | The stub files provided with @value{GDBN} implement the target side of the | |
356 | communication protocol, and the @value{GDBN} side is implemented in the | |
357 | @value{GDBN} source file @file{remote.c}. Normally, you can simply allow | |
358 | these subroutines to communicate, and ignore the details. (If you're | |
359 | implementing your own stub file, you can still ignore the details: start | |
360 | with one of the existing stub files. @file{sparc-stub.c} is the best | |
361 | organized, and therefore the easiest to read.) | |
362 | ||
363 | However, there may be occasions when you need to know something about | |
364 | the protocol---for example, if there is only one serial port to your | |
365 | target machine, you might want your program to do something special if | |
366 | it recognizes a packet meant for @value{GDBN}. | |
367 | ||
085dd6e6 JM |
368 | In the examples below, @samp{<-} and @samp{->} are used to indicate |
369 | transmitted and received data respectfully. | |
370 | ||
c906108c SS |
371 | @cindex protocol, @value{GDBN} remote serial |
372 | @cindex serial protocol, @value{GDBN} remote | |
373 | @cindex remote serial protocol | |
085dd6e6 JM |
374 | All @value{GDBN} commands and responses (other than acknowledgments) |
375 | are sent as a @var{packet}. A @var{packet} is introduced with the | |
376 | character @samp{$}, this is followed by an optional two-digit | |
377 | @var{sequence-id} and the character @samp{:}, the actual | |
378 | @var{packet-data}, and the terminating character @samp{#} followed by a | |
379 | two-digit @var{checksum}: | |
c906108c SS |
380 | |
381 | @example | |
085dd6e6 JM |
382 | @code{$}@var{packet-data}@code{#}@var{checksum} |
383 | @end example | |
384 | @noindent | |
385 | or, with the optional @var{sequence-id}: | |
386 | @example | |
387 | @code{$}@var{sequence-id}@code{:}@var{packet-data}@code{#}@var{checksum} | |
c906108c SS |
388 | @end example |
389 | ||
390 | @cindex checksum, for @value{GDBN} remote | |
391 | @noindent | |
085dd6e6 JM |
392 | The two-digit @var{checksum} is computed as the modulo 256 sum of all |
393 | characters between the leading @samp{$} and the trailing @samp{#} (that | |
394 | consisting of both the optional @var{sequence-id}@code{:} and the actual | |
395 | @var{packet-data}). | |
396 | ||
397 | @cindex sequence-id, for @value{GDBN} remote | |
398 | @noindent | |
399 | The two-digit @var{sequence-id}, when present, is returned with the | |
400 | acknowledgment. Beyond that its meaning is poorly defined. | |
401 | @value{GDBN} is not known to output @var{sequence-id}s. | |
c906108c SS |
402 | |
403 | When either the host or the target machine receives a packet, the first | |
085dd6e6 JM |
404 | response expected is an acknowledgment: either @samp{+} (to indicate |
405 | the package was received correctly) or @samp{-} (to request | |
406 | retransmission): | |
c906108c | 407 | |
085dd6e6 JM |
408 | @example |
409 | <- @code{$}@var{packet-data}@code{#}@var{checksum} | |
410 | -> @code{+} | |
411 | @end example | |
412 | @noindent | |
413 | If the received packet included a @var{sequence-id} than that is | |
414 | appended to a positive acknowledgment: | |
c906108c | 415 | |
085dd6e6 JM |
416 | @example |
417 | <- @code{$}@var{sequence-id}@code{:}@var{packet-data}@code{#}@var{checksum} | |
418 | -> @code{+}@var{sequence-id} | |
419 | @end example | |
c906108c | 420 | |
085dd6e6 JM |
421 | The host (@value{GDBN}) sends @var{command}s, and the target (the |
422 | debugging stub incorporated in your program) sends a @var{response}. In | |
423 | the case of step and continue @var{command}s, the response is only sent | |
424 | when the operation has completed (the target has again stopped). | |
425 | ||
426 | @var{packet-data} consists of a sequence of characters with the | |
427 | exception of @samp{#} and @samp{$} (see @samp{X} packet for an | |
428 | exception). @samp{:} can not appear as the third character in a packet. | |
429 | Fields within the packet should be separated using @samp{,} and @samp{;} | |
430 | (unfortunately some packets chose to use @samp{:}). Except where | |
431 | otherwise noted all numbers are represented in HEX with leading zeros | |
432 | suppressed. | |
433 | ||
434 | Response @var{data} can be run-length encoded to save space. A @samp{*} | |
435 | means that the next character is an ASCII encoding giving a repeat count | |
436 | which stands for that many repetitions of the character preceding the | |
437 | @samp{*}. The encoding is @code{n+29}, yielding a printable character | |
438 | where @code{n >=3} (which is where rle starts to win). Don't use an | |
439 | @code{n > 126}. | |
440 | ||
441 | So: | |
442 | @example | |
443 | "@code{0* }" | |
444 | @end example | |
445 | @noindent | |
446 | means the same as "0000". | |
c906108c | 447 | |
085dd6e6 JM |
448 | The error response, returned for some packets includes a two character |
449 | error number. That number is not well defined. | |
c906108c | 450 | |
085dd6e6 JM |
451 | For any @var{command} not supported by the stub, an empty response |
452 | (@samp{$#00}) should be returned. That way it is possible to extend the | |
453 | protocol. A newer @value{GDBN} can tell if a packet is supported based | |
454 | on the response. | |
c906108c | 455 | |
085dd6e6 JM |
456 | Below is a complete list of all currently defined @var{command}s and |
457 | their corresponding response @var{data}: | |
c906108c | 458 | |
085dd6e6 JM |
459 | @multitable @columnfractions .30 .30 .40 |
460 | @item Packet | |
461 | @tab Request | |
462 | @tab Description | |
c906108c | 463 | |
085dd6e6 JM |
464 | @item extended ops @emph{(optional)} |
465 | @tab @code{!} | |
466 | @tab | |
467 | Use the extended remote protocol. Sticky -- only needs to be set once. | |
468 | The extended remote protocol support the @samp{R} packet. | |
469 | @item | |
470 | @tab reply @samp{} | |
471 | @tab | |
472 | Stubs that support the extended remote protocol return @samp{} which, | |
473 | unfortunately, is identical to the response returned by stubs that do not | |
474 | support protocol extensions. | |
475 | ||
476 | @item last signal | |
477 | @tab @code{?} | |
478 | @tab | |
479 | Reply the current reason for stopping. This is the same reply as is | |
480 | generated for step or cont : @code{S}@var{AA} where @var{AA} is the | |
481 | signal number. | |
482 | ||
483 | @item reserved | |
484 | @tab @code{a} | |
485 | @tab Reserved for future use | |
486 | ||
487 | @item set program arguments @strong{(reserved)} @emph{(optional)} | |
488 | @tab @code{A}@var{arglen}@code{,}@var{argnum}@code{,}@var{arg}@code{,...} | |
489 | @tab | |
490 | Initialized @samp{argv[]} array passed into program. @var{arglen} | |
491 | specifies the number of bytes in the hex encoded byte stream @var{arg}. | |
492 | @item | |
493 | @tab reply @code{OK} | |
494 | @item | |
495 | @tab reply @code{E}@var{NN} | |
496 | ||
497 | @item set baud @strong{(deprecated)} | |
498 | @tab @code{b}@var{baud} | |
499 | @tab | |
500 | Change the serial line speed to @var{baud}. JTC: @emph{When does the | |
501 | transport layer state change? When it's received, or after the ACK is | |
502 | transmitted. In either case, there are problems if the command or the | |
503 | acknowledgment packet is dropped.} Stan: @emph{If people really wanted | |
504 | to add something like this, and get it working for the first time, they | |
505 | ought to modify ser-unix.c to send some kind of out-of-band message to a | |
506 | specially-setup stub and have the switch happen "in between" packets, so | |
507 | that from remote protocol's point of view, nothing actually | |
508 | happened.} | |
509 | ||
510 | @item set breakpoint @strong{(deprecated)} | |
511 | @tab @code{B}@var{addr},@var{mode} | |
512 | @tab | |
513 | Set (@var{mode} is @samp{S}) or clear (@var{mode} is @samp{C}) a | |
514 | breakpoint at @var{addr}. @emph{This has been replaced by the @samp{Z} and | |
515 | @samp{z} packets.} | |
516 | ||
517 | @item continue | |
518 | @tab @code{c}@var{addr} | |
519 | @tab | |
520 | @var{addr} is address to resume. If @var{addr} is omitted, resume at | |
521 | current address. | |
522 | @item | |
523 | @tab reply | |
524 | @tab see below | |
525 | ||
526 | @item continue with signal @emph{(optional)} | |
527 | @tab @code{C}@var{sig}@code{;}@var{addr} | |
528 | @tab | |
529 | Continue with signal @var{sig} (hex signal number). If | |
530 | @code{;}@var{addr} is omitted, resume at same address. | |
531 | @item | |
532 | @tab reply | |
533 | @tab see below | |
c906108c | 534 | |
085dd6e6 JM |
535 | @item toggle debug @emph{(optional)} |
536 | @tab @code{d} | |
537 | @tab | |
538 | toggle debug flag (see 386 & 68k stubs) | |
c906108c | 539 | |
085dd6e6 JM |
540 | @item detach @emph{(optional)} |
541 | @tab @code{D} | |
542 | @tab Reply OK. | |
c906108c | 543 | |
085dd6e6 JM |
544 | @item reserved |
545 | @tab @code{e} | |
546 | @tab Reserved for future use | |
c906108c | 547 | |
085dd6e6 JM |
548 | @item reserved |
549 | @tab @code{E} | |
550 | @tab Reserved for future use | |
c906108c | 551 | |
085dd6e6 JM |
552 | @item reserved |
553 | @tab @code{f} | |
554 | @tab Reserved for future use | |
555 | ||
556 | @item reserved | |
557 | @tab @code{F} | |
558 | @tab Reserved for future use | |
559 | ||
560 | @item read registers | |
561 | @tab @code{g} | |
562 | @tab Read general registers. | |
563 | @item | |
564 | @tab reply @var{XX...} | |
565 | @tab | |
566 | Each byte of register data is described by two hex digits. The bytes | |
567 | with the register are transmitted in target byte order. The size of | |
568 | each register and their position within the @samp{g} @var{packet} is | |
569 | determined by the @var{REGISTER_RAW_SIZE} and @var{REGISTER_NAME} | |
570 | macros. | |
571 | @item | |
572 | @tab @code{E}@var{NN} | |
573 | @tab for an error. | |
574 | ||
575 | @item write regs | |
576 | @tab @code{G}@var{XX...} | |
577 | @tab | |
578 | See @samp{g} for a description of the @var{XX...} data. | |
579 | @item | |
580 | @tab reply @code{OK} | |
581 | @tab for success | |
582 | @item | |
583 | @tab reply @code{E}@var{NN} | |
584 | @tab for an error | |
585 | ||
586 | @item reserved | |
587 | @tab @code{h} | |
588 | @tab Reserved for future use | |
589 | ||
590 | @item set thread @emph{(optional)} | |
591 | @tab @code{H}@var{c}@var{t...} | |
592 | @tab | |
593 | Set thread for subsequent operations. @var{c} = @samp{c} for thread | |
594 | used in step and continue; @var{t...} can be -1 for all threads. | |
595 | @var{c} = @samp{g} for thread used in other operations. If zero, pick a | |
596 | thread, any thread. | |
597 | @item | |
598 | @tab reply @code{OK} | |
599 | @tab for success | |
600 | @item | |
601 | @tab reply @code{E}@var{NN} | |
602 | @tab for an error | |
603 | ||
604 | @item cycle step @strong{(draft)} @emph{(optional)} | |
605 | @tab @code{i}@var{addr}@code{,}@var{nnn} | |
606 | @tab | |
607 | Step the remote target by a single clock cycle. If @code{,}@var{nnn} is | |
608 | present, cycle step @var{nnn} cycles. If @var{addr} is present, cycle | |
609 | step starting at that address. | |
610 | ||
611 | @item signal then cycle step @strong{(reserved)} @emph{(optional)} | |
612 | @tab @code{I} | |
613 | @tab | |
614 | See @samp{i} and @samp{S} for likely syntax and semantics. | |
615 | ||
616 | @item reserved | |
617 | @tab @code{j} | |
618 | @tab Reserved for future use | |
619 | ||
620 | @item reserved | |
621 | @tab @code{J} | |
622 | @tab Reserved for future use | |
623 | ||
624 | @item kill request @emph{(optional)} | |
625 | @tab @code{k} | |
626 | @tab | |
627 | ||
628 | @item reserved | |
629 | @tab @code{l} | |
630 | @tab Reserved for future use | |
631 | ||
632 | @item reserved | |
633 | @tab @code{L} | |
634 | @tab Reserved for future use | |
635 | ||
636 | @item read memory | |
637 | @tab @code{m}@var{addr}@code{,}@var{length} | |
638 | @tab | |
639 | Read @var{length} bytes of memory starting at address @var{addr}. | |
640 | @item | |
641 | @tab reply @var{XX...} | |
642 | @tab | |
643 | @var{XX...} is mem contents. Can be fewer bytes than requested if able to | |
644 | read only part of the data. | |
645 | @item | |
646 | @tab reply @code{E}@var{NN} | |
647 | @tab @var{NN} is errno | |
648 | ||
649 | @item write mem | |
650 | @tab @code{M}@var{addr},@var{length}@code{:}@var{XX...} | |
651 | @tab | |
652 | Write @var{length} bytes of memory starting at address @var{addr}. | |
653 | @var{XX...} is the data. | |
654 | @item | |
655 | @tab reply @code{OK} | |
656 | @tab for success | |
657 | @item | |
658 | @tab reply @code{E}@var{NN} | |
659 | @tab | |
660 | for an error (this includes the case where only part of the data was | |
661 | written). | |
662 | ||
663 | @item reserved | |
664 | @tab @code{n} | |
665 | @tab Reserved for future use | |
666 | ||
667 | @item reserved | |
668 | @tab @code{N} | |
669 | @tab Reserved for future use | |
670 | ||
671 | @item reserved | |
672 | @tab @code{o} | |
673 | @tab Reserved for future use | |
674 | ||
675 | @item reserved | |
676 | @tab @code{O} | |
677 | @tab Reserved for future use | |
678 | ||
679 | @item read reg @strong{(reserved)} | |
680 | @tab @code{p}@var{n...} | |
681 | @tab | |
682 | See write register. | |
683 | @item | |
684 | @tab return @var{r....} | |
685 | @tab The hex encoded value of the register in target byte order. | |
686 | ||
687 | @item write reg @emph{(optional)} | |
688 | @tab @code{P}@var{n...}@code{=}@var{r...} | |
689 | @tab | |
690 | Write register @var{n...} with value @var{r...}, which contains two hex | |
691 | digits for each byte in the register (target byte order). | |
692 | @item | |
693 | @tab reply @code{OK} | |
694 | @tab for success | |
695 | @item | |
696 | @tab reply @code{E}@var{NN} | |
697 | @tab for an error | |
698 | ||
699 | @item general query @emph{(optional)} | |
700 | @tab @code{q}@var{query} | |
701 | @tab | |
702 | Request info about @var{query}. In general @value{GDBN} @var{query}'s | |
703 | have a leading upper case letter. Custom vendor queries should use a | |
704 | leading lower case letter and a company prefix, ex: @samp{qfsf.var}. | |
705 | @var{query} may optionally be followed by a @samp{,} or @samp{;} | |
706 | separated list. Stubs should ensure that they fully match any | |
707 | @var{query} name. | |
708 | @item | |
709 | @tab reply @code{XX...} | |
710 | @tab Hex encoded data from query. The reply can not be empty. | |
711 | @item | |
712 | @tab reply @code{E}@var{NN} | |
713 | @tab error reply | |
714 | @item | |
715 | @tab reply @samp{} | |
716 | @tab Indicating an unrecognized @var{query}. | |
717 | ||
718 | @item current thread | |
719 | @tab @code{q}@code{C} | |
720 | @tab Return the current thread id. | |
721 | @item | |
722 | @tab reply @code{QC}@var{pid} | |
723 | @tab | |
724 | Where @var{pid} is a HEX encoded 16 bit process id. | |
725 | @item | |
726 | @tab reply * | |
727 | @tab Any other reply implies the old pid. | |
728 | ||
729 | @item compute CRC of memory block | |
730 | @tab @code{q}@code{CRC:}@var{addr}@code{,}@var{length} | |
731 | @tab | |
732 | @item | |
733 | @tab reply @code{E}@var{NN} | |
734 | @tab An error (such as memory fault) | |
735 | @item | |
736 | @tab reply @code{C}@var{CRC32} | |
737 | @tab A 32 bit cyclic redundancy check of the specified memory region. | |
738 | ||
739 | @item query @var{LIST} or @var{threadLIST} | |
740 | @tab @code{q}@code{L}@var{startflag}@var{threadcount}@var{nextthread} | |
741 | @tab | |
742 | Obtain thread information from RTOS. @var{startflag} is one hex digit; | |
743 | @var{threadcount} is two hex digits; and @var{nextthread} is 16 hex | |
744 | digits. | |
745 | @item | |
746 | @tab reply * | |
747 | @tab | |
748 | See @code{remote.c:parse_threadlist_response()}. | |
749 | ||
750 | @item query sect offs | |
751 | @tab @code{q}@code{Offsets} | |
752 | @tab Get section offsets. | |
753 | @item | |
754 | @tab reply @code{Text=}@var{xxx}@code{;Data=}@var{yyy}@code{;Bss=}@var{zzz} | |
755 | ||
756 | @item thread info request | |
757 | @tab @code{q}@code{P}@var{mode}@var{threadid} | |
758 | @tab | |
759 | Returns information on @var{threadid}. Where: @var{mode} is a hex | |
760 | encoded 32 bit mode; @var{threadid} is a hex encoded 64 bit thread ID. | |
761 | @item | |
762 | @tab reply * | |
763 | @tab | |
764 | See @code{remote.c:remote_unpack_thread_info_response()}. | |
765 | ||
766 | @item remote command @strong{(reserved)} | |
767 | @tab @code{q}@code{Rcmd,}@var{COMMAND} | |
768 | @tab | |
769 | @var{COMMAND} (hex encoded) is passed to the local interpreter for | |
770 | execution. @emph{Implementors should note that providing access to a | |
771 | stubs's interpreter may have security implications}. | |
772 | @item | |
96baa820 | 773 | @tab reply @var{OUTPUT} or @code{OK} |
085dd6e6 | 774 | @tab |
96baa820 JM |
775 | The @var{OUTPUT} is the hex encoded output from the command. @code{OK} |
776 | is returned when the @var{OUTPUT} would have been empty. The target may | |
777 | also respond with a number of intermediate @code{O}@var{OUTPUT} console | |
778 | output packets. | |
779 | ||
085dd6e6 JM |
780 | @item |
781 | @tab reply @samp{} | |
782 | @tab | |
783 | When @samp{q}@samp{Rcmd} is not recognized. | |
784 | ||
785 | @item general set @emph{(optional)} | |
786 | @tab @code{Q}@var{var}@code{=}@var{val} | |
787 | @tab | |
788 | Set value of @var{var} to @var{val}. See @samp{q} for a discussing of | |
789 | naming conventions. | |
790 | ||
791 | @item reset @emph{(optional)} | |
792 | @tab r | |
793 | @tab reset -- see sparc stub. | |
794 | ||
795 | @item remote restart @emph{(optional)} | |
796 | @tab @code{R}@var{XX} | |
797 | @tab | |
798 | Restart the remote server. @var{XX} while needed has no clear | |
799 | definition. | |
800 | ||
801 | @item step @emph{(optional)} | |
802 | @tab @code{s}@var{addr} | |
803 | @tab | |
804 | @var{addr} is address to resume. If @var{addr} is omitted, resume at | |
805 | same address. | |
806 | @item | |
807 | @tab reply | |
808 | @tab see below | |
809 | ||
810 | @item step with signal @emph{(optional)} | |
811 | @tab @code{S}@var{sig}@code{;}@var{addr} | |
812 | @tab | |
813 | Like @samp{C} but step not continue. | |
814 | @item | |
815 | @tab reply | |
816 | @tab see below | |
817 | ||
818 | @item search @emph{(optional)} | |
819 | @tab @code{t}@var{addr}@code{:}@var{PP}@code{,}@var{MM} | |
820 | @tab | |
821 | Search backwards starting at address @var{addr} for a match with pattern | |
822 | @var{PP} and mask @var{MM}. @var{PP} and @var{MM} are 4 | |
823 | bytes. @var{addr} must be at least 3 digits. | |
824 | ||
825 | @item thread alive @emph{(optional)} | |
826 | @tab @code{T}@var{XX} | |
827 | @tab Find out if the thread XX is alive. | |
828 | @item | |
829 | @tab reply @code{OK} | |
830 | @tab thread is still alive | |
831 | @item | |
832 | @tab reply @code{E}@var{NN} | |
833 | @tab thread is dead | |
834 | ||
835 | @item reserved | |
836 | @tab @code{u} | |
837 | @tab Reserved for future use | |
838 | ||
839 | @item reserved | |
840 | @tab @code{U} | |
841 | @tab Reserved for future use | |
842 | ||
843 | @item reserved | |
844 | @tab @code{v} | |
845 | @tab Reserved for future use | |
846 | ||
847 | @item reserved | |
848 | @tab @code{V} | |
849 | @tab Reserved for future use | |
850 | ||
851 | @item reserved | |
852 | @tab @code{w} | |
853 | @tab Reserved for future use | |
854 | ||
855 | @item reserved | |
856 | @tab @code{W} | |
857 | @tab Reserved for future use | |
858 | ||
859 | @item reserved | |
860 | @tab @code{x} | |
861 | @tab Reserved for future use | |
862 | ||
863 | @item write mem (binary) @emph{(optional)} | |
864 | @tab @code{X}@var{addr}@code{,}@var{length}@var{:}@var{XX...} | |
865 | @tab | |
866 | @var{addr} is address, @var{length} is number of bytes, @var{XX...} is | |
867 | binary data. | |
868 | @item | |
869 | @tab reply @code{OK} | |
870 | @tab for success | |
871 | @item | |
872 | @tab reply @code{E}@var{NN} | |
873 | @tab for an error | |
874 | ||
875 | @item reserved | |
876 | @tab @code{y} | |
877 | @tab Reserved for future use | |
878 | ||
879 | @item reserved | |
880 | @tab @code{Y} | |
881 | @tab Reserved for future use | |
882 | ||
883 | @item remove break or watchpoint @strong{(draft)} @emph{(optional)} | |
884 | @tab @code{z}@var{t}@code{,}@var{addr}@code{,}@var{length} | |
885 | @tab | |
886 | See @samp{Z}. | |
887 | ||
888 | @item insert break or watchpoint @strong{(draft)} @emph{(optional)} | |
889 | @tab @code{Z}@var{t}@code{,}@var{addr}@code{,}@var{length} | |
890 | @tab | |
891 | @var{t} is type: @samp{0} - software breakpoint, @samp{1} - hardware | |
892 | breakpoint, @samp{2} - write watchpoint, @samp{3} - read watchpoint, | |
893 | @samp{4} - access watchpoint; @var{addr} is address; @var{length} is in | |
894 | bytes. For a software breakpoint, @var{length} specifies the size of | |
895 | the instruction to be patched. For hardware breakpoints and watchpoints | |
896 | @var{length} specifies the memory region to be monitored. | |
897 | @item | |
898 | @tab reply @code{E}@var{NN} | |
899 | @tab for an error | |
900 | @item | |
901 | @tab reply @code{OK} | |
902 | @tab for success | |
903 | @item | |
904 | @tab @samp{} | |
905 | @tab If not supported. | |
906 | ||
907 | @item reserved | |
908 | @tab <other> | |
909 | @tab Reserved for future use | |
910 | ||
911 | @end multitable | |
912 | ||
913 | In the case of the @samp{C}, @samp{c}, @samp{S} and @samp{s} packets, | |
914 | there is no immediate response. The reply, described below, comes when | |
915 | the machine stops: | |
916 | ||
917 | @multitable @columnfractions .4 .6 | |
918 | ||
919 | @item @code{S}@var{AA} | |
920 | @tab @var{AA} is the signal number | |
921 | ||
922 | @item @code{T}@var{AA}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;} | |
923 | @tab | |
924 | @var{AA} = two hex digit signal number; @var{n...} = register number | |
925 | (hex), @var{r...} = target byte ordered register contents, size defined | |
926 | by @code{REGISTER_RAW_SIZE}; @var{n...} = @samp{thread}, @var{r...} = | |
927 | thread process ID, this is a hex integer; @var{n...} = other string not | |
928 | starting with valid hex digit. @value{GDBN} should ignore this | |
929 | @var{n...}, @var{r...} pair and go on to the next. This way we can | |
930 | extend the protocol. | |
931 | ||
932 | @item @code{W}@var{AA} | |
933 | @tab | |
934 | The process exited, and @var{AA} is the exit status. This is only | |
935 | applicable for certains sorts of targets. | |
936 | ||
937 | @item @code{X}@var{AA} | |
938 | @tab | |
939 | The process terminated with signal @var{AA}. | |
940 | ||
941 | @item @code{N}@var{AA}@code{;}@var{tttttttt}@code{;}@var{dddddddd}@code{;}@var{bbbbbbbb} @strong{(obsolete)} | |
942 | @tab | |
943 | @var{AA} = signal number; @var{tttttttt} = address of symbol "_start"; | |
944 | @var{dddddddd} = base of data section; @var{bbbbbbbb} = base of bss | |
945 | section. @emph{Note: only used by Cisco Systems targets. The difference | |
946 | between this reply and the "qOffsets" query is that the 'N' packet may | |
947 | arrive spontaneously whereas the 'qOffsets' is a query initiated by the | |
948 | host debugger.} | |
949 | ||
950 | @item @code{O}@var{XX...} | |
951 | @tab | |
952 | @var{XX...} is hex encoding of ASCII data. This can happen at any time | |
953 | while the program is running and the debugger should continue to wait | |
954 | for 'W', 'T', etc. | |
955 | ||
956 | @end multitable | |
957 | ||
958 | Example sequence of a target being re-started. Notice how the restart | |
959 | does not get any direct output: | |
960 | ||
961 | @example | |
962 | <- @code{R00} | |
963 | -> @code{+} | |
964 | @emph{target restarts} | |
965 | <- @code{?} | |
966 | -> @code{+} | |
967 | -> @code{T001:1234123412341234} | |
968 | <- @code{+} | |
969 | @end example | |
970 | ||
971 | Example sequence of a target being stepped by a single instruction: | |
972 | ||
973 | @example | |
974 | <- @code{G1445...} | |
975 | -> @code{+} | |
976 | <- @code{s} | |
977 | -> @code{+} | |
978 | @emph{time passes} | |
979 | -> @code{T001:1234123412341234} | |
980 | <- @code{+} | |
981 | <- @code{g} | |
982 | -> @code{+} | |
983 | -> @code{1455...} | |
984 | <- @code{+} | |
985 | @end example | |
c906108c SS |
986 | |
987 | @kindex set remotedebug | |
988 | @kindex show remotedebug | |
989 | @cindex packets, reporting on stdout | |
990 | @cindex serial connections, debugging | |
991 | If you have trouble with the serial connection, you can use the command | |
992 | @code{set remotedebug}. This makes @value{GDBN} report on all packets sent | |
993 | back and forth across the serial line to the remote machine. The | |
994 | packet-debugging information is printed on the @value{GDBN} standard output | |
995 | stream. @code{set remotedebug off} turns it off, and @code{show | |
996 | remotedebug} shows you its current state. | |
997 | ||
c906108c SS |
998 | @node Server |
999 | @subsubsection Using the @code{gdbserver} program | |
1000 | ||
1001 | @kindex gdbserver | |
1002 | @cindex remote connection without stubs | |
1003 | @code{gdbserver} is a control program for Unix-like systems, which | |
1004 | allows you to connect your program with a remote @value{GDBN} via | |
1005 | @code{target remote}---but without linking in the usual debugging stub. | |
1006 | ||
1007 | @code{gdbserver} is not a complete replacement for the debugging stubs, | |
1008 | because it requires essentially the same operating-system facilities | |
1009 | that @value{GDBN} itself does. In fact, a system that can run | |
1010 | @code{gdbserver} to connect to a remote @value{GDBN} could also run | |
1011 | @value{GDBN} locally! @code{gdbserver} is sometimes useful nevertheless, | |
1012 | because it is a much smaller program than @value{GDBN} itself. It is | |
1013 | also easier to port than all of @value{GDBN}, so you may be able to get | |
1014 | started more quickly on a new system by using @code{gdbserver}. | |
1015 | Finally, if you develop code for real-time systems, you may find that | |
1016 | the tradeoffs involved in real-time operation make it more convenient to | |
1017 | do as much development work as possible on another system, for example | |
1018 | by cross-compiling. You can use @code{gdbserver} to make a similar | |
1019 | choice for debugging. | |
1020 | ||
1021 | @value{GDBN} and @code{gdbserver} communicate via either a serial line | |
1022 | or a TCP connection, using the standard @value{GDBN} remote serial | |
1023 | protocol. | |
1024 | ||
1025 | @table @emph | |
1026 | @item On the target machine, | |
1027 | you need to have a copy of the program you want to debug. | |
1028 | @code{gdbserver} does not need your program's symbol table, so you can | |
1029 | strip the program if necessary to save space. @value{GDBN} on the host | |
1030 | system does all the symbol handling. | |
1031 | ||
1032 | To use the server, you must tell it how to communicate with @value{GDBN}; | |
1033 | the name of your program; and the arguments for your program. The | |
1034 | syntax is: | |
1035 | ||
1036 | @smallexample | |
1037 | target> gdbserver @var{comm} @var{program} [ @var{args} @dots{} ] | |
1038 | @end smallexample | |
1039 | ||
1040 | @var{comm} is either a device name (to use a serial line) or a TCP | |
1041 | hostname and portnumber. For example, to debug Emacs with the argument | |
1042 | @samp{foo.txt} and communicate with @value{GDBN} over the serial port | |
1043 | @file{/dev/com1}: | |
1044 | ||
1045 | @smallexample | |
1046 | target> gdbserver /dev/com1 emacs foo.txt | |
1047 | @end smallexample | |
1048 | ||
1049 | @code{gdbserver} waits passively for the host @value{GDBN} to communicate | |
1050 | with it. | |
1051 | ||
1052 | To use a TCP connection instead of a serial line: | |
1053 | ||
1054 | @smallexample | |
1055 | target> gdbserver host:2345 emacs foo.txt | |
1056 | @end smallexample | |
1057 | ||
1058 | The only difference from the previous example is the first argument, | |
1059 | specifying that you are communicating with the host @value{GDBN} via | |
1060 | TCP. The @samp{host:2345} argument means that @code{gdbserver} is to | |
1061 | expect a TCP connection from machine @samp{host} to local TCP port 2345. | |
1062 | (Currently, the @samp{host} part is ignored.) You can choose any number | |
1063 | you want for the port number as long as it does not conflict with any | |
1064 | TCP ports already in use on the target system (for example, @code{23} is | |
1065 | reserved for @code{telnet}).@footnote{If you choose a port number that | |
1066 | conflicts with another service, @code{gdbserver} prints an error message | |
1067 | and exits.} You must use the same port number with the host @value{GDBN} | |
1068 | @code{target remote} command. | |
1069 | ||
1070 | @item On the @value{GDBN} host machine, | |
1071 | you need an unstripped copy of your program, since @value{GDBN} needs | |
1072 | symbols and debugging information. Start up @value{GDBN} as usual, | |
1073 | using the name of the local copy of your program as the first argument. | |
1074 | (You may also need the @w{@samp{--baud}} option if the serial line is | |
1075 | running at anything other than 9600 bps.) After that, use @code{target | |
1076 | remote} to establish communications with @code{gdbserver}. Its argument | |
1077 | is either a device name (usually a serial device, like | |
1078 | @file{/dev/ttyb}), or a TCP port descriptor in the form | |
1079 | @code{@var{host}:@var{PORT}}. For example: | |
1080 | ||
1081 | @smallexample | |
1082 | (@value{GDBP}) target remote /dev/ttyb | |
1083 | @end smallexample | |
1084 | ||
1085 | @noindent | |
1086 | communicates with the server via serial line @file{/dev/ttyb}, and | |
1087 | ||
1088 | @smallexample | |
1089 | (@value{GDBP}) target remote the-target:2345 | |
1090 | @end smallexample | |
1091 | ||
1092 | @noindent | |
1093 | communicates via a TCP connection to port 2345 on host @w{@file{the-target}}. | |
1094 | For TCP connections, you must start up @code{gdbserver} prior to using | |
1095 | the @code{target remote} command. Otherwise you may get an error whose | |
1096 | text depends on the host system, but which usually looks something like | |
1097 | @samp{Connection refused}. | |
1098 | @end table | |
c906108c | 1099 | |
c906108c SS |
1100 | @node NetWare |
1101 | @subsubsection Using the @code{gdbserve.nlm} program | |
1102 | ||
1103 | @kindex gdbserve.nlm | |
1104 | @code{gdbserve.nlm} is a control program for NetWare systems, which | |
1105 | allows you to connect your program with a remote @value{GDBN} via | |
1106 | @code{target remote}. | |
1107 | ||
1108 | @value{GDBN} and @code{gdbserve.nlm} communicate via a serial line, | |
1109 | using the standard @value{GDBN} remote serial protocol. | |
1110 | ||
1111 | @table @emph | |
1112 | @item On the target machine, | |
1113 | you need to have a copy of the program you want to debug. | |
1114 | @code{gdbserve.nlm} does not need your program's symbol table, so you | |
1115 | can strip the program if necessary to save space. @value{GDBN} on the | |
1116 | host system does all the symbol handling. | |
1117 | ||
1118 | To use the server, you must tell it how to communicate with | |
1119 | @value{GDBN}; the name of your program; and the arguments for your | |
1120 | program. The syntax is: | |
1121 | ||
1122 | @smallexample | |
1123 | load gdbserve [ BOARD=@var{board} ] [ PORT=@var{port} ] | |
1124 | [ BAUD=@var{baud} ] @var{program} [ @var{args} @dots{} ] | |
1125 | @end smallexample | |
1126 | ||
1127 | @var{board} and @var{port} specify the serial line; @var{baud} specifies | |
1128 | the baud rate used by the connection. @var{port} and @var{node} default | |
1129 | to 0, @var{baud} defaults to 9600 bps. | |
1130 | ||
1131 | For example, to debug Emacs with the argument @samp{foo.txt}and | |
1132 | communicate with @value{GDBN} over serial port number 2 or board 1 | |
1133 | using a 19200 bps connection: | |
1134 | ||
1135 | @smallexample | |
1136 | load gdbserve BOARD=1 PORT=2 BAUD=19200 emacs foo.txt | |
1137 | @end smallexample | |
1138 | ||
1139 | @item On the @value{GDBN} host machine, | |
1140 | you need an unstripped copy of your program, since @value{GDBN} needs | |
1141 | symbols and debugging information. Start up @value{GDBN} as usual, | |
1142 | using the name of the local copy of your program as the first argument. | |
1143 | (You may also need the @w{@samp{--baud}} option if the serial line is | |
1144 | running at anything other than 9600 bps. After that, use @code{target | |
1145 | remote} to establish communications with @code{gdbserve.nlm}. Its | |
1146 | argument is a device name (usually a serial device, like | |
1147 | @file{/dev/ttyb}). For example: | |
1148 | ||
1149 | @smallexample | |
1150 | (@value{GDBP}) target remote /dev/ttyb | |
1151 | @end smallexample | |
1152 | ||
1153 | @noindent | |
1154 | communications with the server via serial line @file{/dev/ttyb}. | |
1155 | @end table | |
c906108c | 1156 | |
c906108c SS |
1157 | @node i960-Nindy Remote |
1158 | @subsection @value{GDBN} with a remote i960 (Nindy) | |
1159 | ||
1160 | @cindex Nindy | |
1161 | @cindex i960 | |
1162 | @dfn{Nindy} is a ROM Monitor program for Intel 960 target systems. When | |
1163 | @value{GDBN} is configured to control a remote Intel 960 using Nindy, you can | |
1164 | tell @value{GDBN} how to connect to the 960 in several ways: | |
1165 | ||
1166 | @itemize @bullet | |
1167 | @item | |
1168 | Through command line options specifying serial port, version of the | |
1169 | Nindy protocol, and communications speed; | |
1170 | ||
1171 | @item | |
1172 | By responding to a prompt on startup; | |
1173 | ||
1174 | @item | |
1175 | By using the @code{target} command at any point during your @value{GDBN} | |
1176 | session. @xref{Target Commands, ,Commands for managing targets}. | |
1177 | ||
1178 | @end itemize | |
1179 | ||
1180 | @menu | |
1181 | * Nindy Startup:: Startup with Nindy | |
1182 | * Nindy Options:: Options for Nindy | |
1183 | * Nindy Reset:: Nindy reset command | |
1184 | @end menu | |
1185 | ||
1186 | @node Nindy Startup | |
1187 | @subsubsection Startup with Nindy | |
1188 | ||
1189 | If you simply start @code{@value{GDBP}} without using any command-line | |
1190 | options, you are prompted for what serial port to use, @emph{before} you | |
1191 | reach the ordinary @value{GDBN} prompt: | |
1192 | ||
1193 | @example | |
1194 | Attach /dev/ttyNN -- specify NN, or "quit" to quit: | |
1195 | @end example | |
1196 | ||
1197 | @noindent | |
1198 | Respond to the prompt with whatever suffix (after @samp{/dev/tty}) | |
1199 | identifies the serial port you want to use. You can, if you choose, | |
1200 | simply start up with no Nindy connection by responding to the prompt | |
1201 | with an empty line. If you do this and later wish to attach to Nindy, | |
1202 | use @code{target} (@pxref{Target Commands, ,Commands for managing targets}). | |
1203 | ||
1204 | @node Nindy Options | |
1205 | @subsubsection Options for Nindy | |
1206 | ||
1207 | These are the startup options for beginning your @value{GDBN} session with a | |
1208 | Nindy-960 board attached: | |
1209 | ||
1210 | @table @code | |
1211 | @item -r @var{port} | |
1212 | Specify the serial port name of a serial interface to be used to connect | |
1213 | to the target system. This option is only available when @value{GDBN} is | |
1214 | configured for the Intel 960 target architecture. You may specify | |
1215 | @var{port} as any of: a full pathname (e.g. @samp{-r /dev/ttya}), a | |
1216 | device name in @file{/dev} (e.g. @samp{-r ttya}), or simply the unique | |
1217 | suffix for a specific @code{tty} (e.g. @samp{-r a}). | |
1218 | ||
1219 | @item -O | |
1220 | (An uppercase letter ``O'', not a zero.) Specify that @value{GDBN} should use | |
1221 | the ``old'' Nindy monitor protocol to connect to the target system. | |
1222 | This option is only available when @value{GDBN} is configured for the Intel 960 | |
1223 | target architecture. | |
1224 | ||
1225 | @quotation | |
1226 | @emph{Warning:} if you specify @samp{-O}, but are actually trying to | |
1227 | connect to a target system that expects the newer protocol, the connection | |
1228 | fails, appearing to be a speed mismatch. @value{GDBN} repeatedly | |
1229 | attempts to reconnect at several different line speeds. You can abort | |
1230 | this process with an interrupt. | |
1231 | @end quotation | |
1232 | ||
1233 | @item -brk | |
1234 | Specify that @value{GDBN} should first send a @code{BREAK} signal to the target | |
1235 | system, in an attempt to reset it, before connecting to a Nindy target. | |
1236 | ||
1237 | @quotation | |
1238 | @emph{Warning:} Many target systems do not have the hardware that this | |
1239 | requires; it only works with a few boards. | |
1240 | @end quotation | |
1241 | @end table | |
1242 | ||
1243 | The standard @samp{-b} option controls the line speed used on the serial | |
1244 | port. | |
1245 | ||
1246 | @c @group | |
1247 | @node Nindy Reset | |
1248 | @subsubsection Nindy reset command | |
1249 | ||
1250 | @table @code | |
1251 | @item reset | |
1252 | @kindex reset | |
1253 | For a Nindy target, this command sends a ``break'' to the remote target | |
1254 | system; this is only useful if the target has been equipped with a | |
1255 | circuit to perform a hard reset (or some other interesting action) when | |
1256 | a break is detected. | |
1257 | @end table | |
1258 | @c @end group | |
c906108c | 1259 | |
c906108c SS |
1260 | @node UDI29K Remote |
1261 | @subsection The UDI protocol for AMD29K | |
1262 | ||
1263 | @cindex UDI | |
1264 | @cindex AMD29K via UDI | |
1265 | @value{GDBN} supports AMD's UDI (``Universal Debugger Interface'') | |
1266 | protocol for debugging the a29k processor family. To use this | |
1267 | configuration with AMD targets running the MiniMON monitor, you need the | |
1268 | program @code{MONTIP}, available from AMD at no charge. You can also | |
1269 | use @value{GDBN} with the UDI-conformant a29k simulator program | |
1270 | @code{ISSTIP}, also available from AMD. | |
1271 | ||
1272 | @table @code | |
1273 | @item target udi @var{keyword} | |
1274 | @kindex udi | |
1275 | Select the UDI interface to a remote a29k board or simulator, where | |
1276 | @var{keyword} is an entry in the AMD configuration file @file{udi_soc}. | |
1277 | This file contains keyword entries which specify parameters used to | |
1278 | connect to a29k targets. If the @file{udi_soc} file is not in your | |
1279 | working directory, you must set the environment variable @samp{UDICONF} | |
1280 | to its pathname. | |
1281 | @end table | |
1282 | ||
1283 | @node EB29K Remote | |
1284 | @subsection The EBMON protocol for AMD29K | |
1285 | ||
1286 | @cindex EB29K board | |
1287 | @cindex running 29K programs | |
1288 | ||
1289 | AMD distributes a 29K development board meant to fit in a PC, together | |
1290 | with a DOS-hosted monitor program called @code{EBMON}. As a shorthand | |
1291 | term, this development system is called the ``EB29K''. To use | |
1292 | @value{GDBN} from a Unix system to run programs on the EB29K board, you | |
1293 | must first connect a serial cable between the PC (which hosts the EB29K | |
1294 | board) and a serial port on the Unix system. In the following, we | |
1295 | assume you've hooked the cable between the PC's @file{COM1} port and | |
1296 | @file{/dev/ttya} on the Unix system. | |
1297 | ||
1298 | @menu | |
1299 | * Comms (EB29K):: Communications setup | |
1300 | * gdb-EB29K:: EB29K cross-debugging | |
1301 | * Remote Log:: Remote log | |
1302 | @end menu | |
1303 | ||
1304 | @node Comms (EB29K) | |
1305 | @subsubsection Communications setup | |
1306 | ||
1307 | The next step is to set up the PC's port, by doing something like this | |
1308 | in DOS on the PC: | |
1309 | ||
1310 | @example | |
1311 | C:\> MODE com1:9600,n,8,1,none | |
1312 | @end example | |
1313 | ||
1314 | @noindent | |
1315 | This example---run on an MS DOS 4.0 system---sets the PC port to 9600 | |
1316 | bps, no parity, eight data bits, one stop bit, and no ``retry'' action; | |
1317 | you must match the communications parameters when establishing the Unix | |
1318 | end of the connection as well. | |
1319 | @c FIXME: Who knows what this "no retry action" crud from the DOS manual may | |
1320 | @c mean? It's optional; leave it out? [email protected], 25feb91 | |
1321 | ||
1322 | To give control of the PC to the Unix side of the serial line, type | |
1323 | the following at the DOS console: | |
1324 | ||
1325 | @example | |
1326 | C:\> CTTY com1 | |
1327 | @end example | |
1328 | ||
1329 | @noindent | |
1330 | (Later, if you wish to return control to the DOS console, you can use | |
1331 | the command @code{CTTY con}---but you must send it over the device that | |
1332 | had control, in our example over the @file{COM1} serial line). | |
1333 | ||
1334 | From the Unix host, use a communications program such as @code{tip} or | |
1335 | @code{cu} to communicate with the PC; for example, | |
1336 | ||
1337 | @example | |
1338 | cu -s 9600 -l /dev/ttya | |
1339 | @end example | |
1340 | ||
1341 | @noindent | |
1342 | The @code{cu} options shown specify, respectively, the linespeed and the | |
1343 | serial port to use. If you use @code{tip} instead, your command line | |
1344 | may look something like the following: | |
1345 | ||
1346 | @example | |
1347 | tip -9600 /dev/ttya | |
1348 | @end example | |
1349 | ||
1350 | @noindent | |
1351 | Your system may require a different name where we show | |
1352 | @file{/dev/ttya} as the argument to @code{tip}. The communications | |
1353 | parameters, including which port to use, are associated with the | |
1354 | @code{tip} argument in the ``remote'' descriptions file---normally the | |
1355 | system table @file{/etc/remote}. | |
1356 | @c FIXME: What if anything needs doing to match the "n,8,1,none" part of | |
1357 | @c the DOS side's comms setup? cu can support -o (odd | |
1358 | @c parity), -e (even parity)---apparently no settings for no parity or | |
1359 | @c for character size. Taken from stty maybe...? John points out tip | |
1360 | @c can set these as internal variables, eg ~s parity=none; man stty | |
1361 | @c suggests that it *might* work to stty these options with stdin or | |
1362 | @c stdout redirected... [email protected], 25feb91 | |
1363 | ||
1364 | @kindex EBMON | |
1365 | Using the @code{tip} or @code{cu} connection, change the DOS working | |
1366 | directory to the directory containing a copy of your 29K program, then | |
1367 | start the PC program @code{EBMON} (an EB29K control program supplied | |
1368 | with your board by AMD). You should see an initial display from | |
1369 | @code{EBMON} similar to the one that follows, ending with the | |
1370 | @code{EBMON} prompt @samp{#}--- | |
1371 | ||
1372 | @example | |
1373 | C:\> G: | |
1374 | ||
1375 | G:\> CD \usr\joe\work29k | |
1376 | ||
1377 | G:\USR\JOE\WORK29K> EBMON | |
1378 | Am29000 PC Coprocessor Board Monitor, version 3.0-18 | |
1379 | Copyright 1990 Advanced Micro Devices, Inc. | |
1380 | Written by Gibbons and Associates, Inc. | |
1381 | ||
1382 | Enter '?' or 'H' for help | |
1383 | ||
1384 | PC Coprocessor Type = EB29K | |
1385 | I/O Base = 0x208 | |
1386 | Memory Base = 0xd0000 | |
1387 | ||
1388 | Data Memory Size = 2048KB | |
1389 | Available I-RAM Range = 0x8000 to 0x1fffff | |
1390 | Available D-RAM Range = 0x80002000 to 0x801fffff | |
1391 | ||
1392 | PageSize = 0x400 | |
1393 | Register Stack Size = 0x800 | |
1394 | Memory Stack Size = 0x1800 | |
1395 | ||
1396 | CPU PRL = 0x3 | |
1397 | Am29027 Available = No | |
1398 | Byte Write Available = Yes | |
1399 | ||
1400 | # ~. | |
1401 | @end example | |
1402 | ||
1403 | Then exit the @code{cu} or @code{tip} program (done in the example by | |
1404 | typing @code{~.} at the @code{EBMON} prompt). @code{EBMON} keeps | |
1405 | running, ready for @value{GDBN} to take over. | |
1406 | ||
1407 | For this example, we've assumed what is probably the most convenient | |
1408 | way to make sure the same 29K program is on both the PC and the Unix | |
1409 | system: a PC/NFS connection that establishes ``drive @code{G:}'' on the | |
1410 | PC as a file system on the Unix host. If you do not have PC/NFS or | |
1411 | something similar connecting the two systems, you must arrange some | |
1412 | other way---perhaps floppy-disk transfer---of getting the 29K program | |
1413 | from the Unix system to the PC; @value{GDBN} does @emph{not} download it over the | |
1414 | serial line. | |
1415 | ||
1416 | @node gdb-EB29K | |
1417 | @subsubsection EB29K cross-debugging | |
1418 | ||
1419 | Finally, @code{cd} to the directory containing an image of your 29K | |
1420 | program on the Unix system, and start @value{GDBN}---specifying as argument the | |
1421 | name of your 29K program: | |
1422 | ||
1423 | @example | |
1424 | cd /usr/joe/work29k | |
1425 | @value{GDBP} myfoo | |
1426 | @end example | |
1427 | ||
1428 | @need 500 | |
1429 | Now you can use the @code{target} command: | |
1430 | ||
1431 | @example | |
1432 | target amd-eb /dev/ttya 9600 MYFOO | |
1433 | @c FIXME: test above 'target amd-eb' as spelled, with caps! caps are meant to | |
1434 | @c emphasize that this is the name as seen by DOS (since I think DOS is | |
1435 | @c single-minded about case of letters). [email protected], 25feb91 | |
1436 | @end example | |
1437 | ||
1438 | @noindent | |
1439 | In this example, we've assumed your program is in a file called | |
1440 | @file{myfoo}. Note that the filename given as the last argument to | |
1441 | @code{target amd-eb} should be the name of the program as it appears to DOS. | |
1442 | In our example this is simply @code{MYFOO}, but in general it can include | |
1443 | a DOS path, and depending on your transfer mechanism may not resemble | |
1444 | the name on the Unix side. | |
1445 | ||
1446 | At this point, you can set any breakpoints you wish; when you are ready | |
1447 | to see your program run on the 29K board, use the @value{GDBN} command | |
1448 | @code{run}. | |
1449 | ||
1450 | To stop debugging the remote program, use the @value{GDBN} @code{detach} | |
1451 | command. | |
1452 | ||
1453 | To return control of the PC to its console, use @code{tip} or @code{cu} | |
1454 | once again, after your @value{GDBN} session has concluded, to attach to | |
1455 | @code{EBMON}. You can then type the command @code{q} to shut down | |
1456 | @code{EBMON}, returning control to the DOS command-line interpreter. | |
1457 | Type @code{CTTY con} to return command input to the main DOS console, | |
1458 | and type @kbd{~.} to leave @code{tip} or @code{cu}. | |
1459 | ||
1460 | @node Remote Log | |
1461 | @subsubsection Remote log | |
1462 | @kindex eb.log | |
1463 | @cindex log file for EB29K | |
1464 | ||
1465 | The @code{target amd-eb} command creates a file @file{eb.log} in the | |
1466 | current working directory, to help debug problems with the connection. | |
1467 | @file{eb.log} records all the output from @code{EBMON}, including echoes | |
1468 | of the commands sent to it. Running @samp{tail -f} on this file in | |
1469 | another window often helps to understand trouble with @code{EBMON}, or | |
1470 | unexpected events on the PC side of the connection. | |
1471 | ||
c906108c SS |
1472 | @node ST2000 Remote |
1473 | @subsection @value{GDBN} with a Tandem ST2000 | |
1474 | ||
1475 | To connect your ST2000 to the host system, see the manufacturer's | |
1476 | manual. Once the ST2000 is physically attached, you can run: | |
1477 | ||
1478 | @example | |
1479 | target st2000 @var{dev} @var{speed} | |
1480 | @end example | |
1481 | ||
1482 | @noindent | |
1483 | to establish it as your debugging environment. @var{dev} is normally | |
1484 | the name of a serial device, such as @file{/dev/ttya}, connected to the | |
1485 | ST2000 via a serial line. You can instead specify @var{dev} as a TCP | |
1486 | connection (for example, to a serial line attached via a terminal | |
1487 | concentrator) using the syntax @code{@var{hostname}:@var{portnumber}}. | |
1488 | ||
1489 | The @code{load} and @code{attach} commands are @emph{not} defined for | |
1490 | this target; you must load your program into the ST2000 as you normally | |
1491 | would for standalone operation. @value{GDBN} reads debugging information | |
1492 | (such as symbols) from a separate, debugging version of the program | |
1493 | available on your host computer. | |
1494 | @c FIXME!! This is terribly vague; what little content is here is | |
1495 | @c basically hearsay. | |
1496 | ||
1497 | @cindex ST2000 auxiliary commands | |
1498 | These auxiliary @value{GDBN} commands are available to help you with the ST2000 | |
1499 | environment: | |
1500 | ||
1501 | @table @code | |
1502 | @item st2000 @var{command} | |
1503 | @kindex st2000 @var{cmd} | |
1504 | @cindex STDBUG commands (ST2000) | |
1505 | @cindex commands to STDBUG (ST2000) | |
1506 | Send a @var{command} to the STDBUG monitor. See the manufacturer's | |
1507 | manual for available commands. | |
1508 | ||
1509 | @item connect | |
1510 | @cindex connect (to STDBUG) | |
1511 | Connect the controlling terminal to the STDBUG command monitor. When | |
1512 | you are done interacting with STDBUG, typing either of two character | |
1513 | sequences gets you back to the @value{GDBN} command prompt: | |
1514 | @kbd{@key{RET}~.} (Return, followed by tilde and period) or | |
1515 | @kbd{@key{RET}~@key{C-d}} (Return, followed by tilde and control-D). | |
1516 | @end table | |
c906108c | 1517 | |
c906108c SS |
1518 | @node VxWorks Remote |
1519 | @subsection @value{GDBN} and VxWorks | |
7a292a7a | 1520 | |
c906108c SS |
1521 | @cindex VxWorks |
1522 | ||
1523 | @value{GDBN} enables developers to spawn and debug tasks running on networked | |
1524 | VxWorks targets from a Unix host. Already-running tasks spawned from | |
1525 | the VxWorks shell can also be debugged. @value{GDBN} uses code that runs on | |
1526 | both the Unix host and on the VxWorks target. The program | |
1527 | @code{gdb} is installed and executed on the Unix host. (It may be | |
1528 | installed with the name @code{vxgdb}, to distinguish it from a | |
1529 | @value{GDBN} for debugging programs on the host itself.) | |
1530 | ||
1531 | @table @code | |
1532 | @item VxWorks-timeout @var{args} | |
1533 | @kindex vxworks-timeout | |
1534 | All VxWorks-based targets now support the option @code{vxworks-timeout}. | |
1535 | This option is set by the user, and @var{args} represents the number of | |
1536 | seconds @value{GDBN} waits for responses to rpc's. You might use this if | |
1537 | your VxWorks target is a slow software simulator or is on the far side | |
1538 | of a thin network line. | |
1539 | @end table | |
1540 | ||
1541 | The following information on connecting to VxWorks was current when | |
1542 | this manual was produced; newer releases of VxWorks may use revised | |
1543 | procedures. | |
1544 | ||
1545 | @kindex INCLUDE_RDB | |
1546 | To use @value{GDBN} with VxWorks, you must rebuild your VxWorks kernel | |
1547 | to include the remote debugging interface routines in the VxWorks | |
1548 | library @file{rdb.a}. To do this, define @code{INCLUDE_RDB} in the | |
1549 | VxWorks configuration file @file{configAll.h} and rebuild your VxWorks | |
1550 | kernel. The resulting kernel contains @file{rdb.a}, and spawns the | |
1551 | source debugging task @code{tRdbTask} when VxWorks is booted. For more | |
1552 | information on configuring and remaking VxWorks, see the manufacturer's | |
1553 | manual. | |
1554 | @c VxWorks, see the @cite{VxWorks Programmer's Guide}. | |
1555 | ||
1556 | Once you have included @file{rdb.a} in your VxWorks system image and set | |
1557 | your Unix execution search path to find @value{GDBN}, you are ready to | |
1558 | run @value{GDBN}. From your Unix host, run @code{gdb} (or @code{vxgdb}, | |
1559 | depending on your installation). | |
1560 | ||
1561 | @value{GDBN} comes up showing the prompt: | |
1562 | ||
1563 | @example | |
1564 | (vxgdb) | |
1565 | @end example | |
1566 | ||
1567 | @menu | |
1568 | * VxWorks Connection:: Connecting to VxWorks | |
1569 | * VxWorks Download:: VxWorks download | |
1570 | * VxWorks Attach:: Running tasks | |
1571 | @end menu | |
1572 | ||
1573 | @node VxWorks Connection | |
1574 | @subsubsection Connecting to VxWorks | |
1575 | ||
1576 | The @value{GDBN} command @code{target} lets you connect to a VxWorks target on the | |
1577 | network. To connect to a target whose host name is ``@code{tt}'', type: | |
1578 | ||
1579 | @example | |
1580 | (vxgdb) target vxworks tt | |
1581 | @end example | |
1582 | ||
1583 | @need 750 | |
1584 | @value{GDBN} displays messages like these: | |
1585 | ||
1586 | @smallexample | |
1587 | Attaching remote machine across net... | |
1588 | Connected to tt. | |
1589 | @end smallexample | |
1590 | ||
1591 | @need 1000 | |
1592 | @value{GDBN} then attempts to read the symbol tables of any object modules | |
1593 | loaded into the VxWorks target since it was last booted. @value{GDBN} locates | |
1594 | these files by searching the directories listed in the command search | |
1595 | path (@pxref{Environment, ,Your program's environment}); if it fails | |
1596 | to find an object file, it displays a message such as: | |
1597 | ||
1598 | @example | |
1599 | prog.o: No such file or directory. | |
1600 | @end example | |
1601 | ||
1602 | When this happens, add the appropriate directory to the search path with | |
1603 | the @value{GDBN} command @code{path}, and execute the @code{target} | |
1604 | command again. | |
1605 | ||
1606 | @node VxWorks Download | |
1607 | @subsubsection VxWorks download | |
1608 | ||
1609 | @cindex download to VxWorks | |
1610 | If you have connected to the VxWorks target and you want to debug an | |
1611 | object that has not yet been loaded, you can use the @value{GDBN} | |
1612 | @code{load} command to download a file from Unix to VxWorks | |
1613 | incrementally. The object file given as an argument to the @code{load} | |
1614 | command is actually opened twice: first by the VxWorks target in order | |
1615 | to download the code, then by @value{GDBN} in order to read the symbol | |
1616 | table. This can lead to problems if the current working directories on | |
1617 | the two systems differ. If both systems have NFS mounted the same | |
1618 | filesystems, you can avoid these problems by using absolute paths. | |
1619 | Otherwise, it is simplest to set the working directory on both systems | |
1620 | to the directory in which the object file resides, and then to reference | |
1621 | the file by its name, without any path. For instance, a program | |
1622 | @file{prog.o} may reside in @file{@var{vxpath}/vw/demo/rdb} in VxWorks | |
1623 | and in @file{@var{hostpath}/vw/demo/rdb} on the host. To load this | |
1624 | program, type this on VxWorks: | |
1625 | ||
1626 | @example | |
1627 | -> cd "@var{vxpath}/vw/demo/rdb" | |
1628 | @end example | |
1629 | v | |
1630 | Then, in @value{GDBN}, type: | |
1631 | ||
1632 | @example | |
1633 | (vxgdb) cd @var{hostpath}/vw/demo/rdb | |
1634 | (vxgdb) load prog.o | |
1635 | @end example | |
1636 | ||
1637 | @value{GDBN} displays a response similar to this: | |
1638 | ||
1639 | @smallexample | |
1640 | Reading symbol data from wherever/vw/demo/rdb/prog.o... done. | |
1641 | @end smallexample | |
1642 | ||
1643 | You can also use the @code{load} command to reload an object module | |
1644 | after editing and recompiling the corresponding source file. Note that | |
1645 | this makes @value{GDBN} delete all currently-defined breakpoints, | |
1646 | auto-displays, and convenience variables, and to clear the value | |
1647 | history. (This is necessary in order to preserve the integrity of | |
1648 | debugger data structures that reference the target system's symbol | |
1649 | table.) | |
1650 | ||
1651 | @node VxWorks Attach | |
1652 | @subsubsection Running tasks | |
1653 | ||
1654 | @cindex running VxWorks tasks | |
1655 | You can also attach to an existing task using the @code{attach} command as | |
1656 | follows: | |
1657 | ||
1658 | @example | |
1659 | (vxgdb) attach @var{task} | |
1660 | @end example | |
1661 | ||
1662 | @noindent | |
1663 | where @var{task} is the VxWorks hexadecimal task ID. The task can be running | |
1664 | or suspended when you attach to it. Running tasks are suspended at | |
1665 | the time of attachment. | |
c906108c | 1666 | |
c906108c SS |
1667 | @node Sparclet Remote |
1668 | @subsection @value{GDBN} and Sparclet | |
1669 | @cindex Sparclet | |
1670 | ||
1671 | @value{GDBN} enables developers to debug tasks running on | |
1672 | Sparclet targets from a Unix host. | |
1673 | @value{GDBN} uses code that runs on | |
1674 | both the Unix host and on the Sparclet target. The program | |
1675 | @code{gdb} is installed and executed on the Unix host. | |
1676 | ||
1677 | @table @code | |
1678 | @item timeout @var{args} | |
1679 | @kindex remotetimeout | |
1680 | @value{GDBN} now supports the option @code{remotetimeout}. | |
1681 | This option is set by the user, and @var{args} represents the number of | |
1682 | seconds @value{GDBN} waits for responses. | |
1683 | @end table | |
1684 | ||
1685 | @kindex Compiling | |
1686 | When compiling for debugging, include the options "-g" to get debug | |
1687 | information and "-Ttext" to relocate the program to where you wish to | |
1688 | load it on the target. You may also want to add the options "-n" or | |
1689 | "-N" in order to reduce the size of the sections. | |
1690 | ||
1691 | @example | |
1692 | sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N | |
1693 | @end example | |
1694 | ||
1695 | You can use objdump to verify that the addresses are what you intended. | |
1696 | ||
1697 | @example | |
1698 | sparclet-aout-objdump --headers --syms prog | |
1699 | @end example | |
1700 | ||
1701 | @kindex Running | |
1702 | Once you have set | |
1703 | your Unix execution search path to find @value{GDBN}, you are ready to | |
1704 | run @value{GDBN}. From your Unix host, run @code{gdb} | |
1705 | (or @code{sparclet-aout-gdb}, depending on your installation). | |
1706 | ||
1707 | @value{GDBN} comes up showing the prompt: | |
1708 | ||
1709 | @example | |
1710 | (gdbslet) | |
1711 | @end example | |
1712 | ||
1713 | @menu | |
1714 | * Sparclet File:: Setting the file to debug | |
1715 | * Sparclet Connection:: Connecting to Sparclet | |
1716 | * Sparclet Download:: Sparclet download | |
1717 | * Sparclet Execution:: Running and debugging | |
1718 | @end menu | |
1719 | ||
1720 | @node Sparclet File | |
1721 | @subsubsection Setting file to debug | |
1722 | ||
1723 | The @value{GDBN} command @code{file} lets you choose with program to debug. | |
1724 | ||
1725 | @example | |
1726 | (gdbslet) file prog | |
1727 | @end example | |
1728 | ||
1729 | @need 1000 | |
1730 | @value{GDBN} then attempts to read the symbol table of @file{prog}. | |
1731 | @value{GDBN} locates | |
1732 | the file by searching the directories listed in the command search | |
1733 | path. | |
1734 | If the file was compiled with debug information (option "-g"), source | |
1735 | files will be searched as well. | |
1736 | @value{GDBN} locates | |
1737 | the source files by searching the directories listed in the directory search | |
1738 | path (@pxref{Environment, ,Your program's environment}). | |
1739 | If it fails | |
1740 | to find a file, it displays a message such as: | |
1741 | ||
1742 | @example | |
1743 | prog: No such file or directory. | |
1744 | @end example | |
1745 | ||
1746 | When this happens, add the appropriate directories to the search paths with | |
1747 | the @value{GDBN} commands @code{path} and @code{dir}, and execute the | |
1748 | @code{target} command again. | |
1749 | ||
1750 | @node Sparclet Connection | |
1751 | @subsubsection Connecting to Sparclet | |
1752 | ||
1753 | The @value{GDBN} command @code{target} lets you connect to a Sparclet target. | |
1754 | To connect to a target on serial port ``@code{ttya}'', type: | |
1755 | ||
1756 | @example | |
1757 | (gdbslet) target sparclet /dev/ttya | |
1758 | Remote target sparclet connected to /dev/ttya | |
1759 | main () at ../prog.c:3 | |
1760 | @end example | |
1761 | ||
1762 | @need 750 | |
1763 | @value{GDBN} displays messages like these: | |
1764 | ||
1765 | @smallexample | |
1766 | Connected to ttya. | |
1767 | @end smallexample | |
1768 | ||
1769 | @node Sparclet Download | |
1770 | @subsubsection Sparclet download | |
1771 | ||
1772 | @cindex download to Sparclet | |
1773 | Once connected to the Sparclet target, | |
1774 | you can use the @value{GDBN} | |
1775 | @code{load} command to download the file from the host to the target. | |
1776 | The file name and load offset should be given as arguments to the @code{load} | |
1777 | command. | |
1778 | Since the file format is aout, the program must be loaded to the starting | |
1779 | address. You can use objdump to find out what this value is. The load | |
1780 | offset is an offset which is added to the VMA (virtual memory address) | |
1781 | of each of the file's sections. | |
1782 | For instance, if the program | |
1783 | @file{prog} was linked to text address 0x1201000, with data at 0x12010160 | |
1784 | and bss at 0x12010170, in @value{GDBN}, type: | |
1785 | ||
1786 | @example | |
1787 | (gdbslet) load prog 0x12010000 | |
1788 | Loading section .text, size 0xdb0 vma 0x12010000 | |
1789 | @end example | |
1790 | ||
1791 | If the code is loaded at a different address then what the program was linked | |
1792 | to, you may need to use the @code{section} and @code{add-symbol-file} commands | |
1793 | to tell @value{GDBN} where to map the symbol table. | |
1794 | ||
1795 | @node Sparclet Execution | |
1796 | @subsubsection Running and debugging | |
1797 | ||
1798 | @cindex running and debugging Sparclet programs | |
1799 | You can now begin debugging the task using @value{GDBN}'s execution control | |
1800 | commands, @code{b}, @code{step}, @code{run}, etc. See the @value{GDBN} | |
1801 | manual for the list of commands. | |
1802 | ||
1803 | @example | |
1804 | (gdbslet) b main | |
1805 | Breakpoint 1 at 0x12010000: file prog.c, line 3. | |
1806 | (gdbslet) run | |
1807 | Starting program: prog | |
1808 | Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3 | |
1809 | 3 char *symarg = 0; | |
1810 | (gdbslet) step | |
1811 | 4 char *execarg = "hello!"; | |
1812 | (gdbslet) | |
1813 | @end example | |
1814 | ||
c906108c SS |
1815 | @node Hitachi Remote |
1816 | @subsection @value{GDBN} and Hitachi microprocessors | |
1817 | @value{GDBN} needs to know these things to talk to your | |
1818 | Hitachi SH, H8/300, or H8/500: | |
1819 | ||
1820 | @enumerate | |
1821 | @item | |
1822 | that you want to use @samp{target hms}, the remote debugging interface | |
1823 | for Hitachi microprocessors, or @samp{target e7000}, the in-circuit | |
1824 | emulator for the Hitachi SH and the Hitachi 300H. (@samp{target hms} is | |
1825 | the default when GDB is configured specifically for the Hitachi SH, | |
1826 | H8/300, or H8/500.) | |
1827 | ||
1828 | @item | |
1829 | what serial device connects your host to your Hitachi board (the first | |
1830 | serial device available on your host is the default). | |
1831 | ||
c906108c SS |
1832 | @item |
1833 | what speed to use over the serial device. | |
c906108c SS |
1834 | @end enumerate |
1835 | ||
1836 | @menu | |
1837 | * Hitachi Boards:: Connecting to Hitachi boards. | |
1838 | * Hitachi ICE:: Using the E7000 In-Circuit Emulator. | |
1839 | * Hitachi Special:: Special @value{GDBN} commands for Hitachi micros. | |
1840 | @end menu | |
1841 | ||
1842 | @node Hitachi Boards | |
1843 | @subsubsection Connecting to Hitachi boards | |
1844 | ||
c906108c SS |
1845 | @c only for Unix hosts |
1846 | @kindex device | |
1847 | @cindex serial device, Hitachi micros | |
1848 | Use the special @code{@value{GDBP}} command @samp{device @var{port}} if you | |
1849 | need to explicitly set the serial device. The default @var{port} is the | |
1850 | first available port on your host. This is only necessary on Unix | |
1851 | hosts, where it is typically something like @file{/dev/ttya}. | |
1852 | ||
1853 | @kindex speed | |
1854 | @cindex serial line speed, Hitachi micros | |
1855 | @code{@value{GDBP}} has another special command to set the communications | |
1856 | speed: @samp{speed @var{bps}}. This command also is only used from Unix | |
1857 | hosts; on DOS hosts, set the line speed as usual from outside GDB with | |
1858 | the DOS @kbd{mode} command (for instance, @w{@samp{mode | |
1859 | com2:9600,n,8,1,p}} for a 9600 bps connection). | |
1860 | ||
1861 | The @samp{device} and @samp{speed} commands are available only when you | |
1862 | use a Unix host to debug your Hitachi microprocessor programs. If you | |
1863 | use a DOS host, | |
c906108c SS |
1864 | @value{GDBN} depends on an auxiliary terminate-and-stay-resident program |
1865 | called @code{asynctsr} to communicate with the development board | |
1866 | through a PC serial port. You must also use the DOS @code{mode} command | |
1867 | to set up the serial port on the DOS side. | |
1868 | ||
c906108c SS |
1869 | The following sample session illustrates the steps needed to start a |
1870 | program under @value{GDBN} control on an H8/300. The example uses a | |
1871 | sample H8/300 program called @file{t.x}. The procedure is the same for | |
1872 | the Hitachi SH and the H8/500. | |
1873 | ||
1874 | First hook up your development board. In this example, we use a | |
1875 | board attached to serial port @code{COM2}; if you use a different serial | |
1876 | port, substitute its name in the argument of the @code{mode} command. | |
1877 | When you call @code{asynctsr}, the auxiliary comms program used by the | |
1878 | degugger, you give it just the numeric part of the serial port's name; | |
1879 | for example, @samp{asyncstr 2} below runs @code{asyncstr} on | |
1880 | @code{COM2}. | |
1881 | ||
1882 | @example | |
1883 | C:\H8300\TEST> asynctsr 2 | |
1884 | C:\H8300\TEST> mode com2:9600,n,8,1,p | |
1885 | ||
1886 | Resident portion of MODE loaded | |
1887 | ||
1888 | COM2: 9600, n, 8, 1, p | |
1889 | ||
1890 | @end example | |
1891 | ||
1892 | @quotation | |
1893 | @emph{Warning:} We have noticed a bug in PC-NFS that conflicts with | |
1894 | @code{asynctsr}. If you also run PC-NFS on your DOS host, you may need to | |
1895 | disable it, or even boot without it, to use @code{asynctsr} to control | |
1896 | your development board. | |
1897 | @end quotation | |
1898 | ||
1899 | @kindex target hms | |
1900 | Now that serial communications are set up, and the development board is | |
1901 | connected, you can start up @value{GDBN}. Call @code{@value{GDBP}} with | |
1902 | the name of your program as the argument. @code{@value{GDBP}} prompts | |
1903 | you, as usual, with the prompt @samp{(@value{GDBP})}. Use two special | |
1904 | commands to begin your debugging session: @samp{target hms} to specify | |
1905 | cross-debugging to the Hitachi board, and the @code{load} command to | |
1906 | download your program to the board. @code{load} displays the names of | |
1907 | the program's sections, and a @samp{*} for each 2K of data downloaded. | |
1908 | (If you want to refresh @value{GDBN} data on symbols or on the | |
1909 | executable file without downloading, use the @value{GDBN} commands | |
1910 | @code{file} or @code{symbol-file}. These commands, and @code{load} | |
1911 | itself, are described in @ref{Files,,Commands to specify files}.) | |
1912 | ||
1913 | @smallexample | |
1914 | (eg-C:\H8300\TEST) @value{GDBP} t.x | |
1915 | GDB is free software and you are welcome to distribute copies | |
1916 | of it under certain conditions; type "show copying" to see | |
1917 | the conditions. | |
1918 | There is absolutely no warranty for GDB; type "show warranty" | |
1919 | for details. | |
1920 | GDB @value{GDBVN}, Copyright 1992 Free Software Foundation, Inc... | |
1921 | (gdb) target hms | |
1922 | Connected to remote H8/300 HMS system. | |
1923 | (gdb) load t.x | |
1924 | .text : 0x8000 .. 0xabde *********** | |
1925 | .data : 0xabde .. 0xad30 * | |
1926 | .stack : 0xf000 .. 0xf014 * | |
1927 | @end smallexample | |
1928 | ||
1929 | At this point, you're ready to run or debug your program. From here on, | |
1930 | you can use all the usual @value{GDBN} commands. The @code{break} command | |
1931 | sets breakpoints; the @code{run} command starts your program; | |
1932 | @code{print} or @code{x} display data; the @code{continue} command | |
1933 | resumes execution after stopping at a breakpoint. You can use the | |
1934 | @code{help} command at any time to find out more about @value{GDBN} commands. | |
1935 | ||
1936 | Remember, however, that @emph{operating system} facilities aren't | |
1937 | available on your development board; for example, if your program hangs, | |
1938 | you can't send an interrupt---but you can press the @sc{reset} switch! | |
1939 | ||
1940 | Use the @sc{reset} button on the development board | |
1941 | @itemize @bullet | |
1942 | @item | |
1943 | to interrupt your program (don't use @kbd{ctl-C} on the DOS host---it has | |
1944 | no way to pass an interrupt signal to the development board); and | |
1945 | ||
1946 | @item | |
1947 | to return to the @value{GDBN} command prompt after your program finishes | |
1948 | normally. The communications protocol provides no other way for @value{GDBN} | |
1949 | to detect program completion. | |
1950 | @end itemize | |
1951 | ||
1952 | In either case, @value{GDBN} sees the effect of a @sc{reset} on the | |
1953 | development board as a ``normal exit'' of your program. | |
c906108c SS |
1954 | |
1955 | @node Hitachi ICE | |
1956 | @subsubsection Using the E7000 in-circuit emulator | |
1957 | ||
1958 | @kindex target e7000 | |
1959 | You can use the E7000 in-circuit emulator to develop code for either the | |
1960 | Hitachi SH or the H8/300H. Use one of these forms of the @samp{target | |
1961 | e7000} command to connect @value{GDBN} to your E7000: | |
1962 | ||
1963 | @table @code | |
1964 | @item target e7000 @var{port} @var{speed} | |
1965 | Use this form if your E7000 is connected to a serial port. The | |
1966 | @var{port} argument identifies what serial port to use (for example, | |
1967 | @samp{com2}). The third argument is the line speed in bits per second | |
1968 | (for example, @samp{9600}). | |
1969 | ||
1970 | @item target e7000 @var{hostname} | |
1971 | If your E7000 is installed as a host on a TCP/IP network, you can just | |
1972 | specify its hostname; @value{GDBN} uses @code{telnet} to connect. | |
1973 | @end table | |
1974 | ||
1975 | @node Hitachi Special | |
1976 | @subsubsection Special @value{GDBN} commands for Hitachi micros | |
1977 | ||
1978 | Some @value{GDBN} commands are available only on the H8/300 or the | |
1979 | H8/500 configurations: | |
1980 | ||
1981 | @table @code | |
1982 | @kindex set machine | |
1983 | @kindex show machine | |
1984 | @item set machine h8300 | |
1985 | @itemx set machine h8300h | |
1986 | Condition @value{GDBN} for one of the two variants of the H8/300 | |
1987 | architecture with @samp{set machine}. You can use @samp{show machine} | |
1988 | to check which variant is currently in effect. | |
1989 | ||
1990 | @kindex set memory @var{mod} | |
1991 | @cindex memory models, H8/500 | |
1992 | @item set memory @var{mod} | |
1993 | @itemx show memory | |
1994 | Specify which H8/500 memory model (@var{mod}) you are using with | |
1995 | @samp{set memory}; check which memory model is in effect with @samp{show | |
1996 | memory}. The accepted values for @var{mod} are @code{small}, | |
1997 | @code{big}, @code{medium}, and @code{compact}. | |
1998 | @end table | |
1999 | ||
c906108c SS |
2000 | @node MIPS Remote |
2001 | @subsection @value{GDBN} and remote MIPS boards | |
2002 | ||
2003 | @cindex MIPS boards | |
2004 | @value{GDBN} can use the MIPS remote debugging protocol to talk to a | |
2005 | MIPS board attached to a serial line. This is available when | |
2006 | you configure @value{GDBN} with @samp{--target=mips-idt-ecoff}. | |
2007 | ||
2008 | @need 1000 | |
2009 | Use these @value{GDBN} commands to specify the connection to your target board: | |
2010 | ||
2011 | @table @code | |
2012 | @item target mips @var{port} | |
2013 | @kindex target mips @var{port} | |
2014 | To run a program on the board, start up @code{@value{GDBP}} with the | |
2015 | name of your program as the argument. To connect to the board, use the | |
2016 | command @samp{target mips @var{port}}, where @var{port} is the name of | |
2017 | the serial port connected to the board. If the program has not already | |
2018 | been downloaded to the board, you may use the @code{load} command to | |
2019 | download it. You can then use all the usual @value{GDBN} commands. | |
2020 | ||
2021 | For example, this sequence connects to the target board through a serial | |
2022 | port, and loads and runs a program called @var{prog} through the | |
2023 | debugger: | |
2024 | ||
2025 | @example | |
2026 | host$ @value{GDBP} @var{prog} | |
2027 | GDB is free software and @dots{} | |
2028 | (gdb) target mips /dev/ttyb | |
2029 | (gdb) load @var{prog} | |
2030 | (gdb) run | |
2031 | @end example | |
2032 | ||
2033 | @item target mips @var{hostname}:@var{portnumber} | |
2034 | On some @value{GDBN} host configurations, you can specify a TCP | |
2035 | connection (for instance, to a serial line managed by a terminal | |
2036 | concentrator) instead of a serial port, using the syntax | |
2037 | @samp{@var{hostname}:@var{portnumber}}. | |
2038 | ||
2039 | @item target pmon @var{port} | |
2040 | @kindex target pmon @var{port} | |
2041 | ||
2042 | @item target ddb @var{port} | |
2043 | @kindex target ddb @var{port} | |
2044 | ||
2045 | @item target lsi @var{port} | |
2046 | @kindex target lsi @var{port} | |
2047 | ||
2048 | @end table | |
2049 | ||
2050 | ||
2051 | @noindent | |
2052 | @value{GDBN} also supports these special commands for MIPS targets: | |
2053 | ||
2054 | @table @code | |
2055 | @item set processor @var{args} | |
2056 | @itemx show processor | |
2057 | @kindex set processor @var{args} | |
2058 | @kindex show processor | |
2059 | Use the @code{set processor} command to set the type of MIPS | |
2060 | processor when you want to access processor-type-specific registers. | |
2061 | For example, @code{set processor @var{r3041}} tells @value{GDBN} | |
2062 | to use the CPO registers appropriate for the 3041 chip. | |
2063 | Use the @code{show processor} command to see what MIPS processor @value{GDBN} | |
2064 | is using. Use the @code{info reg} command to see what registers | |
2065 | @value{GDBN} is using. | |
2066 | ||
2067 | @item set mipsfpu double | |
2068 | @itemx set mipsfpu single | |
2069 | @itemx set mipsfpu none | |
2070 | @itemx show mipsfpu | |
2071 | @kindex set mipsfpu | |
2072 | @kindex show mipsfpu | |
2073 | @cindex MIPS remote floating point | |
2074 | @cindex floating point, MIPS remote | |
2075 | If your target board does not support the MIPS floating point | |
2076 | coprocessor, you should use the command @samp{set mipsfpu none} (if you | |
2077 | need this, you may wish to put the command in your @value{GDBINIT} | |
2078 | file). This tells @value{GDBN} how to find the return value of | |
2079 | functions which return floating point values. It also allows | |
2080 | @value{GDBN} to avoid saving the floating point registers when calling | |
2081 | functions on the board. If you are using a floating point coprocessor | |
2082 | with only single precision floating point support, as on the @sc{r4650} | |
2083 | processor, use the command @samp{set mipsfpu single}. The default | |
2084 | double precision floating point coprocessor may be selected using | |
2085 | @samp{set mipsfpu double}. | |
2086 | ||
2087 | In previous versions the only choices were double precision or no | |
2088 | floating point, so @samp{set mipsfpu on} will select double precision | |
2089 | and @samp{set mipsfpu off} will select no floating point. | |
2090 | ||
2091 | As usual, you can inquire about the @code{mipsfpu} variable with | |
2092 | @samp{show mipsfpu}. | |
2093 | ||
2094 | @item set remotedebug @var{n} | |
2095 | @itemx show remotedebug | |
2096 | @kindex set remotedebug | |
2097 | @kindex show remotedebug | |
2098 | @cindex @code{remotedebug}, MIPS protocol | |
2099 | @cindex MIPS @code{remotedebug} protocol | |
2100 | @c FIXME! For this to be useful, you must know something about the MIPS | |
2101 | @c FIXME...protocol. Where is it described? | |
2102 | You can see some debugging information about communications with the board | |
2103 | by setting the @code{remotedebug} variable. If you set it to @code{1} using | |
2104 | @samp{set remotedebug 1}, every packet is displayed. If you set it | |
2105 | to @code{2}, every character is displayed. You can check the current value | |
2106 | at any time with the command @samp{show remotedebug}. | |
2107 | ||
2108 | @item set timeout @var{seconds} | |
2109 | @itemx set retransmit-timeout @var{seconds} | |
2110 | @itemx show timeout | |
2111 | @itemx show retransmit-timeout | |
2112 | @cindex @code{timeout}, MIPS protocol | |
2113 | @cindex @code{retransmit-timeout}, MIPS protocol | |
2114 | @kindex set timeout | |
2115 | @kindex show timeout | |
2116 | @kindex set retransmit-timeout | |
2117 | @kindex show retransmit-timeout | |
2118 | You can control the timeout used while waiting for a packet, in the MIPS | |
2119 | remote protocol, with the @code{set timeout @var{seconds}} command. The | |
2120 | default is 5 seconds. Similarly, you can control the timeout used while | |
2121 | waiting for an acknowledgement of a packet with the @code{set | |
2122 | retransmit-timeout @var{seconds}} command. The default is 3 seconds. | |
2123 | You can inspect both values with @code{show timeout} and @code{show | |
2124 | retransmit-timeout}. (These commands are @emph{only} available when | |
2125 | @value{GDBN} is configured for @samp{--target=mips-idt-ecoff}.) | |
2126 | ||
2127 | The timeout set by @code{set timeout} does not apply when @value{GDBN} | |
2128 | is waiting for your program to stop. In that case, @value{GDBN} waits | |
2129 | forever because it has no way of knowing how long the program is going | |
2130 | to run before stopping. | |
2131 | @end table | |
c906108c | 2132 | |
c906108c SS |
2133 | @node Simulator |
2134 | @subsection Simulated CPU target | |
2135 | ||
c906108c SS |
2136 | @cindex simulator |
2137 | @cindex simulator, Z8000 | |
2138 | @cindex Z8000 simulator | |
2139 | @cindex simulator, H8/300 or H8/500 | |
2140 | @cindex H8/300 or H8/500 simulator | |
2141 | @cindex simulator, Hitachi SH | |
2142 | @cindex Hitachi SH simulator | |
2143 | @cindex CPU simulator | |
2144 | For some configurations, @value{GDBN} includes a CPU simulator that you | |
2145 | can use instead of a hardware CPU to debug your programs. | |
2146 | Currently, simulators are available for ARM, D10V, D30V, FR30, H8/300, | |
2147 | H8/500, i960, M32R, MIPS, MN10200, MN10300, PowerPC, SH, Sparc, V850, | |
2148 | W65, and Z8000. | |
c906108c | 2149 | |
c906108c SS |
2150 | @cindex simulator, Z8000 |
2151 | @cindex Zilog Z8000 simulator | |
2152 | When configured for debugging Zilog Z8000 targets, @value{GDBN} includes | |
2153 | a Z8000 simulator. | |
c906108c | 2154 | |
c906108c SS |
2155 | For the Z8000 family, @samp{target sim} simulates either the Z8002 (the |
2156 | unsegmented variant of the Z8000 architecture) or the Z8001 (the | |
2157 | segmented variant). The simulator recognizes which architecture is | |
2158 | appropriate by inspecting the object code. | |
c906108c SS |
2159 | |
2160 | @table @code | |
2161 | @item target sim @var{args} | |
2162 | @kindex sim | |
2163 | @kindex target sim | |
2164 | Debug programs on a simulated CPU. If the simulator supports setup | |
2165 | options, specify them via @var{args}. | |
2166 | @end table | |
2167 | ||
2168 | @noindent | |
2169 | After specifying this target, you can debug programs for the simulated | |
2170 | CPU in the same style as programs for your host computer; use the | |
2171 | @code{file} command to load a new program image, the @code{run} command | |
2172 | to run your program, and so on. | |
2173 | ||
2174 | As well as making available all the usual machine registers (see | |
2175 | @code{info reg}), the Z8000 simulator provides three additional items | |
2176 | of information as specially named registers: | |
2177 | ||
2178 | @table @code | |
2179 | @item cycles | |
2180 | Counts clock-ticks in the simulator. | |
2181 | ||
2182 | @item insts | |
2183 | Counts instructions run in the simulator. | |
2184 | ||
2185 | @item time | |
2186 | Execution time in 60ths of a second. | |
2187 | @end table | |
2188 | ||
2189 | You can refer to these values in @value{GDBN} expressions with the usual | |
2190 | conventions; for example, @w{@samp{b fputc if $cycles>5000}} sets a | |
2191 | conditional breakpoint that suspends only after at least 5000 | |
2192 | simulated clock ticks. | |
c906108c SS |
2193 | |
2194 | @c need to add much more detail about sims! |