debugginggdbshared-librariescross-compilingcoredump

GDB does not attempt to load any shared library when core file is loaded


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,

  1. Generate self-inflicted assert to trigger a core-file on target, and copy back to host's CWD.
  2. Recreate the target system file structure on host under CWD - copying stripped binary and necessary stripped libraries in their correct location. The library necessity is auto-confirmed by a parsing (using 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*
  1. Within CWD$ path/to/cross-comp-gdb (run under strace -e open,openat -o st.log ...)
(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 ?? ()
  1. And gdb makes no attempt to load libfoo.so or libbar.so... [confirmed by strace st.log]
(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.


Solution

  • 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.