#! /bin/csh -f
#
#	mprof 1.2 7/7/88 15:27:04	
#	Copyright (c) 1987, Benjamin G. Zorn
#
# mprof -- memory profiler for C programs
#
# usage: mprof [ options ] <executable> <mprof-data>
#
# <executable> is the program being profiled
# <mprof-data> is the data file generated by running the executable
#
set rootpath=/spur3/zorn
set commonlisp=cl
set language=:normal
set leaklevel=:show
set execfile="a.out"
set datafile="mprof.data"

top:
	if ($#argv > 0) then
		switch ($argv[1])
		case -leaktable:
			set leaklevel=:show
			shift argv
			goto top
		case -noleaktable:
			set leaklevel=:none
			shift argv
			goto top
		case -offsets:
			set leaklevel=:offsets
			shift argv
			goto top
		case -verbose:
			set language=:verbose
			shift argv
			goto top
		case -normal:
			set language=:normal
			shift argv
			goto top
		case -terse:
			set language=:terse
			shift argv
			goto top
		default:
			if ($#argv > 0) then
				if ($argv[1] != "") then
					set execfile=$argv[1]
					shift argv
				endif
			endif
			if ($#argv > 0) then
				if ($argv[1] != "") then
					set datafile=$argv[1]
				endif
			endif
		endsw
	endif

set t1=\#tmp1\#
set t2=\#tmp2\#
set mproot=$rootpath/mprof
$mproot/mpfilt $execfile $datafile > $t1
$commonlisp >& /dev/null << ENDLISP
(load "$mproot/analysis")
(setq *language* $language)
(setq *leak-level* $leaklevel)
(mprof "$t1" :outfile "$t2" :type :c)
:exit
ENDLISP
cat < $t2
rm $t1 $t2
