linux/tools/testing/selftests/coredump/stackdump
Nam Cao 15858da535
selftests: coredump: Add stackdump test
Add a test which checks that the kstkesp field in /proc/pid/stat can be
read for all threads of a coredumping process.

For full details including the motivation for this test and how it works,
see the README file added by this commit.

Reviewed-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Nam Cao <namcao@linutronix.de>
Link: https://lore.kernel.org/r/50e737b6576208566d14efcf1934fe840de6b1f4.1735805772.git.namcao@linutronix.de
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-01-04 10:12:18 +01:00

14 lines
243 B
Bash
Executable file

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
CRASH_PROGRAM_ID=$1
STACKDUMP_FILE=$2
TMP=$(mktemp)
for t in /proc/$CRASH_PROGRAM_ID/task/*; do
tid=$(basename $t)
cat /proc/$tid/stat | awk '{print $29}' >> $TMP
done
mv $TMP $STACKDUMP_FILE