peterxu422 wrote
Does anyone have any good tips for debugging faulty generated VM code when it's translated from error-free Jack Code by your compiler? It seems stepping through each line in your VM code with the VM translator does not seem like a good strategy since a lot of the VM code is initializing the operating system.
Don't include the OS .vm files in your test directories. This will cause the VM Emulator to simulate the OS initialization and calls so you don't need to step through them.
If you are not already doing so, write the source lines as comments in the VM code. You can have the correlated source and VM code open in a text editor and it will help you find your way around in the VM Emulator's code display.
VM Emulator breakpoints, especially "current function" are useful. Setting a current function breakpoint on Main.main will let you easily step across calls that main makes. Set one on a problematic function and you can run directly up to it without stepping.
If you can localize the source line that's miscompiled, make a minimal source file that include that line.
--Mark