[IronPython] Debugging support PythonEngine

Kristof Wagemans kristof.wagemans at gmail.com
Fri Aug 11 09:35:32 CEST 2006


Are there plans to improve the debugging experience in the future or are you
at a point where it is "as good as it gets"? Being able to debug makes
writing and using python scripts a lot easier.



Inside functions I can see not only the function parameters but also the
newly defined local variables. Are these different from the global
variables? I would have expected that the function locals are also stored
inside a dictionary.



Is it possible to step into python functions without getting into assembly
instructions? This is very frustrating and degrades the debugging experience
a lot. This is the more important issue for me. I'm not going to be using
global variables frequently, but mostly functions loaded in the PythonEngine
that are called from C#.

 

  _____  

From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Shri Borde
Sent: Friday 11 August 2006 0:30
To: Discussion of IronPython
Cc: Glenn Hackney
Subject: Re: [IronPython] Debugging support PythonEngine

 

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
<http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F
0-45DF-8B78-DC1B43134038>  you want to help develop Dynamic languages on
CLR?
(http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F
0-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/20060811/ef124bde/attachment.html>


More information about the Ironpython-users mailing list