Our team currently uses the Alternet Scripter to run our Python code. We use the ScriptRun.RunFunction() method to run the code starting at a specific function.
Our workflow that we would like to achieve is the following.
- User edits python code using the Alternet Editor. User adds a breakpoint at a specific line and we store that information.
- User runs their script in our application, this calls ScriptRun.RunFunction to run the python code. When the line of code which had a breakpoint added is executed, show the Alternet Debugger. Allow the debugger to step through the code that had started executing by calling ScriptRun.RunFunction.
Is this feasible with Alternet Debugger. I noticed that the debugger has the function of the ScriptRun.Run() method where the entire script is run.
It should be possible to achieve this with some small modifications to our Python script debugger, which would allow starting debugging from the specific function.
I’ve uploaded a sample project that demonstrates how this can be done. The Run Me button executes a specific function in the script; the Debug Me button places a breakpoint inside this function and executes it in the debug mode. You can see how it works if you run the application from the bin folder.
Potentially Debugger functionality can be made as a separate application, provided that the script does not reference any application-specific objects.
The main form does not have an editor or functionality to save/load breakpoints, but this can be added fairly easily.
Please let me know if this is what you’re looking for.
Thanks for your help. Yes, the sample project you have provided is helpful.
Adding the option to specify the “MethodName” and “MethodArgs” to the Debugger StartDebuggingOptions will be great.
Thank you for confirming. We will add these parameters to the StartDebuggingOptions and include these changes in the next minor update.
We have just published an update to NuGet (version 8.1.10), where we’ve extended StartDebuggingOptions with MethodName and MethodArgs properties; these properties are used in Python/IronPython/TypeScript debuggers so it can start execution from the specific function.
I tried Alternet.Scripter.Debugger.Python.ScriptDebugger with StartDebuggingOptions MethodName and MethodArgs, it’s working well.
Is it available for Alternet.Scripter.Debugger.ScriptDebugger(C#) as well?
Sorry for the late reply. Roslyn script debugger executes the script application in a separate process, which starts execution from the entry point. So it’s not possible to start debugging from a specific method name.