From 346637cb93ae39223f91f318bf265a1b7ba87abb Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 7 Sep 2022 16:01:12 +0200 Subject: add "Pause all userspace processes" --- _posts/snippets/gdb_sleep_all/gdb_sleep_all.sh | 17 +++++++++++++++++ _posts/snippets/gdb_sleep_all/sleep.gdb | 2 ++ 2 files changed, 19 insertions(+) create mode 100755 _posts/snippets/gdb_sleep_all/gdb_sleep_all.sh create mode 100644 _posts/snippets/gdb_sleep_all/sleep.gdb (limited to '_posts/snippets/gdb_sleep_all') diff --git a/_posts/snippets/gdb_sleep_all/gdb_sleep_all.sh b/_posts/snippets/gdb_sleep_all/gdb_sleep_all.sh new file mode 100755 index 0000000..e923740 --- /dev/null +++ b/_posts/snippets/gdb_sleep_all/gdb_sleep_all.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail + +# Select all process IDs that are _not_ children of PID 2, [kthreadd]. +pids="$( ps -o pid --no-headers --ppid 2 -p 2 --deselect )" + +for pid in $pids; do + cmdline="$( cat "/proc/$pid/cmdline" | tr '\0' ' ' )" || continue + echo ------------------------------------------------------------------ + echo "PID: $pid" + echo "Command line: $cmdline" + echo ------------------------------------------------------------------ + gdb -p "$pid" -x sleep.gdb -batch & +done + +wait diff --git a/_posts/snippets/gdb_sleep_all/sleep.gdb b/_posts/snippets/gdb_sleep_all/sleep.gdb new file mode 100644 index 0000000..04f17fc --- /dev/null +++ b/_posts/snippets/gdb_sleep_all/sleep.gdb @@ -0,0 +1,2 @@ +shell sleep 30 +quit -- cgit v1.2.3