Remote Debugging with GDB
As Linux becomes more popular with embedded system developers, it's
becoming increasingly important for gdb to be able to do remote debugging
of an embedded Linux target. Fortunately, as of version 5.3, gdb includes a
gdbserver that works even for multithreaded programs.
This feature was
added on 11 June 2002 by Daniel Jacobowitz.
I have tested this feature on x86 and ppc405 linux, and it works --
from an x86 Debian system, I successfully debugged multithreaded programs
running on remote x86 and ppc405 Linux boxes.
the approximate recipe I use to build a newer gdb for ppc405 on top of
Hard Hat 2.0. This recipe makes use of the
option I added to gdb's configure in July 2002.
There are a few gotchas:
Hats off to Daniel Jacobowitz of Montavista Software for getting this
feature in, and for his active support of gdb on the gdb mailing list.
- When you start gdb and attach to a remote gdbserver, you must 'continue' rather than 'run', as the program
is already started.
- It's ok to run a stripped binary on the remote system as long as
you keep the unstripped binary around for use by gdb on the local system.
This is pretty important, since unstripped binaries compiled with -g can
be too big to fit on some embedded devices.
- When cross-debugging (i.e. when the remote system is running
a different OS or on a different processor type), you may have to
set the path gdb uses to find shared libraries when you start gdb,
or it will fail with strange errors.
The GDB manual is silent on this important topic; Daniel Jacobowitz
told me about it, and I also found some doc
about it at Axis Communications.
My recipe takes care of this for my environment, but you may need
to futz around a bit with this if gdb acts insane on startup.
Related Web Pages
Last update: 4 Sept 2002
Copyright 2002 Dan Kegel
[Back to www.kegel.com]