#!/bin/sh

if [ "`id -u`" != "0" ]; then
 echo "You must be root to use this program!"
 exit 0
fi

if ! test -x /usr/bin/gdb; then
  echo "gdb (package gdb, series d) must be installed before running this program!"
  exit 0
fi

tmpfile=`mktemp /tmp/xf86debug.XXXXXXXXXX`

echo -n "Starting X Server in Debugger ... "
gdb << EOF &> $tmpfile
file  /usr/X11R6/bin/X
set args :1
handle SIGUSR1 nostop
run
bt
quit
EOF
echo "done"

echo "Debugger output written to $tmpfile." 
