tags:

views:

93

answers:

2

I've just spent a whole day trying to find a way to enable gdb debugging from QtCreater or Eclipse. I learned that there are basically two approaches to launch the target application:

  • using ssh (ssh host gdb)
  • using gdbserver

I was able to use both approaches to launch gdb remotely and start the application. However, GDB never reponds to any breakpoints set in the IDE. Also I can't pause the application to inspect the program state. In QtCreator I just get an obscure stack trace (I might have been looking at the traces of ssh or gdb actually...).

Can anyone help me to get started?

Progress!

I found that with QtCreater 2.0 there is an feature called "Attach and debug remote appliction." It's based on gdbserver. The good thing is that it stops on the IDE's breakpoints. However there are two issues:

  • when it hits a breakpoint it only shows assembly code, not the source code
  • gdb often quits because of 'signal received'

I should probably mention that the remote executable is compiled with an older version of gcc than the one installed on my local PC. Perhaps some of the problems are related to this.

+1  A: 

So that gdb on your host (the machine you develop and compile on, so where you have QtCreator) you have to give it access to the "symbol file".

I usually don't use QtCreator, but gdb and gdbserver directly for cross-compiled programs remote-debugging. You could maybe give this a try to be sure that this works for you and maybe then find the missing option in QtCreator (or maybe this will help you find what is missing).

On the target machine run: gdbserver :5000 yourprogram

On the host machine, run gdb and then load the symbol file: (gdb) symbol-file yourprogram

On gdb on the host machine, you then have to connect to connect gdb to the remote gdbserver: (gdb) target remote target_ip_address:5000. From then you can use gdb on the host controlling the program on the target.

I hope this helps !

Longfield
One of the parameters that I have to pass to QtCreator is a local copy of the executable. Am I right in thinking that it will have the symbols embedded when compiled with debugging options (-ggdb)?
StackedCrooked
Yes the debug symbols should be included with the -ggdb option. I usually use the -g option that is general, but -ggdb seems even better (it produces additional debug info for use with gdb).Could it be that you don't have the debug version of the libraries installed on your target ?
Longfield
A: 

Due to peculiarities in our makefile buildsystem the file references contained in the debugging symbols look like this:

../src/main.cpp
../../src/utils/logger.cpp

This is no problem for gdb, but QtCreator was unable to map these paths to the actual files. I was able to fix this by adding 'dir' statements in the gdb init file:

dir src
dir src/utils
...

Now it works.

StackedCrooked