Writing a Jack debugger

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

Writing a Jack debugger

jacklack
I would like to add a Jack debugger to the jack on windows compiler I made (generates x86 code for windows).

My idea is to use Visual Studio as an IDE for debugging, source editing etc... (VS can be extended to allow custom languages to be added to it).

Does anyone know who to tackle this?
Or know how to create a debugger for Jack (not necessarily a windows one)?
Any books or online resources that might help understanding how to write a debugger?

Many thanks
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Jack debugger

ivant
I was also thinking about Jack debugger, though integrated with the VM emulator. My idea is to add debugging comments to the generated VM code. Things like line number and variable names are two of the more obvious things to add. With these, the VM emulator can load the .jack file, show the currently executed line, show the local, instance and class variables and their values, set breakpoints, etc.

Line number comments may be affected by some optimizations, so the compiler may decide to not apply them, when instructed to generate debug info.

Another option would be to extend the VM specs with pseudo-instructions, which add the debugging metadata, but I don't think it's the right option for Jack.

P.S. I don't know when I'll be able to work on this, but I'll be happy to keep compatibility with your implementation if possible.
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Jack debugger

jacklack
Or maybe create a standalone debug file that contain debug info and symbols for each compiled executable? (like the PDB file for example for windows).

I am just thinking on how to start on this, and didn't commit to it yet. But will try to do it so it can be as portable as possible. That is this debugger should be capable of debugging a simulated Hack hardware too (much like debugging embedded hardware with Visual studio).

Are you trying to do in Java in a new gui? Something like a "Jack emulator"?
And then use the screen in the VM emulator as a display for the screen output?
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Jack debugger

ivant
Having the debug info in a separate file means, that the two may start to point to different versions. E.g. you compile once with debug info, make some changes, compile a second time, but forget to add the debug switch. The debugger will happily load the old debug file and show strange results.

Are there any advantages, which compensate this?

For the moment I haven't done anything regarding this. I was thinking about extending the current tools.
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Jack debugger

jacklack
This post was updated on .
I see what you mean.
To be honest, I have no idea right now on how to start making this debugger, I'll post updates here as I work on it.

My idea is to have work on visual studio, so that the Jack language will benefit from the great features of this IDE. (Eclipse is another option too, but will try to do the Visual studio).
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Jack debugger

jacklack
In reply to this post by jacklack
Some updates for those who are interested.

This turns out to be a non trivial task. To get jack on visual studio I have to first create a jack project type, have the editor recognize the jack syntax etc...
The debugger comes really last in this.

Just setting the environment to develop on is hard itself. (visual studio sdk, different VS versions etc...)
But I made some tiny progress and this drives me to keep on.
Stay tuned!
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Jack debugger

jacklack
Baby steps having Jack on visual studio.

I have it now able to create a jack project and most importantly classify the jack syntax (colorise keywords, variables, comments etc...)

For this it uses the tokenizer that I developped to nandtotetris.
The red underlines you see are syntax errors that should be fixed once I plugin the parser...

Here is a picture of a Jack file inside the IDE.

Next is the syntax checking...