| 1 | .\" Copyright (C) 1993, 2011 Free Software Foundation, Inc. |
| 2 | .\" See section COPYING for conditions for redistribution |
| 3 | .TH gdbserver 1 "2 November 1993" "Cygnus Support" "GNU Development Tools" |
| 4 | .SH NAME |
| 5 | gdbserver \- Remote Server for the GNU Debugger |
| 6 | .SH SYNOPSIS |
| 7 | .na |
| 8 | .TP |
| 9 | .B gdbserver |
| 10 | .RB tty |
| 11 | .RB prog |
| 12 | .RB "[\|" args... "\|]" |
| 13 | .PP |
| 14 | .B gdbserver |
| 15 | .RB tty |
| 16 | .B --attach |
| 17 | .RB PID |
| 18 | .ad b |
| 19 | .SH DESCRIPTION |
| 20 | GDBSERVER is a program that allows you to run GDB on a different machine |
| 21 | than the one which is running the program being debugged. |
| 22 | |
| 23 | Usage (server (target) side): |
| 24 | |
| 25 | First, you need to have a copy of the program you want to debug put onto |
| 26 | the target system. The program can be stripped to save space if needed, as |
| 27 | GDBserver doesn't care about symbols. All symbol handling is taken care of by |
| 28 | the GDB running on the host system. |
| 29 | |
| 30 | To use the server, you log on to the target system, and run the `gdbserver' |
| 31 | program. You must tell it (a) how to communicate with GDB, (b) the name of |
| 32 | your program, and (c) its arguments. The general syntax is: |
| 33 | |
| 34 | target> gdbserver COMM PROGRAM [ARGS ...] |
| 35 | |
| 36 | For example, using a serial port, you might say: |
| 37 | |
| 38 | target> gdbserver /dev/com1 emacs foo.txt |
| 39 | |
| 40 | This tells gdbserver to debug emacs with an argument of foo.txt, and to |
| 41 | communicate with GDB via /dev/com1. Gdbserver now waits patiently for the |
| 42 | host GDB to communicate with it. |
| 43 | |
| 44 | To use a TCP connection, you could say: |
| 45 | |
| 46 | target> gdbserver host:2345 emacs foo.txt |
| 47 | |
| 48 | This says pretty much the same thing as the last example, except that we are |
| 49 | going to communicate with the host GDB via TCP. The `host:2345' argument means |
| 50 | that we are expecting to see a TCP connection from `host' to local TCP port |
| 51 | 2345. (Currently, the `host' part is ignored.) You can choose any number you |
| 52 | want for the port number as long as it does not conflict with any existing TCP |
| 53 | ports on the target system. This same port number must be used in the host |
| 54 | GDBs `target remote' command, which will be described shortly. Note that if |
| 55 | you chose a port number that conflicts with another service, gdbserver will |
| 56 | print an error message and exit. |
| 57 | |
| 58 | On some targets, gdbserver can also attach to running programs. |
| 59 | This is accomplished via the --attach argument. The syntax is: |
| 60 | |
| 61 | target> gdbserver COMM --attach PID |
| 62 | |
| 63 | PID is the process ID of a currently running process. It isn't |
| 64 | necessary to point gdbserver at a binary for the running process. |
| 65 | |
| 66 | Usage (host side): |
| 67 | |
| 68 | You need an unstripped copy of the target program on your host system, since |
| 69 | GDB needs to examine it's symbol tables and such. Start up GDB as you normally |
| 70 | would, with the target program as the first argument. (You may need to use the |
| 71 | --baud option if the serial line is running at anything except 9600 baud.) |
| 72 | Ie: `gdb TARGET-PROG', or `gdb --baud BAUD TARGET-PROG'. After that, the only |
| 73 | new command you need to know about is `target remote'. It's argument is either |
| 74 | a device name (usually a serial device, like `/dev/ttyb'), or a HOST:PORT |
| 75 | descriptor. For example: |
| 76 | |
| 77 | (gdb) target remote /dev/ttyb |
| 78 | |
| 79 | communicates with the server via serial line /dev/ttyb, and: |
| 80 | |
| 81 | (gdb) target remote the-target:2345 |
| 82 | |
| 83 | communicates via a TCP connection to port 2345 on host `the-target', where |
| 84 | you previously started up gdbserver with the same port number. Note that for |
| 85 | TCP connections, you must start up gdbserver prior to using the `target remote' |
| 86 | command, otherwise you may get an error that looks something like |
| 87 | `Connection refused'. |
| 88 | .SH OPTIONS |
| 89 | You have to supply the name of the program to debug |
| 90 | and the tty to communicate on; the remote GDB will do everything else. |
| 91 | Any remaining arguments will be passed to the program verbatim. |
| 92 | .SH "SEE ALSO" |
| 93 | .RB "`\|" gdb "\|'" |
| 94 | entry in |
| 95 | .B info\c |
| 96 | \&; |
| 97 | .I |
| 98 | Using GDB: A Guide to the GNU Source-Level Debugger\c |
| 99 | , Richard M. Stallman and Roland H. Pesch, July 1991. |
| 100 | .SH COPYING |
| 101 | Copyright (c) 1993 Free Software Foundation, Inc. |
| 102 | .PP |
| 103 | Permission is granted to make and distribute verbatim copies of |
| 104 | this manual provided the copyright notice and this permission notice |
| 105 | are preserved on all copies. |
| 106 | .PP |
| 107 | Permission is granted to copy and distribute modified versions of this |
| 108 | manual under the conditions for verbatim copying, provided that the |
| 109 | entire resulting derived work is distributed under the terms of a |
| 110 | permission notice identical to this one. |
| 111 | .PP |
| 112 | Permission is granted to copy and distribute translations of this |
| 113 | manual into another language, under the above conditions for modified |
| 114 | versions, except that this permission notice may be included in |
| 115 | translations approved by the Free Software Foundation instead of in |
| 116 | the original English. |