blob: cd3b7abe32e1db1cfa72a113315b035cfbb2a68a (
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
34
35
36
37
38
39
40
|
import gdb
gr = gdb.execute
inf = gdb.selected_inferior()
pid = inf.pid
base = None
for line in open("/proc/%d/maps" % pid):
parts = line.split()
try:
lo, hi = [int(x,16) for x in parts[0].split('-')]
except Exception:
continue
if base is None and "libnvidia-eglcore" in line and int(parts[2],16) == 0:
base = lo
print("BASE 0x%x" % (base or 0))
class B(gdb.Breakpoint):
def __init__(self):
super().__init__("*0x%x" % (base + 0xA12DDF), internal=False)
self.silent = True; self.done = False
def stop(self):
if self.done:
return True
self.done = True
try:
rdi = int(gdb.parse_and_eval("$rdi"))
rsi = int(gdb.parse_and_eval("$rsi"))
rdx = int(gdb.parse_and_eval("$rdx"))
print("POLL nfds=%d timeout=%d arr=0x%x" % (rsi, rdx, rdi))
fd = int(gdb.parse_and_eval("*(int*)0x%x" % rdi))
ev = int(gdb.parse_and_eval("*(unsigned short*)0x%x" % (rdi + 4)))
rv = int(gdb.parse_and_eval("*(unsigned short*)0x%x" % (rdi + 6)))
print("FDPOLL fd=%d events=0x%x revents=0x%x" % (fd, ev, rv))
except Exception as e:
print("fail %s" % e)
return True
try:
B(); print("BP-SET")
gr("continue")
except Exception as e:
print("bpfail %s" % e)
print("T96-DONE")
|