summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/bp999.py
blob: db83d7dc605ccc03a41bd51a569d61e3f1725621 (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
# gdb script: break on the libcuda instructions that produce CUDA errors
# 719 (0x2cf) and 999 (0x3e7), then print the stack that led there.
# Run: sudo gdb -p <cdt-pid> -batch -x /tmp/bp999.py
import gdb

out = gdb.execute("info proc mappings", to_string=True)
base = None
for line in out.splitlines():
    if "libcuda" in line and "r-xp" in line:
        f = line.split()
        base = int(f[0], 16) - int(f[3], 16)
        break
print("BASE=0x%x" % (base or 0))
if base is None:
    raise SystemExit
for off in (0x44fb80, 0x44fb6c):
    gdb.execute("break *0x%x" % (base + off))
gdb.execute("set pagination off")
gdb.execute("set confirm off")
try:
    gdb.execute("continue")
except gdb.error as e:
    print("CONTINUE_ERR %s" % e)
print("HIT_OR_EXIT")
try:
    print(gdb.execute("bt 16", to_string=True))
except Exception as e:
    print("bt_fail %s" % e)
try:
    print(gdb.execute("info registers rdi rsi rdx rax rbx rbp rip", to_string=True))
except Exception as e:
    print("regs_fail %s" % e)
try:
    gdb.execute("detach")
except Exception:
    pass