<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>

<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
        {font-family:"Bookman Old Style";
        panose-1:2 5 6 4 5 5 5 2 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.balloontextchar0
        {mso-style-name:balloontextchar;
        mso-style-priority:99;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Arial","sans-serif";
        color:windowtext;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Arial","sans-serif";
        color:navy;}
span.EmailStyle23
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle24
        {mso-style-type:personal;
        font-family:"Arial","sans-serif";
        color:navy;}
span.EmailStyle25
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>We have started doing some work for improving debugging as shown
by the VSIP sample (<a
href="http://blogs.msdn.com/aaronmar/archive/2006/02/16/533273.aspx">http://blogs.msdn.com/aaronmar/archive/2006/02/16/533273.aspx</a>).
However, it still needs more work for it to be production-quality. By tools
support, I was referring more to VSIP sample. We don&#8217;t have a concrete
timeline for when we will be able to improve it further.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Btw, using your sample script below, in most cases, I am able to
step from Python code into C# code in IronPython.dll if I hit F11 in VS. However,
when IronPython.dll calls the method Add, we step into native code for a while
before actually reaching the source code for Add. This looks like something we
can fix by changing the debug information we generate. After doing this fix, it
would be possible to mark </span><span style='font-size:10.0pt;font-family:
"Arial","sans-serif";color:navy'>IronPython.dll as library code (either using DebuggerNonUserCodeAttribute
or through some other scheme), and be able to step from Python code into a
Python method.</span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>x
= 1<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>y
= 2<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>def
Add(a, b):<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;&nbsp;
return a + b<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>z
= Add(x, y) </span><span style='font-size:10.0pt;font-family:Wingdings;
color:#0070C0'>&szlig;</span><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#0070C0'> Stepping in here takes you to IronPython.dll source code, then
native code, and then the source code for Add</span><span style='font-size:
10.0pt;font-family:"Arial","sans-serif"'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>print
z<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div>

<div style='border:none;border-top:solid #91C0FF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'>From:</span></b><span
style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Kristof Wagemans<br>
<b>Sent:</b> Saturday, August 12, 2006 1:38 AM<br>
<b>To:</b> 'Discussion of IronPython'<br>
<b>Subject:</b> Re: [IronPython] Debugging support PythonEngine<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:navy'>Thanks for the info. It&#8217;s good to hear that there will be
improvement possible in this area in the future. Although, the way I interpret
your explanation, it&#8217;s not going to be anytime soon (or even this year),
because you need enhancements to the underlying platform to make this possible.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:navy'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:navy'>I&#8217;ve experimented a bit with
System.Diagnostics.DebuggerNonUserCodeAttribute to see if it wasn&#8217;t
possible to skip stepping into IronPython code. Unfortunately, the point where
I get stuck in the assembly instructions is in generated code. I don&#8217;t
understand this part of the code well enough to know if it&#8217;s possible to
make the debugger skip these lines. Maybe this is why you need the changes to
the platform?<o:p></o:p></span></p>

<div>

<div class=MsoNormal align=center style='text-align:center'>

<hr size=3 width="100%" align=center>

</div>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Shri Borde<br>
<b>Sent:</b> Friday 11 August 2006 21:04<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] Debugging support PythonEngine</span><o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Yes, we will definitely be working on improving the debugging
support as it is a critical part of the development process. &nbsp;However,
full support will need work in all parts of the tool chain including VS.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Python local variables are implemented as normal MSIL variables
(except in cases like closures). Hence, VS is able to display them.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Currently, the best way to debug Python functions in VS while
using PythonEngine would be to enable EngineOptions.</span><span
style='font-size:10.0pt;font-family:"Arial","sans-serif"'>ClrDebuggingEnable</span><span
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>,
open the PY file in VS and put a breakpoint where you want. Stepping in and out
of Python functions will step you through methods in IronPython.dll .<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'>From:</span></b><span
style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Kristof Wagemans<br>
<b>Sent:</b> Friday, August 11, 2006 12:36 AM<br>
<b>To:</b> 'Discussion of IronPython'<br>
<b>Subject:</b> Re: [IronPython] Debugging support PythonEngine<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:10.0pt;
font-family:"Arial","sans-serif";color:navy'>Are there plans to improve the
debugging experience in the future or are you at a point where it is &#8220;as
good as it gets&#8221;? Being able to debug makes writing and using python
scripts a lot easier.<o:p></o:p></span></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:10.0pt;
font-family:"Arial","sans-serif";color:navy'>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.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:navy'>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&#8217;m not going
to be using global variables frequently, but mostly functions loaded in the
PythonEngine that are called from C#.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:navy'><o:p>&nbsp;</o:p></span></p>

<div>

<div class=MsoNormal align=center style='text-align:center'>

<hr size=3 width="100%" align=center>

</div>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Shri Borde<br>
<b>Sent:</b> Friday 11 August 2006 0:30<br>
<b>To:</b> Discussion of IronPython<br>
<b>Cc:</b> Glenn Hackney<br>
<b>Subject:</b> Re: [IronPython] Debugging support PythonEngine</span><o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>If EngineOptions.</span><span style='font-size:10.0pt;
font-family:"Arial","sans-serif"'>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.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>If EngineOptions.</span><span style='font-size:10.0pt;
font-family:"Arial","sans-serif"'>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.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>So
</span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>If EngineOptions.</span><span style='font-size:10.0pt;
font-family:"Arial","sans-serif"'>ClrDebuggingEnabled is will improve your
debugging experience, but it wont give you a perfect experience.</span><span
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#1F497D'>________</span></b><span style='font-size:8.0pt;font-family:
"Bookman Old Style","serif";color:#1F497D'> <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:8.0pt;font-family:"Bookman Old Style","serif";
color:#1F497D'><a
href="http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038">Do
you want to help develop Dynamic languages on CLR?</a> </span><span
style='font-size:1.0pt;font-family:"Bookman Old Style","serif";color:white'>(<a
href="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</a>)</span><span
style='font-size:8.0pt;font-family:"Bookman Old Style","serif"'><o:p></o:p></span></p>

</div>

<div>

<div style='border:none;border-top:solid #91C0FF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'>From:</span></b><span
style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Kristof Wagemans<br>
<b>Sent:</b> Thursday, August 10, 2006 2:10 PM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> [IronPython] Debugging support PythonEngine<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>I
have been experimenting with the debugging support for the PythonEngine. When I
use the following code I have several problems.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>PythonEngine
_pe;<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>EngineOptions
options = new EngineOptions();<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>options.ClrDebuggingEnabled
= true;<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>_pe
= new PythonEngine(options);<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>_pe.ExecuteFile(@&quot;&nbsp;
&lt;script&gt;&nbsp; &quot;);<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Test
script:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>x
= 1<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>y
= 2<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>def
Add(a, b):<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;&nbsp;
return a + b<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>z
= Add(x, y)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>print
z<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>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.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>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.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>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&#8217;t need to set ClrDebuggingEnabled in this case.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>PythonEngine
_pe;<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>_pe
= new PythonEngine();<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>OptimizedEngineModule
engineModule = _pe.CreateOptimizedModule(@&quot;&nbsp; &lt;script&gt;&nbsp;
&quot;, &quot;__main__&quot;, true);<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>engineModule.Execute();<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>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?<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p>

</div>

</body>

</html>