Debugging Tips for Jack to VM Code

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Debugging Tips for Jack to VM Code

peterxu422
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.
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Tips for Jack to VM Code

cadet1620
Administrator
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
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Tips for Jack to VM Code

peterxu422
Thanks! Those are great tips. How do you set up a "current function" breakpoint?
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Tips for Jack to VM Code

cadet1620
Administrator
peterxu422 wrote
Thanks! Those are great tips. How do you set up a "current function" breakpoint?
Run|Breakpoints menu or red flag button brings up the Breakpoint Panel. The "+" button brings up the Breakpoint Variables dialog. Select "current function" from the dropdown on the right then type Main.main (for example) in the Value: editbox. Hit the green checkmark button.

--Mark