Gdbserver: Difference between revisions

Content deleted Content added
Accessory (talk | contribs)
No edit summary
Adding short description: "Remote debugging program"
 
(25 intermediate revisions by 19 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 makes 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> Running on the same system as the program to be debugged, it allows the [[GNU Debugger]] to connect from another system; 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’sdeveloper's local computer ("host"). The connection can be either TCP or a serial line.
 
'''gdbserver''' is a computer program that makes 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> Running on the same system as the program to be debugged, it allows the [[GNU Debugger]] to connect from another system; that is, only the executable to be debugged needs to be resident on the target system, while the source code and a copy of the binary file to be debugged reside on the developer’s local computer. The connection can be either TCP or a serial line.
 
== How it works ==
# <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 portnumberport number, and
#* The path and filename of the executable to be debugged
#:It then waits passively for the host gdb to communicate with it.
Line 13 ⟶ 12:
#* 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 called <code>hello_world</code> on a remote hosttarget using TCP ("23452159" is the [[List of TCP and UDP port numbers#Registered ports|registered TCP port number for remote GDB]]):
<syntaxhighlight lang="console">
<pre>
remote@~$ gdbserver :23452159 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 33 ⟶ 32:
10 printf("x[%d] = %g\n", i, x[i]);
(gdb)
</syntaxhighlight>
</pre>
 
== Alternatives ==
Another technique for debugging programs remotely is to use a ''remote stub''.<ref>[httphttps://davissourceware.lbl.govorg/Manualsgdb/GDBonlinedocs/gdb_17gdb/Remote-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".
 
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.
 
== See also ==
Line 48 ⟶ 45:
 
== 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]
 
Line 62 ⟶ 58:
[[Category:Unix programming tools]]
 
 
[[fr:Gdbserver]]
{{compu-prog-stub|date=February 2010}}