[IronPython] Debugging support PythonEngine

Shri Borde Shri.Borde at microsoft.com
Thu Aug 17 23:49:03 CEST 2006

The first issue is probably the same that IL offset 0 does not have any debug information.

Calling the delegate "add" steps into a DynamicMethod which confuses VS. A workaround for now is to add this statement before creating the PythonEngine.
IronPython.Compiler.Options.GenerateDynamicMethods = false;
This disabled the use of DynamicMethods altogether and will instead use AssemblyBuilder. This is not generally recommended or supported since you are going to leak memory since AssemblyBuilder memory cannot be reclaimed. However, VS seems to be better able to deal with AssemblyBuilder during stepping, and it might be good enough for you. This is a case where we will would need to teach the tool (VS) to handle DynamicMethods differently than it currently does.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kristof Wagemans
Sent: Thursday, August 17, 2006 1:54 PM
To: 'Discussion of IronPython'
Subject: Re: [IronPython] Debugging support PythonEngine

It's good to hear that it's fixable. But, off course, here's the next one J.

With the same little script:
x = 1
y = 2

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

z = Add(x, y)
print z

And the following C# code:
EngineOptions options = new EngineOptions();
options.ClrDebuggingEnabled = true;
PythonEngine _pe = new PythonEngine(options);

delegate int Add(int a, int b);

_pe.ExecuteFile(@"  script path   ");
Add add = _pe.EvaluateAs<Add>("Add");
int var1 = add(2, 3);
int var2 = add(3, 4);

The following happens:
(I use a release version of Ironpython (RC2). There are no debug symbols present, so that I don't step into the engine code.)
I step into ExecuteFile (F11) and get into native code. After a few lines of native code, I can go back to the source code view and I'm in the Python script file. Maybe this is a similar issue as with stepping into a function?
Next, I get a delegate to the Python Add function. The first time I step into the add delegate I get the stepping into a function problem and then I'm inside the function. But, when I try to step into the next add delegate this doesn't work anymore: the line is marked in green in Visual Studio and I remain in the C# code. The next step into command resumes on the next line in the C# code. I can't see a reason why it would fail with the next add. Setting a breakpoint in the Python function stops the execution at that point in both cases.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Shri Borde
Sent: Thursday 17 August 2006 20:25
To: Discussion of IronPython
Subject: Re: [IronPython] Debugging support PythonEngine

I have opened this bug - http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&WorkItemId=2248 - to track the issue with stepping in. We are not emitting any line number information for IL offset 0.

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

More information about the Ironpython-users mailing list