I've been looking at MIPS emulators lately. Given the big writeup on the Emulators page I thought GXemul would be worth checking out. Well, it works. Mostly. The big show-stopper bug I found is that breakpoints don't work! At least not for a 4Kc processor in kernel mode. That sort of kills the deal for me.
OK, so I finally figured out how to get breakpoints to work after a few hours of trial and error. Reading the code was no help, nor was adding a ton of printf-like statements all over the place to track down the problem.
With an emulated MIPS32 processor like the 4Kc in little-endian mode you must enter the breakpoint address as a sign-extended 64-bit hex value. Let's say you're debugging startup code, like I am, and there's a spot early on where the code goes into a long loop, such as setting up the caches, or copying bytes from ROM to RAM. You want to set a breakpoint after this lengthy operation is complete, and you want it to break when the program reaches, say, address 0x9fc01018 (in Kseg0). The ONLY way to make that happen is to enter the breakpoint like this:
breakpoint add 0xffffffff9fc01018GXemul will not complain if you just enter 0x9fc01018, it just won't break there. Using the "breakpoint show" command to list the active breakpoints will result in a list that looks fine and dandy. The reality, however, is very different.
Unfortunately the reason for this behavior is that at its core GXemul is a 64-bit emulator and when it comes to dealing with 32-bit code the author casts and converts 64 bit values into 32 bit values, and vice versa, with abandon. Things like that will cause you a lot of grief and there's plenty to go around inside GXemul.
For what it's worth, I think overall Anders has done a good job on GXemul. It's not perfect, but that's the beauty of Open Source and Free Software. If you think you can do better you're welcome to have at it. Often there is a lot of code available for you to start with.
Thanks for making GXemul available, Anders. It drives me crazy at times but it has helped me find a few problems in my MIPS assembler code which otherwise I probably would not have found.
Alec v 12:02, 31 Jan 2006 (GMT) We could open an "alternative" mailing list to conversate and collect a patches.