summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/wall2/t80r.py
blob: ac2263b888b86d5193faddf9b99a41f82802c926 (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
import gdb, sys
inf = gdb.selected_inferior()
pid = inf.pid
cands = []
for line in open("/proc/%d/maps" % pid):
    if "nvidiactl" in line and "rw-s" in line:
        parts = line.split()
        try:
            lo, hi = [int(x,16) for x in parts[0].split('-')]
        except Exception:
            continue
        if hi - lo == 0x4000:
            cands.append(lo + 0x80)
print("CANDIDATES %s" % ["0x%x" % c for c in cands])
class W(gdb.Breakpoint):
    def __init__(self, addr):
        super().__init__("*(unsigned int*)0x%x" % addr, gdb.BP_WATCHPOINT, gdb.WP_READ, internal=False)
        self.addr = addr
        self.silent = True
    def stop(self):
        print("READWORD 0x%x" % self.addr)
        return True
armed = 0
for c in cands:
    try:
        W(c); armed += 1
    except Exception as e:
        print("watchfail 0x%x: %s" % (c, e))
print("ARMED %d" % armed)
if armed:
    gdb.execute("continue")
print("T80R-DONE")