[IronPython] Debugging IronPython script code

Rainer Worbis r.worbis at cubido.at
Tue Oct 14 07:04:06 CEST 2008


My initial question was if it is possible to debug code that  is
executed with ScriptSource.Execute(string) - so I do not have a file.

If having a file is important I can 'in debug mode' save my code before
executing.

To answer your question - if I use a filename (ex.: 'C:\Temp\script.py')
I can set breakpoints there - and they will stop execution.

Only when using 'System.Diagnostics.Debugging.Break()' only a decompiled
code is shown. Using this Code is preferred because I normally do not
have the script beforehand - it is partly generated.

 

Rainer

 

Von: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] Im Auftrag von Dino Viehland
Gesendet: Montag, 13. Oktober 2008 18:03
An: Discussion of IronPython
Betreff: Re: [IronPython] Debugging IronPython script code

 

How is the filename specified in the Create call?  Is it a full path?
If you just open the file in VS does VS recognize the code (e.g. can you
set breakpoints)?

 

From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Rainer Worbis
Sent: Sunday, October 12, 2008 10:48 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Debugging IronPython script code

 

Now is't working partly - i used a app.config  <microsoft.scripting
debugMode="true"> which apearently does not setup debugging right.

What is not working is that I get only a disassembly  - no source code
attached.

Is there something to setup before?

 

Rainer

 

Von: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] Im Auftrag von Dino Viehland
Gesendet: Montag, 13. Oktober 2008 07:15
An: Discussion of IronPython
Betreff: Re: [IronPython] Debugging IronPython script code

 

Oh, sorry, it looks like it needs to be a bool, not "true" in quotes...
With that in mind this works for me:

 

        Dictionary<String, object> options = new
Dictionary<string,object>();

        options["Debug"] = true;

        ScriptEngine engine = Python.CreateEngine(options);

        ScriptSource source =
engine.CreateScriptSourceFromFile("C:\\Users\\Dino\\test.py");

        source.Execute();

 

I can put breakpoints in test.py and hit them.

 

From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Rainer Worbis
Sent: Sunday, October 12, 2008 10:02 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Debugging IronPython script code

 

No - i get the Call Stack showed below 

 

[Lightweight Function] 

>
Microsoft.Scripting.dll!Microsoft.Scripting.Runtime.OptimizedScriptCode.
InvokeTarget(Microsoft.Linq.Expressions.LambdaExpression code =
{Microsoft.Linq.Expressions.Expression<Microsoft.Scripting.Runtime.DlrMa
inCallTarget>}, Microsoft.Scripting.Runtime.Scope scope =
{Microsoft.Scripting.Runtime.Scope}) + 0x1c6 bytes           

 
Microsoft.Scripting.dll!Microsoft.Scripting.ScriptCode.Run(Microsoft.Scr
ipting.Runtime.Scope scope = {Microsoft.Scripting.Runtime.Scope}) + 0x42
bytes        

 
Microsoft.Scripting.dll!Microsoft.Scripting.Hosting.CompiledCode.Execute
(Microsoft.Scripting.Hosting.ScriptScope scope =
{Microsoft.Scripting.Hosting.ScriptScope}) + 0x77 bytes             

...

 

Rainer

 

Von: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] Im Auftrag von Dino Viehland
Gesendet: Montag, 13. Oktober 2008 06:55
An: Discussion of IronPython
Betreff: Re: [IronPython] Debugging IronPython script code

 

If you right click in the call stack window and check Show External Code
do you see the code then?

 

From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Rainer Worbis
Sent: Sunday, October 12, 2008 9:53 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Debugging IronPython script code

 

I got as far as that - when the breakpoint is hit - VS pops up but not
in some python code but in the call  to Execute - the python code is
marked as external code.

So is there a possibility to have VS show the script code?

 

Rainer

 

Von: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] Im Auftrag von Dino Viehland
Gesendet: Sonntag, 12. Oktober 2008 21:21
An: Discussion of IronPython
Betreff: Re: [IronPython] Debugging IronPython script code

 

You can set DebugMode = true on a ScriptRuntimeSetup object.  If you're
using the Python class you can pass a Dictionary object to CreateRuntime
with "Debug" = "true" and we'll set it for you.

 

From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Rainer Worbis
Sent: Sunday, October 12, 2008 12:10 PM
To: Users at lists.ironpython.com
Subject: [IronPython] Debugging IronPython script code

 

Hallo all,

 

is there a possibility to debug IronPython code that is executed with
ScriptSource.Execute or CompiledCode.Execute within VisualStudio?

Setting breakpoints in the python code will can be done by
System.Diagnostics.Debugger.Break() - the code breaks but I don't know
how to tell VS to get into my code.

 

Rainer

 

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


More information about the Ironpython-users mailing list