gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > DS screen of death?

#110288 - PypeBros - Mon Nov 27, 2006 5:01 pm

Is there anyone around working on something like a "blue screen of death" library for the DS? i had a couple of debbuging sessions "darker than the nights" lately, and i'm missing the time where i was catching segmentation faults on the PC and dumping the register and stack content on the screen.

Is there something like a "software fault" trap on the DS, which i could reprogram to give debugging information? or at least is there a way to inspect ARM9 registers from a "guru meditation" tool that would be running on the ARM7 (assuming that the ARM7 has the ability of modifying the VRAM, which i'm unsure of).

Let me hear your random thoughts on the subject.
_________________
SEDS: Sprite Edition on DS :: modplayer

#110289 - simonjhall - Mon Nov 27, 2006 5:24 pm

Yes you can catch the execution of illegal instructions, read/write to invalid addresses, breakpoints and...I think there's something else.
It's relatively easy to do, and it's the basis of the debugger that I wrote.
I'll whip out some code for you when I get home later, assuming someone doesn't get there first!

And I'm thinking of releasing the debugger again... (but that's off topic, so let's not discuss that here!)

#110310 - Mighty Max - Mon Nov 27, 2006 8:24 pm

defaultExceptionHandler() installs a some kind of bluescreen already. Trapping into an exception will cause a "Guru Meditation Error" Screen showing the registers content at the time of the exception.

If it fails to display information (flickering of the upper lines) the cause of the exception was a jump into an invalid addressspace for reading, causing yet another exception.
_________________
GBAMP Multiboot

#110314 - simonjhall - Mon Nov 27, 2006 9:13 pm

I left my card reader at work, so I can't make a bit of code for you, but check out Mighty Max's exception stuff (search the forums) as that's the stuff I used to trap exceptions!

Basically you set the interrupt vector to point to an exception-handling function which stores all your registers and gives you a bit of stack. Once this gets called (ie your program has done something wrong), you can then from there jump to your real handling function which'll look at the CPSR to decide what kind of exception it was. You can then draw your blue screen of death.

This bit is optional:
If it was a data abort, read back the instruction which failed, decode it and compute the address which was accessed which caused the failure. You'll need an accurate copy of all the registers in order to do this.

Really off topic:
If you'd like to do some kind of virtual memory stuff you can use that failed address as an index into some fake memory space (like a file). Then insert the data at that address into the target register of the failed instruction (assuming it was a read) and continue execution from the instruction after the failed instruction. Easy? Yeah :-)