-
Notifications
You must be signed in to change notification settings - Fork 2
/
client.py
49 lines (37 loc) · 1.15 KB
/
client.py
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
import sys
import requests
import json
import zlib
from base64 import b64encode
from vmprof.process.reader import (
read_prof, read_ranges, read_sym_file, LibraryData
)
from vmprof.process.addrspace import AddressSpace
def main(prof, prof_sym):
period, profiles, symmap = read_prof(prof)
libs = read_ranges(symmap)
for lib in libs:
lib.read_object_data()
libs.append(
LibraryData(
'<virtual>',
0x8000000000000000L,
0x8fffffffffffffffL,
True,
symbols=read_sym_file(prof_sym))
)
addrspace = AddressSpace(libs)
filtered_profiles, addr_set = addrspace.filter_addr(profiles)
d = {}
for addr in addr_set:
name, _ = addrspace.lookup(addr | 0x8000000000000000L)
d[addr] = name
return {'profiles': filtered_profiles, 'addresses': d}
if __name__ == '__main__':
prof = open(sys.argv[1], 'rb').read()
prof_sym = open(sys.argv[2], 'rb').read()
data = zlib.compress(json.dumps(main(prof, prof_sym)))
response = requests.post("http://127.0.0.1:8000/api/log/", data={
'data': b64encode(data)
})
print response.json()