Mike Stall recently completed a project to embed IronPython into the MDbg debugger as an MDbg extension. IronPython's hosting interface is pretty slick, in fact it took Mike only 10 steps to get IronPython running inside MDbg and expose the debugger functionality to Python scripts via a variable named Shell.
After playing with Mike's extension for a few hours, I'm absolutely amazed by not only how easy it is to use, but how seamless the integration is. For instance, I haven't used Python since college, and have never written an MDbg extension before. However, less than an hour after I sat down to play with this I was able to write a script (which is less than 125 lines of code) that pops up a tree view displaying the processes being debugged, its AppDomains (and the assemblies loaded into them), and the threads with call stacks and locals:
It took only about 10-15 minutes to write a quick script that enables you to set the debugger options via a GUI, which should cut down on the amount of time I spend trying to remember which letter combinations I want to type after "catch" :-)
Since IronPython allows you to use most managed code, including the majority of the frameworks themselves from within your scripts, I used the System.Diagnostics.Process class to kick off a native debugger in order to snap a minidump of the process being debugged:
Of course not wanting to leave well enough alone, I made a couple of modifications to the extension (original source code here). First, I added some new paths to the Python path:
After that, I added the ability to have an autorun script, Startup.py. As the last step of initialization, I simply look for a Startup.py in each of the directories on the path, and if I find it kick it off:
Finally, I added a PythonExtVersion property to the MDbgUtil variable, which allows a script to find out what version of the MDbg python extension it's running under.
This is pretty powerful stuff -- I can easily see not wanting to run MDbg without the ability to lo PythonExt for anything but trivial debugging. Considering how easy it was to get this up and running, if you've got a decent object model to expose to users, embedding IronPython into your application really opens up new doors for your users to use your application in ways you might not have thought of (or didn't have time to implement yourself) -- yet makes their experience much better.