[Python-Dev] profiler hooks

Fred L. Drake, Jr. fdrake@acm.org
Fri, 12 Oct 2001 17:03:36 -0400


Samuele Pedroni writes:
 > Will your changes propagate to changes to pdb etc?
 > because in that case they will need to be ported
 > to jython, that actually supports both tracers (pdb ) and profilers 
 > (profile ).

  Changes to bdb/pdb will probably be required, but I'm not sure yet.
The biggest change I expect for debugging is that a 'return' event
will be generated even when an exception is being propogated, but what
this means is that the code that runs for the 'exception' event will
not need to be so magical (this was why the old profiler results were
so terribly difficult to interpret -- the times were often wrong
depending on just how exceptions were handled in the application
code).
  The recent changes to ceval.c for the profiler ensure that the
profiler receives a 'return' event when control leaves a frame, even
if an exception was set, and expception events are no longer reported
to the profiler.  This avoids the messy code needed to ensure the
profiler accounted for timimg properly for 'exception' events, which
is still quite fragile -- it works very hard just to make sure it
doesn't lose track of the stack.  Making the tracer also receive
matching call/return events means that the exception events should no
longer need to worry about stack management, which should make the
code simpler.
  I don't know if Jython uses the same pdb.py as CPython, so I don't
know what affects will show up there.


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation