#!/bin/csh

alias reset_c004 "/usr/tds/tds3/system/mcp500.setup /dev/nap0 > /dev/null"

set USAGE = "USAGE: my_debug  bootable_file  core_dump_size"
if ($#argv != 2) then
  echo $USAGE
  exit
endif

# Disconnect workers from host (we don't want code still running
# on them sending data to host links while we're trying to analyse 
# that transputer!)...

nt_ctl > /dev/null << END
c 0.0.2 0.e.4
c 0.0.3 0.e.5
q
END

# "Core dump" the host transputer ("standard 'iserver' has a bug
# to do with memory peeking)...

setenv ISERVER /usr/itools/source/iserver/iserver

echo Attempting core dump...

idump $1 $2
if ($status) then
  reset_c004
  exit
endif

setenv ISERVER /usr/tds/tds3/system/iserver.sun4

# Reset/analyse the workers...

~dbc/bin/snode_analyse
if ($status) then
  reset_c004
  exit
endif

# Connect workers back into n