Tuesday, 13 February 2007

yet another disguised rant or how you won't run GDB remotely

I tried for the whole day to understand how I can debug remotely an application in a qemu machine.

Why would I want that?
  • I need to debug the i386 variant
  • I don't want to screw up my system
  • I need a large display since the program uses some big data structures and need to see them at the same time (no, pretty print is not enough)
  • actually I would like to use DDD or something like that so I don't feel (that much) like a cripple man (I always had this feeling when facing the task of using gdb - powerful but feels incredibly like a huge hack and the interface is planly ugly from an usability POV)
  • cgdb is not enough and has a marginal gain compared to plain gdb (and you loose tab completion)
  • I wasn't planning on installing X in the qemu machine
The closest I could get was to start by hand qemu with the guest qemu serial port set on a tcp socket, start gdbserver on (guest) /dev/ttyS0 and try to start gdb remotely on that socket opened by qemu. This resulted, as expected in some errors...

Now, after reading all kinds of threads on the net, reading qemu's docs and gdb's docs, I gave up, I am installing X in the qemu machine.

BTW, I couldn't find a way to tell DDD to connect to a socket to debug :-/.


Of course, any help and advices would be mostly appreciated.

2 comments:

Daniel Jacobowitz said...

Oh, c'mon, this is easy :-) Of course, it's harder to help you since you didn't say what errors...

Avoid using serial ports; TCP works better, and in particular gdbserver is broken on serial in unstable at the moment (fixed upstream). Tell qemu to forward a TCP port to your guest. Run gdbserver on that port "gdbserver :PORT ./program". Then, from outside the guest, run "gdb ./program" and "target remote :FORWARDEDPORT".

You tell DDD to connect to a socket by typing the same command at DDD's GDB console.

If you found the manual unclear, please, post to the GDB mailing list saying what you looked for and had trouble finding. Otherwise we can't fix it.

Anonymous said...

CGDB supports tab completion perfectly fine. You are probably using an old version.