Xojoscript Debugging

I’m building an app that will require a lot of scripting from the user. My current options are Xojoscript, Wren (via Einhugur) or a custom language I’ll need to write.

A key requirement is to be able to debug the script, including stepping through the code.

If I understand correctly, there is currently no debugging hooks for Xojoscript. For example, you can’t step through line by line or view the call stack. Is that correct @William_Yu or @Travis_Hill?

Wren does not support debugging (at least not on the main branch although @Björn_Eiríksson there is now an experimental debugger branch for Wren on Github which if you implemented would solve all my problems!).

Writing my own language with a steppable VM is the nuclear option that I am not keen on doing!

How do people debug their Xojoscript?

Is it even technically possible for the Xojo engineers to implement step by step debugging?

We have written our own xojoScript Debugger for our Workflow-Designer. It makes some demands on the source code but we can debug our Scripts Step-By-Step, take a look at variables defined in the script and contains a log window.

This is a complete IDE for xojo Apps, which we want to release in the future. The product will include an follow up of BKeeney Shorts and a project management system. This system bundles scripts and reports in a project, so that you can easily export a project from a test environment into a production environment.

1 Like

That sounds pretty interesting.

What approach did you take to implement stepping through the script line by line? I’m curious as to the big picture engineering required to do it?

Because some very good developers pointed me to the xojo license, I want to make one thing clear. It will not be a standalone app, but a xojo module that developers can integrate into their xojo apps. So this should not be a problem, because everyone needs a xojo license to make use of it.

Same - I’m building a game engine with Xojo and need to script game objects - hence the need for an embedded language.

As I mentioned in the opening post, there are several options but none allow step through debugging.

Single-stepping through the code would probably entail programmatically putting a “tailored” call to the script context before and after each executable line of script code. These calls could cause the context to display an indication of where the execution is in the original code. Doable if all you want is to follow program flow.

If you also want to display script variable values, then it would be a completely different and much nastier task, involving parsing the code, etc.

Yeah, that’s what I figured.

As usual I’m reinventing the wheel. I’m writing my own scripting language instead. That way I can control its VM and implement a debugging mode.

To quote Deadpool:

Maximum effort.

1 Like

Yeah, that’s right…

It was no easy task to get it working. Especially when running scripts in a thread and updating the user interface…

A challenge that you simply have to accept :wink:

Let’s get me right… there are still cases to fix. As I mentioned actually the script must be formatted with regard to the debugging process…

And one is still on my wishlist… workers or helpers executing the scripts… what would you prefer?

But hey it would be boring without challenges…

The Beta branch looks a bit weird.

(and little documentation too)

It basically seems to pop you into VS code to debug. And compiled switch would have to be set on the wren code to enable debugging which of course would mean in plugin that its always on. Since of course the plugin is compiled in advance

Is that the correct thread?
Seams nothing to do with the other topics…

Has everything to do with the topic. Check the first post.

1 Like

Sorry. yes it was out of my mind already…

That was my feeling too. I think it’s probably just not quite ready yet for prime time. Glad you took a look though as your C is a lot better than mine!

I still might make a test. I have a feeling they wont be making any other kind than the one that pops you into VS code when debugging.

By all means take a crack at it. Happy to help out if I can.