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