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