Difference between revisions of "Remote debugging"

From Klaus' wiki
Jump to: navigation, search
(gdbserver)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
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.
 
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 options: DDD or Eclipse.
+
There are two (at least) options: DDD or Eclipse.
 
+
===DDD===
+
  
 
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.
 
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.
Line 9: 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 it
+
* 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 15: Line 13:
 
When the code has been compiled and transferred to the target host start the remote gdbserver on the target:
 
When the code has been compiled and transferred to the target host start the remote gdbserver on the target:
  
 +
===gdbserver===
 
<source lang="bash">
 
<source lang="bash">
]$ gdbserver <host-to-expect-connection-from>:<port-number> <programme>
+
]$ gdbserver <host-to-expect-connection-from>:<port-number> <program>
 
</source>
 
</source>
  
Line 24: Line 23:
 
]$ gdbserver 10.1.18.73:11000 myprogram
 
]$ gdbserver 10.1.18.73:11000 myprogram
 
</source>
 
</source>
 +
 +
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:
 
Now on the debugging host start DDD. In the command window below type in:

Latest revision as of 11:53, 5 October 2014

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:

gdbserver

]$ gdbserver <host-to-expect-connection-from>:<port-number> <program>

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.

Ddd debugging.png

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.

Gdbserver debugging1.png

In the debugger tab choose gdbserver debugger.

Gdbserver debugging2.png

Finally set-up the communication in the Connection tab.

Gdbserver debugging3.png