From 7f68c4e93d8d4be37e13f30db0ed024360103419 Mon Sep 17 00:00:00 2001 From: Joshua Smith Date: Fri, 4 Oct 2024 12:02:00 -0500 Subject: [PATCH] documentation for gdb --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/game_overlay.c | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fa27baa608..2ba656092c 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,49 @@ This repository builds the following ROMs: * [**pokeplatinum.us.nds**](https://datomatic.no-intro.org/index.php?page=show_record&s=28&n=3541) `sha1: ce81046eda7d232513069519cb2085349896dec7` For contacts and other pret projects, see [pret.github.io](https://pret.github.io/). In addition to the pret Discord, also see the [VoidMatrix Discord (#decomp)](https://discord.gg/prUAgd5). + +## Debugging with GDB + overlays + +1. Download and build custom GDB debugger from https://github.com/joshua-smith-12/binutils-gdb-nds - this build includes changes to help aid overlay debugging. (Regular gdb-multiarch works as well but will handle overlays poorly) + +2. Create a `.vscode/launch.json` with the below contents, updating `miDebuggerPath`: + +``` +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug in melonDS", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/debug.nef", + "MIMode": "gdb", + "cwd": "${workspaceFolder}", + "externalConsole": true, + "miDebuggerServerAddress": "localhost:3333", + "miDebuggerPath": "/path/to/custom/build/gdb/gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set architecture", + "text": "set architecture auto" + }, + { + "description": "Enable overlays", + "text": "overlay auto" + } + ], + "stopAtConnect": false, + "stopAtEntry": false + } + ] +} +``` + +3. Launch melonDS with GDB stub enabled and launch the pokeplatinum ROM (you may need to fiddle with the config file to make this work, melonDS GDB stub config is off and may not actually enable properly through the UI) + +4. Run debugger through VS Code, it should connect to melonDS automatically. \ No newline at end of file diff --git a/src/game_overlay.c b/src/game_overlay.c index b37d2d3e31..f76d13b4a0 100644 --- a/src/game_overlay.c +++ b/src/game_overlay.c @@ -63,7 +63,7 @@ void LoadOverlayGDB(const FSOverlayID overlayID) // and the size field is not correct compared to what's stored in the NEF. // the standard overlay manager in GDB bases comparisons on VMA and LMA, so it's not viable here. // requires a custom GDB build which uses section name and which can override section size. - // see + // see https://github.com/joshua-smith-12/binutils-gdb-nds _ovly_table[overlayID].vma = overlayInfo.header.ram_address; _ovly_table[overlayID].lma = 0; _ovly_table[overlayID].size = overlayInfo.header.ram_size;