Difference between revisions of "Remote debugging"
Line 7: | Line 7: | ||
There are some prerequisites: | There are some prerequisites: | ||
− | * There shall be opened a port for connecting on the target, if a firewall is installed on | + | * There shall be opened a port for connecting on the target, if a firewall is installed on the target |
* The source shall be available on the debugging host | * The source shall be available on the debugging host | ||
* The gdbserver shall be included on the target system (use make menuconfig) | * The gdbserver shall be included on the target system (use make menuconfig) | ||
Line 24: | Line 24: | ||
</source> | </source> | ||
− | Remember to look options on the man page! | + | Remember to look up options on the man page! |
==On the devhost== | ==On the devhost== |
Revision as of 09:02, 17 November 2013
Debugging on a tiny target system may be impossible, because there are no room for the gdb and all the source and binary files on the target system. Luckily remote debugging is available.
There are two (at least) options: DDD or Eclipse.
DDD is a gui for gdb, the GNU debugger. DDD might be available in Cygwin, I don't know. But it is available in all decent Linux distributions.
There are some prerequisites:
- There shall be opened a port for connecting on the target, if a firewall is installed on the target
- The source shall be available on the debugging host
- The gdbserver shall be included on the target system (use make menuconfig)
When the code has been compiled and transferred to the target host start the remote gdbserver on the target:
Contents
gdbserver
]$ gdbserver <host-to-expect-connection-from>:<port-number> <programme>
example:
]$ gdbserver 10.1.18.73:11000 myprogram
Remember to look up options on the man page!
On the devhost
Fire up your debugging environment, i.e. DDD or Eclipse.
DDD
Now on the debugging host start DDD. In the command window below type in:
target extended-remote <target-host>:<port-number> <programme>
example:
(gdb) target 10.1.18.210:11000 myprogram
In the console where you've started the gdbserver you should now see that a remote debugger has connected.
Remote debugging from host 10.1.18.73
Next open the executable in the DDD using the file command:
file <path-to-executable>/<executable>
example:
file myprogram
The source shall open in the upper window.
Set a breakpoint either by continuously right-click on the line you want the breakpoint or by typing
break <path-to-source>/<source-file>:<line-number>
example:
break ../main.cpp:14
Now run the program using the small window with the Run, Interrupt, Step,... buttons or typing run in the lower window.
You can single step by clicking on the Step button or by typing step in the lower window.
Try the different possibilities - its almost like using the built-in debugger in Eclipse (which by the way is also gdb :-) ).
Eclipse
In order to setup Eclipse as a debug station follow these instructions:
First setup the debug configuration as shown.
In the debugger tab choose gdbserver debugger.
Finally set-up the communication in the Connection tab.