import gdb-1999-08-16 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
085dd6e6 98* Protocol:: Definition 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
085dd6e6
JM
368In the examples below, @samp{<-} and @samp{->} are used to indicate
369transmitted and received data respectfully.
370
c906108c
SS
371@cindex protocol, @value{GDBN} remote serial
372@cindex serial protocol, @value{GDBN} remote
373@cindex remote serial protocol
085dd6e6
JM
374All @value{GDBN} commands and responses (other than acknowledgments)
375are sent as a @var{packet}. A @var{packet} is introduced with the
376character @samp{$}, this is followed by an optional two-digit
377@var{sequence-id} and the character @samp{:}, the actual
378@var{packet-data}, and the terminating character @samp{#} followed by a
379two-digit @var{checksum}:
c906108c
SS
380
381@example
085dd6e6
JM
382@code{$}@var{packet-data}@code{#}@var{checksum}
383@end example
384@noindent
385or, with the optional @var{sequence-id}:
386@example
387@code{$}@var{sequence-id}@code{:}@var{packet-data}@code{#}@var{checksum}
c906108c
SS
388@end example
389
390@cindex checksum, for @value{GDBN} remote
391@noindent
085dd6e6
JM
392The two-digit @var{checksum} is computed as the modulo 256 sum of all
393characters between the leading @samp{$} and the trailing @samp{#} (that
394consisting of both the optional @var{sequence-id}@code{:} and the actual
395@var{packet-data}).
396
397@cindex sequence-id, for @value{GDBN} remote
398@noindent
399The two-digit @var{sequence-id}, when present, is returned with the
400acknowledgment. Beyond that its meaning is poorly defined.
401@value{GDBN} is not known to output @var{sequence-id}s.
c906108c
SS
402
403When either the host or the target machine receives a packet, the first
085dd6e6
JM
404response expected is an acknowledgment: either @samp{+} (to indicate
405the package was received correctly) or @samp{-} (to request
406retransmission):
c906108c 407
085dd6e6
JM
408@example
409<- @code{$}@var{packet-data}@code{#}@var{checksum}
410-> @code{+}
411@end example
412@noindent
413If the received packet included a @var{sequence-id} than that is
414appended to a positive acknowledgment:
c906108c 415
085dd6e6
JM
416@example
417<- @code{$}@var{sequence-id}@code{:}@var{packet-data}@code{#}@var{checksum}
418-> @code{+}@var{sequence-id}
419@end example
c906108c 420
085dd6e6
JM
421The host (@value{GDBN}) sends @var{command}s, and the target (the
422debugging stub incorporated in your program) sends a @var{response}. In
423the case of step and continue @var{command}s, the response is only sent
424when the operation has completed (the target has again stopped).
425
426@var{packet-data} consists of a sequence of characters with the
427exception of @samp{#} and @samp{$} (see @samp{X} packet for an
428exception). @samp{:} can not appear as the third character in a packet.
429Fields within the packet should be separated using @samp{,} and @samp{;}
430(unfortunately some packets chose to use @samp{:}). Except where
431otherwise noted all numbers are represented in HEX with leading zeros
432suppressed.
433
434Response @var{data} can be run-length encoded to save space. A @samp{*}
435means that the next character is an ASCII encoding giving a repeat count
436which stands for that many repetitions of the character preceding the
437@samp{*}. The encoding is @code{n+29}, yielding a printable character
438where @code{n >=3} (which is where rle starts to win). Don't use an
439@code{n > 126}.
440
441So:
442@example
443"@code{0* }"
444@end example
445@noindent
446means the same as "0000".
c906108c 447
085dd6e6
JM
448The error response, returned for some packets includes a two character
449error number. That number is not well defined.
c906108c 450
085dd6e6
JM
451For any @var{command} not supported by the stub, an empty response
452(@samp{$#00}) should be returned. That way it is possible to extend the
453protocol. A newer @value{GDBN} can tell if a packet is supported based
454on the response.
c906108c 455
085dd6e6
JM
456Below is a complete list of all currently defined @var{command}s and
457their corresponding response @var{data}:
c906108c 458
085dd6e6
JM
459@multitable @columnfractions .30 .30 .40
460@item Packet
461@tab Request
462@tab Description
c906108c 463
085dd6e6
JM
464@item extended ops @emph{(optional)}
465@tab @code{!}
466@tab
467Use the extended remote protocol. Sticky -- only needs to be set once.
468The extended remote protocol support the @samp{R} packet.
469@item
470@tab reply @samp{}
471@tab
472Stubs that support the extended remote protocol return @samp{} which,
473unfortunately, is identical to the response returned by stubs that do not
474support protocol extensions.
475
476@item last signal
477@tab @code{?}
478@tab
479Reply the current reason for stopping. This is the same reply as is
480generated for step or cont : @code{S}@var{AA} where @var{AA} is the
481signal number.
482
483@item reserved
484@tab @code{a}
485@tab Reserved for future use
486
487@item set program arguments @strong{(reserved)} @emph{(optional)}
488@tab @code{A}@var{arglen}@code{,}@var{argnum}@code{,}@var{arg}@code{,...}
489@tab
490Initialized @samp{argv[]} array passed into program. @var{arglen}
491specifies the number of bytes in the hex encoded byte stream @var{arg}.
492@item
493@tab reply @code{OK}
494@item
495@tab reply @code{E}@var{NN}
496
497@item set baud @strong{(deprecated)}
498@tab @code{b}@var{baud}
499@tab
500Change the serial line speed to @var{baud}. JTC: @emph{When does the
501transport layer state change? When it's received, or after the ACK is
502transmitted. In either case, there are problems if the command or the
503acknowledgment packet is dropped.} Stan: @emph{If people really wanted
504to add something like this, and get it working for the first time, they
505ought to modify ser-unix.c to send some kind of out-of-band message to a
506specially-setup stub and have the switch happen "in between" packets, so
507that from remote protocol's point of view, nothing actually
508happened.}
509
510@item set breakpoint @strong{(deprecated)}
511@tab @code{B}@var{addr},@var{mode}
512@tab
513Set (@var{mode} is @samp{S}) or clear (@var{mode} is @samp{C}) a
514breakpoint at @var{addr}. @emph{This has been replaced by the @samp{Z} and
515@samp{z} packets.}
516
517@item continue
518@tab @code{c}@var{addr}
519@tab
520@var{addr} is address to resume. If @var{addr} is omitted, resume at
521current address.
522@item
523@tab reply
524@tab see below
525
526@item continue with signal @emph{(optional)}
527@tab @code{C}@var{sig}@code{;}@var{addr}
528@tab
529Continue with signal @var{sig} (hex signal number). If
530@code{;}@var{addr} is omitted, resume at same address.
531@item
532@tab reply
533@tab see below
c906108c 534
085dd6e6
JM
535@item toggle debug @emph{(optional)}
536@tab @code{d}
537@tab
538toggle debug flag (see 386 & 68k stubs)
c906108c 539
085dd6e6
JM
540@item detach @emph{(optional)}
541@tab @code{D}
542@tab Reply OK.
c906108c 543
085dd6e6
JM
544@item reserved
545@tab @code{e}
546@tab Reserved for future use
c906108c 547
085dd6e6
JM
548@item reserved
549@tab @code{E}
550@tab Reserved for future use
c906108c 551
085dd6e6
JM
552@item reserved
553@tab @code{f}
554@tab Reserved for future use
555
556@item reserved
557@tab @code{F}
558@tab Reserved for future use
559
560@item read registers
561@tab @code{g}
562@tab Read general registers.
563@item
564@tab reply @var{XX...}
565@tab
566Each byte of register data is described by two hex digits. The bytes
567with the register are transmitted in target byte order. The size of
568each register and their position within the @samp{g} @var{packet} is
569determined by the @var{REGISTER_RAW_SIZE} and @var{REGISTER_NAME}
570macros.
571@item
572@tab @code{E}@var{NN}
573@tab for an error.
574
575@item write regs
576@tab @code{G}@var{XX...}
577@tab
578See @samp{g} for a description of the @var{XX...} data.
579@item
580@tab reply @code{OK}
581@tab for success
582@item
583@tab reply @code{E}@var{NN}
584@tab for an error
585
586@item reserved
587@tab @code{h}
588@tab Reserved for future use
589
590@item set thread @emph{(optional)}
591@tab @code{H}@var{c}@var{t...}
592@tab
593Set thread for subsequent operations. @var{c} = @samp{c} for thread
594used in step and continue; @var{t...} can be -1 for all threads.
595@var{c} = @samp{g} for thread used in other operations. If zero, pick a
596thread, any thread.
597@item
598@tab reply @code{OK}
599@tab for success
600@item
601@tab reply @code{E}@var{NN}
602@tab for an error
603
604@item cycle step @strong{(draft)} @emph{(optional)}
605@tab @code{i}@var{addr}@code{,}@var{nnn}
606@tab
607Step the remote target by a single clock cycle. If @code{,}@var{nnn} is
608present, cycle step @var{nnn} cycles. If @var{addr} is present, cycle
609step starting at that address.
610
611@item signal then cycle step @strong{(reserved)} @emph{(optional)}
612@tab @code{I}
613@tab
614See @samp{i} and @samp{S} for likely syntax and semantics.
615
616@item reserved
617@tab @code{j}
618@tab Reserved for future use
619
620@item reserved
621@tab @code{J}
622@tab Reserved for future use
623
624@item kill request @emph{(optional)}
625@tab @code{k}
626@tab
627
628@item reserved
629@tab @code{l}
630@tab Reserved for future use
631
632@item reserved
633@tab @code{L}
634@tab Reserved for future use
635
636@item read memory
637@tab @code{m}@var{addr}@code{,}@var{length}
638@tab
639Read @var{length} bytes of memory starting at address @var{addr}.
640@item
641@tab reply @var{XX...}
642@tab
643@var{XX...} is mem contents. Can be fewer bytes than requested if able to
644read only part of the data.
645@item
646@tab reply @code{E}@var{NN}
647@tab @var{NN} is errno
648
649@item write mem
650@tab @code{M}@var{addr},@var{length}@code{:}@var{XX...}
651@tab
652Write @var{length} bytes of memory starting at address @var{addr}.
653@var{XX...} is the data.
654@item
655@tab reply @code{OK}
656@tab for success
657@item
658@tab reply @code{E}@var{NN}
659@tab
660for an error (this includes the case where only part of the data was
661written).
662
663@item reserved
664@tab @code{n}
665@tab Reserved for future use
666
667@item reserved
668@tab @code{N}
669@tab Reserved for future use
670
671@item reserved
672@tab @code{o}
673@tab Reserved for future use
674
675@item reserved
676@tab @code{O}
677@tab Reserved for future use
678
679@item read reg @strong{(reserved)}
680@tab @code{p}@var{n...}
681@tab
682See write register.
683@item
684@tab return @var{r....}
685@tab The hex encoded value of the register in target byte order.
686
687@item write reg @emph{(optional)}
688@tab @code{P}@var{n...}@code{=}@var{r...}
689@tab
690Write register @var{n...} with value @var{r...}, which contains two hex
691digits for each byte in the register (target byte order).
692@item
693@tab reply @code{OK}
694@tab for success
695@item
696@tab reply @code{E}@var{NN}
697@tab for an error
698
699@item general query @emph{(optional)}
700@tab @code{q}@var{query}
701@tab
702Request info about @var{query}. In general @value{GDBN} @var{query}'s
703have a leading upper case letter. Custom vendor queries should use a
704leading lower case letter and a company prefix, ex: @samp{qfsf.var}.
705@var{query} may optionally be followed by a @samp{,} or @samp{;}
706separated list. Stubs should ensure that they fully match any
707@var{query} name.
708@item
709@tab reply @code{XX...}
710@tab Hex encoded data from query. The reply can not be empty.
711@item
712@tab reply @code{E}@var{NN}
713@tab error reply
714@item
715@tab reply @samp{}
716@tab Indicating an unrecognized @var{query}.
717
718@item current thread
719@tab @code{q}@code{C}
720@tab Return the current thread id.
721@item
722@tab reply @code{QC}@var{pid}
723@tab
724Where @var{pid} is a HEX encoded 16 bit process id.
725@item
726@tab reply *
727@tab Any other reply implies the old pid.
728
729@item compute CRC of memory block
730@tab @code{q}@code{CRC:}@var{addr}@code{,}@var{length}
731@tab
732@item
733@tab reply @code{E}@var{NN}
734@tab An error (such as memory fault)
735@item
736@tab reply @code{C}@var{CRC32}
737@tab A 32 bit cyclic redundancy check of the specified memory region.
738
739@item query @var{LIST} or @var{threadLIST}
740@tab @code{q}@code{L}@var{startflag}@var{threadcount}@var{nextthread}
741@tab
742Obtain thread information from RTOS. @var{startflag} is one hex digit;
743@var{threadcount} is two hex digits; and @var{nextthread} is 16 hex
744digits.
745@item
746@tab reply *
747@tab
748See @code{remote.c:parse_threadlist_response()}.
749
750@item query sect offs
751@tab @code{q}@code{Offsets}
752@tab Get section offsets.
753@item
754@tab reply @code{Text=}@var{xxx}@code{;Data=}@var{yyy}@code{;Bss=}@var{zzz}
755
756@item thread info request
757@tab @code{q}@code{P}@var{mode}@var{threadid}
758@tab
759Returns information on @var{threadid}. Where: @var{mode} is a hex
760encoded 32 bit mode; @var{threadid} is a hex encoded 64 bit thread ID.
761@item
762@tab reply *
763@tab
764See @code{remote.c:remote_unpack_thread_info_response()}.
765
7be570e7 766@item remote command
085dd6e6
JM
767@tab @code{q}@code{Rcmd,}@var{COMMAND}
768@tab
769@var{COMMAND} (hex encoded) is passed to the local interpreter for
7be570e7
JM
770execution. Invalid commands should be reported using the output string.
771Before the final result packet, the target may also respond with a
772number of intermediate @code{O}@var{OUTPUT} console output
773packets. @emph{Implementors should note that providing access to a
085dd6e6
JM
774stubs's interpreter may have security implications}.
775@item
7be570e7
JM
776@tab reply @code{OK}
777@tab
778A command response with no output.
779@item
780@tab reply @var{OUTPUT}
781@tab
782A command response with the hex encoded output string @var{OUTPUT}.
783@item
784@tab reply @code{E}@var{NN}
085dd6e6 785@tab
7be570e7 786Indicate a badly formed request.
96baa820 787
085dd6e6
JM
788@item
789@tab reply @samp{}
790@tab
791When @samp{q}@samp{Rcmd} is not recognized.
792
793@item general set @emph{(optional)}
794@tab @code{Q}@var{var}@code{=}@var{val}
795@tab
796Set value of @var{var} to @var{val}. See @samp{q} for a discussing of
797naming conventions.
798
799@item reset @emph{(optional)}
800@tab r
801@tab reset -- see sparc stub.
802
803@item remote restart @emph{(optional)}
804@tab @code{R}@var{XX}
805@tab
806Restart the remote server. @var{XX} while needed has no clear
807definition.
808
809@item step @emph{(optional)}
810@tab @code{s}@var{addr}
811@tab
812@var{addr} is address to resume. If @var{addr} is omitted, resume at
813same address.
814@item
815@tab reply
816@tab see below
817
818@item step with signal @emph{(optional)}
819@tab @code{S}@var{sig}@code{;}@var{addr}
820@tab
821Like @samp{C} but step not continue.
822@item
823@tab reply
824@tab see below
825
826@item search @emph{(optional)}
827@tab @code{t}@var{addr}@code{:}@var{PP}@code{,}@var{MM}
828@tab
829Search backwards starting at address @var{addr} for a match with pattern
830@var{PP} and mask @var{MM}. @var{PP} and @var{MM} are 4
831bytes. @var{addr} must be at least 3 digits.
832
833@item thread alive @emph{(optional)}
834@tab @code{T}@var{XX}
835@tab Find out if the thread XX is alive.
836@item
837@tab reply @code{OK}
838@tab thread is still alive
839@item
840@tab reply @code{E}@var{NN}
841@tab thread is dead
842
843@item reserved
844@tab @code{u}
845@tab Reserved for future use
846
847@item reserved
848@tab @code{U}
849@tab Reserved for future use
850
851@item reserved
852@tab @code{v}
853@tab Reserved for future use
854
855@item reserved
856@tab @code{V}
857@tab Reserved for future use
858
859@item reserved
860@tab @code{w}
861@tab Reserved for future use
862
863@item reserved
864@tab @code{W}
865@tab Reserved for future use
866
867@item reserved
868@tab @code{x}
869@tab Reserved for future use
870
871@item write mem (binary) @emph{(optional)}
872@tab @code{X}@var{addr}@code{,}@var{length}@var{:}@var{XX...}
873@tab
874@var{addr} is address, @var{length} is number of bytes, @var{XX...} is
875binary data.
876@item
877@tab reply @code{OK}
878@tab for success
879@item
880@tab reply @code{E}@var{NN}
881@tab for an error
882
883@item reserved
884@tab @code{y}
885@tab Reserved for future use
886
887@item reserved
888@tab @code{Y}
889@tab Reserved for future use
890
891@item remove break or watchpoint @strong{(draft)} @emph{(optional)}
892@tab @code{z}@var{t}@code{,}@var{addr}@code{,}@var{length}
893@tab
894See @samp{Z}.
895
896@item insert break or watchpoint @strong{(draft)} @emph{(optional)}
897@tab @code{Z}@var{t}@code{,}@var{addr}@code{,}@var{length}
898@tab
899@var{t} is type: @samp{0} - software breakpoint, @samp{1} - hardware
900breakpoint, @samp{2} - write watchpoint, @samp{3} - read watchpoint,
901@samp{4} - access watchpoint; @var{addr} is address; @var{length} is in
902bytes. For a software breakpoint, @var{length} specifies the size of
903the instruction to be patched. For hardware breakpoints and watchpoints
904@var{length} specifies the memory region to be monitored.
905@item
906@tab reply @code{E}@var{NN}
907@tab for an error
908@item
909@tab reply @code{OK}
910@tab for success
911@item
912@tab @samp{}
913@tab If not supported.
914
915@item reserved
916@tab <other>
917@tab Reserved for future use
918
919@end multitable
920
921In the case of the @samp{C}, @samp{c}, @samp{S} and @samp{s} packets,
922there is no immediate response. The reply, described below, comes when
923the machine stops:
924
925@multitable @columnfractions .4 .6
926
927@item @code{S}@var{AA}
928@tab @var{AA} is the signal number
929
930@item @code{T}@var{AA}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;}
931@tab
932@var{AA} = two hex digit signal number; @var{n...} = register number
933(hex), @var{r...} = target byte ordered register contents, size defined
934by @code{REGISTER_RAW_SIZE}; @var{n...} = @samp{thread}, @var{r...} =
935thread process ID, this is a hex integer; @var{n...} = other string not
936starting with valid hex digit. @value{GDBN} should ignore this
937@var{n...}, @var{r...} pair and go on to the next. This way we can
938extend the protocol.
939
940@item @code{W}@var{AA}
941@tab
942The process exited, and @var{AA} is the exit status. This is only
943applicable for certains sorts of targets.
944
945@item @code{X}@var{AA}
946@tab
947The process terminated with signal @var{AA}.
948
949@item @code{N}@var{AA}@code{;}@var{tttttttt}@code{;}@var{dddddddd}@code{;}@var{bbbbbbbb} @strong{(obsolete)}
950@tab
951@var{AA} = signal number; @var{tttttttt} = address of symbol "_start";
952@var{dddddddd} = base of data section; @var{bbbbbbbb} = base of bss
953section. @emph{Note: only used by Cisco Systems targets. The difference
954between this reply and the "qOffsets" query is that the 'N' packet may
955arrive spontaneously whereas the 'qOffsets' is a query initiated by the
956host debugger.}
957
958@item @code{O}@var{XX...}
959@tab
960@var{XX...} is hex encoding of ASCII data. This can happen at any time
961while the program is running and the debugger should continue to wait
962for 'W', 'T', etc.
963
964@end multitable
965
966Example sequence of a target being re-started. Notice how the restart
967does not get any direct output:
968
969@example
970<- @code{R00}
971-> @code{+}
972@emph{target restarts}
973<- @code{?}
974-> @code{+}
975-> @code{T001:1234123412341234}
976<- @code{+}
977@end example
978
979Example sequence of a target being stepped by a single instruction:
980
981@example
982<- @code{G1445...}
983-> @code{+}
984<- @code{s}
985-> @code{+}
986@emph{time passes}
987-> @code{T001:1234123412341234}
988<- @code{+}
989<- @code{g}
990-> @code{+}
991-> @code{1455...}
992<- @code{+}
993@end example
c906108c
SS
994
995@kindex set remotedebug
996@kindex show remotedebug
997@cindex packets, reporting on stdout
998@cindex serial connections, debugging
999If you have trouble with the serial connection, you can use the command
1000@code{set remotedebug}. This makes @value{GDBN} report on all packets sent
1001back and forth across the serial line to the remote machine. The
1002packet-debugging information is printed on the @value{GDBN} standard output
1003stream. @code{set remotedebug off} turns it off, and @code{show
1004remotedebug} shows you its current state.
1005
c906108c
SS
1006@node Server
1007@subsubsection Using the @code{gdbserver} program
1008
1009@kindex gdbserver
1010@cindex remote connection without stubs
1011@code{gdbserver} is a control program for Unix-like systems, which
1012allows you to connect your program with a remote @value{GDBN} via
1013@code{target remote}---but without linking in the usual debugging stub.
1014
1015@code{gdbserver} is not a complete replacement for the debugging stubs,
1016because it requires essentially the same operating-system facilities
1017that @value{GDBN} itself does. In fact, a system that can run
1018@code{gdbserver} to connect to a remote @value{GDBN} could also run
1019@value{GDBN} locally! @code{gdbserver} is sometimes useful nevertheless,
1020because it is a much smaller program than @value{GDBN} itself. It is
1021also easier to port than all of @value{GDBN}, so you may be able to get
1022started more quickly on a new system by using @code{gdbserver}.
1023Finally, if you develop code for real-time systems, you may find that
1024the tradeoffs involved in real-time operation make it more convenient to
1025do as much development work as possible on another system, for example
1026by cross-compiling. You can use @code{gdbserver} to make a similar
1027choice for debugging.
1028
1029@value{GDBN} and @code{gdbserver} communicate via either a serial line
1030or a TCP connection, using the standard @value{GDBN} remote serial
1031protocol.
1032
1033@table @emph
1034@item On the target machine,
1035you need to have a copy of the program you want to debug.
1036@code{gdbserver} does not need your program's symbol table, so you can
1037strip the program if necessary to save space. @value{GDBN} on the host
1038system does all the symbol handling.
1039
1040To use the server, you must tell it how to communicate with @value{GDBN};
1041the name of your program; and the arguments for your program. The
1042syntax is:
1043
1044@smallexample
1045target> gdbserver @var{comm} @var{program} [ @var{args} @dots{} ]
1046@end smallexample
1047
1048@var{comm} is either a device name (to use a serial line) or a TCP
1049hostname and portnumber. For example, to debug Emacs with the argument
1050@samp{foo.txt} and communicate with @value{GDBN} over the serial port
1051@file{/dev/com1}:
1052
1053@smallexample
1054target> gdbserver /dev/com1 emacs foo.txt
1055@end smallexample
1056
1057@code{gdbserver} waits passively for the host @value{GDBN} to communicate
1058with it.
1059
1060To use a TCP connection instead of a serial line:
1061
1062@smallexample
1063target> gdbserver host:2345 emacs foo.txt
1064@end smallexample
1065
1066The only difference from the previous example is the first argument,
1067specifying that you are communicating with the host @value{GDBN} via
1068TCP. The @samp{host:2345} argument means that @code{gdbserver} is to
1069expect a TCP connection from machine @samp{host} to local TCP port 2345.
1070(Currently, the @samp{host} part is ignored.) You can choose any number
1071you want for the port number as long as it does not conflict with any
1072TCP ports already in use on the target system (for example, @code{23} is
1073reserved for @code{telnet}).@footnote{If you choose a port number that
1074conflicts with another service, @code{gdbserver} prints an error message
1075and exits.} You must use the same port number with the host @value{GDBN}
1076@code{target remote} command.
1077
1078@item On the @value{GDBN} host machine,
1079you need an unstripped copy of your program, since @value{GDBN} needs
1080symbols and debugging information. Start up @value{GDBN} as usual,
1081using the name of the local copy of your program as the first argument.
1082(You may also need the @w{@samp{--baud}} option if the serial line is
1083running at anything other than 9600 bps.) After that, use @code{target
1084remote} to establish communications with @code{gdbserver}. Its argument
1085is either a device name (usually a serial device, like
1086@file{/dev/ttyb}), or a TCP port descriptor in the form
1087@code{@var{host}:@var{PORT}}. For example:
1088
1089@smallexample
1090(@value{GDBP}) target remote /dev/ttyb
1091@end smallexample
1092
1093@noindent
1094communicates with the server via serial line @file{/dev/ttyb}, and
1095
1096@smallexample
1097(@value{GDBP}) target remote the-target:2345
1098@end smallexample
1099
1100@noindent
1101communicates via a TCP connection to port 2345 on host @w{@file{the-target}}.
1102For TCP connections, you must start up @code{gdbserver} prior to using
1103the @code{target remote} command. Otherwise you may get an error whose
1104text depends on the host system, but which usually looks something like
1105@samp{Connection refused}.
1106@end table
c906108c 1107
c906108c
SS
1108@node NetWare
1109@subsubsection Using the @code{gdbserve.nlm} program
1110
1111@kindex gdbserve.nlm
1112@code{gdbserve.nlm} is a control program for NetWare systems, which
1113allows you to connect your program with a remote @value{GDBN} via
1114@code{target remote}.
1115
1116@value{GDBN} and @code{gdbserve.nlm} communicate via a serial line,
1117using the standard @value{GDBN} remote serial protocol.
1118
1119@table @emph
1120@item On the target machine,
1121you need to have a copy of the program you want to debug.
1122@code{gdbserve.nlm} does not need your program's symbol table, so you
1123can strip the program if necessary to save space. @value{GDBN} on the
1124host system does all the symbol handling.
1125
1126To use the server, you must tell it how to communicate with
1127@value{GDBN}; the name of your program; and the arguments for your
1128program. The syntax is:
1129
1130@smallexample
1131load gdbserve [ BOARD=@var{board} ] [ PORT=@var{port} ]
1132 [ BAUD=@var{baud} ] @var{program} [ @var{args} @dots{} ]
1133@end smallexample
1134
1135@var{board} and @var{port} specify the serial line; @var{baud} specifies
1136the baud rate used by the connection. @var{port} and @var{node} default
1137to 0, @var{baud} defaults to 9600 bps.
1138
1139For example, to debug Emacs with the argument @samp{foo.txt}and
1140communicate with @value{GDBN} over serial port number 2 or board 1
1141using a 19200 bps connection:
1142
1143@smallexample
1144load gdbserve BOARD=1 PORT=2 BAUD=19200 emacs foo.txt
1145@end smallexample
1146
1147@item On the @value{GDBN} host machine,
1148you need an unstripped copy of your program, since @value{GDBN} needs
1149symbols and debugging information. Start up @value{GDBN} as usual,
1150using the name of the local copy of your program as the first argument.
1151(You may also need the @w{@samp{--baud}} option if the serial line is
1152running at anything other than 9600 bps. After that, use @code{target
1153remote} to establish communications with @code{gdbserve.nlm}. Its
1154argument is a device name (usually a serial device, like
1155@file{/dev/ttyb}). For example:
1156
1157@smallexample
1158(@value{GDBP}) target remote /dev/ttyb
1159@end smallexample
1160
1161@noindent
1162communications with the server via serial line @file{/dev/ttyb}.
1163@end table
c906108c 1164
c906108c
SS
1165@node i960-Nindy Remote
1166@subsection @value{GDBN} with a remote i960 (Nindy)
1167
1168@cindex Nindy
1169@cindex i960
1170@dfn{Nindy} is a ROM Monitor program for Intel 960 target systems. When
1171@value{GDBN} is configured to control a remote Intel 960 using Nindy, you can
1172tell @value{GDBN} how to connect to the 960 in several ways:
1173
1174@itemize @bullet
1175@item
1176Through command line options specifying serial port, version of the
1177Nindy protocol, and communications speed;
1178
1179@item
1180By responding to a prompt on startup;
1181
1182@item
1183By using the @code{target} command at any point during your @value{GDBN}
1184session. @xref{Target Commands, ,Commands for managing targets}.
1185
1186@end itemize
1187
1188@menu
1189* Nindy Startup:: Startup with Nindy
1190* Nindy Options:: Options for Nindy
1191* Nindy Reset:: Nindy reset command
1192@end menu
1193
1194@node Nindy Startup
1195@subsubsection Startup with Nindy
1196
1197If you simply start @code{@value{GDBP}} without using any command-line
1198options, you are prompted for what serial port to use, @emph{before} you
1199reach the ordinary @value{GDBN} prompt:
1200
1201@example
1202Attach /dev/ttyNN -- specify NN, or "quit" to quit:
1203@end example
1204
1205@noindent
1206Respond to the prompt with whatever suffix (after @samp{/dev/tty})
1207identifies the serial port you want to use. You can, if you choose,
1208simply start up with no Nindy connection by responding to the prompt
1209with an empty line. If you do this and later wish to attach to Nindy,
1210use @code{target} (@pxref{Target Commands, ,Commands for managing targets}).
1211
1212@node Nindy Options
1213@subsubsection Options for Nindy
1214
1215These are the startup options for beginning your @value{GDBN} session with a
1216Nindy-960 board attached:
1217
1218@table @code
1219@item -r @var{port}
1220Specify the serial port name of a serial interface to be used to connect
1221to the target system. This option is only available when @value{GDBN} is
1222configured for the Intel 960 target architecture. You may specify
1223@var{port} as any of: a full pathname (e.g. @samp{-r /dev/ttya}), a
1224device name in @file{/dev} (e.g. @samp{-r ttya}), or simply the unique
1225suffix for a specific @code{tty} (e.g. @samp{-r a}).
1226
1227@item -O
1228(An uppercase letter ``O'', not a zero.) Specify that @value{GDBN} should use
1229the ``old'' Nindy monitor protocol to connect to the target system.
1230This option is only available when @value{GDBN} is configured for the Intel 960
1231target architecture.
1232
1233@quotation
1234@emph{Warning:} if you specify @samp{-O}, but are actually trying to
1235connect to a target system that expects the newer protocol, the connection
1236fails, appearing to be a speed mismatch. @value{GDBN} repeatedly
1237attempts to reconnect at several different line speeds. You can abort
1238this process with an interrupt.
1239@end quotation
1240
1241@item -brk
1242Specify that @value{GDBN} should first send a @code{BREAK} signal to the target
1243system, in an attempt to reset it, before connecting to a Nindy target.
1244
1245@quotation
1246@emph{Warning:} Many target systems do not have the hardware that this
1247requires; it only works with a few boards.
1248@end quotation
1249@end table
1250
1251The standard @samp{-b} option controls the line speed used on the serial
1252port.
1253
1254@c @group
1255@node Nindy Reset
1256@subsubsection Nindy reset command
1257
1258@table @code
1259@item reset
1260@kindex reset
1261For a Nindy target, this command sends a ``break'' to the remote target
1262system; this is only useful if the target has been equipped with a
1263circuit to perform a hard reset (or some other interesting action) when
1264a break is detected.
1265@end table
1266@c @end group
c906108c 1267
c906108c
SS
1268@node UDI29K Remote
1269@subsection The UDI protocol for AMD29K
1270
1271@cindex UDI
1272@cindex AMD29K via UDI
1273@value{GDBN} supports AMD's UDI (``Universal Debugger Interface'')
1274protocol for debugging the a29k processor family. To use this
1275configuration with AMD targets running the MiniMON monitor, you need the
1276program @code{MONTIP}, available from AMD at no charge. You can also
1277use @value{GDBN} with the UDI-conformant a29k simulator program
1278@code{ISSTIP}, also available from AMD.
1279
1280@table @code
1281@item target udi @var{keyword}
1282@kindex udi
1283Select the UDI interface to a remote a29k board or simulator, where
1284@var{keyword} is an entry in the AMD configuration file @file{udi_soc}.
1285This file contains keyword entries which specify parameters used to
1286connect to a29k targets. If the @file{udi_soc} file is not in your
1287working directory, you must set the environment variable @samp{UDICONF}
1288to its pathname.
1289@end table
1290
1291@node EB29K Remote
1292@subsection The EBMON protocol for AMD29K
1293
1294@cindex EB29K board
1295@cindex running 29K programs
1296
1297AMD distributes a 29K development board meant to fit in a PC, together
1298with a DOS-hosted monitor program called @code{EBMON}. As a shorthand
1299term, this development system is called the ``EB29K''. To use
1300@value{GDBN} from a Unix system to run programs on the EB29K board, you
1301must first connect a serial cable between the PC (which hosts the EB29K
1302board) and a serial port on the Unix system. In the following, we
1303assume you've hooked the cable between the PC's @file{COM1} port and
1304@file{/dev/ttya} on the Unix system.
1305
1306@menu
1307* Comms (EB29K):: Communications setup
1308* gdb-EB29K:: EB29K cross-debugging
1309* Remote Log:: Remote log
1310@end menu
1311
1312@node Comms (EB29K)
1313@subsubsection Communications setup
1314
1315The next step is to set up the PC's port, by doing something like this
1316in DOS on the PC:
1317
1318@example
1319C:\> MODE com1:9600,n,8,1,none
1320@end example
1321
1322@noindent
1323This example---run on an MS DOS 4.0 system---sets the PC port to 9600
1324bps, no parity, eight data bits, one stop bit, and no ``retry'' action;
1325you must match the communications parameters when establishing the Unix
1326end of the connection as well.
1327@c FIXME: Who knows what this "no retry action" crud from the DOS manual may
1328@c mean? It's optional; leave it out? ---doc@cygnus.com, 25feb91
1329
1330To give control of the PC to the Unix side of the serial line, type
1331the following at the DOS console:
1332
1333@example
1334C:\> CTTY com1
1335@end example
1336
1337@noindent
1338(Later, if you wish to return control to the DOS console, you can use
1339the command @code{CTTY con}---but you must send it over the device that
1340had control, in our example over the @file{COM1} serial line).
1341
1342From the Unix host, use a communications program such as @code{tip} or
1343@code{cu} to communicate with the PC; for example,
1344
1345@example
1346cu -s 9600 -l /dev/ttya
1347@end example
1348
1349@noindent
1350The @code{cu} options shown specify, respectively, the linespeed and the
1351serial port to use. If you use @code{tip} instead, your command line
1352may look something like the following:
1353
1354@example
1355tip -9600 /dev/ttya
1356@end example
1357
1358@noindent
1359Your system may require a different name where we show
1360@file{/dev/ttya} as the argument to @code{tip}. The communications
1361parameters, including which port to use, are associated with the
1362@code{tip} argument in the ``remote'' descriptions file---normally the
1363system table @file{/etc/remote}.
1364@c FIXME: What if anything needs doing to match the "n,8,1,none" part of
1365@c the DOS side's comms setup? cu can support -o (odd
1366@c parity), -e (even parity)---apparently no settings for no parity or
1367@c for character size. Taken from stty maybe...? John points out tip
1368@c can set these as internal variables, eg ~s parity=none; man stty
1369@c suggests that it *might* work to stty these options with stdin or
1370@c stdout redirected... ---doc@cygnus.com, 25feb91
1371
1372@kindex EBMON
1373Using the @code{tip} or @code{cu} connection, change the DOS working
1374directory to the directory containing a copy of your 29K program, then
1375start the PC program @code{EBMON} (an EB29K control program supplied
1376with your board by AMD). You should see an initial display from
1377@code{EBMON} similar to the one that follows, ending with the
1378@code{EBMON} prompt @samp{#}---
1379
1380@example
1381C:\> G:
1382
1383G:\> CD \usr\joe\work29k
1384
1385G:\USR\JOE\WORK29K> EBMON
1386Am29000 PC Coprocessor Board Monitor, version 3.0-18
1387Copyright 1990 Advanced Micro Devices, Inc.
1388Written by Gibbons and Associates, Inc.
1389
1390Enter '?' or 'H' for help
1391
1392PC Coprocessor Type = EB29K
1393I/O Base = 0x208
1394Memory Base = 0xd0000
1395
1396Data Memory Size = 2048KB
1397Available I-RAM Range = 0x8000 to 0x1fffff
1398Available D-RAM Range = 0x80002000 to 0x801fffff
1399
1400PageSize = 0x400
1401Register Stack Size = 0x800
1402Memory Stack Size = 0x1800
1403
1404CPU PRL = 0x3
1405Am29027 Available = No
1406Byte Write Available = Yes
1407
1408# ~.
1409@end example
1410
1411Then exit the @code{cu} or @code{tip} program (done in the example by
1412typing @code{~.} at the @code{EBMON} prompt). @code{EBMON} keeps
1413running, ready for @value{GDBN} to take over.
1414
1415For this example, we've assumed what is probably the most convenient
1416way to make sure the same 29K program is on both the PC and the Unix
1417system: a PC/NFS connection that establishes ``drive @code{G:}'' on the
1418PC as a file system on the Unix host. If you do not have PC/NFS or
1419something similar connecting the two systems, you must arrange some
1420other way---perhaps floppy-disk transfer---of getting the 29K program
1421from the Unix system to the PC; @value{GDBN} does @emph{not} download it over the
1422serial line.
1423
1424@node gdb-EB29K
1425@subsubsection EB29K cross-debugging
1426
1427Finally, @code{cd} to the directory containing an image of your 29K
1428program on the Unix system, and start @value{GDBN}---specifying as argument the
1429name of your 29K program:
1430
1431@example
1432cd /usr/joe/work29k
1433@value{GDBP} myfoo
1434@end example
1435
1436@need 500
1437Now you can use the @code{target} command:
1438
1439@example
1440target amd-eb /dev/ttya 9600 MYFOO
1441@c FIXME: test above 'target amd-eb' as spelled, with caps! caps are meant to
1442@c emphasize that this is the name as seen by DOS (since I think DOS is
1443@c single-minded about case of letters). ---doc@cygnus.com, 25feb91
1444@end example
1445
1446@noindent
1447In this example, we've assumed your program is in a file called
1448@file{myfoo}. Note that the filename given as the last argument to
1449@code{target amd-eb} should be the name of the program as it appears to DOS.
1450In our example this is simply @code{MYFOO}, but in general it can include
1451a DOS path, and depending on your transfer mechanism may not resemble
1452the name on the Unix side.
1453
1454At this point, you can set any breakpoints you wish; when you are ready
1455to see your program run on the 29K board, use the @value{GDBN} command
1456@code{run}.
1457
1458To stop debugging the remote program, use the @value{GDBN} @code{detach}
1459command.
1460
1461To return control of the PC to its console, use @code{tip} or @code{cu}
1462once again, after your @value{GDBN} session has concluded, to attach to
1463@code{EBMON}. You can then type the command @code{q} to shut down
1464@code{EBMON}, returning control to the DOS command-line interpreter.
1465Type @code{CTTY con} to return command input to the main DOS console,
1466and type @kbd{~.} to leave @code{tip} or @code{cu}.
1467
1468@node Remote Log
1469@subsubsection Remote log
1470@kindex eb.log
1471@cindex log file for EB29K
1472
1473The @code{target amd-eb} command creates a file @file{eb.log} in the
1474current working directory, to help debug problems with the connection.
1475@file{eb.log} records all the output from @code{EBMON}, including echoes
1476of the commands sent to it. Running @samp{tail -f} on this file in
1477another window often helps to understand trouble with @code{EBMON}, or
1478unexpected events on the PC side of the connection.
1479
c906108c
SS
1480@node ST2000 Remote
1481@subsection @value{GDBN} with a Tandem ST2000
1482
1483To connect your ST2000 to the host system, see the manufacturer's
1484manual. Once the ST2000 is physically attached, you can run:
1485
1486@example
1487target st2000 @var{dev} @var{speed}
1488@end example
1489
1490@noindent
1491to establish it as your debugging environment. @var{dev} is normally
1492the name of a serial device, such as @file{/dev/ttya}, connected to the
1493ST2000 via a serial line. You can instead specify @var{dev} as a TCP
1494connection (for example, to a serial line attached via a terminal
1495concentrator) using the syntax @code{@var{hostname}:@var{portnumber}}.
1496
1497The @code{load} and @code{attach} commands are @emph{not} defined for
1498this target; you must load your program into the ST2000 as you normally
1499would for standalone operation. @value{GDBN} reads debugging information
1500(such as symbols) from a separate, debugging version of the program
1501available on your host computer.
1502@c FIXME!! This is terribly vague; what little content is here is
1503@c basically hearsay.
1504
1505@cindex ST2000 auxiliary commands
1506These auxiliary @value{GDBN} commands are available to help you with the ST2000
1507environment:
1508
1509@table @code
1510@item st2000 @var{command}
1511@kindex st2000 @var{cmd}
1512@cindex STDBUG commands (ST2000)
1513@cindex commands to STDBUG (ST2000)
1514Send a @var{command} to the STDBUG monitor. See the manufacturer's
1515manual for available commands.
1516
1517@item connect
1518@cindex connect (to STDBUG)
1519Connect the controlling terminal to the STDBUG command monitor. When
1520you are done interacting with STDBUG, typing either of two character
1521sequences gets you back to the @value{GDBN} command prompt:
1522@kbd{@key{RET}~.} (Return, followed by tilde and period) or
1523@kbd{@key{RET}~@key{C-d}} (Return, followed by tilde and control-D).
1524@end table
c906108c 1525
c906108c
SS
1526@node VxWorks Remote
1527@subsection @value{GDBN} and VxWorks
7a292a7a 1528
c906108c
SS
1529@cindex VxWorks
1530
1531@value{GDBN} enables developers to spawn and debug tasks running on networked
1532VxWorks targets from a Unix host. Already-running tasks spawned from
1533the VxWorks shell can also be debugged. @value{GDBN} uses code that runs on
1534both the Unix host and on the VxWorks target. The program
1535@code{gdb} is installed and executed on the Unix host. (It may be
1536installed with the name @code{vxgdb}, to distinguish it from a
1537@value{GDBN} for debugging programs on the host itself.)
1538
1539@table @code
1540@item VxWorks-timeout @var{args}
1541@kindex vxworks-timeout
1542All VxWorks-based targets now support the option @code{vxworks-timeout}.
1543This option is set by the user, and @var{args} represents the number of
1544seconds @value{GDBN} waits for responses to rpc's. You might use this if
1545your VxWorks target is a slow software simulator or is on the far side
1546of a thin network line.
1547@end table
1548
1549The following information on connecting to VxWorks was current when
1550this manual was produced; newer releases of VxWorks may use revised
1551procedures.
1552
1553@kindex INCLUDE_RDB
1554To use @value{GDBN} with VxWorks, you must rebuild your VxWorks kernel
1555to include the remote debugging interface routines in the VxWorks
1556library @file{rdb.a}. To do this, define @code{INCLUDE_RDB} in the
1557VxWorks configuration file @file{configAll.h} and rebuild your VxWorks
1558kernel. The resulting kernel contains @file{rdb.a}, and spawns the
1559source debugging task @code{tRdbTask} when VxWorks is booted. For more
1560information on configuring and remaking VxWorks, see the manufacturer's
1561manual.
1562@c VxWorks, see the @cite{VxWorks Programmer's Guide}.
1563
1564Once you have included @file{rdb.a} in your VxWorks system image and set
1565your Unix execution search path to find @value{GDBN}, you are ready to
1566run @value{GDBN}. From your Unix host, run @code{gdb} (or @code{vxgdb},
1567depending on your installation).
1568
1569@value{GDBN} comes up showing the prompt:
1570
1571@example
1572(vxgdb)
1573@end example
1574
1575@menu
1576* VxWorks Connection:: Connecting to VxWorks
1577* VxWorks Download:: VxWorks download
1578* VxWorks Attach:: Running tasks
1579@end menu
1580
1581@node VxWorks Connection
1582@subsubsection Connecting to VxWorks
1583
1584The @value{GDBN} command @code{target} lets you connect to a VxWorks target on the
1585network. To connect to a target whose host name is ``@code{tt}'', type:
1586
1587@example
1588(vxgdb) target vxworks tt
1589@end example
1590
1591@need 750
1592@value{GDBN} displays messages like these:
1593
1594@smallexample
1595Attaching remote machine across net...
1596Connected to tt.
1597@end smallexample
1598
1599@need 1000
1600@value{GDBN} then attempts to read the symbol tables of any object modules
1601loaded into the VxWorks target since it was last booted. @value{GDBN} locates
1602these files by searching the directories listed in the command search
1603path (@pxref{Environment, ,Your program's environment}); if it fails
1604to find an object file, it displays a message such as:
1605
1606@example
1607prog.o: No such file or directory.
1608@end example
1609
1610When this happens, add the appropriate directory to the search path with
1611the @value{GDBN} command @code{path}, and execute the @code{target}
1612command again.
1613
1614@node VxWorks Download
1615@subsubsection VxWorks download
1616
1617@cindex download to VxWorks
1618If you have connected to the VxWorks target and you want to debug an
1619object that has not yet been loaded, you can use the @value{GDBN}
1620@code{load} command to download a file from Unix to VxWorks
1621incrementally. The object file given as an argument to the @code{load}
1622command is actually opened twice: first by the VxWorks target in order
1623to download the code, then by @value{GDBN} in order to read the symbol
1624table. This can lead to problems if the current working directories on
1625the two systems differ. If both systems have NFS mounted the same
1626filesystems, you can avoid these problems by using absolute paths.
1627Otherwise, it is simplest to set the working directory on both systems
1628to the directory in which the object file resides, and then to reference
1629the file by its name, without any path. For instance, a program
1630@file{prog.o} may reside in @file{@var{vxpath}/vw/demo/rdb} in VxWorks
1631and in @file{@var{hostpath}/vw/demo/rdb} on the host. To load this
1632program, type this on VxWorks:
1633
1634@example
1635-> cd "@var{vxpath}/vw/demo/rdb"
1636@end example
1637v
1638Then, in @value{GDBN}, type:
1639
1640@example
1641(vxgdb) cd @var{hostpath}/vw/demo/rdb
1642(vxgdb) load prog.o
1643@end example
1644
1645@value{GDBN} displays a response similar to this:
1646
1647@smallexample
1648Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
1649@end smallexample
1650
1651You can also use the @code{load} command to reload an object module
1652after editing and recompiling the corresponding source file. Note that
1653this makes @value{GDBN} delete all currently-defined breakpoints,
1654auto-displays, and convenience variables, and to clear the value
1655history. (This is necessary in order to preserve the integrity of
1656debugger data structures that reference the target system's symbol
1657table.)
1658
1659@node VxWorks Attach
1660@subsubsection Running tasks
1661
1662@cindex running VxWorks tasks
1663You can also attach to an existing task using the @code{attach} command as
1664follows:
1665
1666@example
1667(vxgdb) attach @var{task}
1668@end example
1669
1670@noindent
1671where @var{task} is the VxWorks hexadecimal task ID. The task can be running
1672or suspended when you attach to it. Running tasks are suspended at
1673the time of attachment.
c906108c 1674
c906108c
SS
1675@node Sparclet Remote
1676@subsection @value{GDBN} and Sparclet
1677@cindex Sparclet
1678
1679@value{GDBN} enables developers to debug tasks running on
1680Sparclet targets from a Unix host.
1681@value{GDBN} uses code that runs on
1682both the Unix host and on the Sparclet target. The program
1683@code{gdb} is installed and executed on the Unix host.
1684
1685@table @code
1686@item timeout @var{args}
1687@kindex remotetimeout
1688@value{GDBN} now supports the option @code{remotetimeout}.
1689This option is set by the user, and @var{args} represents the number of
1690seconds @value{GDBN} waits for responses.
1691@end table
1692
1693@kindex Compiling
1694When compiling for debugging, include the options "-g" to get debug
1695information and "-Ttext" to relocate the program to where you wish to
1696load it on the target. You may also want to add the options "-n" or
1697"-N" in order to reduce the size of the sections.
1698
1699@example
1700sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N
1701@end example
1702
1703You can use objdump to verify that the addresses are what you intended.
1704
1705@example
1706sparclet-aout-objdump --headers --syms prog
1707@end example
1708
1709@kindex Running
1710Once you have set
1711your Unix execution search path to find @value{GDBN}, you are ready to
1712run @value{GDBN}. From your Unix host, run @code{gdb}
1713(or @code{sparclet-aout-gdb}, depending on your installation).
1714
1715@value{GDBN} comes up showing the prompt:
1716
1717@example
1718(gdbslet)
1719@end example
1720
1721@menu
1722* Sparclet File:: Setting the file to debug
1723* Sparclet Connection:: Connecting to Sparclet
1724* Sparclet Download:: Sparclet download
1725* Sparclet Execution:: Running and debugging
1726@end menu
1727
1728@node Sparclet File
1729@subsubsection Setting file to debug
1730
1731The @value{GDBN} command @code{file} lets you choose with program to debug.
1732
1733@example
1734(gdbslet) file prog
1735@end example
1736
1737@need 1000
1738@value{GDBN} then attempts to read the symbol table of @file{prog}.
1739@value{GDBN} locates
1740the file by searching the directories listed in the command search
1741path.
1742If the file was compiled with debug information (option "-g"), source
1743files will be searched as well.
1744@value{GDBN} locates
1745the source files by searching the directories listed in the directory search
1746path (@pxref{Environment, ,Your program's environment}).
1747If it fails
1748to find a file, it displays a message such as:
1749
1750@example
1751prog: No such file or directory.
1752@end example
1753
1754When this happens, add the appropriate directories to the search paths with
1755the @value{GDBN} commands @code{path} and @code{dir}, and execute the
1756@code{target} command again.
1757
1758@node Sparclet Connection
1759@subsubsection Connecting to Sparclet
1760
1761The @value{GDBN} command @code{target} lets you connect to a Sparclet target.
1762To connect to a target on serial port ``@code{ttya}'', type:
1763
1764@example
1765(gdbslet) target sparclet /dev/ttya
1766Remote target sparclet connected to /dev/ttya
1767main () at ../prog.c:3
1768@end example
1769
1770@need 750
1771@value{GDBN} displays messages like these:
1772
1773@smallexample
1774Connected to ttya.
1775@end smallexample
1776
1777@node Sparclet Download
1778@subsubsection Sparclet download
1779
1780@cindex download to Sparclet
1781Once connected to the Sparclet target,
1782you can use the @value{GDBN}
1783@code{load} command to download the file from the host to the target.
1784The file name and load offset should be given as arguments to the @code{load}
1785command.
1786Since the file format is aout, the program must be loaded to the starting
1787address. You can use objdump to find out what this value is. The load
1788offset is an offset which is added to the VMA (virtual memory address)
1789of each of the file's sections.
1790For instance, if the program
1791@file{prog} was linked to text address 0x1201000, with data at 0x12010160
1792and bss at 0x12010170, in @value{GDBN}, type:
1793
1794@example
1795(gdbslet) load prog 0x12010000
1796Loading section .text, size 0xdb0 vma 0x12010000
1797@end example
1798
1799If the code is loaded at a different address then what the program was linked
1800to, you may need to use the @code{section} and @code{add-symbol-file} commands
1801to tell @value{GDBN} where to map the symbol table.
1802
1803@node Sparclet Execution
1804@subsubsection Running and debugging
1805
1806@cindex running and debugging Sparclet programs
1807You can now begin debugging the task using @value{GDBN}'s execution control
1808commands, @code{b}, @code{step}, @code{run}, etc. See the @value{GDBN}
1809manual for the list of commands.
1810
1811@example
1812(gdbslet) b main
1813Breakpoint 1 at 0x12010000: file prog.c, line 3.
1814(gdbslet) run
1815Starting program: prog
1816Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3
18173 char *symarg = 0;
1818(gdbslet) step
18194 char *execarg = "hello!";
1820(gdbslet)
1821@end example
1822
c906108c
SS
1823@node Hitachi Remote
1824@subsection @value{GDBN} and Hitachi microprocessors
1825@value{GDBN} needs to know these things to talk to your
1826Hitachi SH, H8/300, or H8/500:
1827
1828@enumerate
1829@item
1830that you want to use @samp{target hms}, the remote debugging interface
1831for Hitachi microprocessors, or @samp{target e7000}, the in-circuit
1832emulator for the Hitachi SH and the Hitachi 300H. (@samp{target hms} is
1833the default when GDB is configured specifically for the Hitachi SH,
1834H8/300, or H8/500.)
1835
1836@item
1837what serial device connects your host to your Hitachi board (the first
1838serial device available on your host is the default).
1839
c906108c
SS
1840@item
1841what speed to use over the serial device.
c906108c
SS
1842@end enumerate
1843
1844@menu
1845* Hitachi Boards:: Connecting to Hitachi boards.
1846* Hitachi ICE:: Using the E7000 In-Circuit Emulator.
1847* Hitachi Special:: Special @value{GDBN} commands for Hitachi micros.
1848@end menu
1849
1850@node Hitachi Boards
1851@subsubsection Connecting to Hitachi boards
1852
c906108c
SS
1853@c only for Unix hosts
1854@kindex device
1855@cindex serial device, Hitachi micros
1856Use the special @code{@value{GDBP}} command @samp{device @var{port}} if you
1857need to explicitly set the serial device. The default @var{port} is the
1858first available port on your host. This is only necessary on Unix
1859hosts, where it is typically something like @file{/dev/ttya}.
1860
1861@kindex speed
1862@cindex serial line speed, Hitachi micros
1863@code{@value{GDBP}} has another special command to set the communications
1864speed: @samp{speed @var{bps}}. This command also is only used from Unix
1865hosts; on DOS hosts, set the line speed as usual from outside GDB with
1866the DOS @kbd{mode} command (for instance, @w{@samp{mode
1867com2:9600,n,8,1,p}} for a 9600 bps connection).
1868
1869The @samp{device} and @samp{speed} commands are available only when you
1870use a Unix host to debug your Hitachi microprocessor programs. If you
1871use a DOS host,
c906108c
SS
1872@value{GDBN} depends on an auxiliary terminate-and-stay-resident program
1873called @code{asynctsr} to communicate with the development board
1874through a PC serial port. You must also use the DOS @code{mode} command
1875to set up the serial port on the DOS side.
1876
c906108c
SS
1877The following sample session illustrates the steps needed to start a
1878program under @value{GDBN} control on an H8/300. The example uses a
1879sample H8/300 program called @file{t.x}. The procedure is the same for
1880the Hitachi SH and the H8/500.
1881
1882First hook up your development board. In this example, we use a
1883board attached to serial port @code{COM2}; if you use a different serial
1884port, substitute its name in the argument of the @code{mode} command.
1885When you call @code{asynctsr}, the auxiliary comms program used by the
1886degugger, you give it just the numeric part of the serial port's name;
1887for example, @samp{asyncstr 2} below runs @code{asyncstr} on
1888@code{COM2}.
1889
1890@example
1891C:\H8300\TEST> asynctsr 2
1892C:\H8300\TEST> mode com2:9600,n,8,1,p
1893
1894Resident portion of MODE loaded
1895
1896COM2: 9600, n, 8, 1, p
1897
1898@end example
1899
1900@quotation
1901@emph{Warning:} We have noticed a bug in PC-NFS that conflicts with
1902@code{asynctsr}. If you also run PC-NFS on your DOS host, you may need to
1903disable it, or even boot without it, to use @code{asynctsr} to control
1904your development board.
1905@end quotation
1906
1907@kindex target hms
1908Now that serial communications are set up, and the development board is
1909connected, you can start up @value{GDBN}. Call @code{@value{GDBP}} with
1910the name of your program as the argument. @code{@value{GDBP}} prompts
1911you, as usual, with the prompt @samp{(@value{GDBP})}. Use two special
1912commands to begin your debugging session: @samp{target hms} to specify
1913cross-debugging to the Hitachi board, and the @code{load} command to
1914download your program to the board. @code{load} displays the names of
1915the program's sections, and a @samp{*} for each 2K of data downloaded.
1916(If you want to refresh @value{GDBN} data on symbols or on the
1917executable file without downloading, use the @value{GDBN} commands
1918@code{file} or @code{symbol-file}. These commands, and @code{load}
1919itself, are described in @ref{Files,,Commands to specify files}.)
1920
1921@smallexample
1922(eg-C:\H8300\TEST) @value{GDBP} t.x
1923GDB is free software and you are welcome to distribute copies
1924 of it under certain conditions; type "show copying" to see
1925 the conditions.
1926There is absolutely no warranty for GDB; type "show warranty"
1927for details.
1928GDB @value{GDBVN}, Copyright 1992 Free Software Foundation, Inc...
1929(gdb) target hms
1930Connected to remote H8/300 HMS system.
1931(gdb) load t.x
1932.text : 0x8000 .. 0xabde ***********
1933.data : 0xabde .. 0xad30 *
1934.stack : 0xf000 .. 0xf014 *
1935@end smallexample
1936
1937At this point, you're ready to run or debug your program. From here on,
1938you can use all the usual @value{GDBN} commands. The @code{break} command
1939sets breakpoints; the @code{run} command starts your program;
1940@code{print} or @code{x} display data; the @code{continue} command
1941resumes execution after stopping at a breakpoint. You can use the
1942@code{help} command at any time to find out more about @value{GDBN} commands.
1943
1944Remember, however, that @emph{operating system} facilities aren't
1945available on your development board; for example, if your program hangs,
1946you can't send an interrupt---but you can press the @sc{reset} switch!
1947
1948Use the @sc{reset} button on the development board
1949@itemize @bullet
1950@item
1951to interrupt your program (don't use @kbd{ctl-C} on the DOS host---it has
1952no way to pass an interrupt signal to the development board); and
1953
1954@item
1955to return to the @value{GDBN} command prompt after your program finishes
1956normally. The communications protocol provides no other way for @value{GDBN}
1957to detect program completion.
1958@end itemize
1959
1960In either case, @value{GDBN} sees the effect of a @sc{reset} on the
1961development board as a ``normal exit'' of your program.
c906108c
SS
1962
1963@node Hitachi ICE
1964@subsubsection Using the E7000 in-circuit emulator
1965
1966@kindex target e7000
1967You can use the E7000 in-circuit emulator to develop code for either the
1968Hitachi SH or the H8/300H. Use one of these forms of the @samp{target
1969e7000} command to connect @value{GDBN} to your E7000:
1970
1971@table @code
1972@item target e7000 @var{port} @var{speed}
1973Use this form if your E7000 is connected to a serial port. The
1974@var{port} argument identifies what serial port to use (for example,
1975@samp{com2}). The third argument is the line speed in bits per second
1976(for example, @samp{9600}).
1977
1978@item target e7000 @var{hostname}
1979If your E7000 is installed as a host on a TCP/IP network, you can just
1980specify its hostname; @value{GDBN} uses @code{telnet} to connect.
1981@end table
1982
1983@node Hitachi Special
1984@subsubsection Special @value{GDBN} commands for Hitachi micros
1985
1986Some @value{GDBN} commands are available only on the H8/300 or the
1987H8/500 configurations:
1988
1989@table @code
1990@kindex set machine
1991@kindex show machine
1992@item set machine h8300
1993@itemx set machine h8300h
1994Condition @value{GDBN} for one of the two variants of the H8/300
1995architecture with @samp{set machine}. You can use @samp{show machine}
1996to check which variant is currently in effect.
1997
1998@kindex set memory @var{mod}
1999@cindex memory models, H8/500
2000@item set memory @var{mod}
2001@itemx show memory
2002Specify which H8/500 memory model (@var{mod}) you are using with
2003@samp{set memory}; check which memory model is in effect with @samp{show
2004memory}. The accepted values for @var{mod} are @code{small},
2005@code{big}, @code{medium}, and @code{compact}.
2006@end table
2007
c906108c
SS
2008@node MIPS Remote
2009@subsection @value{GDBN} and remote MIPS boards
2010
2011@cindex MIPS boards
2012@value{GDBN} can use the MIPS remote debugging protocol to talk to a
2013MIPS board attached to a serial line. This is available when
2014you configure @value{GDBN} with @samp{--target=mips-idt-ecoff}.
2015
2016@need 1000
2017Use these @value{GDBN} commands to specify the connection to your target board:
2018
2019@table @code
2020@item target mips @var{port}
2021@kindex target mips @var{port}
2022To run a program on the board, start up @code{@value{GDBP}} with the
2023name of your program as the argument. To connect to the board, use the
2024command @samp{target mips @var{port}}, where @var{port} is the name of
2025the serial port connected to the board. If the program has not already
2026been downloaded to the board, you may use the @code{load} command to
2027download it. You can then use all the usual @value{GDBN} commands.
2028
2029For example, this sequence connects to the target board through a serial
2030port, and loads and runs a program called @var{prog} through the
2031debugger:
2032
2033@example
2034host$ @value{GDBP} @var{prog}
2035GDB is free software and @dots{}
2036(gdb) target mips /dev/ttyb
2037(gdb) load @var{prog}
2038(gdb) run
2039@end example
2040
2041@item target mips @var{hostname}:@var{portnumber}
2042On some @value{GDBN} host configurations, you can specify a TCP
2043connection (for instance, to a serial line managed by a terminal
2044concentrator) instead of a serial port, using the syntax
2045@samp{@var{hostname}:@var{portnumber}}.
2046
2047@item target pmon @var{port}
2048@kindex target pmon @var{port}
2049
2050@item target ddb @var{port}
2051@kindex target ddb @var{port}
2052
2053@item target lsi @var{port}
2054@kindex target lsi @var{port}
2055
2056@end table
2057
2058
2059@noindent
2060@value{GDBN} also supports these special commands for MIPS targets:
2061
2062@table @code
2063@item set processor @var{args}
2064@itemx show processor
2065@kindex set processor @var{args}
2066@kindex show processor
2067Use the @code{set processor} command to set the type of MIPS
2068processor when you want to access processor-type-specific registers.
2069For example, @code{set processor @var{r3041}} tells @value{GDBN}
2070to use the CPO registers appropriate for the 3041 chip.
2071Use the @code{show processor} command to see what MIPS processor @value{GDBN}
2072is using. Use the @code{info reg} command to see what registers
2073@value{GDBN} is using.
2074
2075@item set mipsfpu double
2076@itemx set mipsfpu single
2077@itemx set mipsfpu none
2078@itemx show mipsfpu
2079@kindex set mipsfpu
2080@kindex show mipsfpu
2081@cindex MIPS remote floating point
2082@cindex floating point, MIPS remote
2083If your target board does not support the MIPS floating point
2084coprocessor, you should use the command @samp{set mipsfpu none} (if you
2085need this, you may wish to put the command in your @value{GDBINIT}
2086file). This tells @value{GDBN} how to find the return value of
2087functions which return floating point values. It also allows
2088@value{GDBN} to avoid saving the floating point registers when calling
2089functions on the board. If you are using a floating point coprocessor
2090with only single precision floating point support, as on the @sc{r4650}
2091processor, use the command @samp{set mipsfpu single}. The default
2092double precision floating point coprocessor may be selected using
2093@samp{set mipsfpu double}.
2094
2095In previous versions the only choices were double precision or no
2096floating point, so @samp{set mipsfpu on} will select double precision
2097and @samp{set mipsfpu off} will select no floating point.
2098
2099As usual, you can inquire about the @code{mipsfpu} variable with
2100@samp{show mipsfpu}.
2101
2102@item set remotedebug @var{n}
2103@itemx show remotedebug
2104@kindex set remotedebug
2105@kindex show remotedebug
2106@cindex @code{remotedebug}, MIPS protocol
2107@cindex MIPS @code{remotedebug} protocol
2108@c FIXME! For this to be useful, you must know something about the MIPS
2109@c FIXME...protocol. Where is it described?
2110You can see some debugging information about communications with the board
2111by setting the @code{remotedebug} variable. If you set it to @code{1} using
2112@samp{set remotedebug 1}, every packet is displayed. If you set it
2113to @code{2}, every character is displayed. You can check the current value
2114at any time with the command @samp{show remotedebug}.
2115
2116@item set timeout @var{seconds}
2117@itemx set retransmit-timeout @var{seconds}
2118@itemx show timeout
2119@itemx show retransmit-timeout
2120@cindex @code{timeout}, MIPS protocol
2121@cindex @code{retransmit-timeout}, MIPS protocol
2122@kindex set timeout
2123@kindex show timeout
2124@kindex set retransmit-timeout
2125@kindex show retransmit-timeout
2126You can control the timeout used while waiting for a packet, in the MIPS
2127remote protocol, with the @code{set timeout @var{seconds}} command. The
2128default is 5 seconds. Similarly, you can control the timeout used while
2129waiting for an acknowledgement of a packet with the @code{set
2130retransmit-timeout @var{seconds}} command. The default is 3 seconds.
2131You can inspect both values with @code{show timeout} and @code{show
2132retransmit-timeout}. (These commands are @emph{only} available when
2133@value{GDBN} is configured for @samp{--target=mips-idt-ecoff}.)
2134
2135The timeout set by @code{set timeout} does not apply when @value{GDBN}
2136is waiting for your program to stop. In that case, @value{GDBN} waits
2137forever because it has no way of knowing how long the program is going
2138to run before stopping.
2139@end table
c906108c 2140
c906108c
SS
2141@node Simulator
2142@subsection Simulated CPU target
2143
c906108c
SS
2144@cindex simulator
2145@cindex simulator, Z8000
2146@cindex Z8000 simulator
2147@cindex simulator, H8/300 or H8/500
2148@cindex H8/300 or H8/500 simulator
2149@cindex simulator, Hitachi SH
2150@cindex Hitachi SH simulator
2151@cindex CPU simulator
2152For some configurations, @value{GDBN} includes a CPU simulator that you
2153can use instead of a hardware CPU to debug your programs.
2154Currently, simulators are available for ARM, D10V, D30V, FR30, H8/300,
2155H8/500, i960, M32R, MIPS, MN10200, MN10300, PowerPC, SH, Sparc, V850,
2156W65, and Z8000.
c906108c 2157
c906108c
SS
2158@cindex simulator, Z8000
2159@cindex Zilog Z8000 simulator
2160When configured for debugging Zilog Z8000 targets, @value{GDBN} includes
2161a Z8000 simulator.
c906108c 2162
c906108c
SS
2163For the Z8000 family, @samp{target sim} simulates either the Z8002 (the
2164unsegmented variant of the Z8000 architecture) or the Z8001 (the
2165segmented variant). The simulator recognizes which architecture is
2166appropriate by inspecting the object code.
c906108c
SS
2167
2168@table @code
2169@item target sim @var{args}
2170@kindex sim
2171@kindex target sim
2172Debug programs on a simulated CPU. If the simulator supports setup
2173options, specify them via @var{args}.
2174@end table
2175
2176@noindent
2177After specifying this target, you can debug programs for the simulated
2178CPU in the same style as programs for your host computer; use the
2179@code{file} command to load a new program image, the @code{run} command
2180to run your program, and so on.
2181
2182As well as making available all the usual machine registers (see
2183@code{info reg}), the Z8000 simulator provides three additional items
2184of information as specially named registers:
2185
2186@table @code
2187@item cycles
2188Counts clock-ticks in the simulator.
2189
2190@item insts
2191Counts instructions run in the simulator.
2192
2193@item time
2194Execution time in 60ths of a second.
2195@end table
2196
2197You can refer to these values in @value{GDBN} expressions with the usual
2198conventions; for example, @w{@samp{b fputc if $cycles>5000}} sets a
2199conditional breakpoint that suspends only after at least 5000
2200simulated clock ticks.
c906108c
SS
2201
2202@c need to add much more detail about sims!
This page took 0.128269 seconds and 4 git commands to generate.