gak / pycallgraph

pycallgraph is a Python module that creates call graphs for Python programs.
GNU General Public License v2.0
1.83k stars 335 forks source link

Not registering 'return' #46

Closed gak closed 15 years ago

gak commented 15 years ago

The callgraphs I generated looked wrong. It turns out that the tracer function needs to return a tracer to be used in each local scope! (See http://www.python.org/doc/2.3.4/lib/debugger-hooks.html#debugger-hooks)

I added a line to tracer, to return itself. That seemed to work:

{{{ def tracer(frame, event, arg): ................ if event == 'return': if pr: print 'return' if call_stack: call_stack.pop(-1) return tracer #new

}}}

gak commented 15 years ago

Author: mig000 yepp, same problem with the same solution

gak commented 15 years ago

Author: gak