|NewtOS: Memory Sample PC SP «Einstein» Contribute|
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.
If you like to give Retargeting a try, I recommend that you compile Einstein from scratch from the current SVN.
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.
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()).
I added retargeting commands to the Monitor. These commands create "C" code that replaces individual functions inside the ROM using code as it would be generated by the JIT compiler. You can immediately drop-in that code, or hand-optimize it if you wish.
Take a look at test.cp and test.h . These files should contain code that you can simply copy into Newt/SimCollection1.cp and Newt/SimCollection1.h in your Einstein Source Tree. The code will hook itself into the Newton ROM and will be executed instead of the ROM code.
If the translated code should trigger a DataAbort, control is given back to emulator.
Instead of an address, rt cjit can also handle symbolic names of functions if the symbol table has been loaded, for example: rt cjit GetCurrentHeap .
It is perfectly legal to translate only parts os a function, however you must make sure that no branch instruction jumps outside of the given range.
It has becode tedious to type retargeting commands for multiple functions. Using the !filenae command runs every line of text in that file as if it was entered into the monitor (the command syntax is an exclamation mark, directly followed by the full path and filename of a text file).
(c) 2014 firstname.lastname@example.org - Impressum