x86simulator Using the GDB Server - 2023.2 English

Vitis Tutorials: AI Engine (XD100)

Document ID
XD100
Release Date
2024-03-05
Version
2023.2 English

This feature uses the GDB server to debug and requires two terminals working together. One terminal for x86simulator and the other terminal for GDB server.

  1. In Terminal 1, update the configuration file, ${PROJECT_PATH}/Work/options/x86sim.options, by changing the valgrind-gdb=no to valgrind-gdb=yes, and issue the command, x86simulator, or directly issue the command, x86simulator --valgrind-gdb, directly.

    >>x86simulator --valgrind-gdb
    ==44263== Memcheck, a memory error detector
    ==44263== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==44263== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
    ==44263== Command: ./Work/pthread/sim.out
    ==44263==
    ==44263== (action at startup) vgdb me ...
    ==44263==
    ==44263== TO DEBUG THIS PROCESS USING GDB: start GDB like this
    ==44263==   /path/to/gdb ./Work/pthread/sim.out
    ==44263== and then give GDB the following command
    ==44263==   target remote | /tools/baton/valgrind/3.16.1/lib/valgrind/../../bin/vgdb --pid=44263
    ==44263== --pid is optional if only one valgrind process is running
    ==44263==
    
  2. In Terminal 2, set up the Vitis tool and Valgrind tool environment variables as described in Memory Access Violation and Valgrind Support.

  3. Navigate to the project directory, and issue the command gdb ./Work/pthread/sim.out.

    >>gdb ./Work/pthread/sim.out
    GNU gdb (GDB) 11.2
    Copyright (C) 2022 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 "x86_64-pc-linux-gnu".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <https://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
       <http://www.gnu.org/software/gdb/documentation/>.
    
    For help, type "help".
    Type "apropos word" to search for commands related to "word"...
    Reading symbols from ./Work/pthread/sim.out...
    
  4. In Terminal 2, issue the command, target remote | <VALGRIND_INSTALL_PATH/valgrind/3.16.1/bin/vgdb:

    (gdb) target remote | /tools/baton/valgrind/3.16.1/bin/vgdb
    Remote debugging using | /tools/baton/valgrind/3.16.1/bin/vgdb
    relaying data between gdb and process 44263
    warning: remote target does not support file transfer, attempting to access files from local filesystem.
    Reading symbols from /lib64/ld-linux-x86-64.so.2...
    (No debugging symbols found in /lib64/ld-linux-x86-64.so.2)
    0x0000000004001140 in _start () from /lib64/ld-linux-x86-64.so.2
    (gdb)
    
  5. From now, you can follow the steps 1-5, and set the breakpoint of interest, observe local values, stack values etc, and finally once the GDB server exited normally, you can observe the Terminal 1 for the valgrind runs completion and overall status summaries.

    INFO: Reading options file './Work/options/x86sim.options'.
    ==44263==
    ==44263== HEAP SUMMARY:
    ==44263==     in use at exit: 183,522 bytes in 530 blocks
    ==44263==   total heap usage: 179,047 allocs, 178,517 frees, 9,341,190 bytes allocated
    ==44263==
    ==44263== For a detailed leak analysis, rerun with: --leak-check=full
    ==44263==
    ==44263== For lists of detected and suppressed errors, rerun with: -s
    ==44263== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)