From c7649842853de89c9a67c3f361f967349b17cb5f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 31 Dec 2020 18:34:37 -0500 Subject: A simple tool to see branch tracing arcs --- lab/branch_trace.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lab/branch_trace.py (limited to 'lab') diff --git a/lab/branch_trace.py b/lab/branch_trace.py new file mode 100644 index 00000000..7e8e88f9 --- /dev/null +++ b/lab/branch_trace.py @@ -0,0 +1,17 @@ +import sys + +pairs = set() +last = -1 + +def trace(frame, event, arg): + global last + if event == "line": + this = frame.f_lineno + pairs.add((last, this)) + last = this + return trace + +code = open(sys.argv[1]).read() +sys.settrace(trace) +exec(code) +print(sorted(pairs)) -- cgit v1.2.1