* Copyright (c) 1991 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)utilities.c 5.3 (Berkeley) %G%";
#include <sys/resource.h>
# define proffile "/vb/grad/mckusick/px/profile/pcnt.out"
double counts
[NUMOPS
]; /* instruction counts */
long runs
; /* number of interpreter runs */
long startdate
; /* date profile started */
long usrtime
; /* total user time consumed */
long systime
; /* total system time consumed */
double stmts
; /* number of pascal stmts executed */
getrusage(RUSAGE_SELF
, &ru
);
datafile
= fopen(proffile
,"r");
count
= fread(&profdata
,1,sizeof(profdata
),datafile
);
if (count
!= sizeof(profdata
))
for (count
= 0; count
< NUMOPS
; count
++)
profdata
.counts
[count
] += _profcnts
[count
];
profdata
.stmts
+= _stcnt
;
profdata
.usrtime
+= ru
.ru_utime
.tv_sec
;
profdata
.systime
+= ru
.ru_stime
.tv_sec
;
datafile
= freopen(proffile
,"w",datafile
);
count
= fwrite(&profdata
,1,sizeof(profdata
),datafile
);
if (count
!= sizeof(profdata
))
"\n%1ld statements executed in %d.%02d seconds cpu time.\n",
_stcnt
, ru
.ru_utime
.tv_sec
, ru
.ru_utime
.tv_usec
/ 10000);
register struct dispsave
*mydp
;
register struct blockmark
*ap
;
fputs("Program was not executed.\n",stderr
);
fprintf(stderr
, "\n\t%s in \"", type
);
i
= linum
- (((ap
)->entry
)->offset
& 0177777);
fprintf(stderr
,"%s\"",(ap
->entry
)->name
);
fprintf(stderr
,"+%D near line %D.",i
,linum
);
if (mydp
<= &_display
.frame
[1]){
fputs("\tCalled by \"",stderr
);
PMFLUSH(_cntrs
, _rtns
, _pcpcount
);
fputs("Execution terminated",stderr
);
fputs(" abnormally",stderr
);
* Routines to field various types of signals
* catch a library error and generate a backtrace
* catch an interrupt and generate a backtrace
backtrace("Interrupted");
signal(SIGSEGV
, memsize
);
ERROR("Run time stack overflow\n");
* catch random system faults
ERROR("Panic: Computational error in interpreter\n");