summaryrefslogtreecommitdiffstats
path: root/userspace/cuda/570.144/scripts/disasm.sh
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-23 07:05:45 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-23 07:05:45 -0400
commit54ca82d81bacb56197a607d0039ca6a015f5ac44 (patch)
tree355be543e9da05468c5c0003ff7ddb60944221ec /userspace/cuda/570.144/scripts/disasm.sh
parent893318f45eff1a2b5f4d554297d08a9e987c2a52 (diff)
downloadopen-iov-54ca82d81bacb56197a607d0039ca6a015f5ac44.tar.gz
open-iov-54ca82d81bacb56197a607d0039ca6a015f5ac44.zip
userspace/cuda: libcuda analysis tree (debug-focused), guest ioctl tracer
Analysis tooling for debugging CUDA execution in Open-IOV guests: - userspace/cuda/570.144/: fetch a library from a running guest (nc), objdump helpers, crash ip -> file vaddr + symbol mapping, and Ghidra headless import/analysis/decompile scripts (project kept so single functions decompile in seconds). The purpose is debugging correctness and performance of CUDA in Open-IOV VMs (not a reimplementation); extracted binaries and decompiled output are gitignored. - tools/guest-diag/ioctl_trace.c: ptrace tracker for the NVIDIA driver ioctls of a child (libcuda issues raw syscalls, so LD_PRELOAD sees nothing). Decodes RM_ALLOC (class) and RM_CONTROL (cmd) arguments; this is how the cuCtxCreate crash sequence was captured. - tools/test/cuda_drv_test.c: unbuffered + per-call markers so a crash identifies the CUDA call it happened in.
Diffstat (limited to 'userspace/cuda/570.144/scripts/disasm.sh')
-rwxr-xr-xuserspace/cuda/570.144/scripts/disasm.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/userspace/cuda/570.144/scripts/disasm.sh b/userspace/cuda/570.144/scripts/disasm.sh
new file mode 100755
index 0000000..01fea69
--- /dev/null
+++ b/userspace/cuda/570.144/scripts/disasm.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# disasm.sh - objdump helpers for a library under analysis.
+#
+# Usage:
+# scripts/disasm.sh <file> <hex-vaddr> [before] [after]
+# disassemble [vaddr-before, vaddr+after] (default 0x40 each side)
+# scripts/disasm.sh --bytes <file> <hex-start> <hex-end>
+# raw bytes in the range
+# scripts/disasm.sh --symbol <file> <name>
+# exported symbol address/size (readelf dyn-syms)
+# scripts/disasm.sh --nearest <file> <hex-vaddr>
+# nearest preceding exported symbol (FUNC) and the offset into it
+set -e
+
+cmd="${1:?usage: disasm.sh [--bytes|--symbol|--nearest] <file> ...}"
+case "$cmd" in
+--bytes)
+ file="$2"; start="$3"; end="$4"
+ objdump -s --start-address="$start" --stop-address="$end" "$file"
+ ;;
+--symbol)
+ file="$2"; name="$3"
+ readelf -sW --dyn-syms "$file" | awk -v n="$name" '$8 == n {print}'
+ ;;
+--nearest)
+ file="$2"; target="$3"
+ python3 - "$file" "$target" <<'PY'
+import subprocess, sys
+path, t = sys.argv[1], int(sys.argv[2], 16)
+out = subprocess.check_output(["readelf", "-sW", "--dyn-syms", path], text=True)
+syms = []
+for line in out.splitlines():
+ p = line.split()
+ if len(p) >= 8 and p[3] == "FUNC":
+ try:
+ syms.append((int(p[1], 16), int(p[2]), p[7]))
+ except ValueError:
+ pass
+syms.sort()
+prev = None
+for a, s, n in syms:
+ if a <= t:
+ prev = (a, s, n)
+ else:
+ break
+if prev:
+ print("nearest exported: %s at 0x%x size 0x%x (+0x%x)" %
+ (prev[2], prev[0], prev[1], t - prev[0]))
+else:
+ print("no exported symbol before 0x%x" % t)
+PY
+ ;;
+*)
+ file="$1"; vaddr="$2"
+ before="${3:-0x40}"; after="${4:-0x40}"
+ start=$(printf '0x%x' $(( vaddr - before )) 2>/dev/null || echo "$vaddr")
+ end=$(printf '0x%x' $(( vaddr + after )) 2>/dev/null || echo "$vaddr")
+ # allow hex arithmetic with shell
+ start=$(python3 -c "print(hex(int('$vaddr',16)-int('$before',16)))")
+ end=$(python3 -c "print(hex(int('$vaddr',16)+int('$after',16)))")
+ objdump -d -Mintel --start-address="$start" --stop-address="$end" "$file"
+ ;;
+esac