Standard preamble:
========================================================================
..
.... Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.
If the F register is turned on, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.
Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF
Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================
Title "GDBSERVER 1"
way too many mistakes in technical documents.
gdbserver --attach comm pid
gdbserver --multi comm
Usage (server (target) side):
First, you need to have a copy of the program you want to debug put onto the target system. The program can be stripped to save space if needed, as \fBgdbserver doesn't care about symbols. All symbol handling is taken care of by the \s-1GDB\s0 running on the host system.
To use the server, you log on to the target system, and run the gdbserver program. You must tell it (a) how to communicate with \s-1GDB, \s0(b) the name of your program, and (c) its arguments. The general syntax is:
.Vb 1 target> gdbserver <comm> <program> [<args> ...] .Ve
For example, using a serial port, you might say:
.Vb 1 target> gdbserver /dev/com1 emacs foo.txt .Ve
This tells gdbserver to debug emacs with an argument of foo.txt, and to communicate with \s-1GDB\s0 via /dev/com1. gdbserver now waits patiently for the host \s-1GDB\s0 to communicate with it.
To use a \s-1TCP\s0 connection, you could say:
.Vb 1 target> gdbserver host:2345 emacs foo.txt .Ve
This says pretty much the same thing as the last example, except that we are going to communicate with the \*(C`host\*(C' \s-1GDB\s0 via \s-1TCP. \s0 The \*(C`host:2345\*(C' argument means that we are expecting to see a \s-1TCP\s0 connection from \*(C`host\*(C' to local \s-1TCP\s0 port 2345. (Currently, the \*(C`host\*(C' part is ignored.) You can choose any number you want for the port number as long as it does not conflict with any existing \s-1TCP\s0 ports on the target system. This same port number must be used in the host GDBs \*(C`target remote\*(C' command, which will be described shortly. Note that if you chose a port number that conflicts with another service, gdbserver will print an error message and exit.
\fBgdbserver can also attach to running programs. This is accomplished via the --attach argument. The syntax is:
.Vb 1 target> gdbserver --attach <comm> <pid> .Ve
\fIpid is the process \s-1ID\s0 of a currently running process. It isn't necessary to point gdbserver at a binary for the running process.
To start \*(C`gdbserver\*(C' without supplying an initial command to run or process \s-1ID\s0 to attach, use the --multi command line option. In such case you should connect using \*(C`target extended-remote\*(C' to start the program you want to debug.
.Vb 1 target> gdbserver --multi <comm> .Ve
Usage (host side):
You need an unstripped copy of the target program on your host system, since \s-1GDB\s0 needs to examine it's symbol tables and such. Start up \s-1GDB\s0 as you normally would, with the target program as the first argument. (You may need to use the \fB--baud option if the serial line is running at anything except 9600 baud.) That is \*(C`gdb TARGET-PROG\*(C', or \*(C`gdb --baud BAUD TARGET-PROG\*(C'. After that, the only new command you need to know about is \*(C`target remote\*(C' (or \*(C`target extended-remote\*(C'). Its argument is either a device name (usually a serial device, like /dev/ttyb), or a \*(C`HOST:PORT\*(C' descriptor. For example:
.Vb 1 (gdb) target remote /dev/ttyb .Ve
communicates with the server via serial line /dev/ttyb, and:
.Vb 1 (gdb) target remote the-target:2345 .Ve
communicates via a \s-1TCP\s0 connection to port 2345 on host `the-target', where you previously started up gdbserver with the same port number. Note that for \s-1TCP\s0 connections, you must start up gdbserver prior to using the `target remote' command, otherwise you may get an error that looks something like `Connection refused'.
\fBgdbserver can also debug multiple inferiors at once, described in the \s-1GDB\s0 manual in node \*(C`Inferiors and Programs\*(C' \*(-- shell command \*(C`info -f gdb -n \*(AqInferiors and Programs\*(Aq\*(C'. In such case use the \*(C`extended-remote\*(C' \s-1GDB\s0 command variant:
.Vb 1 (gdb) target extended-remote the-target:2345 .Ve
The gdbserver option --multi may or may not be used in such case.
In each of the modes you may specify these options:
.Vb 1 info gdb .Ve
should give you access to the complete manual.
\fIUsing \s-1GDB: A\s0 Guide to the \s-1GNU\s0 Source-Level Debugger, Richard M. Stallman and Roland H. Pesch, July 1991.
Permission is granted to copy, distribute and/or modify this document under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being \*(L"Free Software\*(R" and \*(L"Free Software Needs Free Documentation\*(R", with the Front-Cover Texts being \*(L"A \s-1GNU\s0 Manual,\*(R" and with the Back-Cover Texts as in (a) below.
(a) The \s-1FSF\s0's Back-Cover Text is: \*(L"You are free to copy and modify this \s-1GNU\s0 Manual. Buying copies from \s-1GNU\s0 Press supports the \s-1FSF\s0 in developing \s-1GNU\s0 and promoting software freedom.\*(R"