summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-29 09:24:47 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-29 09:24:47 -0400
commit74719b81d9a463b2f7cba68504b1cbfc1498ba91 (patch)
tree45ec3d5d6aa01df267b718e214e457f07becfed7 /tools
parent26fce4914011914bb1e2ee520fe62e790326877e (diff)
downloadopen-iov-74719b81d9a463b2f7cba68504b1cbfc1498ba91.tar.gz
open-iov-74719b81d9a463b2f7cba68504b1cbfc1498ba91.zip
tools: scanerr.py - dump the non-zero RM error record behind a forced 999
The libcuda error scanner (FUN_0054fa00) walks a context list and returns 999 when its force flag is set and any context's RM error record has a non-zero class. ctx999 only shows the first (zeroed) record; scanerr walks the whole list and prints every non-zero record so the failing control or alloc is named. Pushed by push_guest_tools.sh.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/guest-diag/push_guest_tools.sh2
-rwxr-xr-xtools/guest-diag/scanerr.py74
2 files changed, 76 insertions, 0 deletions
diff --git a/tools/guest-diag/push_guest_tools.sh b/tools/guest-diag/push_guest_tools.sh
index 42b91ae..b0711d4 100755
--- a/tools/guest-diag/push_guest_tools.sh
+++ b/tools/guest-diag/push_guest_tools.sh
@@ -27,6 +27,8 @@ push_b64 "$REPO/tools/test/cuda_drv_test.c" /tmp/cdt.c
push_b64 "$HERE/dumpctx.py" /tmp/dumpctx.py
push_b64 "$HERE/trkinfo.py" /tmp/trkinfo.py
push_b64 "$HERE/bp999.py" /tmp/bp999.py
+push_b64 "$HERE/ctx999.py" /tmp/ctx999.py
+push_b64 "$HERE/scanerr.py" /tmp/scanerr.py
push_b64 "$HERE/sem_counters.py" /tmp/sem_counters.py
push_b64 "$HERE/sem_slots.py" /tmp/sem_slots.py
push_b64 "$HERE/read_va.py" /tmp/read_va.py
diff --git a/tools/guest-diag/scanerr.py b/tools/guest-diag/scanerr.py
new file mode 100755
index 0000000..c3af2f5
--- /dev/null
+++ b/tools/guest-diag/scanerr.py
@@ -0,0 +1,74 @@
+# gdb script: at the libcuda error-scanner entry (FUN_0054fa00), walk the
+# context list and dump every non-zero RM error record (magic words,
+# errorClass at +0x8, shorts at +0xc/+0xe). This names the source of a
+# forced 999: the scanner returns 999 when param_2 != 0 and any record's
+# class fields are non-zero.
+# Run: sudo gdb -p <cdt-pid> -batch -x /tmp/scanerr.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
+
+gdb.execute("set pagination off")
+gdb.execute("set confirm off")
+gdb.execute("break *0x%x" % (base + 0x44fa00))
+try:
+ gdb.execute("continue")
+except gdb.error as e:
+ print("CONTINUE %s" % e)
+print("HIT")
+
+
+def rd64(a):
+ try:
+ return int(gdb.parse_and_eval("*(unsigned long *)0x%x" % a)) & 0xffffffffffffffff
+ except Exception:
+ return None
+
+
+def rd32(a):
+ try:
+ return int(gdb.parse_and_eval("*(unsigned int *)0x%x" % a)) & 0xffffffff
+ except Exception:
+ return None
+
+
+try:
+ p1 = int(gdb.parse_and_eval("$rdi")) & 0xffffffffffffffff
+ p2 = int(gdb.parse_and_eval("$rsi")) & 0xffffffff
+ print("param_1=0x%x param_2=%d" % (p1, p2))
+ pl = rd64(p1)
+ n = 0
+ while pl and n < 64:
+ mgr = rd64(pl + 0x1291 * 8)
+ if mgr:
+ reg = rd64(mgr + 0x10)
+ if reg:
+ rec = rd64(reg + 0x10)
+ if rec:
+ vals = [rd32(rec + i) or 0 for i in range(0, 0x28, 4)]
+ if any(vals):
+ print("ENTRY %d ctx=0x%x mgr=0x%x rec=0x%x rec=%s" %
+ (n, pl, mgr, rec,
+ ' '.join('0x%08x' % v for v in vals)))
+ pl = rd64(pl + 0x128e * 8)
+ n += 1
+ print("WALKED %d" % n)
+except Exception as e:
+ print("dump_fail %s" % e)
+try:
+ gdb.execute("bt 8", to_string=True)
+except Exception:
+ pass
+try:
+ gdb.execute("detach")
+except Exception:
+ pass