Debug Application
This how-to describes the process of debugging an application on the target with GDB.
Table of Contents
Task Dependencies (Pre-requisites)
- Target is running Linux
- Host and target Linux need to be able to communicate over Ethernet
Tools Required
- GDB server on the target filesystem
- GDB client on the host
Input Files Required
- Application for debug
Output Files Produced
- None
Task Description
Preparing for debug
GDB will need the application binary to contain debugging information. For this, the application needs to be compiled with the '-g' flag:host> <toolchain>-gcc app.c -g -o app
The IP of the target machine will need to be used later:
zynq> ifconfig
Starting the debug server
In order to debug the application a GDB server must be run on the target machine. Execute the following command to start a GDB server for the given application:zynq> chmod u+x app zynq> gdbserver HOST:<port> app
Debugging the application
Now that the server is running a GDB client can connect to the server to perform debugging:host> <toolchain>-gdb app
(gdb) target remote <IP of the target>:<port>
(gdb) b main (gdb) cont
host> arm-xilinxa9-linux-gnueabi-gdb app GNU gdb (Sourcery G++ Lite 2010.09-62) 7.2.50.20100908-cvs Copyright (C) 2010 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=i686-pc-linux-gnu --target=arm-xilinx-linux-gnueabi". For bug reporting instructions, please see: <https://support.codesourcery.com/GNUToolchain/>... Reading symbols from /<path to>/app ...done. (gdb) target remote localhost:1234 Remote debugging using localhost:1234 warning: Unable to find dynamic linker breakpoint function. GDB will be unable to debug shared library initializers and track explicitly loaded dynamic code. 0x400aa7a0 in ?? () (gdb) b main Cannot access memory at address 0x0 Breakpoint 1 at 0x8434: file app.c, line 5. (gdb) cont Continuing. warning: Could not load shared library symbols for 3 libraries, e.g. /lib/libgcc_s.so.1. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? Breakpoint 1, main () at app.c:5 5 printf("Hello World!\n"); (gdb)
(gdb) n
Related Links
© Copyright 2019 - 2022 Xilinx Inc. Privacy Policy