summaryrefslogtreecommitdiffstats
path: root/openbsc/contrib/bt.py
blob: 1b111efc8b046bbdfbc9f5be4018d026dd17f843 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python

import os

f = open("unbalanced")
lines = []
for line in f:
    lines.append(line)

filenames = {}

output = []
for line in lines:
    if "[0x" in line:
        start = line.find("[")
        end = line.find("]")
        addr = line[start+1:end]
        try:
            file = filenames[addr]
        except KeyError:
            r = os.popen("addr2line -fs -e ./bsc_hack %s" % addr)
            all = r.read().replace("\n", ",")
            file = all
            filenames[addr] = file

        line = line.replace(addr, file)
    output.append(line)

g = open("unbalanced.2", "w")
g.write("".join(output))