Yocto Gdb
Overview
The Yocto ramdisk contains gdbserver and binaries/libraries without debugging symbols so gdb remote debugging is required. The Yocto SDK and the FESA DU/Class contain debugging symbols by default.
The executable to be tested is started with gdbserver on the frontend. gdb is started on the development host and needs paths to the SDK to find symbols.
gdbserver on the remote and gdb on the development host need to use the same IP port number; the fesa scripts have used 46697.
gdbserver on frontend
gdbserver just runs the binary on the frontend and knows nothing of symbols.
To attach gdbserver to a running process (started via Systemd or script):
gdbserver --attach localhost:46697 `pidof My_DU`
To start the DU process with gdbserver (e.g. if it segfaults immediately):
from NFS:
cd /opt/fesa/nfs/local/myFEC/My_DU
startManuallyMy_DU_M.sh -r
from ramdisk, use the same paths as systemd:
gdbserver localhost:46697 My_DU -confdir /etc/fesa -instance /etc/fesa/instances/My_DU.instance
This starts gdbserver at port 46697 to match the dev host scripts. The symbols may not be loaded until debugging starts.
gdb on development host
gdb on the development host needs the folowing information :
Path to binary (DU) via -s (or "set symbol file")
Path(s) to libraries (FESA class .so, any others required by project) via "set solib-search-path"
Path to SDK sysroot (with symbols in e.g. /usr/lib/.debug) via "set sysroot"
If no paths are provided, gdb will attempt to download then from the remote and will not find full debug symbols
Example
REMOTE_DEBUG_PORT=46697
FEC_NAME=scuxl1234
BINARY=/pathtodu/MY_DU
LIBRARY_PATH=/pathtoworkspace/MyClass/build/lib/yocto
SDK_PATH=/common/usr/embedded/yocto/fesa/current/sdk/sysroots/core2-64-ffos-linux
gdb -ex "set sysroot ${SDK_PATH}" -ex "target remote ${FEC_NAME}:${REMOTE_DEBUG_PORT}" -ex "set solib-search-path ${LIBRARY_PATH}" -s ${BINARY}
To Check if symbols are loaded
(gdb) info sharedlibrary
gdb script on dev host
#todo: codegen in SDK needs update
Use startscript in workspace/My_DU/src/test/myFEC with yocto remote option
startManuallyMy_DU_M.sh -y
Optimization
With optimization on gdb will find variables / code optimized away.
The default yocto compile flag _FORTIFY_SOURCE forces an optimization level of O1 regardless of your project settings.