NVIDIA Tegra
NVIDIA DRIVE OS 5.1 Linux

Developer Guide
5.1.0.2 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:
http://www.gnu.org/software/gdb/documentation
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:
<top>/drive-t186ref-linux_src/yocto/scripts-vib5/build/tmp/deploy/SDK/oecore-i686-aarch64-toolchain-nodistro.0.sh
3. Extract the Yocto SDK at $PWD/SDK with this command:
<top>/drive-t186ref-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:
<top>/drive-t186ref-linux_src/yocto/scripts-vib5/SDKsysroots/i686-oesdk-linux/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-gdb
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-t186ref-linux/targetfs"
set sysroot "<top>/drive-<e3550 | p2888>-linux/targetfs"
set solib-search-path "<top>/drive-t186ref-linux/targetfs/lib:<top>/drive-t186ref-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>