Closed epatters closed 5 years ago
The macropy library shows how to implement a simple form of tracing by AST rewriting, although I don't think we need the full macropy
machinery:
https://github.com/lihaoyi/macropy#tracing https://github.com/lihaoyi/macropy/blob/master/macropy/tracing.py
Using
sys.settrace
(orsys.setprofile
) for tracing function calls was a quick way to get started but has fundamental limitations, some of which are documented in #10, #11, and #12.A more flexible and scalable approach is to rewrite the AST with explicit tracing machinery. In a nutshell, replace function calls
with
where
CALL
is a special shim that calls and records a function.It will take a little effort to get this approach off the ground, but it should ultimately work better. We took this approach from the beginning in rflowgraph, because R has no equivalent to
sys.settrace
AFAIK.