[Python-Dev] playback debugging

Jack Diederich jack@performancedrivers.com
Thu, 9 Jan 2003 13:57:00 -0500


On Wed, Jan 08, 2003 at 09:12:26PM -0500, Guido van Rossum wrote:
> > Would it be possible to save every function return/stack in a running
> > python program and then playback the results in a debugger?
> > <snip>
> > The idea would be that every function return replays the orignal return
> > even if the outcome is different.  core operations that call out to
> > C wouldn't actually make the call, so random() would always return the
> > same value that it orignally did at that spot.  Ditto for file.read().  
> > The pure python code would almost by definition do excatly the same thing,
> > b/c the inputs would always be identical.  If this isn't always possible a 
> > warning could be issued and the orignal value be returned regardless.
> 
> This sounds like a really cool idea, and I think it would probably be
> possible for small example programs.  I don't know how much work it
> would be, but I support you in trying to get this to work -- as long
> as it doesn't mean extra work for me (I simply have no time).
> Ideally, you would define a *very* small set of changes to the
> existing Python VM that would let you write the rest of the logic of
> this code in Python (even if it had to be ugly Python).  You might
> even try to see if the existing debugger hooks will let you do this --
> you can trap Python function entries and exits.  But I don't think you
> can trap calls to functions implemented in C, so I expect you'll need
> more hooks.  The smaller the hooks are, the more likely they are to be
> accepted in the codebase.  Oh, and they have to be safe -- it should
> not be possible to cause segfaults or other nastiness by abusing the
> hooks.

I was actually just going to mention it, but I guess I'll take a peek
at implementing it too.

Which files define the VM and whither are the debug hooks?
I grepped around for debug hooks, but everything 'grep -i debug *.c'
just seemed to turn up instances of Py_DEBUG or things that only run
when Py_DEBUG is defined.

For C functions it may be possible to wrap them in python by doing
a little name munging on import.  Although that could be tricky and
introduce small problems when people screw with module __dict__'s

-jackdied