summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/gdb_now.sh
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-29 21:41:26 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-29 21:41:26 -0400
commit6d380a3c3f5cc3cac1fb3bea913b18bbfb1f3a13 (patch)
treede75609532d917ca404cea2f3b19d85baa22f696 /tools/guest-diag/gdb_now.sh
parentd0688c92692cc936ce2c347f26572b1bb55dc660 (diff)
downloadopen-iov-6d380a3c3f5cc3cac1fb3bea913b18bbfb1f3a13.tar.gz
open-iov-6d380a3c3f5cc3cac1fb3bea913b18bbfb1f3a13.zip
guest-diag: one-shot gdb/state samplers for timed post-control captures
gdb_now.sh attaches once at a host-chosen moment (final RM control) and dumps all threads; oneshot_gdb.sh triggers on user-running state; state_log.sh records state/syscall/wchan so kernel busy-waits can be told apart from real userspace spins.
Diffstat (limited to 'tools/guest-diag/gdb_now.sh')
-rw-r--r--tools/guest-diag/gdb_now.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/guest-diag/gdb_now.sh b/tools/guest-diag/gdb_now.sh
new file mode 100644
index 0000000..b58fe3d
--- /dev/null
+++ b/tools/guest-diag/gdb_now.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+# gdb_now.sh <pid> - attach gdb once immediately (root), dump all threads,
+# detach, CONT. Used when the host has seen the final RM control, so the
+# attach is timed to the post-control window instead of state sampling.
+PID="$1"
+LOG="${2:-/tmp/gdbbt2.log}"
+: > "$LOG"
+{
+ echo "=== FORCED $(date +%T.%3N) pid=$PID ==="
+ for t in /proc/$PID/task/*; do
+ echo "--- thread $(basename $t): $(awk '{print $3}' $t/stat 2>/dev/null) $(cat $t/comm 2>/dev/null) syscall=$(cat $t/syscall 2>/dev/null | cut -d' ' -f1-2)"
+ cat "$t/stack" 2>/dev/null | sed 's/^/ kstack: /'
+ done
+ grep -E "libcuda|nvidia" /proc/$PID/maps | head -4
+} >> "$LOG" 2>&1
+timeout 90 gdb -p "$PID" -batch \
+ -ex "set pagination off" -ex "set height 0" -ex "set confirm off" \
+ -ex "info threads" \
+ -ex "thread apply all bt 12" \
+ -ex "thread apply all info registers rip rsp rbp rbx rax rdi rsi rdx rcx r8 r9" \
+ -ex "thread apply all x/10i \$pc" \
+ >> "$LOG" 2>&1
+echo "=== GDB DONE $(date +%T.%3N) ===" >> "$LOG"
+kill -CONT "$PID" 2>/dev/null