Debugging

The toolchain offers the ability to debug your programs using the CEmu emulator.

Add #include <debug.h> to a source file, and use make debug instead of make to build a debug program. You may need to run make clean beforehand in order to ensure all source files are rebuilt.

Printing to the console

Printing is a classic debugging technique. dbg_printf() allows you to print variables and strings to the CEmu console. It uses the standard printf format specifiers.

Here are some examples:

int var = 10;
unsigned code = 3;

dbg_printf("Initialized some things...\n");
dbg_printf("var value: %d\n", var);
dbg_printf("PROGRAM ABORTED (code = %u)\n", code);

To view the output of these functions within CEmu, enable the console using Docks > Console.