Skip to content

Commit c764984

Browse files
committed
A simple tool to see branch tracing arcs
1 parent bd90b20 commit c764984

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lab/branch_trace.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import sys
2+
3+
pairs = set()
4+
last = -1
5+
6+
def trace(frame, event, arg):
7+
global last
8+
if event == "line":
9+
this = frame.f_lineno
10+
pairs.add((last, this))
11+
last = this
12+
return trace
13+
14+
code = open(sys.argv[1]).read()
15+
sys.settrace(trace)
16+
exec(code)
17+
print(sorted(pairs))

0 commit comments

Comments
 (0)