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
|
#!/bin/bash
cd /tmp
(timeout 120 /tmp/vk_frame 1 64 64 5 /tmp 0 > /tmp/vk65.out 2>&1 &)
sleep 5
PID=$(pgrep -x vk_frame | head -1)
cp /proc/$PID/maps /tmp/maps_d.txt
gdb -p $PID -batch -ex "set pagination off" -ex "bt 12" 2>&1 | grep -E "^#" > /tmp/bt_gap3.txt
python3 - <<'PY'
import re
maps=open('/tmp/maps_d.txt').read().splitlines()
segs=[]
for m in maps:
p=m.split()
if len(p)<6: continue
lo,hi=[int(x,16) for x in p[0].split('-')]
off=int(p[2],16)
segs.append((lo,hi,off,p[5]))
for line in open('/tmp/bt_gap3.txt'):
m=re.match(r'#(\d+)\s+0x([0-9a-f]+)', line)
if not m: continue
a=int(m.group(2),16)
for lo,hi,off,name in segs:
if lo<=a<hi:
print('#%s %s + 0x%x' % (m.group(1), name.split('/')[-1], off+(a-lo)))
break
else:
print('#%s 0x%x unmapped' % (m.group(1), a))
PY
|