Debugging the emulation with the Monitor

Einstein has a built-in debugger on OS X and Linux. The debugger is calle Monitor and can be accessed via Option+Command+M. The Monitor window has an output area at the top that shows CPU registers and some hardware registers on the left when the CPU is stopped, and general output on the right. The bottom line is used to enter commands. The commandline interpreter is not very forgiving. Make sure that you enter the commands exacty as described on the help page.

The Monitor has all the basic commands needed to debug the emulated code. The list below focusses on the commands that may be useful for retargeting.


Watchpoints

Watchpoints are a way to mark points in memory that trigger a breakpoint when they are read or written. They are not essential for retargeting, but useful for following memory access.

Example:

Let's say you want to know who reads the variable gCurrentGlobals located at 0x0C10105C in RAM.

Start Einstein, open the Monitor (Alt+Cmd+M) and type stop. Now enter wpr 0C10105C, then type run. The next time, this address is read, execution will stop and you can find the function that reads this variable (in my sample case, it was IRQCleanUp()).