documentation for gdb

This commit is contained in:
Joshua Smith
2024-10-04 12:02:00 -05:00
parent 33ac4aa146
commit 7f68c4e93d
2 changed files with 47 additions and 1 deletions

View File

@@ -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.

View File

@@ -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;