Writing an Iron Python debugger

前端 未结 2 1748
囚心锁ツ
囚心锁ツ 2021-01-05 00:54

As a learning exercise I\'m writing myself a simple extension / plugin / macro framework using IronPython - I\'ve gotten the basics working but I\'d like to add some basic d

2条回答
  •  余生分开走
    2021-01-05 01:31

    A few more links have started to make this a lot clearer - there are 2 ways of adding debugger support that I've seen:

    Debugging IronPython as a CLR application

    The first is to use the fact that IronPython emits IL and debug it using standard techniques used for debugging .Net apps. There is a series of blog posts on this approach by Harry Pierson here about the development of ipydbg - a python debugger that uses this approach.

    • See this post for an overview on where .Net debugging functionality is exposed, and the various wrappers around it (mdbg)
    • The disadvantage of this approach is that this form of debugging completely blocks the application being debugged, and so you must execute your scripts in a second application.

    Using Microsoft.Scripting.Debugging

    Because of this limitation the Microsoft.Scripting.Debugging library was produced instead which is far more suited to for applications which run IronPython "embedded" (i.e. in the same process).

    There is an introduction to it here and a more extensive blog post on how it used here - essentially it consists of a callback function which is executed every time anything "interesting" happens (every time we enter a function, every time we return from a function and every time a line is executed). Execution of the script is blocked while the callback function is running, which allows you to "break" the script.

    I've decided to take the second approach - i'll update this post as I find more information that might be helpful to other trying to do this.

提交回复
热议问题