This sections walk you through debugging for software emulation using the GDB in the command line.
Clone the git repository, and locate the
Makefile
to build the system for software emulation.Set the environment variables as described in Introduction.
Do
make all
ormake aie
,make kernels
,make xsa
,make host
andmake package
one after the other to complete the build for software emulation.NOTE: Make sure to compile the host application using the option
-g
to debug using the GDB.To debug using the GDB, invoke the lauch emulation script using the option,
-kernel-dbg true
../sw/launch_sw_emu.sh -kernel-dbg true
The option
-kernel-dbg true
will set up the emulator to rungdb
at the execution of the application.Observe the QEMU emulation environment and Linux boot.
Run the following commands in the
QEMU
shell.export LD_LIBRARY_PATH=/mnt/sd*1:/tmp:$LD_LIBRARY_PATH export XCL_EMULATION_MODE=sw_emu export XILINX_XRT=/usr
Run the PS application using
./host.exe a.xclbin
.This will start running the host application and launch the GDB in a separate terminal as follows:
Place breakpoints in the
s2mm
,mm2s
, andpeak_detect
functions as follows, and run the application:(gdb) b s2mm Function "s2mm" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (s2mm) pending. (gdb) b mm2s Function "mm2s" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 2 (mm2s) pending. (gdb) b peak_detect:24 No symbol table is loaded. Use the "file" command. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 3 (peak_detect:24) pending.
Now type
r
to run the program, and observe it stops at the breakpoint inmm2s
.[Switching to Thread 0x7fffef7fe700 (LWP 45539)] Breakpoint 2, mm2s (mem=0x7ffff0007000, s=..., size=448) at /wrk/xhdhdnobkup4/viswanad/2023_1/11_4_git_viswa/Vitis-Tutorials/AI_Engine_Development/Feature_Tutorials/20-debug-walkthrough-new/2_cmd/_x/link/int/xo/mm2s/mm2s/cpu_sources/mm2s.cpp:34 34 for(int i = 0; i < size; i++) { (gdb)
You can press
Ctrl
+XA
in the GDB console, which opens the source code where the debugger stopped. Toggle using the same keyboard shortcut to come back to the original console.Tpe
c
to continue execution, and observe it stops at thes2mm
function now.Type
c
again, and observe the breakpoint now hits atpeak_detect
function.Type
next
to debug line by line, and observe variable values, e.g, max_out usingprint max_out
.Use all the
gdb debug
options and debug as mentioned in x86simulation with the GDB section.Type
d
to delete all breakpoints andr
to complete the run.Observe
Test Passed
in the Linux console.