# 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 -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