File: vinfo_dump.py

package info (click to toggle)
psyco-doc 1.6-1
  • links: PTS
  • area: contrib
  • in suites: lenny
  • size: 1,832 kB
  • ctags: 3,236
  • sloc: ansic: 23,895; python: 5,646; perl: 1,309; makefile: 153
file content (56 lines) | stat: -rw-r--r-- 1,613 bytes parent folder | download | duplicates (7)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from xam import *
import httpxam


def load_vi_array(dumpfile, d):
    match = re_int.match(dumpfile.readline())
    assert match
    count = int(match.group(1))
    a = []
    for i in range(count):
        line = dumpfile.readline()
        match = re_int.match(line)
        assert match
        addr = long(match.group(1))
        if d.has_key(addr):
            vi = d[addr]
        else:
            line = dumpfile.readline()
            match = re_ctvinfo.match(line)
            if match:
                vi = CompileTimeVInfo(int(match.group(1)),
                                      long(match.group(2)))
            else:
                match = re_rtvinfo.match(line)
                if match:
                    vi = RunTimeVInfo(long(match.group(1)))
                else:
                    match = re_vtvinfo.match(line)
                    assert match
                    vi = VirtualTimeVInfo(long(match.group(1), 16))
            d[addr] = vi
            vi.addr = addr
            vi.array = load_vi_array(dumpfile, d)
        a.append(vi)
    a.reverse()
    return a

def main(dumpfile):
    import os, tempfile
    array = load_vi_array(dumpfile, {0: None})
    text = httpxam.show_vinfos(array, {})
    if os.fork() == 0:
        TMP = tempfile.mktemp('.html')
        g = open(TMP, 'w')
        g.write('<html><head></head><body>\n')
        g.write(text)
        g.write('</body>\n')
        g.close()
        try:
            os.system('xterm -e lynx -force_html %s' % TMP)
        finally:
            os.unlink(TMP)

if __name__ == '__main__':
    import sys
    main(sys.stdin)