I am creating a process to improve debugging of a remote LINUX system by enabling core dumps on an embedded platform. But I'm having trouble getting gdb to load symbols from shared libraries after loading a core file.
I've amended my CI build system to automatically create --only-keep-debug
ELF files for all binaries and libraries based upon build-id as seems to be recommended practice - in addition to --strip-unneeded
versions for the target.
Debugging the process,
cross-comp-readelf --all core.a.out | grep,awk,sort,etc...
) that produces:/lib/libfoo.so
/usr/lib/libbar.so
that allows the process to auto create from CI archive:
CWD/sysroot/bin/a.out *stripped-binary-that-crashed*
CWD/sysroot/lib/libfoo.so *some-stripped-libraries*
CWD/sysroot/usr/lib/libbar.so *more-stripped-libraries*
(gdb) set sysroot CWD/sysroot
(gdb) set solid-absolute-prefix CWD/sysroot
(gdb) file sysroot/bin/a.out
Reading symbols from sysroot/bin/a.out...
Reading symbols from CWD/.build-id/b5/9700de946784bbf2d65f9993145d14a3ba9a89.debug...
(gdb) core-file core.a.out
[New LWP 10226]
Core was generated by `a.out'.
Program terminated with signal SIGABRT, Aborted.
#0 0xb661dd16 in ?? ()
(gdb) info sharedlibrary
No shared libraries loaded at this time.
$ grep "libfoo" st.log
$
I have confirmed gdb's auto-solib-add is on, and I've also tried every other setting I can find on any gdb documentation sites - like set auto-load safe-path /
But I cannot fathom why gdb is not attempting to open and read symbols from libfoo.so or libbar.so once it has loaded the core-file.
What is your coredump_filter setting ? It will be under /proc/
The value in that file is in Hex and refer the linux documentation on core (man core). The bit 4 needs to be set to dump all ELF headers.