munificent / craftinginterpreters

Repository for the book "Crafting Interpreters"
http://www.craftinginterpreters.com/
Other
9.1k stars 1.06k forks source link

Implementation tips for implementing step/debug features #922

Open EmmanuelOga opened 3 years ago

EmmanuelOga commented 3 years ago

Hi,

I suspect implementing a stepper debugger would be easier in some ways when doing it on top of the bytecode VM, and I can think of a few ways for doing it ... although I bet it can get trickier than it seems! (thinking of this explanation of how GDB works).

Stepping through the AST interpreter seems somewhat more involved, and I only found some paper describing a smalltalk AST tree walker debugger using some sort of visitor pattern to grant the ability to pause in any given node.

I was wondering what are your thoughts about adding debugging support to Lox and languages in general. I feel like this is a weak area of many languages tooling.

EmmanuelOga commented 1 year ago

I think adding breakpoints to the interpreter or VM would probably be a lot simpler than implementing a debugger for some executable format. In any case, I found some links that I think this will be educational / informative even though most of them talk about debugging compiled Linux ELF/DWARF executables.

I actually found some of the above links through this article: