Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load shared libraries symbols for remote source level debugging with gdb and gdbserver?

I've installed gdb and gdbserver on an angstrom linux ARM board (with external access), and am trying to get source level debugging of a shared library working from my local machine. Currently, if I ssh into the device, I can run gdb and I am able to get everything working, including setting a breakpoint, hitting it and doing a backtrace.

My problem comes when I try and do the same using gdbserver and running gdb on my host machine in order to accomplish the same thing (eventually I'd like to get this working in eclipse, but in gdb is good enough for the moment).

I notice that when I just use gdb on the server and run "info shared", it correctly loads symbol files (syms read : yes for all), which I'm then able to debug. I've had no such luck doing so remotely, using "symbol-file" or "directory" or "shared". Its obviously seeing the files, but I can't get it load any symbols, even when I specify remote files directly. Any advice on what I can try next?

like image 660
Joe Avatar asked Oct 01 '22 01:10

Joe


1 Answers

There are a few different ways for this to fail, but the typical one is for gdb to pick up local files rather than files from the server.

There are also a few different ways to fix this, but the simplest by far is to do this before invoking target remote:

(gdb) set sysroot remote:

This tells gdb to fetch files from the remote system. If you have debug info there (which I gather from your post that you do), then it will all work fine.

The typical problem with this approach is that it requires copying data from the remote. This can be a pain if you have a bad link. In this case you can keep a copy of the data locally and point sysroot at the copy. However, this requires some attention to keeping things in sync.

like image 129
Tom Tromey Avatar answered Oct 19 '22 22:10

Tom Tromey