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