Debugging

Discussion in 'NDS - Emulation and Homebrew' started by gudenau, Jan 16, 2012.

  1. gudenau
    OP

    gudenau Never a unique idea

    Member
    3,257
    1,224
    Jul 7, 2010
    United States
    /dev/random
    How may I do this on a nds, I have a Trainer Toolkit and ards, so is there a way that I may use my pc to remote debug my nds?
     
  2. LeRodeur

    LeRodeur GBAtemp Regular

    Member
    162
    10
    Dec 12, 2009
    France
    I think that no$gba is still the greatest debugger for nds, though I never tried other emulators ones. I don't think you can debug directly on nds, if it is your homebrew then you only have to output messages, easiest way of debugging
     
  3. gudenau
    OP

    gudenau Never a unique idea

    Member
    3,257
    1,224
    Jul 7, 2010
    United States
    /dev/random
    Well, nds emus don't work for me, oh well...
     
  4. LeRodeur

    LeRodeur GBAtemp Regular

    Member
    162
    10
    Dec 12, 2009
    France
    Whats the game? Most run fine on nogba
     
  5. smealum

    smealum growing up sucks.

    Member
    635
    2,019
    May 1, 2006
    United States
    SF
    You might want to read this : http://www.console-dev.de/2009/09/20/guru-meditation-error-data-abort-exception/ ; it explains how to use the "guru meditation error" you might sometimes see in homebrew games (among other things) to debug your games. Basically, every time your program crashes, it will give you information which you can use to know which line of your code is faulty. Of course, it's only one tool and it won't give useful information every time, but it's better than nothing, and it'll work on the DS (you don't need an emulator to get it to work).
     
  6. gudenau
    OP

    gudenau Never a unique idea

    Member
    3,257
    1,224
    Jul 7, 2010
    United States
    /dev/random
    The ds emulators don't like to run on my computer.

    Thanks.
     
  7. Schmendrick

    Schmendrick Advanced Member

    Newcomer
    55
    3
    Sep 12, 2009
    Netherlands
    You could also use the console to print info to the screen. It's very limited, but it'll get you some more info on specific variables.

    My game framework contains, among other debugging functions, simple logging options that can be accessed at any time while playing, and automatically gets saved to the sd card when it crashes with said guru exceptions; See my level editor app for an example (link in my sig, press select+L+R). It's easy enough to make, and I find it very useful, though the logs do take up some memory (if memory is an issue for you).
     
  8. Dirbaio

    Dirbaio GBAtemp Regular

    Member
    158
    15
    Sep 26, 2010
    Spain
    Yea. Pretty much your debugging choices are:
    - No$GBA Debugger: Awesome debugger, but bad emulator. Supports breakpoints and many other stuff, console printing, but doesn't support DLDI :(
    - Desmume: You can print out with it if you use the dev+ builds, accurate emulation, DLDI supporting
    - Real DS: you can just use the guru error screen, and libnds console. The guru error doesn't catch all kinds of errors though.

    The one I always use is demume. It's accurate as hell :)

    I always open the .ELF file in IDA Pro and look up the faulty addresses. You can get many, many more info this way, you can look at the registers and see what variable they are :) That, eif you know how to read ARM assembler code :)
     
  9. DanTheManMS

    DanTheManMS aka Ricochet Otter

    Member
    4,330
    107
    Jun 2, 2007
    United States
    Georgia
    With the FCSR thing, you can build your filesystem into a single *.nds executable that no$gba can load. It's read-only, but it works for testing sometimes. I usually used the DLDIrc addon to quickly build my FCSR images for testing. If you're interested I can give more detailed instructions and a more stable image builder tool.
     
  10. CoolAs

    CoolAs Advanced Member

    Newcomer
    75
    17
    Oct 21, 2011
    Hehe when i get guru's I use the arm-eabi-objdump tool you provide it with an .elf and it gives a conplete dissembly. Work's like a free version of IDA's .elf reader. (but you cant hack .arm9 in games with it xD).
    In terms of debugging you could also make a ram dump to a file.(and a vram  dump if you are really needy) then just print the offsets of all your variables to a file. Allowing you to check everything. Also you could make it read ram dumps so you can modify variables and see what happens. Although my preferred debugger is desmume, this is because it has not only Dldi, but also can read ram, view vram, and heaps more. The only thing it can't do is dissemblies.
    But yeah, try ram dumping to see whats happening - that is without an emulator.
     
  11. Nagato

    Nagato GBAtemp Advanced Fan

    Member
    531
    509
    Jul 15, 2011
    United States
    If you're already using IDA Pro then I'd suggest taking it a step further and looking into compiling an SVN copy of DeSmuME with the gdbstub enabled (see also the command line arguments for when you have the gdbstub enabled). IDA Pro already includes a way to attach to a gdb server so you will have the power of IDA Pro and the ability to debug NDS software at the same time.
     
  12. Dirbaio

    Dirbaio GBAtemp Regular

    Member
    158
    15
    Sep 26, 2010
    Spain
    Yeah, I've used desmume's GDB too, but it's way too unstable for me. It tends to hang / screw up/ crash :(

    It works a bit more reliably if using Insight as a GDB client instead of IDA but it's still far from ideal.