Debug in the Command Line - 2023.1 English

Vitis Tutorials: AI Engine Development

Document ID
XD100
Release Date
2023-10-03
Version
2023.1 English

This sections walk you through debugging for software emulation using the GDB in the command line.

  1. Clone the git repository, and locate the Makefile to build the system for software emulation.

  2. Set the environment variables as described in Introduction.

  3. Do make all or make 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.

  4. 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 run gdb at the execution of the application.

  5. Observe the QEMU emulation environment and Linux boot.

  6. 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
    
  7. 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: gdb console

  8. Place breakpoints in the s2mm, mm2s, and peak_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.
    
  9. Now type r to run the program, and observe it stops at the breakpoint in mm2s.

    [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) 
    
  10. 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.

  11. Tpe c to continue execution, and observe it stops at the s2mm function now.

  12. Type c again, and observe the breakpoint now hits at peak_detect function.

  13. Type next to debug line by line, and observe variable values, e.g, max_out using print max_out.

  14. Use all the gdb debug options and debug as mentioned in x86simulation with the GDB section.

  15. Type d to delete all breakpoints and r to complete the run.

  16. Observe Test Passed in the Linux console.