Search code examples
linuxdebugginggccgdbpostmortem-debugging

GDB - Loading Debug information from external ".sym" files


I am attempting to carry out postmortem analysis of a crashed binary, "TestApp", on a linux system.

I have a copy of the binaries and and shared objects that are copied onto the device in a path:

/usr/public/target

This folder contains all the binaries in question in the directory structure used on the system under test, ie:

/usr/public/target/sbin/TestApp
/usr/public/target/lib/TestAppLib.so
/usr/public/target/usr/lib/TestAppAPILib.so

The automated build process strips the debug information from the binaries, and stores them in external, symbol files, all under:

/usr/public/target_external_symbols

So the symbol information for the above binaries would exist in files named:

/usr/public/target_external_symbols/sbin/TestApp.sym
/usr/public/target_external_symbols/lib/TestAppLib.so.sym
/usr/public/target_external_symbols/usr/lib/TestAppAPILib.so.sym

How do I get GDB to be aware of the existence of these external symbols and to load them?

I typically invoke GDB via:

gdb TestApp TestApp.core

I've referred to other articles on creating a test .gdbinit file and passing it to GDB via the -command argument, but it doesn't appear to work. Every time I attempt to get a backtrace from my core file, I get an indication from GDB that it cannot open the debug symbols. Any help in resolving this is appreciated.

(gdb) info shared
From        To          Syms Read   Shared Object Library
0x78000000  0x780061e8  Yes (*)     /usr/public/target/lib/TestAppLib.so
0x78010000  0x7806e60c  Yes (*)     /usr/public/target/usr/lib/TestAppAPILib.so
0x78070000  0x78091d2c  Yes (*)     /usr/public/target/lib/libm.so.2
(*): Shared library is missing debugging information.

Thank you.


Solution

  • There are commands set debug-file-directory, symbol-file and add-symbol-file to load debugging symbols from within a gdb session. The latter one might require the address where the shared library was loaded into memory.

    Maybe during your build process 'gnu debuglinks' have been added to your binaries. This would mean that in the executables there's a path coded that directs gdb where to look for debug symbols. More can be found here.