Skip to content
Snippets Groups Projects
Commit e04e5b36 authored by Fons Rademakers's avatar Fons Rademakers
Browse files

added comments in gdb-backtrace-script, added new gdb-backtrace.sh

which is a copy of /usr/bin/gstack with some minor mods.


git-svn-id: http://root.cern.ch/svn/root/trunk@17025 27541ba8-7e3a-0410-8455-c3a389f83636
parent 10a59b58
No related branches found
No related tags found
No related merge requests found
# This script is used by TUnixSystem::StackTrace() on Mac OS X.
echo \n echo \n
echo ========== STACKS OF ALL THREADS ==========\n echo ========== STACKS OF ALL THREADS ==========\n
thread apply all bt thread apply all bt
......
#!/bin/sh
# This script is almost identical to /usr/bin/gstack.
# It is used by TUnixSystem::StackTrace() on Linux.
if test $# -ne 1; then
echo "Usage: `basename $0 .sh` <process-id>" 1>&2
exit 1
fi
if test ! -r /proc/$1; then
echo "Process $1 not found." 1>&2
exit 1
fi
# GDB doesn't allow "thread apply all bt" when the process isn't
# threaded; need to peek at the process to determine if that or the
# simpler "bt" should be used.
backtrace="bt"
if test -d /proc/$1/task ; then
# Newer kernel; has a task/ directory.
if test `ls /proc/$1/task | wc -l` -gt 1 2>/dev/null ; then
backtrace="thread apply all bt"
fi
elif test -f /proc/$1/maps ; then
# Older kernel; go by it loading libpthread.
if grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then
backtrace="thread apply all bt"
fi
fi
GDB=${GDB:-gdb}
if $GDB -nx --quiet --batch --readnever > /dev/null 2>&1; then
readnever=--readnever
else
readnever=
fi
# Run GDB, strip out unwanted noise.
$GDB --quiet $readnever -nx /proc/$1/exe $1 <<EOF 2>&1 |
$backtrace
EOF
sed -n \
-e 's/^(gdb) //' \
-e '/^#/p' \
-e '/^Thread/p'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment