The toolchain offers the ability to debug your programs using the emulator CEmu.
#include <debug.h> to a source file, and use
make debug instead of
make to build a debug program.
You may need
make clean in order to ensure all source files are rebuilt.
Printing to the console¶
Printing is a classic debugging technique.
dbg_sprintf() allows you to print variables and strings to the CEmu console.
It uses these format specifiers.
Here are some examples:
int var = 10; unsigned code = 3; dbg_sprintf(dbgout, "Initialized some things...\n"); dbg_sprintf(dbgout, "var value: %d\n", var); dbg_sprintf(dbgerr, "PROGRAM ABORTED (code = %u)\n", code);
To view the output of these functions within CEmu, enable the console using Docks > Console.