mamcx
mamcx

Reputation: 16186

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?

Upvotes: 5

Views: 2826

Answers (2)

Daniel Duarte
Daniel Duarte

Reputation: 494

Visual Studio Code offer the possibility to implement your own extensions adding:

  • Custom Language
  • Custom REPL
  • Custom Debugger

Here is a tutorial covering all those topics step by step.

Upvotes: 0

Andru Luvisi
Andru Luvisi

Reputation: 25338

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.

Upvotes: 4

Related Questions