DEV Community

Discussion on: How do you write a breakpointed visual debugger?

Collapse
 
brandinchiu profile image
Brandin Chiu

This is purely speculative, but I believe the debuggers run your code through a custom interpreter /compiler.

You're essentially taking over/replacing the process that normally executes your code.

This is why xdebug for PHP is written in C, for example, since PHP uses a C interpreter.

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

Interesting, this sounds reasonable. Okay so I am writing (very slowly) a programming language and did plan to put an interpreter together at some point. This Language is aiming to be compiled. My language is a subset of ES5 JavaScript with some bits that are wildly off spec, such as CSS as primitives and data structures. I guess I would look at forking an old js debugger and fixing it up.

Thread Thread
 
brandinchiu profile image
Brandin Chiu

That's probably a good way to get started to understanding how it works.

Eventually you'll probably want to cut out the middleman so you can debug your subset of Javascript without having to compile it first.

You could also look to see if there are any open source typescript debuggers, as that's more or less the same thing you're trying to do.

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

Excellent suggestions Brandon, thank you. 😁