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