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