Launch debugger when breakpoint is hit during python script execution

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.

  1. User edits python code using the Alternet Editor. User adds a breakpoint at a specific line and we store that information.
  2. 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.

Hi,

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.

https://drive.google.com/file/d/1BoUo4lKAq0tOB5vgTBIup7-af9tJFItl/view?usp=share_link

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.

Regards,
Dmitry

Hi Dmitry,

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.

Thanks,
Allan

Hi Alan,

Thank you for confirming. We will add these parameters to the StartDebuggingOptions and include these changes in the next minor update.

Kind regards,
Dmitry

Hi Alan,

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.

Kind regards,
Dmitry

Hi Dmitry,

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?
Thanks.

Hi Sara,

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.

Kind regards,
Dmitry