Gdbserver: Difference between revisions

Content deleted Content added
SmackBot (talk | contribs)
m Date maintenance tags and general fixes: build 400:
Adding short description: "Remote debugging program"
 
(37 intermediate revisions by 27 users not shown)
Line 1:
{{Short description|Remote debugging program}}
{{Orphan|date=February 2010}}
{{lowercase|title=gdbserver}}
{{compu-prog-stub|date=February 2010}}
'''gdbserver''' is a computer program that allowsmakes it possible to remotely [[Debugging|debug]] other programs.<ref>[http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_130.html GDB Manual]</ref>. It runsRunning inon the same system withas the program to be debugged, andit allows the [[GNU Debugger]] to connect from aanother differentsystem; that is, only the executable to be debugged needs to be resident on the target system ("target"), while the source code and a copy of the binary file to be debugged reside on the developer's local computer ("host"). The connection can be either TCP or a serial line.
 
== How Itit Worksworks ==
'''gdbserver''' is a computer program that allows to remotely [[Debugging|debug]] other programs<ref>[http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_130.html GDB Manual]</ref>. It runs in the system with the program to be debugged and allows the [[GNU Debugger]] to connect from a different system.
# <code>gdbserver</code> is launched on the target system, with the arguments:
#* Either a device name (to use a serial line) or a TCP hostname and port number, and
#* The path and filename of the executable to be debugged
#:It then waits passively for the host gdb to communicate with it.
# <code>gdb</code> is run on the host, with the arguments:
#* The path and filename of the executable (and any sources) on the host, and
#* A device name (for a serial line) or the IP address and port number needed for connection to the target system.
 
Example for debugging a program in a remote host called <code>hello_world</code> on a remote target using TCP ("23452159" is the [[List of TCP and UDP port numbers#Registered ports|registered TCP port number for remote GDB]]):
It only needs the presence of the executable on the target, while the source code and a copy of the binary file stay in the computer used by the developer.
<syntaxhighlight lang="console">
 
remote@~$ gdbserver :23452159 hello_world
== How It Works ==
# <code>gdbserver</code> is launched on the target with the path and name of the executable to debug, and a port number (TCP or UDP). It listens for connections on the port.
# <code>gdb</code> is run on the host with the path and name of the executable (and the sources) on the host, and the IP address and port number to connect to the target.
 
Example for debugging a program in a remote host called <code>hello_world</code> ("2345" is the TCP port number):
<pre>
remote$ gdbserver :2345 hello_world
Process hello_world created; pid = 2509
Listening on port 23452159
</syntaxhighlight>
</pre>
 
<syntaxhighlight lang="console">
<pre>
local@~$ gdb -q hello_world
Reading symbols from /home/user/hello_world...done.
(gdb) target remote 192.168.0.11:23452159
Remote debugging using 192.168.0.11:23452159
0x002f3850 in ?? () from /lib/ld-linux.so.2
(gdb) continue
Line 30 ⟶ 32:
10 printf("x[%d] = %g\n", i, x[i]);
(gdb)
</syntaxhighlight>
</pre>
 
== Alternatives ==
A differentAnother technique to remotelyfor debugdebugging programs remotely is to use a ''remote stub''.<ref>[httphttps://davissourceware.lbl.govorg/Manualsgdb/GDBonlinedocs/gdb/gdb_17Remote-Stub.html#SEC140 Debugging with GDB]</ref>.{{Clarify|date=February 2010}} In this case, the program to be debugged is linked with a few special-purpose subroutines that implement the GDB remote serial protocol. The file containing these subroutines is called a "debugging stub".
 
The program to debug is linked with a few special-purpose subroutines that implement the GDB remote serial protocol. The file containing these subroutines is called a debugging stub.
 
== See also ==
Line 42:
 
== Notes ==
{{reflistReflist}}
 
== References ==
* Andreas Zeller: <cite>Why Programs Fail: A Guide to Systematic Debugging</cite>, Morgan Kaufmann, 2005. {{ISBN |1-55860-866-4}}
 
== External links ==
* [httphttps://www.gnu.org/software/gdb/ GDB homepage]
* [http://man-wiki.net/index.php/1:gdbserver gdbserver] [[man page]]
* [http://davis.lbl.gov/Manuals/GDB/gdb_17.html Debugging with GDB]
 
{{GNU}}
 
[[Category:Debugging| Debuggers]]
[[Category:GNU project software|DebuggerDebugging]]
[[Category:GNU Project software|Debugger]]
[[Category:Unix programming tools]]
 
 
[[fr:Gdbserver]]
{{compu-prog-stub|date=February 2010}}