#110574 - masscat - Wed Nov 29, 2006 12:19 pm
PLEASE NOTE:The GDB stub in desmume discussed in this thread is old, you can find information on a newer version here.
I have added a GDB stub to desmume so you can now use it to do debugging on your PC.
Currently it has only been integrated into the GTK version of desmume (linux only? - other builds are likely to be broken and not build/run).
The stub can only do stepping, instruction breakpoints, continue and stopping a running target. There is no setting register and memory values or memory watchpoints yet.
One reason I developed this was to provide a tool to investigate the NDS itself, i.e. stepping through code to see how it sets things up.
EDIT: If you use Windows you can get a binary from here. The patch below does not contain the Windows code.
Building and patching Desmume source
You need to get and be able to build the Desmume for he sourceforge repository. When asked for a password by cvs just hit return. Change to tthe directory where you want the desmume source to be placed and do the following.
This will create a copy of the desmume source with files no later than their 2006-11-27 version, i.e. the same source as the gdb stub is being developed against. Make sure that you can build the source by running the configure script in the desmume directory - resolve any missing libraries and the like until the script completes successfully.
Download the tarball containing the gdbstub code and patch. Change into the desmume directory and extract the tarball.
This will create the src/gdb_stub directory and its contents and the gdbstub_20061129.patch patch file. Finally run the patch file to patch the desmume source.
Rerun the configure script and type make to build the GDB stub enabled Desmume.
Using the GDB stub
The GDB stub creates two TCP sockets for GDB to connect to. The one at port 20000 is for the ARM7 and the one at port 20001 is for the ARM9 (only the ARM9 stub is active as delivered - to disable/enable the stub for each ARM edit /src/gtk/main.c at line 1313. This shows the ARM9 been activated).
Run desmume and load the .nds file you wish to debug. Press the play button. The emulation will start running but nothing will appear on screen as the ARM9 is stalled until GDB connects and tells it to run.
Get yourself a ARM aware version of GDB or Insight (see here and here for info on how to get one or build one). Run GDB with the .elf ile corresponding to the ARM9 code (optional) and connect to the stub as follows.
If you issue the continue command desmume will leap into life. You can now debug to your heart's delight.
I have added a GDB stub to desmume so you can now use it to do debugging on your PC.
Currently it has only been integrated into the GTK version of desmume (linux only? - other builds are likely to be broken and not build/run).
The stub can only do stepping, instruction breakpoints, continue and stopping a running target. There is no setting register and memory values or memory watchpoints yet.
One reason I developed this was to provide a tool to investigate the NDS itself, i.e. stepping through code to see how it sets things up.
EDIT: If you use Windows you can get a binary from here. The patch below does not contain the Windows code.
Building and patching Desmume source
You need to get and be able to build the Desmume for he sourceforge repository. When asked for a password by cvs just hit return. Change to tthe directory where you want the desmume source to be placed and do the following.
Code: Select all
cvs -d:pserver:anonymous@desmume.cvs.sourceforge.net:/cvsroot/desmume login
cvs -z3 -d:pserver:anonymous@desmume.cvs.sourceforge.net:/cvsroot/desmume co -D 2006-11-27 -P desmume
Download the tarball containing the gdbstub code and patch. Change into the desmume directory and extract the tarball.
Code: Select all
tar -xvjf path_to_tarball/desmume_gdbstub_20061129.tar.bz2
Code: Select all
patch -p0 <gdbstub_20061129.patch
Using the GDB stub
The GDB stub creates two TCP sockets for GDB to connect to. The one at port 20000 is for the ARM7 and the one at port 20001 is for the ARM9 (only the ARM9 stub is active as delivered - to disable/enable the stub for each ARM edit /src/gtk/main.c at line 1313. This shows the ARM9 been activated).
Run desmume and load the .nds file you wish to debug. Press the play button. The emulation will start running but nothing will appear on screen as the ARM9 is stalled until GDB connects and tells it to run.
Get yourself a ARM aware version of GDB or Insight (see here and here for info on how to get one or build one). Run GDB with the .elf ile corresponding to the ARM9 code (optional) and connect to the stub as follows.
Code: Select all
target remote 127.0.0.1:20001