1

This is wrt Ubuntu setup.

In short, if I use command "objcopy --add-gnu-debuglink=/mntsymbols/binsymbol/prog.debug prog" it does not work and while doing gdb, symbols are not found. gdb gets symbols only if prog.debug is in same folder as prog. Things work after I do gdb> symbol-file /mntsymbols/binsymbol/prog.debug

/mntsymbols is mounted folder from remote machine. prog is stripped binary. prog.debug is debug symbol file for prog created using "objcopy --only-keep-debug".

I am trying to setup a gdb symbol server for a simple test program. sys1 is gdb symbol server. Will keep symbol files as sys1:/root/symboldir/testp1symbols/prog.debug sys1:/root/symboldir/testp1symbols/shared1.so.debug

Will mount sys1:/root/symboldir/ on sys2, and I should be able debug using gdb on sys2. how to achieve this using --add-gnu-debuglink or any other way.

devdebug
  • 93
  • 1
  • 5
  • Have you tried this [answer](http://stackoverflow.com/a/15556670/7561577)? – login_not_failed May 17 '17 at 15:31
  • 1
    As per this answer it is recommending to bring remote file to local and then use it. where as I specifically want to use remote debug symbol file. Also file command allows to load only one symbol file. where as a program in general can require more than one symbol file if it used shared(so) files. – devdebug May 18 '17 at 10:52
  • Also, In my case mounting remote directory (that contained symbol files) did not help. – devdebug May 18 '17 at 12:11
  • I use `set solib-search-path /path/to/the/shared/libs` – Juan Gonzalez Burgos May 27 '21 at 10:27

1 Answers1

4

Documentation.

You should use --add-gnu-debuglink=prog.debug and set debug-file-directory in GDB to /mntsymbols/binsymbol.

The way you have set this up, GDB probably looks for prog.debug in /usr/lib/debug/mntsymbols/binsymbol. You can verify this by running GDB itself under strace -e open.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • 1
    When I did --add-gnu-debuglink=prog.debug I had to keep prog.debug in same directory, else command was failing. Then I kept prog.debug in default dir /usr/lib/debug as well as /mntsymbols/binsymbol. While using gdb, did 'set debug-file-directory' and made sure using 'show debug-file-directory'. (I added this to ~/.gdbinit also). But still it does not find symbols. May be I need to reload all the symbols after doing set debug-file-directory, I had read it but lost the commands. – devdebug May 18 '17 at 08:24
  • I have not tried strace trick you mentioned. will try and post. – devdebug May 18 '17 at 08:27
  • In my case if I set debug-file-directory to `/some-dir`, then gdb was searching symbol file in `/some-dir/dir1/dir2/` for the original file in `/dir1/dir2`. – Alex Che Apr 23 '19 at 18:12