summaryrefslogtreecommitdiffstats
path: root/userspace/cuda/570.144/scripts/ghidra_decompile_project.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
commit2aafde5cc3679020d8b31277c03d70fd6908384c (patch)
treea3d89236459b5586e5a4d0c3b2b1b574fbfb274b /userspace/cuda/570.144/scripts/ghidra_decompile_project.sh
parent7fdbe8713c8cf746cd1a15e93e0de39d333905c7 (diff)
downloadopen-iov-2aafde5cc3679020d8b31277c03d70fd6908384c.tar.gz
open-iov-2aafde5cc3679020d8b31277c03d70fd6908384c.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/ghidra_decompile_project.sh')
-rwxr-xr-xuserspace/cuda/570.144/scripts/ghidra_decompile_project.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/userspace/cuda/570.144/scripts/ghidra_decompile_project.sh b/userspace/cuda/570.144/scripts/ghidra_decompile_project.sh
new file mode 100755
index 0000000..66d7c90
--- /dev/null
+++ b/userspace/cuda/570.144/scripts/ghidra_decompile_project.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# ghidra_decompile_project.sh - decompile a function from an already-analyzed
+# Ghidra project (run scripts/ghidra_analyze.sh once first). No re-import and
+# no analysis, so this takes seconds.
+#
+# Usage: scripts/ghidra_decompile_project.sh <hex-vaddr> [outfile] [program]
+# env: GHIDRA_HOME, PROJECT_DIR, PROJECT_NAME (same as ghidra_analyze.sh)
+set -e
+
+HERE="$(cd "$(dirname "$0")" && pwd)"
+ROOT="$(cd "$HERE/.." && pwd)"
+RUN="$ROOT/run"
+VADDR="${1:?usage: $0 <hex-vaddr> [outfile] [program]}"
+OUT="${2:-$RUN/fn_$VADDR.c}"
+PROGRAM="${3:-libcuda.so.570.144}"
+
+GHIDRA_HOME="${GHIDRA_HOME:-/snap/ghidra/current/ghidra}"
+ANALYZE="$GHIDRA_HOME/support/analyzeHeadless"
+PROJECT_DIR="${PROJECT_DIR:-$RUN/ghidra-proj}"
+PROJECT_NAME="${PROJECT_NAME:-cuda-analysis}"
+
+[ -d "$PROJECT_DIR" ] || { echo "no project at $PROJECT_DIR (run ghidra_analyze.sh)"; exit 1; }
+mkdir -p "$RUN"
+
+echo "[*] decompiling $PROGRAM at $VADDR (project) -> $OUT"
+"$ANALYZE" "$PROJECT_DIR" "$PROJECT_NAME" \
+ -process "$PROGRAM" \
+ -noanalysis \
+ -scriptPath "$ROOT/ghidra" \
+ -postScript DecompileAt.java "$VADDR" "$OUT" \
+ 2>&1 | tail -3
+
+[ -f "$OUT" ] || { echo "[FAIL] no output"; exit 1; }
+echo "[ok] $OUT"