Reply To: Debugging Support for Lua

Home Forums General Programming Debugging Support for Lua Reply To: Debugging Support for Lua

#30706
synth
Participant
  • Topics: 13
  • Replies: 35
  • Total: 48

That sounds good for now 🙂

What would be really awesome to try, and is also a lot more complex, is to update the Method Editor window itself with an arrow pointing out the current line of execution. And have buttons there to control resuming, stopping, setting breakpoints etc. Currently we cannot do that because the lua code executes in the main thread and updates the lua state there. So if I write an infinite loop in a Lua method, the only way to stop it would be to shut down Ctrlr 😛

So we need to move the panel execution to its own thread. So a panel can be debugged. And a misbehaving panel cannot crash the editor itself. Just like browsers do with various tabs.

But I think we can have only one other thread and only one panel executing at any time to prevent 2 threads calling into C++ code via the lua bindings and causing race conditions and other threading conditions.

So the run_code method() always executes in a separate asynchronous task and the main thread simply disables the panel UI and the method editor UI and also the console :P. This way we prevent the lua state from being accessed from 2 threads and being corrupted.

When run_code() finishes in the async task we get a callback. If run_code() causes the debug function to be called, this function needs to communicate

    the current line of execution
    the current stack and
    the values of watched variables

to the main thread.

  • This reply was modified 7 years, 7 months ago by synth.
  • This reply was modified 7 years, 7 months ago by synth.
  • This reply was modified 7 years, 7 months ago by synth.
Ctrlr