DRIVE 5.0 Linux Open Source Software

Development Guide Release

GNU Debugger
Building GDB Client with Yocto
Debugging with gdb-multiarch Tool
Setting Up GDB Remote-Debugging Session
GDB, which stands for GNU debugger, is an open-source debugger for the Executable and Linkable Format (ELF) that works well with components built with the GNU C compiler (GCC). This section describes the procedures for installing and setting up GDB. For details on GDB usage, see:
To debug with GDB, set up remote-debugging sessions with gdbserver in targetfs and with gdb-client on the host side.
Building GDB Client with Yocto
You can build a GDB client in toolchain builds through Yocto by following the procedure below.
To build a GDB client on the host
1. If you have not rebuilt the toolchain, on the host run the following command to build it:
./build_yocto.sh -c meta-toolchain -t all
2. Locate the Yocto SDK at:
3. Extract the Yocto SDK at $PWD/sdk with this command:
<top>/drive-<p3407|p2379>-linux_src/yocto/scripts-vib5/build/tmp/deploy/sdk/oecore-i686-aarch64-toolchain-nodistro.0.sh -y -d $PWD/sdk
The gdb-client is at:
You can move the above gdb-client tool to any location within the same system.
Note: Leave the extracted directory as is because the gdb-client tool depends on the libraries in the path $PWD/sdk.
Debugging with gdb-multiarch Tool
Beginning with Ubuntu 14.04, the Ubuntu X86_64 and X86 distributions include a GDB client called gdb-multiarch, which supports aarch64 targets. You can use gdb-multiarch during remote-debugging sessions with gdbserver running in the target.
To install the package gdb-multiarch on the host
Run the following command:
sudo apt-get install gdb-multiarch
Setting Up GDB Remote-Debugging Session
After installing gdb-client according to the procedure under Building GDB Client with Yocto, set up a remote debugging session with gdb-client and gdbserver.
To set up a remote-debugging session
1. On the host, build the application for debugging with the -g option in gcc:
./toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-gcc -g <source> -o <application>
2. Copy <application> to targetfs and start gdbserver:
gdbserver :<port> ./<application>
Where <port> is the port number, which can be any positive integer used in gdb-client.
3. On the host, create a .gdbinit file and keep it in $PWD. Following are the important parameters to set up:
set architecture aarch64
set solib-absolute-prefix "<top>/drive-<p3407|p2379>-linux/targetfs"
set sysroot "<top>/drive-<p3407|p2379>-linux/targetfs"
set solib-search-path "<top>/drive-<p3407|p2379>-linux/targetfs/lib:<top>/drive-<p3407|p2379>-linux/targetfs/usr/lib"
set directories "<sources_dir>"
Where <sources_dir> is the directory in which the application source files reside.
4. Connect to the target through gdb-client via the network:
(gdb) target remote <target-ip-address>:<port>