A Time Travelling Debugger for Python

Department of Computing Imperial College London

MEng Individual Project

A Time Travelling Debugger for Python

Niklas Steidl

supervised by Dr. Robert Chatley

June 2016

Abstract Time travelling debuggers (TTD) allow programmers to step backwards through the execution of their program, helping them to explore code and find the cause of bugs. This project presents an efficient TTD for the Python[28] language. Through modifying the Jython[15] Python interpreter, we implement a) tdb, a simple re-execution based TTD, b) odb a logging based TTD and c) a design for an efficient hybrid TTD. Existing TTDs are either implemented by logging changes to a program's state during execution or by taking snapshots of the program and re-executing to a given time point. Such debuggers run slowly and / or use large amounts of memory. A Python TTD written in Python would be straightforward to implement, but slow as the debugger itself would be interpreted in addition to the program being debugged. Our hybrid design embeds TTD functionality in the interpreter. In order to support responsive debugging of non-trivial programs, we have implemented interpreter level instruction counting and a copy-on-write mechanism to maintain history. This is difficult as the internal representation of objects and data structures must be modified. Combined, we use these features to efficiently travel backwards through the execution of a program. Our implementation performs better or on a level with with state of the art TTDs. The performance of tdb and odb are respectively 4 and 3 orders of magnitudes better than epdb, an existing Python TTD, when running the bm call method, bm call simple, bm fannkuch, bm nbody, bm raytrace CPython performance benchmarks1. The instruction counting method used in odb and tdb has half the overhead of epdb when running the textitpybench benchmark. These initial findings show that our hybrid design is viable, and could be applied to other languages.

1

Acknowledgments

I would like to express my sincere thanks to: My supervisor, Dr. Robert Chatley, for agreeing to supervise my project and giving me great advice when I doubted my project. My personal tutor, Dr. Tony Field, for his words of encouragement, and the guidance has given me over the past 4 years. My family, for supporting me in any way they could. I appreciate everything you have done for me. Last but not least, my friends, who made the last 4 years fly by. In particular, my group project dream team: Stephen, Adrian, Bradley, Luke, George, Tom and Oskar.

iii

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download