debugger

Jul 8, 2009 at 1:02 AM
Are there any examples of developing a debugger for a scripting engine
based on the DLR?

Thanks!

slide

--
slide-o-blog
http://slide-o-blog.blogspot.com/
Jul 8, 2009 at 1:43 AM
There's this: http://devhawk.net/CategoryView,category,Debugger.aspx

On Tue, Jul 7, 2009 at 7:02 PM, slide_o_mix <notifications@codeplex.com> wrote:

From: slide_o_mix

Are there any examples of developing a debugger for a scripting engine
based on the DLR?

Thanks!

slide

--
slide-o-blog
http://slide-o-blog.blogspot.com/

Read the full discussion online.

To add a post to this discussion, reply to this email (dlr@discussions.codeplex.com)

To start a new discussion for this project, email dlr@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jul 8, 2009 at 8:09 AM

The ipydbg one mentioned is looking good. I've also started work on a debugging infrastructure for my own DLR project at http://connectbasic.codeplex.com/ which I'm hoping will end up working both in interpreted and compiled mode, if you look in the source on CodePlex it's primarily under the ConnectDebug project, it's still very early days but it's getting better and does stepping and locals inspection.

Coordinator
Jul 8, 2009 at 6:13 PM

We also just added a new assembly called Microsoft.Scripting.Debugging that supports an in-proc form of debugging.  The advantage of this is usually that you can keep the debugged process responsive while debugging.  That’s extremely useful when you’re plugging scripting into an existing application and you don’t want the application to freeze. 

There’s no good isolated example of how to use this but if you look in IronPython at FunctionCode.GetGeneratorOrNormalLambdaTracing you can see where we hook in and re-write the code so that it supports this.  And then PythonTracebackListener is the class which responds to all of the available debugging events.

From: diakopter [mailto:notifications@codeplex.com]
Sent: Tuesday, July 07, 2009 5:43 PM
To: Dino Viehland
Subject: Re: debugger [dlr:61789]

From: diakopter

There's this: http://devhawk.net/CategoryView,category,Debugger.aspx

On Tue, Jul 7, 2009 at 7:02 PM, slide_o_mix <notifications@codeplex.com> wrote:

From: slide_o_mix

Are there any examples of developing a debugger for a scripting engine
based on the DLR?

Thanks!

slide

--
slide-o-blog
http://slide-o-blog.blogspot.com/

Read the full discussion online.

To add a post to this discussion, reply to this email (dlr@discussions.codeplex.com)

To start a new discussion for this project, email dlr@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Read the full discussion online.

To add a post to this discussion, reply to this email (dlr@discussions.codeplex.com)

To start a new discussion for this project, email dlr@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Aug 19, 2009 at 3:01 PM

Help !
Is there any more information available on how to use the new debugging classes for embedded hosting?
I have tried the code below and it doesn't work - the OnTraceBack event never fires.


Dictionary options = new Dictionary();
options["FullFrames"] = ScriptingRuntimeHelpers.True;
options["Debug"] = ScriptingRuntimeHelpers.True;
ScriptEngine engine = Python.CreateEngine(options);
Python.SetTrace(engine, OnTraceBack);
try
{
engine.ExecuteFile("C:\\Workspace\\ScriptDemo\\ScriptDemo\\test.py");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}

Thanks

<font face="Courier New" size="2"><font face="Courier New" size="2">

 

 

 

</font></font><font face="Courier New" size="2">

 

</font>

 

 

Coordinator
Aug 19, 2009 at 5:28 PM

What does test.py contain?  Is it just all top-level code (no functions)? 

This looks like it’s a bug in IronPython – we don’t support tracing module code.  I’ve created a bug at:

http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=24381

Thanks for reporting this!

From: atomicpigeon [mailto:notifications@codeplex.com]
Sent: Wednesday, August 19, 2009 7:02 AM
To: Dino Viehland
Subject: Re: debugger [dlr:61789]

From: atomicpigeon

Help !
Is there any more information available on how to use the new debugging classes for embedded hosting?
I have tried the code below and it doesn't work - the OnTraceBack event never fires.

Dictionary options = new Dictionary();
options["FullFrames"] = ScriptingRuntimeHelpers.True;
options["Debug"] = ScriptingRuntimeHelpers.True;
ScriptEngine engine = Python.CreateEngine(options);
Python.SetTrace(engine, OnTraceBack);
try
{
engine.ExecuteFile("C:\\Workspace\\ScriptDemo\\ScriptDemo\\test.py");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}

Thanks

<font face="Courier New" size="2"><font face="Courier New" size="2">

</font></font><font face="Courier New" size="2">

</font>

Read the full discussion online.

To add a post to this discussion, reply to this email (dlr@discussions.codeplex.com)

To start a new discussion for this project, email dlr@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Aug 20, 2009 at 11:49 AM

Thanks.

Test.py does contain only top level code:

for i in range(1, 5):
  for j in range (1, 5):
    print i
    print j

So if I had this code in a function, would it work ?

Also has the debugging functionality been implemented only for IronPython or for the DLR generally ?

Specifically, if I were to write my own scripting language for the DLR, what would I need to do implement script debugging ?

I am mainly interested in debugging  scripts executed within a C# app (as opposed to scripts execute from a console like IPY.EXE)

 

Coordinator
Aug 20, 2009 at 4:40 PM

Yes, if it was in a function you’d be able to debug the function.

There is general DLR support for debugging in Microsoft.Scripting.Debugging. But languages need to make some changes to call into this DLL to get debugging support enabled.  In particular they need to make a DebugContext object, create a TracePipeline for that debug context, and then use the debug context to re-write the code to be debuggable using DebugContext.TransformLambda.  They then get calls back to the trace pipeline which includes stepping, function entry, etc… that they can expose out to the language however they like (in python’s case via sys.settrace).

From: atomicpigeon [mailto:notifications@codeplex.com]
Sent: Thursday, August 20, 2009 3:50 AM
To: Dino Viehland
Subject: Re: debugger [dlr:61789]

From: atomicpigeon

Thanks.

Test.py does contain only top level code:

for i in range(1, 5):
for j in range (1, 5):
print i
print j

So if I had this code in a function, would it work ?

Also has the debugging functionality been implemented only for IronPython or for the DLR generally ?

Specifically, if I were to write my own scripting language for the DLR, what would I need to do implement script debugging ?

I am mainly interested in debugging scripts executed within a C# app (as opposed to scripts execute from a console like IPY.EXE)

Read the full discussion online.

To add a post to this discussion, reply to this email (dlr@discussions.codeplex.com)

To start a new discussion for this project, email dlr@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Sep 3, 2009 at 5:03 PM
Edited Sep 3, 2009 at 5:07 PM

Still having problems. I am now executing this script containing a single function call.

def testfunc():
  for i in range(1, 5):
    for j in range (1, 5):
      print i
      print j

testfunc()

When I execute this with debugging enabled, it fails with an exception:

Object reference not set to an instance of an object   at IronPython.Runtime.PythonFunction.FunctionCaller.Call0(CallSite site, CodeContext context, Object func) in C:\\Workspace\\IronPython_Main\\Src\\IronPython\\Runtime\\PythonFunction.Generated.cs:line 258   at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting.Core\\Actions\\UpdateDelegates.Generated.cs:line 388   at <unnamed>$2.<unnamed>(Scope $scope, LanguageContext $language) in C:\\Workspace\\ScriptDemo\\ScriptDemo\\test.py:line 7  at IronPython.Compiler.PythonScriptCode.Run(Scope scope) in C:\\Workspace\\IronPython_Main\\Src\\IronPython\\Compiler\\PythonScriptCode.cs:line 43  at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(LambdaExpression code, Scope scope) in C:\\Workspace\\IronPython_Main\\Src\\IronPython\\Compiler\\RuntimeScriptCode.cs:line 77   at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope) in C:\\Workspace\\IronPython_Main\\Src\\IronPython\\Compiler\\RuntimeScriptCode.cs:line 56  at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting\\SourceUnit.cs:line 232  at Microsoft.Scripting.SourceUnit.Execute(Scope scope) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting\\SourceUnit.cs:line 217  at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting\\Hosting\\ScriptSource.cs:line 133   at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path, ScriptScope scope) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting\\Hosting\\ScriptEngine.cs:line 164  at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting\\Hosting\\ScriptEngine.cs:line 153  at ScriptDemo.Form1.buttonRun_Click(Object sender, EventArgs e) in C:\\Workspace\\ScriptDemo\\ScriptDemo\\Form1.cs:line 128"

 

Coordinator
Sep 3, 2009 at 5:26 PM

Can you include the actual exception name/type?  For comparison this program executes fine for me:

using IronPython.Hosting;

using IronPython.Runtime.Exceptions;

using Microsoft.Scripting;

using System;

using IronPython.Runtime;

using IronPython.Runtime.Types;

namespace Fail {

    public class Fail {

        private static TracebackDelegate TraceFunc(TraceBackFrame x, string y, object z) {

            Console.WriteLine("{0} {1} {2}", x, y, z);

            return TraceFunc;

        }

       

        public static void Main() {

            var pythonEngine = Python.CreateEngine();

            pythonEngine.SetTrace(TraceFunc);

            var source = pythonEngine.CreateScriptSourceFromString(@"

def testfunc():

    for i in range(1, 5):

        for j in range (1, 5):

          print i

          print j

testfunc()

",

    SourceCodeKind.File);

            source.Execute();

           

        }

    }

}

From: atomicpigeon [mailto:notifications@codeplex.com]
Sent: Thursday, September 03, 2009 9:04 AM
To: Dino Viehland
Subject: Re: debugger [dlr:61789]

From: atomicpigeon

Still having problems. I am now executing this script containing a single function call.

def testfunc():
for i in range(1, 5):
for j in range (1, 5):
print i
print j

testfunc()

When I execute this with debugging enabled, it fails with an execption:

" at IronPython.Runtime.PythonFunction.FunctionCaller.Call0(CallSite site, CodeContext context, Object func) in C:\\Workspace\\IronPython_Main\\Src\\IronPython\\Runtime\\PythonFunction.Generated.cs:line 258\r\n at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting.Core\\Actions\\UpdateDelegates.Generated.cs:line 388\r\n at <unnamed>$2.<unnamed>(Scope $scope, LanguageContext $language) in C:\\Workspace\\ScriptDemo\\ScriptDemo\\test.py:line 7\r\n at IronPython.Compiler.PythonScriptCode.Run(Scope scope) in C:\\Workspace\\IronPython_Main\\Src\\IronPython\\Compiler\\PythonScriptCode.cs:line 43\r\n at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(LambdaExpression code, Scope scope) in C:\\Workspace\\IronPython_Main\\Src\\IronPython\\Compiler\\RuntimeScriptCode.cs:line 77\r\n at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope) in C:\\Workspace\\IronPython_Main\\Src\\IronPython\\Compiler\\RuntimeScriptCode.cs:line 56\r\n at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting\\SourceUnit.cs:line 232\r\n at Microsoft.Scripting.SourceUnit.Execute(Scope scope) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting\\SourceUnit.cs:line 217\r\n at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting\\Hosting\\ScriptSource.cs:line 133\r\n at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path, ScriptScope scope) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting\\Hosting\\ScriptEngine.cs:line 164\r\n at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path) in C:\\Workspace\\IronPython_Main\\Src\\Runtime\\Microsoft.Scripting\\Hosting\\ScriptEngine.cs:line 153\r\n at ScriptDemo.Form1.buttonRun_Click(Object sender, EventArgs e) in C:\\Workspace\\ScriptDemo\\ScriptDemo\\Form1.cs:line 128"

Read the full discussion online.

To add a post to this discussion, reply to this email (dlr@discussions.codeplex.com)

To start a new discussion for this project, email dlr@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Sep 4, 2009 at 3:31 PM
Edited Sep 4, 2009 at 3:34 PM

The only significant difference between your code and mine is that I set a Debug option in the engine options: 

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

options["FullFrames"] = ScriptingRuntimeHelpers.True;

options["Debug"] = ScriptingRuntimeHelpers.True;

ScriptEngine engine = Python.CreateEngine(options);

When I comment this out my program works !

I thought the Debug option was needed to enable debugging but was wrong.

In answer to your question, the exception  was a Null Reference Exception.

 

 

When do you use the options then ?

Coordinator
Sep 4, 2009 at 5:16 PM

The Debug option enables CLR-style debugging – this lets Visual Studio and other .NET debuggers attach to the process, set break points, step through code, etc…  It’s not necessary if you want to do Python style debugging w/ sys.settrace.  In fact I would recommend against it because it forces all code to be compiled in a way which prevents the GC from ever collecting it.

The good news is this combination seems to be working correctly in the latest source code.

From: atomicpigeon [mailto:notifications@codeplex.com]
Sent: Friday, September 04, 2009 7:31 AM
To: Dino Viehland
Subject: Re: debugger [dlr:61789]

From: atomicpigeon

The only significant difference between your code and mine is that I set a Debug option in the engine options:

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

options["FullFrames"] = ScriptingRuntimeHelpers.True;

options["Debug"] = ScriptingRuntimeHelpers.True;

ScriptEngine engine = Python.CreateEngine(options);

Python.SetTrace(engine, OnTraceBack);

When I comment this out my program works !

I thought the Debug option was needed to enable debugging but was wrong.

<font size="2">

When do you use the options then ?

</font>

In answer to your question, the exception was a Null Reference Exception.

Read the full discussion online.

To add a post to this discussion, reply to this email (dlr@discussions.codeplex.com)

To start a new discussion for this project, email dlr@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com