Friday, December 08, 2006

Separate debug symbols

Jeremy Bettis
Mon, 11 Sep 2006 07:20:35 -0700

Someone mentioned that gdb can separate the symbols from the executables, as a motivating factor for removing debug=yes and debug=no. How do you do this? I cannot find a gcc command to write the symbols to a different file, and the support for reading the separate symbol files in gdb seems clunky. Here is what I have found so far.
1) Strip can remove debug symbols, and write them to a separate file:
strip shared_debug_obj/app.exe -o app.exe
strip shared_debug_obj/app.exe --only-keep-debug -o app.dbg
strip shared_debug_obj/lib.dll -o lib.dll
strip shared_debug_obj/lib.dll --only-keep-debug -o lib.dbg

2) gdb can read the separate symbol files, but only if you tell it too:
add-symbol-file app.dbg
add-symbol-file lib.dbg

3) gdb is ok with add-symbol-file on dynamic libraries before they have been loaded. If gdb would automatically look for the symbol files by some algorithm, that would be wonderful. The appeal of being able to ship a stripped version of my software and then being able to drop in the symbol files and start debugging, is almost too good to resist.

1 comment:

Can you see what I think ? said...

Good finding dude. Will be handy. Thanks.