[IronPython] Debugging support PythonEngine

Shri Borde Shri.Borde at microsoft.com
Fri Aug 11 00:30:13 CEST 2006


If EngineOptions.ClrDebuggingEnabled is set, we use AssemblyBuilder, TypeBuilder, etc for PythonEngine.Executed. The code generated by AssemblyBuilder, TypeBuilder, etc supports PDB debug information tracking for the methods, and so you will be able to set breakpoints in the code. However, it does not guarantee a perfect debugging experience. PythonEngine.ExecuteFile will use a dictionary for storing global variables, and these will not be visible because VS does not know about the dictionary. If you use PythonEngine.CreateOptimizedModule, most global variables are implemented using CLR statics, and so VS may be able to display them for you. Global variables added using an exec statement will still not be visible.

If EngineOptions.ClrDebuggingEnabled is false, we will use System.Reflection.Emit.DynamicMethod. This does not support debug information tracking at all, and you will not even be able to see function variables.

So If EngineOptions.ClrDebuggingEnabled is will improve your debugging experience, but it wont give you a perfect experience.

________
Do you want to help develop Dynamic languages on CLR?<http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038> (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kristof Wagemans
Sent: Thursday, August 10, 2006 2:10 PM
To: Discussion of IronPython
Subject: [IronPython] Debugging support PythonEngine

I have been experimenting with the debugging support for the PythonEngine. When I use the following code I have several problems.

PythonEngine _pe;
EngineOptions options = new EngineOptions();
options.ClrDebuggingEnabled = true;
_pe = new PythonEngine(options);
_pe.ExecuteFile(@"  <script>  ");

Test script:

x = 1
y = 2

def Add(a, b):
    return a + b

z = Add(x, y)
print z


I opened the script file in Visual Studio and placed a breakpoint at the beginning of the file. The application runs and breaks at the correct location. Stepping through the lines works, but I cannot see any values of the global variables.
When I try to step into the function I get a notification that there is no source code available and I must show the disassembly. After I step several times through the assembly instructions I can return to the original source code. Inside the function I can see the values of the function variables.
I have tried debugging ipy.exe with the script and there I can see the global variables, but I still have the problem with stepping into a function. In ipy.exe the script file is executed in a different way. Using the same method I can also see the global variables with my PythonEngine instance. I apparently don't need to set ClrDebuggingEnabled in this case.

PythonEngine _pe;
_pe = new PythonEngine();
OptimizedEngineModule engineModule = _pe.CreateOptimizedModule(@"  <script>  ", "__main__", true);
engineModule.Execute();

Are you required to use an OptimizedEngineModule to be able to debug completely? Am I forgetting some settings for debugging? Can I step directly into a function without getting into the assembly instructions?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060810/cb314eb5/attachment.html>


More information about the Ironpython-users mailing list