Hot Code Patching in CPython: Supporting Edit-and-Continue Debugging in CPython with Less Than 300 Lines of Code

Some language runtimes such as Java Hotspot or the virtual machine for Squeak/Smalltalk support edit-and-continue debugging, which allows developers to make changes to a program while it is running. This capability is especially useful for recovering from errors in a program. However, it is not supported by CPython, the reference interpreter for Python. In this paper, we demonstrate how edit-and-continue debugging can be integrated into CPython in just under 300 lines of code. We evaluate performance implications, demonstrate how this style of debugging improves the programming experience, and discuss limitations of our approach.

[1]  Robert Hirschfeld,et al.  How Live are Live Programming Systems?: Benchmarking the Response Times of Live Programming Environments , 2016, PX/16.

[2]  Galen C. Hunt,et al.  Debugging in the (very) large: ten years of implementation and experience , 2009, SOSP '09.

[3]  M.N. Sastry,et al.  Structure and interpretation of computer programs , 1986, Proceedings of the IEEE.

[4]  et al.,et al.  Jupyter Notebooks - a publishing format for reproducible computational workflows , 2016, ELPUB.

[5]  Gerald J. Sussman,et al.  Structure and interpretation of computer programs , 1985, Proceedings of the IEEE.

[6]  G. vanRossum Python reference manual , 1995 .

[7]  Foreword to Why Programs Fail: A Guide to Systematic Debugging , 2005 .

[8]  Robert Hirschfeld,et al.  Exploratory and Live, Programming and Coding: A Literature Study Comparing Perspectives on Liveness , 2018, Art Sci. Eng. Program..

[9]  Steven K. Feiner,et al.  Multi-Language Edit-and-Continue for the Masses , 2005 .

[10]  Jason Trenouth A Survey of Exploratory Software Development , 1991, Comput. J..

[11]  Robert Hirschfeld,et al.  Live Multi-language Development and Runtime Environments , 2018, Art Sci. Eng. Program..

[12]  Bil Lewis,et al.  Debugging Backwards in Time , 2003, ArXiv.

[13]  Mikhail Dmitriev Profiling Java applications using code hotswapping and dynamic call graph revelation , 2004, WOSP '04.

[14]  David W. Sandberg Smalltalk and exploratory programming , 1988, SIGP.

[15]  Carl Friedrich Bolz,et al.  Tracing the meta-level: PyPy's tracing JIT compiler , 2009, ICOOOLPS@ECOOP.

[16]  David Pacheco Postmortem Debugging in Dynamic Environments , 2011, ACM Queue.