refactor: extract melonDS GDB debugging procedures into melonds-gdb-debugger skill

Create the workspace skill .agents/skills/melonds-gdb-debugger/ with
SKILL.md and diagnose_melonds.sh diagnostic automation script.
Streamline AGENTS.md to link to the new skill to keep it short and concise.

Co-authored-by: Antigravity <antigravity@google.com>
This commit is contained in:
phillipandAntigravity committed 2026-10-04 00:36:22 +02:00
1 parent a819c712dc
commit f4c77b32d1
3 files changed
+173 -6

No files matched your search

+7 -6
View File
@@ -61,6 +61,10 @@ snakePlus/
├── tools/ # Tooling & automation scripts
│ └── clang_tidy_watch.sh # File watcher script running clang-tidy on file change
│
├── .agents/ # Workspace agent customizations
│ └── skills/
│ └── melonds-gdb-debugger/ # GDB debugging runbook & diagnostic script
│
├── .vscode/ # VS Code configuration
│ ├── launch.json # GDB debugger launch for melonDS (port 3333)
│ ├── settings.json # clangd and editor settings
@@ -238,12 +242,9 @@ The repository includes preconfigured tasks in [`.vscode/tasks.json`](.vscode/ta
- **Input Scanning Frequency & Bus Contention:** `scanKeys()` must be called once per frame synchronized with `swiWaitForVBlank()`. Calling `scanKeys()` in an unthrottled loop (spinning at 66 MHz) saturates ARM7 IPC queues (`touchRead`, `keypadGetState`), resets key-debounce edge detectors within microseconds, and leads to dropped inputs.
- **Boot Subsystem Sequencing:** Always complete hardware configuration, console initialization, and data structure setup (`setup()`) before enabling the VBlank interrupt (`irqSet(IRQ_VBLANK, handle_vblank)`). Enabling the ISR beforehand causes VBlank interrupts to fire while `consoleLoadFont` is streaming font tiles to VRAM, triggering Data Aborts at startup.
- **Safe State Re-initialization:** In `init_game()`, call `timerStop(0)` before resetting game state or clearing containers, and only call `timerStart(0, ...)` at the very end when all state members and HUD caches are cleanly initialized.
3. **Debugging Traps & Data Abort Diagnosis with GDB:**
- In Calico/devkitARM, unhandled Data Aborts route to `__arm_excpt_dabt` (`0x01ff8560`) and trap into an infinite loop at `__excpt_entry` (`0x01ff8594`).
- If melonDS appears unresponsive or logs `attempt to restore CPSR under bad mode`, attach `arm-none-eabi-gdb` to port 3333 (`target remote localhost:3333`):
- In `__excpt_entry`, inspect memory at `0x02fffd80`: the faulted instruction's address (`lr_abt - 8`) is pushed to `0x02fffd98`, and the faulted `SPSR` is at `0x02fffd90`.
- An unaligned/odd stack pointer (e.g. `sp = 0x02fffd8f`) indicates memory corruption caused by an `sp_irq` stack overflow clobbering `__sp_usr`.
- Use `info line *0x...` in GDB on the faulted PC to instantly locate the offending C++ line.
3. **Debugging with GDB & melonDS:**
- melonDS exposes a GDB stub on `localhost:3333`.
- For step-by-step instructions, exception vector addresses (`__arm_excpt_dabt`, `__excpt_entry`), stack-smash diagnosis, and automated diagnostic scripts, refer to the [`melonds-gdb-debugger`](.agents/skills/melonds-gdb-debugger/SKILL.md) skill.
4. **Hardware Registers & Memory Banking:**
- Graphic tiles and palettes must be transferred using DMA (`dmaCopy`) or direct memory copies into allocated VRAM / OAM memory banks.
- Do not modify VRAM allocation configurations without ensuring compatibility with console text generators and OAM sub-engines.