To implement a debugger for a system in ares, you can register callbacks with the GDB::server object. The server is designed to be neutral, meaning operations like stopping, stepping, or reading memory should not affect the game's cycle-accurate behavior.
Interactions are categorized into:
- Hooks: Callbacks that allow GDB to call functions in your system (e.g., memory/register access).
- Report-functions: Methods to notify GDB about events (e.g., exceptions or PC updates).
- Status-functions: Helpers to check the current GDB status (e.g., if breakpoints are set).
For a minimal working session, you must implement register/memory reads and a way to report the Program Counter (PC).
// Example: Registering a register read hook
GDB::server.hooks.regRead = [](u32 regIdx) {
return hex(cpu.readRegister(regIdx), 16, '0');
};
// Example: Main execution loop with PC reporting
while(!endOfFrame && GDB::server.reportPC(cpu.getPC())) {
cpu.step();
}