summaryrefslogtreecommitdiff
path: root/lab/branch_trace.py
blob: 7e8e88f9a0ba4982dc78d0f71d876b26a5097b93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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))