Talks -Toby Ho: Rewind: Python Time-Travel Debugger

Learn about PyRewind, a powerful time-travel debugger for Python that lets you step backwards and forwards through program execution and inspect state history.

Key takeaways
  • PyRewind is a time-travel debugger for Python that allows stepping backwards and forwards through program execution

  • The debugger stores program state history in a SQLite database containing:

    • Python code files
    • Runtime errors
    • Function calls
    • Variable values
    • Stack traces
    • Print output
  • Two main approaches to time-travel debugging:

    • Record/replay of program execution and inputs
    • Immutable state updates with history preservation
  • Key benefits over traditional debuggers:

    • No need to set breakpoints
    • Can inspect program state at any point in time
    • Eliminates Heisenbugs by providing deterministic replay
    • Allows live code editing during debugging
  • Technical implementation details:

    • Logs all state changes and function calls
    • Captures communication with external world
    • Creates deterministic replay from recorded logs
    • Built as a fork of Python 3.10 interpreter
  • Inspired by:

    • Brett Victor’s “Inventing on Principle” talk
    • Redux developer tools
    • Mozilla’s RR debugger
    • Omniscient debugging concepts
  • Limitations:

    • Complex to implement at interpreter level
    • Storage requirements for program state history
    • Handling infinite loops remains challenging
    • Non-deterministic inputs need special handling