@c -*- Texinfo -*-
@c Copyright (c) 1990 1991 1992 1993 Free Software Foundation, Inc.
@c This file is part of the source for the GDB manual.
-@c This text diverted to "Remote Debugging" section in general case;
-@c however, if we're doing a manual specifically for one of these, it
-@c belongs up front (in "Getting In and Out" chapter).
-@ifset REMOTESTUB
@node Remote Serial
@subsection The @value{GDBN} remote serial protocol
To debug a program running on another machine (the debugging
@dfn{target} machine), you must first arrange for all the usual
prerequisites for the program to run by itself. For example, for a C
-program, you need
+program, you need:
@enumerate
@item
implement the @value{GDBN} remote serial protocol. The file containing these
subroutines is called a @dfn{debugging stub}.
-@ifset GDBSERVER
On certain remote targets, you can use an auxiliary program
@code{gdbserver} instead of linking a stub into your program.
@xref{Server,,Using the @code{gdbserver} program}, for details.
-@end ifset
@end table
The debugging stub is specific to the architecture of the remote
These working remote stubs are distributed with @value{GDBN}:
@table @code
-@item sparc-stub.c
-@kindex sparc-stub.c
-For @sc{sparc} architectures.
+
+@item i386-stub.c
+@kindex i386-stub.c
+@cindex Intel
+@cindex i386
+For Intel 386 and compatible architectures.
@item m68k-stub.c
@kindex m68k-stub.c
@cindex m680x0
For Motorola 680x0 architectures.
-@item i386-stub.c
-@kindex i386-stub.c
-@cindex Intel
-@cindex i386
-For Intel 386 and compatible architectures.
+@item sh-stub.c
+@kindex sh-stub.c
+@cindex Hitachi
+@cindex SH
+For Hitachi SH architectures.
+
+@item sparc-stub.c
+@kindex sparc-stub.c
+@cindex Sparc
+For @sc{sparc} architectures.
+
+@item sparcl-stub.c
+@kindex sparcl-stub.c
+@cindex Fujitsu
+@cindex SparcLite
+For Fujitsu @sc{sparclite} architectures.
+
@end table
The @file{README} file in the @value{GDBN} distribution may list other
* Bootstrapping:: What you must do for the stub
* Debug Session:: Putting it all together
* Protocol:: Outline of the communication protocol
-@ifset GDBSERVER
* Server:: Using the `gdbserver' program
-@end ifset
+* NetWare:: Using the `gdbserve.nlm' program
@end menu
@node Stub Contents
For the 386, @var{exception_address} should be installed as an interrupt
gate so that interrupts are masked while the handler runs. The gate
should be at privilege level 0 (the most privileged level). The
-@sc{sparc} and 68k stubs are able to mask interrupts themself without
+@sc{sparc} and 68k stubs are able to mask interrupts themselves without
help from @code{exceptionHandler}.
@item void flush_i_cache()
@kindex flush_i_cache
-Write this subroutine to flush the instruction cache, if any, on your
-target machine. If there is no instruction cache, this subroutine may
-be a no-op.
+(sparc and sparclite only) Write this subroutine to flush the
+instruction cache, if any, on your target machine. If there is no
+instruction cache, this subroutine may be a no-op.
On target machines that have instruction caches, @value{GDBN} requires this
function to make certain that the state of your program is stable.
@item
For the 680x0 stub only, you need to provide a variable called
-@code{exceptionHook}. Normally you just use
+@code{exceptionHook}. Normally you just use:
@example
void (*exceptionHook)() = 0;
@item
Make sure you have a serial connection between your target machine and
-the @value{GDBN} host, and identify the serial port used for this on the host.
+the @value{GDBN} host, and identify the serial port on the host.
@item
@c The "remote" target now provides a `load' command, so we should
Command packets are distinguished by their first character, which
identifies the kind of command.
-These are the commands currently supported:
+These are some of the commands currently supported (for a complete list of
+commands, look in @file{gdb/remote.c.}):
@table @code
@item g
Report the most recent signal. To allow you to take advantage of the
@value{GDBN} signal handling commands, one of the functions of the debugging
stub is to report CPU traps as the corresponding POSIX signal values.
+
+@item T
+Allows the remote stub to send only the registers that @value{GDBN} needs
+to make a quick decision about single-stepping or conditional breakpoints.
+This eliminates the need to fetch the entire register set for each instruction
+being stepped through.
+
+@value{GDBN} now implements a write-through cache for registers and only
+re-reads the registers if the target has run.
@end table
@kindex set remotedebug
stream. @code{set remotedebug off} turns it off, and @code{show
remotedebug} shows you its current state.
-@ifset GDBSERVER
@node Server
@subsubsection Using the @code{gdbserver} program
text depends on the host system, but which usually looks something like
@samp{Connection refused}.
@end table
-@end ifset
-@end ifset
+@node NetWare
+@subsubsection Using the @code{gdbserve.nlm} program
+
+@kindex gdbserve.nlm
+@code{gdbserve.nlm} is a control program for NetWare systems, which
+allows you to connect your program with a remote @value{GDBN} via
+@code{target remote}.
+
+@value{GDBN} and @code{gdbserve.nlm} communicate via a serial line,
+using the standard @value{GDBN} remote serial protocol.
+
+@table @emph
+@item On the target machine,
+you need to have a copy of the program you want to debug.
+@code{gdbserve.nlm} does not need your program's symbol table, so you
+can strip the program if necessary to save space. @value{GDBN} on the
+host system does all the symbol handling.
+
+To use the server, you must tell it how to communicate with
+@value{GDBN}; the name of your program; and the arguments for your
+program. The syntax is:
+
+@smallexample
+load gdbserve [ BOARD=@var{board} ] [ PORT=@var{port} ]
+ [ BAUD=@var{baud} ] @var{program} [ @var{args} @dots{} ]
+@end smallexample
+
+@var{board} and @var{port} specify the serial line; @var{baud} specifies
+the baud rate used by the connection. @var{port} and @var{node} default
+to 0, @var{baud} defaults to 9600 bps.
+
+For example, to debug Emacs with the argument @samp{foo.txt}and
+communicate with @value{GDBN} over serial port number 2 or board 1
+using a 19200 bps connection:
+
+@smallexample
+load gdbserve BOARD=1 PORT=2 BAUD=19200 emacs foo.txt
+@end smallexample
+
+@item On the @value{GDBN} host machine,
+you need an unstripped copy of your program, since @value{GDBN} needs
+symbols and debugging information. Start up @value{GDBN} as usual,
+using the name of the local copy of your program as the first argument.
+(You may also need the @w{@samp{--baud}} option if the serial line is
+running at anything other than 9600 bps. After that, use @code{target
+remote} to establish communications with @code{gdbserve.nlm}. Its
+argument is a device name (usually a serial device, like
+@file{/dev/ttyb}). For example:
+
+@smallexample
+(@value{GDBP}) target remote /dev/ttyb
+@end smallexample
+
+@noindent
+communications with the server via serial line @file{/dev/ttyb}.
+@end table
-@ifset I960
@node i960-Nindy Remote
@subsection @value{GDBN} with a remote i960 (Nindy)
a break is detected.
@end table
@c @end group
-@end ifset
-@ifset AMD29K
@node UDI29K Remote
@subsection The UDI protocol for AMD29K
protocol for debugging the a29k processor family. To use this
configuration with AMD targets running the MiniMON monitor, you need the
program @code{MONTIP}, available from AMD at no charge. You can also
-use @value{GDBN} with the UDI conformant a29k simulator program
+use @value{GDBN} with the UDI-conformant a29k simulator program
@code{ISSTIP}, also available from AMD.
@table @code
you must match the communications parameters when establishing the Unix
end of the connection as well.
@c FIXME: Who knows what this "no retry action" crud from the DOS manual may
-@c mean? It's optional; leave it out? ---pesch@cygnus.com, 25feb91
+@c mean? It's optional; leave it out? ---doc@cygnus.com, 25feb91
To give control of the PC to the Unix side of the serial line, type
the following at the DOS console:
@c for character size. Taken from stty maybe...? John points out tip
@c can set these as internal variables, eg ~s parity=none; man stty
@c suggests that it *might* work to stty these options with stdin or
-@c stdout redirected... ---pesch@cygnus.com, 25feb91
+@c stdout redirected... ---doc@cygnus.com, 25feb91
@kindex EBMON
Using the @code{tip} or @code{cu} connection, change the DOS working
target amd-eb /dev/ttya 9600 MYFOO
@c FIXME: test above 'target amd-eb' as spelled, with caps! caps are meant to
@c emphasize that this is the name as seen by DOS (since I think DOS is
-@c single-minded about case of letters). ---pesch@cygnus.com, 25feb91
+@c single-minded about case of letters). ---doc@cygnus.com, 25feb91
@end example
@noindent
another window often helps to understand trouble with @code{EBMON}, or
unexpected events on the PC side of the connection.
-@end ifset
-
-@ifset ST2000
@node ST2000 Remote
@subsection @value{GDBN} with a Tandem ST2000
To connect your ST2000 to the host system, see the manufacturer's
-manual. Once the ST2000 is physically attached, you can run
+manual. Once the ST2000 is physically attached, you can run:
@example
target st2000 @var{dev} @var{speed}
@kbd{@key{RET}~.} (Return, followed by tilde and period) or
@kbd{@key{RET}~@key{C-d}} (Return, followed by tilde and control-D).
@end table
-@end ifset
-@ifset VXWORKS
@node VxWorks Remote
@subsection @value{GDBN} and VxWorks
+
@cindex VxWorks
@value{GDBN} enables developers to spawn and debug tasks running on networked
installed with the name @code{vxgdb}, to distinguish it from a
@value{GDBN} for debugging programs on the host itself.)
+@table @code
+@item VxWorks-timeout @var{args}
+@kindex vxworks-timeout
+All VxWorks-based targets now support the option @code{vxworks-timeout}.
+This option is set by the user, and @var{args} represents the number of
+seconds @value{GDBN} waits for responses to rpc's. You might use this if
+your VxWorks target is a slow software simulator or is on the far side
+of a thin network line.
+@end table
+
The following information on connecting to VxWorks was current when
this manual was produced; newer releases of VxWorks may use revised
procedures.
@example
-> cd "@var{vxpath}/vw/demo/rdb"
@end example
-
+v
Then, in @value{GDBN}, type:
@example
where @var{task} is the VxWorks hexadecimal task ID. The task can be running
or suspended when you attach to it. Running tasks are suspended at
the time of attachment.
-@end ifset
-@ifset H8
+@node Sparclet Remote
+@subsection @value{GDBN} and Sparclet
+@cindex Sparclet
+
+@value{GDBN} enables developers to debug tasks running on
+Sparclet targets from a Unix host.
+@value{GDBN} uses code that runs on
+both the Unix host and on the Sparclet target. The program
+@code{gdb} is installed and executed on the Unix host.
+
+@table @code
+@item timeout @var{args}
+@kindex remotetimeout
+@value{GDBN} now supports the option @code{remotetimeout}.
+This option is set by the user, and @var{args} represents the number of
+seconds @value{GDBN} waits for responses.
+@end table
+
+@kindex Compiling
+When compiling for debugging, include the options "-g" to get debug
+information and "-Ttext" to relocate the program to where you wish to
+load it on the target. You may also want to add the options "-n" or
+"-N" in order to reduce the size of the sections.
+
+@example
+sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N
+@end example
+
+You can use objdump to verify that the addresses are what you intended.
+
+@example
+sparclet-aout-objdump --headers --syms prog
+@end example
+
+@kindex Running
+Once you have set
+your Unix execution search path to find @value{GDBN}, you are ready to
+run @value{GDBN}. From your Unix host, run @code{gdb}
+(or @code{sparclet-aout-gdb}, depending on your installation).
+
+@value{GDBN} comes up showing the prompt:
+
+@example
+(gdbslet)
+@end example
+
+@menu
+* Sparclet File:: Setting the file to debug
+* Sparclet Connection:: Connecting to Sparclet
+* Sparclet Download:: Sparclet download
+* Sparclet Execution:: Running and debugging
+@end menu
+
+@node Sparclet File
+@subsubsection Setting file to debug
+
+The @value{GDBN} command @code{file} lets you choose with program to debug.
+
+@example
+(gdbslet) file prog
+@end example
+
+@need 1000
+@value{GDBN} then attempts to read the symbol table of @file{prog}.
+@value{GDBN} locates
+the file by searching the directories listed in the command search
+path.
+If the file was compiled with debug information (option "-g"), source
+files will be searched as well.
+@value{GDBN} locates
+the source files by searching the directories listed in the directory search
+path (@pxref{Environment, ,Your program's environment}).
+If it fails
+to find a file, it displays a message such as:
+
+@example
+prog: No such file or directory.
+@end example
+
+When this happens, add the appropriate directories to the search paths with
+the @value{GDBN} commands @code{path} and @code{dir}, and execute the
+@code{target} command again.
+
+@node Sparclet Connection
+@subsubsection Connecting to Sparclet
+
+The @value{GDBN} command @code{target} lets you connect to a Sparclet target.
+To connect to a target on serial port ``@code{ttya}'', type:
+
+@example
+(gdbslet) target sparclet /dev/ttya
+Remote target sparclet connected to /dev/ttya
+main () at ../prog.c:3
+@end example
+
+@need 750
+@value{GDBN} displays messages like these:
+
+@smallexample
+Connected to ttya.
+@end smallexample
+
+@node Sparclet Download
+@subsubsection Sparclet download
+
+@cindex download to Sparclet
+Once connected to the Sparclet target,
+you can use the @value{GDBN}
+@code{load} command to download the file from the host to the target.
+The file name and load offset should be given as arguments to the @code{load}
+command.
+Since the file format is aout, the program must be loaded to the starting
+address. You can use objdump to find out what this value is. The load
+offset is an offset which is added to the VMA (virtual memory address)
+of each of the file's sections.
+For instance, if the program
+@file{prog} was linked to text address 0x1201000, with data at 0x12010160
+and bss at 0x12010170, in @value{GDBN}, type:
+
+@example
+(gdbslet) load prog 0x12010000
+Loading section .text, size 0xdb0 vma 0x12010000
+@end example
+
+If the code is loaded at a different address then what the program was linked
+to, you may need to use the @code{section} and @code{add-symbol-file} commands
+to tell @value{GDBN} where to map the symbol table.
+
+@node Sparclet Execution
+@subsubsection Running and debugging
+
+@cindex running and debugging Sparclet programs
+You can now begin debugging the task using @value{GDBN}'s execution control
+commands, @code{b}, @code{step}, @code{run}, etc. See the @value{GDBN}
+manual for the list of commands.
+
+@example
+(gdbslet) b main
+Breakpoint 1 at 0x12010000: file prog.c, line 3.
+(gdbslet) run
+Starting program: prog
+Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3
+3 char *symarg = 0;
+(gdbslet) step
+4 char *execarg = "hello!";
+(gdbslet)
+@end example
+
@node Hitachi Remote
@subsection @value{GDBN} and Hitachi microprocessors
@value{GDBN} needs to know these things to talk to your
what serial device connects your host to your Hitachi board (the first
serial device available on your host is the default).
-@ifclear H8EXCLUSIVE
-@c this is only for Unix hosts, not of interest to Hitachi
@item
what speed to use over the serial device.
-@end ifclear
@end enumerate
@menu
-* Hitachi Boards:: Connecting to Hitachi boards
-* Hitachi ICE:: Using the E7000 In-Circuit Emulator
-* H8500 Special:: Special @value{GDBN} commands for the H8/500
+* Hitachi Boards:: Connecting to Hitachi boards.
+* Hitachi ICE:: Using the E7000 In-Circuit Emulator.
+* Hitachi Special:: Special @value{GDBN} commands for Hitachi micros.
@end menu
@node Hitachi Boards
@subsubsection Connecting to Hitachi boards
-@ifclear H8EXCLUSIVE
@c only for Unix hosts
@kindex device
@cindex serial device, Hitachi micros
The @samp{device} and @samp{speed} commands are available only when you
use a Unix host to debug your Hitachi microprocessor programs. If you
use a DOS host,
-@end ifclear
@value{GDBN} depends on an auxiliary terminate-and-stay-resident program
called @code{asynctsr} to communicate with the development board
through a PC serial port. You must also use the DOS @code{mode} command
to set up the serial port on the DOS side.
-@ifset DOSHOST
The following sample session illustrates the steps needed to start a
program under @value{GDBN} control on an H8/300. The example uses a
sample H8/300 program called @file{t.x}. The procedure is the same for
@code{COM2}.
@example
-(eg-C:\H8300\TEST) mode com2:9600,n,8,1,p
+C:\H8300\TEST> asynctsr 2
+C:\H8300\TEST> mode com2:9600,n,8,1,p
Resident portion of MODE loaded
COM2: 9600, n, 8, 1, p
-(eg-C:\H8300\TEST) asynctsr 2
@end example
@quotation
@code{big}, @code{medium}, and @code{compact}.
@end table
-@end ifset
-@end ifset
-
-@ifset MIPS
@node MIPS Remote
@subsection @value{GDBN} and remote MIPS boards
connection (for instance, to a serial line managed by a terminal
concentrator) instead of a serial port, using the syntax
@samp{@var{hostname}:@var{portnumber}}.
+
+@item target pmon @var{port}
+@kindex target pmon @var{port}
+
+@item target ddb @var{port}
+@kindex target ddb @var{port}
+
+@item target lsi @var{port}
+@kindex target lsi @var{port}
+
@end table
+
@noindent
@value{GDBN} also supports these special commands for MIPS targets:
@table @code
-@item set mipsfpu off
+@item set processor @var{args}
+@itemx show processor
+@kindex set processor @var{args}
+@kindex show processor
+Use the @code{set processor} command to set the type of MIPS
+processor when you want to access processor-type-specific registers.
+For example, @code{set processor @var{r3041}} tells @value{GDBN}
+to use the CPO registers appropriate for the 3041 chip.
+Use the @code{show processor} command to see what MIPS processor @value{GDBN}
+is using. Use the @code{info reg} command to see what registers
+@value{GDBN} is using.
+
+@item set mipsfpu double
+@itemx set mipsfpu single
+@itemx set mipsfpu none
@itemx show mipsfpu
-@kindex set mipsfpu off
+@kindex set mipsfpu
@kindex show mipsfpu
@cindex MIPS remote floating point
@cindex floating point, MIPS remote
If your target board does not support the MIPS floating point
-coprocessor, you should use the command @samp{set mipsfpu off} (if you
+coprocessor, you should use the command @samp{set mipsfpu none} (if you
need this, you may wish to put the command in your @value{GDBINIT}
file). This tells @value{GDBN} how to find the return value of
functions which return floating point values. It also allows
@value{GDBN} to avoid saving the floating point registers when calling
-functions on the board. (As usual, you can inquire about the
-@code{mipsfpu} variable with @samp{show mipsfpu}.)
+functions on the board. If you are using a floating point coprocessor
+with only single precision floating point support, as on the @sc{r4650}
+processor, use the command @samp{set mipsfpu single}. The default
+double precision floating point coprocessor may be selected using
+@samp{set mipsfpu double}.
+
+In previous versions the only choices were double precision or no
+floating point, so @samp{set mipsfpu on} will select double precision
+and @samp{set mipsfpu off} will select no floating point.
+
+As usual, you can inquire about the @code{mipsfpu} variable with
+@samp{show mipsfpu}.
@item set remotedebug @var{n}
@itemx show remotedebug
You can inspect both values with @code{show timeout} and @code{show
retransmit-timeout}. (These commands are @emph{only} available when
@value{GDBN} is configured for @samp{--target=mips-idt-ecoff}.)
+
+The timeout set by @code{set timeout} does not apply when @value{GDBN}
+is waiting for your program to stop. In that case, @value{GDBN} waits
+forever because it has no way of knowing how long the program is going
+to run before stopping.
@end table
-@end ifset
-@ifset SIMS
@node Simulator
@subsection Simulated CPU target
-@ifset GENERIC
@cindex simulator
@cindex simulator, Z8000
@cindex Z8000 simulator
@cindex Hitachi SH simulator
@cindex CPU simulator
For some configurations, @value{GDBN} includes a CPU simulator that you
-can use instead of a hardware CPU to debug your programs. Currently,
-a simulator is available when @value{GDBN} is configured to debug Zilog
-Z8000 or Hitachi microprocessor targets.
-@end ifset
+can use instead of a hardware CPU to debug your programs.
+Currently, simulators are available for ARM, D10V, D30V, FR30, H8/300,
+H8/500, i960, M32R, MIPS, MN10200, MN10300, PowerPC, SH, Sparc, V850,
+W65, and Z8000.
-@ifclear GENERIC
-@ifset H8
-@cindex simulator, H8/300 or H8/500
-@cindex Hitachi H8/300 or H8/500 simulator
-@cindex simulator, Hitachi SH
-@cindex Hitachi SH simulator
-When configured for debugging Hitachi microprocessor targets,
-@value{GDBN} includes a CPU simulator for the target chip (a Hitachi SH,
-H8/300, or H8/500).
-@end ifset
-
-@ifset Z8K
@cindex simulator, Z8000
@cindex Zilog Z8000 simulator
When configured for debugging Zilog Z8000 targets, @value{GDBN} includes
a Z8000 simulator.
-@end ifset
-@end ifclear
-@ifset Z8K
For the Z8000 family, @samp{target sim} simulates either the Z8002 (the
unsegmented variant of the Z8000 architecture) or the Z8001 (the
segmented variant). The simulator recognizes which architecture is
appropriate by inspecting the object code.
-@end ifset
@table @code
-@item target sim
+@item target sim @var{args}
@kindex sim
@kindex target sim
-Debug programs on a simulated CPU
-@ifset GENERIC
-(which CPU depends on the @value{GDBN} configuration)
-@end ifset
+Debug programs on a simulated CPU. If the simulator supports setup
+options, specify them via @var{args}.
@end table
@noindent
to run your program, and so on.
As well as making available all the usual machine registers (see
-@code{info reg}), this debugging target provides three additional items
+@code{info reg}), the Z8000 simulator provides three additional items
of information as specially named registers:
@table @code
conventions; for example, @w{@samp{b fputc if $cycles>5000}} sets a
conditional breakpoint that suspends only after at least 5000
simulated clock ticks.
-@end ifset
+
+@c need to add much more detail about sims!