debug_winbindd.sh: use fuser, don't rely on process name to detect the idmap child
[slow/toolbox.git] / gdb_sbt_by_procname.sh
1 #!/bin/sh
2
3 BASENAME=`basename $0`
4 PROCNAME="$1"
5 ID=`id -u`
6
7 test x"${PROCNAME}" = x"" && {
8     echo "Usage: ${BASENAME} <procname>"
9     exit 1
10 }
11
12 which gdb > /dev/null 2>&1
13 test $? -ne 0 && {
14     echo "Please install the GNU debugger gdb"
15     exit 1
16 }    
17
18 test  x"$ID" != x"0" && {
19     echo "Must be run as root!"
20     exit 1
21 }
22
23 PIDS=$(ps -eo pid,comm | awk "/ $PROCNAME\$/ "'{print $1}')
24
25 for pid in $PIDS ; do
26     printf "\nSBT for $PROCNAME with pid $pid\n================================\n"
27     gdb -p $pid -batch -ex "info locals" -ex "thread apply all bt full"
28 done