[IronPython] how to get mdbg to work with IP - or is it even possible?

Dino Viehland dinov at exchange.microsoft.com
Thu Sep 13 17:33:30 CEST 2007


What are you trying to debug in particular?  Is it a file of Python code or code you enter at the console?

Code in a file is generally debuggable (presumably by all debuggers) where code entered at the console, via eval or exec, is not debuggable - by any debugger.  The reason for this is that the latter is generated using DynamicMethod's (which are fully collectable by the GC) but don't have any debugging support at the CLR level.

Additionally we did run into some issues when we tried testing IronPython w/ MDBG and these could be what you're hitting.  If we compile a file such as:

def foo():
        print 'hello'

def bar():
        print 'goodbye'

foo()
bar()

We end up creating 3 (really more, but only 3 are important) methods in a single type.  The first two methods are foo and bar.   The 3rd method is an Initialize method which is the file of code which contains foo and bar.  Because of this and the fact that the code gets generated w/ Ref Emit MDBG receives multiple notifications of when a symbols are loaded.  On those notifications it updates it's source mapping and because there is overlap between the methods it gets confused.  The MDBG team has a bug on this issue as they recognize it'll be a common problem w/ dynamic languages.  Unfortunately I'm not sure if they fixed it yet - they're busy working on Silverlight and we haven't pushed them very hard on the issue.

In theory it should be possible to write an MDBG extension that can successfully set breakpoints in this case (or fix the bug in the publicly available mdbg source code) but by default you're going to have a difficult time with it.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of David.Lawler at franke.com
Sent: Thursday, September 13, 2007 5:21 AM
To: Discussion of IronPython
Subject: Re: [IronPython] how to get mdbg to work with IP - or is it even possible?

Hi - Thanks Dave,

But while that shows how to embed Ironpython in Mdbg, I am looking to use
Mdbg to debug IronPython
programs/scripts.  When I do this now with Clrdbg I can load the source
and step through it, set break points etc.
With Mdbg, if I use a self compiled version of Ironpython with the pdb
files in place I can see the IronPython source
and put breakpoints in it.  However, I cannot do anything at the
Ironpython program/script level.  If I use a release version
of Ironpython (or the binary) then I can't get anything useful to happen.

David

users-bounces at lists.ironpython.com wrote on 09/12/2007 07:48:26 PM:

> This link (http://blogs.msdn.
> com/jmstall/archive/2005/08/31/Mdbg_Python_ext.aspx) is a bit out of
> date, but hopefully points you in the right direction.
>
> Dave
>
> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-
> bounces at lists.ironpython.com] On Behalf Of David.Lawler at franke.com
> Sent: Wednesday, September 12, 2007 4:21 PM
> To: Discussion of IronPython
> Subject: [IronPython] how to get mdbg to work with IP - or is it
> even possible?
>
> I can debug IP 2 programs fairly nicely with clrdbg even setting break
> points and examining variables but I have tried to get mdbg (and cordbg)
> to work with no success.  I am interested in mdbg because I would like
to
> learn more about how debugging support works with the clr and with IP in
> particular and the source is available for mdbg.  Has anyone had success
> with mdbg and Ironpython or does this just not work.  If it can work can
> you give me some clues about the commands that make it work?
>
> Thanks!
>
> David
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list