x86simulation with the GDB - 2023.2 English

Vitis Tutorials: AI Engine (XD100)

Document ID
Release Date
2023.2 English

This topic walks you through running the x86simulator with the GDB.

  1. Running the x86simulator with the --gdb command line switch breaks immediately before entering main() in the graph.cpp file. This pauses execution before any AI Engine kernels have started because the graph has not been run. To exit the GDB, type quit or help for more commands.

    Now, update the configuration file, ${PROJECT_PATH}/Work/options/x86sim.options, by changing the gdb=no to gdb=yes, then do make sim or directly issue the command, x86simulator --gdb, to launch the x86simulator.

    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib64/libthread_db.so.1".
    INFO: Reading options file './Work/options/x86sim.options'.
    [New Thread 0x7ffff595b700 (LWP 38956)]
    [New Thread 0x7ffff515a700 (LWP 38957)]
    [New Thread 0x7ffff4959700 (LWP 38958)]
    [New Thread 0x7fffeffff700 (LWP 38959)]
    [New Thread 0x7fffef7fe700 (LWP 38960)]
    Thread 1 "sim.out" hit Temporary breakpoint 1, main () at ../../aie/graph.cpp:7
    7      mygraph.init();
  2. After x86simulator is launched successfully with the GDB, set up a breakpoint using the break command.

    (gdb) break data_shuffle
    Breakpoint 2 at 0x410f47: file ./../.././aie/kernels/data_shuffle.cc, line 9.
  3. Type c and continue execution until the breakpoint is hit.

    (gdb) c
    [New Thread 0x7fffeeffd700 (LWP 39520)]
    [New Thread 0x7fffee7fc700 (LWP 39521)]
    [New Thread 0x7fffedffb700 (LWP 39522)]
    [Switching to Thread 0x7fffedffb700 (LWP 39522)]
    Thread 9 "sim.out" hit Breakpoint 2, data_shuffle (from_prev=..., outmax=0x7fffedffad78, out_shift=...)
       at ./../.././aie/kernels/data_shuffle.cc:9
    9       auto InIter = aie::begin_vector<8>(from_prev);
  4. Type info locals to examine the local variables and info stack to observe call stack.

    (gdb) info stack
    #0  data_shuffle (from_prev=..., outmax=0x7fffedffad78, out_shift=...) at ./../.././aie/kernels/data_shuffle.cc:9
    #1  0x0000000000411814 in b5_kernel_wrapper (arg0=..., arg1=0x4a26b0, arg2=...) at wrap_data_shuffle.cc:6
    #2  0x000000000042180a in x86sim::Kernel_b5_data_shuffle::invokeKernel (this=0x4a5a90) at PthreadSim.cpp:82
    #3  0x00007ffff7b4293f in x86sim::IMEKernel::execute() () from /proj/xbuilds/SWIP/2023.1_0427_0137/installs/lin64/Vitis/2023.1/aietools/lib/lnx64.o/libx86sim.so
    #4  0x00007ffff7b59564 in ?? () from /proj/xbuilds/SWIP/2023.1_0427_0137/installs/lin64/Vitis/2023.1/aietools/lib/lnx64.o/libx86sim.so
    #5  0x00007ffff7483dff in std::execute_native_thread_routine (__p=0x4a8890) at ../../../.././libstdc++-v3/src/c++11/thread.cc:80
    #6  0x00007ffff7bc6ea5 in start_thread () from /lib64/libpthread.so.0
    #7  0x00007ffff6be096d in clone () from /lib64/libc.so.6
  5. You can also set the breakpoint of your interest in any kernel source code at any line. For example, using break ./../.././aie/kernels/data_shuffle.cc:21 sets the breakpoint at line 21 in the data_shuffle.cc source code.

  6. You can remove all breakpoints by typing delete and continue execution until end of the program. Issue quit to exit out of the GDB.

    (gdb) delete
    Delete all breakpoints? (y or n) y
    (gdb) c
    [Thread 0x7fffeeffd700 (LWP 39520) exited]
    [Thread 0x7fffee7fc700 (LWP 39521) exited]
    [Thread 0x7fffedffb700 (LWP 39522) exited]
    [Thread 0x7fffef7fe700 (LWP 38960) exited]
    [Thread 0x7fffeffff700 (LWP 38959) exited]
    [Thread 0x7ffff4959700 (LWP 38958) exited]
    [Thread 0x7ffff515a700 (LWP 38957) exited]
    [Thread 0x7ffff595b700 (LWP 38956) exited]
    [Inferior 1 (process 37514) exited normally]

    The following are some useful GDB commands:

GDB Command Description
break Pause execution at specified.
continue Causes the debugger to run to completion.
delete Delete all breakpoints.
finish Exits the current function call but keeps the simulation paused.
info locals Shows the current status of local variables within the scope of the function call shown in the call stack.
info stack Shows a track of the function call stack at the current breakpoint.
print Prints the current value of a single variable.