How it works...

Once in possession of the core dump file, use the cross GDB in the host to load it and get some useful information, such as the backtrace, using the following steps:

First set up the environment in the host:

$ source /opt/poky/2.4/environment-setup-cortexa9hf-neon-poky-linux-gnueabi  

This is using the toolchain we have previously prepared with debug information for all packages.

You can then start the cross GDB debugger, passing it a debug version of the application. Debug versions are stored in the sysroot in the same location as the unstripped binary, but under a .debug directory.

The whole GDB banner looks as follows but will be omitted in future examples:

$ ${GDB} /opt/poky/2.4/sysroots/cortexa
9hf-neon-poky-linux-gnueabi/usr/bin/.debug/wvdial core
GNU gdb (GDB) 8.0
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-pokysdk-linux --target=arm-poky-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/bin/.debug/wvdial...done.
[New LWP 560]

warning: Could not load shared library symbols for 14 libraries, e.g. /usr/lib/libwvstreams.so.4.6. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? Core was generated by `wvdial -c'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x76b43c7c in ?? ()

Now point GDB to the location of the toolchain's sysroot:

(gdb) set sysroot /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/
Reading symbols from /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libwvstreams.so.4.6...(no debugging symbols foun
d)...done.
Reading symbols from /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libwvutils.so.4.6...(no debugging symbols found)
...done.
Reading symbols from /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libwvbase.so.4.6...(no debugging symbols found).
..done.
Reading symbols from /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libuniconf.so.4.6...(no debugging symbols found)
...done.
Reading symbols from /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libstdc++.so.6...Reading symbols from /opt/poky/
2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/.debug/libstdc++.so.6.0.24...done.
done.
warning: File "/opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libstdc++.so.6.0.24-gdb.py" auto-loading has been decl
ined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
       add-auto-load-safe-path /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/libstdc++.so.6.0.24-gdb.py
line to your configuration file "/home/alex/.gdbinit".
To completely disable this security protection add
        set auto-load safe-path /
line to your configuration file "/home/alex/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
     info "(gdb)Auto-loading safe path"
[...]
Reading symbols from /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/lib/libdl.so.2...Reading symbols from /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-gnueabi/lib/.debug/libdl-2.26.so...done.
  

You can now inquire GDB for the application's backtrace as follows:

(gdb) bt
      #0  0x76b43c7c in __GI___select (nfds=1, readfds=0x7ee58018,  
writefds=0x7ee58098, exceptfds=0x7ee58118, timeout=0x7ee57fe8)
at /usr/src/debug/glibc/2.26-
r0/git/sysdeps/unix/sysv/linux/select.c:41
#1 0x76db3cd8 in WvStream::_do_select(IWvStream::SelectInfo&) () from /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-
gnueabi/usr/lib/libwvbase.so.4.6
#2 0x76db3ea4 in WvStream::_select(long, bool, bool, bool, bool)
()
from /opt/poky/2.4/sysroots/cortexa9hf-neon-poky-linux-
gnueabi/usr/lib/libwvbase.so.4.6
#3 0x000191bc in WvStream::select (isex=false, writable=false,
readable=true, msec_timeout=1, this=<optimized out>)
at /usr/include/wvstreams/wvstream.h:417 #4 WvDialer::wait_for_modem (this=this@entry=0x7ee58cb0,
strs=0x0, strs@entry=0x76df4c00 <WvFastString::nullbuf>,
timeout=1,
timeout@entry=5000, neednewline=neednewline@entry=true,
verbose=verbose@entry=true)
at /usr/src/debug/wvdial/1.61-r0/wvdial-1.61/wvdialer.cc:1357 #5 0x00019b60 in WvDialer::init_modem
(this=this@entry=0x7ee58cb0) at /usr/src/debug/wvdial/1.61-
r0/wvdial-1.61/wvdialer.cc:768
#6 0x0001c9c0 in WvDialer::WvDialer (this=0x7ee58cb0, _cfg=...,
_sect_list=<optimized out>, _chat_mode=<optimized out>)
at /usr/src/debug/wvdial/1.61-r0/wvdial-1.61/wvdialer.cc:119 #7 0x00014d74 in main (argc=<optimized out>, argv=<optimized
out>) at /usr/src/debug/wvdial/1.61-r0/wvdial-1.61/wvdial.cc:212

Even though the core dump came from a production system with no debug information, by creating a matching sysroot with the debug symbols we have been able to show a complete backtrace.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset