Search code examples
debuggingprogramming-languages

How create a debugger for self-made language?


I wanna build a language, but I think that to be useful it need at least a REPL and a debugger.

How incorporate a debugger is the thing that look like magic to me. I remember how great the old Visual FoxPro was, and how much sucks the xcode (in comparison) so I suspect is something hard.

Which kind of language make easier to integrate a debugger? A interpreter? Compiled? Imperative? Functional?

Make a difference if the language is made in LLVM, Lua/LuaJit, on top of objective-c? (I ask about this because for my pet language how easier could be is a critical factor. So the easier target that will make a easier answer, I suppose)

Is the best way to use GDB/LLDB or roll my own?

Where to look about this?


Solution

  • This will be much easier for an interpreter. Before executing a statement, you can check whether a global "paused" flag is set and pause if it is. Before executing a procedure, you can check to see whether a "traced" flag is set on that procedure, and set the "paused" flag, restoring it to its previous value on return.