Installing a Nintendo DS debugger environment on the Mac
[Note that this has been superceded by the 0.6 version of the gdb-stubs]
Following this list of steps will add a debugger and emulator to the /opt/local root that MacPorts uses for its installed software. Since it can be useful to upgrade devkitpro independently of these, I've left these packages outside the devkitpro tree. Feel free to change the "./configure" lines to place them inside the tree if you wish :-)
Install the support software and emulator/debugger
Open a new terminal window so you pick up the values you've just changed (all the following things are done in this terminal)
- Type sudo port install wget libsdl
gtk2
- Type cvs
-d:pserver:anonymous@desmume.cvs.sourceforge.net:/cvsroot/desmume
login
- Press the return key when it prompts you for a
password. You may get a warning about .cvspass - you can
ignore this...
- Type cvs -z3
-d:pserver:anonymous@desmume.cvs.sourceforge.net:/cvsroot/desmume
co -D 2006-11-27 -P desmume
- Type cd desmume
- Type wget
http://blog.gornall.net/assets/desmume_gdbstub_20061129.tar.bz2
- Type tar xjvf
desmume_gdbstub_20061129.tar.bz2
- Type patch -p0 <
gdbstub_20061129.patch
- Type ./configure --prefix=/opt/local
- Type make
- Type make install (and make sure
you see it say it was installing 'desmume' into
/opt/local/bin)
- Type cd ..
- Type wget
http://blog.gornall.net/assets/gdb-6.6.tar.bz2
- Type tar xjvf gdb-6.6.tar.bz2
- Type cd gdb-6.6
- Type ./configure --target=arm-none-eabi
--prefix=/opt/local
- Type make
- Type make install
... and you're done.
Using the debugger
The patch to desmume means the emulator will create two TCP sockets for GDB to talk to, the ARM7 is on 20000, the ARM9 on 20001. Only the ARM9 is active as delivered - you'll have to change src/gtk/main.c at line 1313 to get the ARM7.
So, run desmume, load the NDS file you wish to debug, press 'play', and the emulation will start, but nothing will happen just yet - it's waiting to talk to the debugger.
In a different window (to prevent spew from both programs confusing you), run arm-none-eabi-gdb /path/to/arm9.elf (where arm9.elf is the ELF file that the NDS file was created from - this gives you source-level context while you're debugging) and connect to desmume with:
target remote localhost:20001
Now, you're debugging...
I'd just like to re-iterate that none of this is my work. All I'm documenting is how to get it working on the Mac...