Debug Using printf() - Debug Using printf() - 2025.2 English - XD100

Vitis Tutorials: AI Engine Development (XD100)

Document ID
XD100
Release Date
2026-03-27
Version
2025.2 English

The simplest form of tracing is to use a formatted printf() statement in the code to print debug messages. Visual inspection of intermediate values and addresses can help you understand the progress of program execution. You can add printf() statements to your code to be processed during x86 simulation, and remove them or comment them out for hardware builds. To identify which kernel prints a line, use the X86SIM_KERNEL_NAME macro.

This section discusses adding a printf() statement in the source code, compile, and run x86simulator, and checking the output in the console.

  1. From the Vitis IDE, browse to the [AI Engine] component and expand Sourceskernelsclick on peak_detect.cc.

  2. Add #include <adf/x86sim/x86simDebug.h> at the beginning of the source file and printf("%s: %s, %d\n", __FUNCTION__, X86SIM_KERNEL_NAME, __LINE__); after the for loop.

  3. To compile the project, select Build under X86 SIMULATION in Flow navigator.

  4. To run the project, select Run under X86SIMULATION in Flow navigator.

  5. The expected result is as follows. printf support

  6. Remove the added printf statement from the peak_detect.cc file to use it for other features.