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