#!/bin/csh -f
#
#	$Id: debugger2,v 1.9 2007/11/29 21:17:02 pvmsrc Exp $
#
#	debugger2.csh
#
#	this script is invoked in an xterm by the generic debugger script.
#	it starts the debugger and waits when it exits to prevent the
#	window from closing.
#
#	it expects the pvmd to set envar PVM_ARCH.
#
#	06 Apr 1993  Manchek
#

set noglob

# scratch file for debugger commands

set TEMPCMD=debugger2.$$

# default debugger and flags

set DBCMD="dbx"
set DBFF="-c $TEMPCMD"

#
# try to pick the debugger by arch name
#

switch ($PVM_ARCH)

case SUN2:
case SUN3:
case SUN4:
	set DBFF="-s $TEMPCMD"
	breaksw

case HPPA:
case HPIA64:
	set DBCMD="xdb"
	set DBFF="-p $TEMPCMD"
	breaksw

case TITN:
	set DBCMD="dbg"
	set DBFF=""
	breaksw

case LINUX:
case LINUX64:
case LINUXALPHA:
case LINUXHPPA:
case LINUXSPARC:
case LINUXATARI:
case NEXT:
	set DBCMD="gdb"
	set DBFF="-q -x $TEMPCMD"
	breaksw

case KSR1:
	set DBCMD="udb"
	set DBFF="-W $TEMPCMD"
	breaksw

case CNVX:
case CNVXN:
	set DBCMD="csd"
	set DBFF=""
	breaksw

case AIX5SP2:
case AIX4SP2:
case SP2MPI:
	set DBCMD="pdbx $argv[1-]"
	breaksw

case CSPP:
	set DBCMD="cxdb"
	set DBFF="-nw "
	breaksw

case CRAY:
	set DBCMD="totalview"
	breaksw

default:
# ALPHA PMAX SYMM RS6K
	breaksw
endsw

#
# run the debugger
#

echo use:
echo run $argv[2-]
echo __________________________________________________
echo ""
#echo run $argv[2-] > $TEMPCMD
#echo $DBCMD $DBFF $argv[1]
#$DBCMD $DBFF $argv[1]

$DBCMD $argv[1]

#rm -f $TEMPCMD

#
# wait to go away
#

#reset
#sleep 1
echo "********"
echo "$DBCMD terminated"
echo -n "hit return to close window:"
set a="$<"

exit 0

