get rid of panics, so that all signals and errors pass through ERROR()
authorKirk McKusick <mckusic@ucbvax.Berkeley.EDU>
Wed, 3 Feb 1982 16:01:07 +0000 (08:01 -0800)
committerKirk McKusick <mckusic@ucbvax.Berkeley.EDU>
Wed, 3 Feb 1982 16:01:07 +0000 (08:01 -0800)
SCCS-vsn: usr.bin/pascal/px/int.c 1.7
SCCS-vsn: usr.bin/pascal/px/utilities.c 1.5
SCCS-vsn: usr.bin/pascal/px/Makefile 1.10
SCCS-vsn: usr.bin/pascal/px/vars.h 1.9
SCCS-vsn: usr.bin/pascal/px/interp.c 1.19

usr/src/usr.bin/pascal/px/Makefile
usr/src/usr.bin/pascal/px/int.c
usr/src/usr.bin/pascal/px/interp.c
usr/src/usr.bin/pascal/px/utilities.c
usr/src/usr.bin/pascal/px/vars.h

index 085b2e3..38042f5 100644 (file)
@@ -1,4 +1,4 @@
-SCCSID = "@(#)Makefile 1.9 %G%"
+SCCSID = "@(#)Makefile 1.10 %G%"
 
 CFLAGS = -O
 DESTDIR =
 
 CFLAGS = -O
 DESTDIR =
@@ -16,11 +16,11 @@ PCHDR =     libpc.h
 
 PXHDR =        vars.h machdep.h
 
 
 PXHDR =        vars.h machdep.h
 
-PXSRC =        int.c interp.c except.c utilities.c
+PXSRC =        int.c interp.c utilities.c
 
 
-PXOBJ =        int.o interp.o except.o utilities.o
+PXOBJ =        int.o interp.o utilities.o
 
 
-PXUTL =        make.ed1 panics interp.sed clean.sed version.c
+PXUTL =        interp.sed clean.sed version.c
 
 sources: ${PXHDR} ${PXSRC} ${PXUTL}
 ${PSHDR}:
 
 sources: ${PXHDR} ${PXSRC} ${PXUTL}
 ${PSHDR}:
@@ -44,8 +44,6 @@ interp.o interp.s: interp.c
        /usr/lib/pc2 <interp.s >tmp
        mv tmp interp.s
        as -o interp.o interp.s
        /usr/lib/pc2 <interp.s >tmp
        mv tmp interp.s
        as -o interp.o interp.s
-panics.h: panics make.ed1
-       ex - <make.ed1
 h02opcs.h: OPnames.h opc.c
        ${CC} ${CFLAGS} opc.c -o opc
        ./opc >h02opcs.h
 h02opcs.h: OPnames.h opc.c
        ${CC} ${CFLAGS} opc.c -o opc
        ./opc >h02opcs.h
@@ -56,7 +54,7 @@ install: px
 
 clean:
        ${RM}  *.o *.s px version opc* pic* OPnames.h objfmt.h libpc.h\
 
 clean:
        ${RM}  *.o *.s px version opc* pic* OPnames.h objfmt.h libpc.h\
-               panics.h h02opcs.h errs lpr core tmp
+               h02opcs.h errs lpr core tmp
 
 prt: interp.s
        sed -f clean.sed <interp.s
 
 prt: interp.s
        sed -f clean.sed <interp.s
@@ -66,7 +64,7 @@ grind: sources
        ${SRCDIR}/vgrind -t -x index >lpr
        ${CC} ${CFLAGS} -o pic pic.c
        ${SRCDIR}/vgrind -t -n READ_ME makefile lst >>lpr
        ${SRCDIR}/vgrind -t -x index >lpr
        ${CC} ${CFLAGS} -o pic pic.c
        ${SRCDIR}/vgrind -t -n READ_ME makefile lst >>lpr
-       ${SRCDIR}/vgrind -t ${PCHDR} ${PXHDR} objfmt.h panics.h whoami.h >>lpr
+       ${SRCDIR}/vgrind -t ${PCHDR} ${PXHDR} objfmt.h whoami.h >>lpr
        ${SRCDIR}/vgrind -t ${PXSRC} >>lpr
        ./pic >lst
        ${SRCDIR}/vpr lst
        ${SRCDIR}/vgrind -t ${PXSRC} >>lpr
        ./pic >lst
        ${SRCDIR}/vpr lst
@@ -90,16 +88,12 @@ depend:     sources
 
 # DO NOT DELETE THIS LINE -- make depend uses it
 # DEPENDENCIES MUST END AT END OF FILE
 
 # DO NOT DELETE THIS LINE -- make depend uses it
 # DEPENDENCIES MUST END AT END OF FILE
-except.o: whoami.h
-except.o: panics.h
-except.o: vars.h
 int.o: whoami.h
 int.o: vars.h
 int.o: objfmt.h
 interp.o: whoami.h
 interp.o: objfmt.h
 interp.o: vars.h
 int.o: whoami.h
 int.o: vars.h
 int.o: objfmt.h
 interp.o: whoami.h
 interp.o: objfmt.h
 interp.o: vars.h
-interp.o: panics.h
 interp.o: h02opcs.h
 interp.o: machdep.h
 interp.o: libpc.h
 interp.o: h02opcs.h
 interp.o: machdep.h
 interp.o: libpc.h
@@ -107,7 +101,6 @@ opc.o: OPnames.h
 pic.o: OPnames.h
 utilities.o: whoami.h
 utilities.o: vars.h
 pic.o: OPnames.h
 utilities.o: whoami.h
 utilities.o: vars.h
-utilities.o: panics.h
 utilities.o: h02opcs.h
 # DEPENDENCIES MUST END AT END OF FILE
 # IF YOU PUT STUFF HERE IT WILL GO AWAY
 utilities.o: h02opcs.h
 # DEPENDENCIES MUST END AT END OF FILE
 # IF YOU PUT STUFF HERE IT WILL GO AWAY
index 5058080..a6c12e7 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)int.c 1.6 %G%";
+static char sccsid[] = "@(#)int.c 1.7 %G%";
 
 /*
  * px - interpreter for Berkeley Pascal
 
 /*
  * px - interpreter for Berkeley Pascal
@@ -15,6 +15,7 @@ static char sccsid[] = "@(#)int.c 1.6 %G%";
 #include       <signal.h>
 #include       "whoami.h"
 #include       "vars.h"
 #include       <signal.h>
 #include       "whoami.h"
 #include       "vars.h"
+#include       "libpc.h"
 #include       "objfmt.h"
 
 /*
 #include       "objfmt.h"
 
 /*
@@ -128,7 +129,7 @@ main(ac,av)
        if (signal(SIGINT,SIG_IGN) != SIG_IGN)
                signal(SIGINT,intr);
        signal(SIGSEGV,memsize);
        if (signal(SIGINT,SIG_IGN) != SIG_IGN)
                signal(SIGINT,intr);
        signal(SIGSEGV,memsize);
-       signal(SIGFPE,except);
+       signal(SIGFPE,EXCEPT);
        signal(SIGTRAP,liberr);
 
        /*
        signal(SIGTRAP,liberr);
 
        /*
@@ -153,7 +154,6 @@ main(ac,av)
        signal(SIGBUS,SIG_DFL);
        signal(SIGSYS,SIG_DFL);
        PFLUSH();
        signal(SIGBUS,SIG_DFL);
        signal(SIGSYS,SIG_DFL);
        PFLUSH();
-       /* pfree(objprog); */
        psexit(0);
 }
 
        psexit(0);
 }
 
index 544e1e5..3e89624 100644 (file)
@@ -1,12 +1,11 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)interp.c 1.18 %G%";
+static char sccsid[] = "@(#)interp.c 1.19 %G%";
 
 #include <math.h>
 #include "whoami.h"
 #include "objfmt.h"
 #include "vars.h"
 
 #include <math.h>
 #include "whoami.h"
 #include "objfmt.h"
 #include "vars.h"
-#include "panics.h"
 #include "h02opcs.h"
 #include "machdep.h"
 #include "libpc.h"
 #include "h02opcs.h"
 #include "machdep.h"
 #include "libpc.h"
@@ -312,7 +311,7 @@ interpreter(base)
                        continue;
                case O_LINO:
                        if (_dp->stp->tos != pushsp((long)(0)))
                        continue;
                case O_LINO:
                        if (_dp->stp->tos != pushsp((long)(0)))
-                               panic(PSTKNEMP);
+                               ERROR("Panic: stack not empty between statements\n");
                        _lino = *pc.cp++;       /* set line number */
                        if (_lino == 0)
                                _lino = *pc.sp++;
                        _lino = *pc.cp++;       /* set line number */
                        if (_lino == 0)
                                _lino = *pc.sp++;
@@ -355,8 +354,7 @@ interpreter(base)
                        tl = pop4();
                        tl1 = pop4();
                cmplong:
                        tl = pop4();
                        tl1 = pop4();
                cmplong:
-                       tl2 = *pc.cp++;
-                       switch (tl2) {
+                       switch (*pc.cp++) {
                        case releq:
                                push2(tl1 == tl);
                                continue;
                        case releq:
                                push2(tl1 == tl);
                                continue;
@@ -376,7 +374,8 @@ interpreter(base)
                                push2(tl1 >= tl);
                                continue;
                        default:
                                push2(tl1 >= tl);
                                continue;
                        default:
-                               panic(PSYSTEM);
+                               ERROR("Panic: bad relation %d to REL4*\n",
+                                   *(pc.cp - 1));
                                continue;
                        }
                case O_RELG:
                                continue;
                        }
                case O_RELG:
@@ -404,7 +403,7 @@ interpreter(base)
                                tb = RELSGE(tl, tcp + tl1, tcp);
                                break;
                        default:
                                tb = RELSGE(tl, tcp + tl1, tcp);
                                break;
                        default:
-                               panic(PSYSTEM);
+                               ERROR("Panic: bad relation %d to RELG*\n", tl2);
                                break;
                        }
                        popsp(tl1 << 1);
                                break;
                        }
                        popsp(tl1 << 1);
@@ -434,7 +433,7 @@ interpreter(base)
                                tb = RELTGE(tl1, tcp + tl1, tcp);
                                break;
                        default:
                                tb = RELTGE(tl1, tcp + tl1, tcp);
                                break;
                        default:
-                               panic(PSYSTEM);
+                               ERROR("Panic: bad relation %d to RELT*\n", tl2);
                                break;
                        }
                        popsp(tl1 << 1);
                                break;
                        }
                        popsp(tl1 << 1);
@@ -480,7 +479,8 @@ interpreter(base)
                                push2(td1 >= td);
                                continue;
                        default:
                                push2(td1 >= td);
                                continue;
                        default:
-                               panic(PSYSTEM);
+                               ERROR("Panic: bad relation %d to REL8*\n",
+                                   *(pc.cp - 1));
                                continue;
                        }
                case O_AND:
                                continue;
                        }
                case O_AND:
@@ -1067,7 +1067,11 @@ interpreter(base)
                        continue;
                case O_HALT:
                        pc.cp++;
                        continue;
                case O_HALT:
                        pc.cp++;
-                       panic(PHALT);
+                       if (_nodump == TRUE)
+                               psexit(0);
+                       fputs("\nCall to procedure halt\n", stderr);
+                       backtrace("Halted");
+                       psexit(0);
                        continue;
                case O_PXPBUF:
                        pc.cp++;
                        continue;
                case O_PXPBUF:
                        pc.cp++;
@@ -1635,7 +1639,7 @@ interpreter(base)
                        push4(TRUNC(pop8()));
                        continue;
                default:
                        push4(TRUNC(pop8()));
                        continue;
                default:
-                       panic(PBADOP);
+                       ERROR("Panic: bad op code\n");
                        continue;
                }
        }
                        continue;
                }
        }
index a94a576..e3cca71 100644 (file)
@@ -1,10 +1,10 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)utilities.c 1.4 %G%";
+static char sccsid[] = "@(#)utilities.c 1.5 %G%";
 
 
+#include       <signal.h>
 #include       "whoami.h"
 #include       "vars.h"
 #include       "whoami.h"
 #include       "vars.h"
-#include       "panics.h"
 #include       "h02opcs.h"
 
 stats()
 #include       "h02opcs.h"
 
 stats()
@@ -62,8 +62,8 @@ skipprof:
                _stcnt,l);
 }
 \f
                _stcnt,l);
 }
 \f
-backtrace(errnum)
-       int     errnum;
+backtrace(type)
+       char    *type;
 {
        register struct disp *mydp;
        register struct stack *ap;
 {
        register struct disp *mydp;
        register struct stack *ap;
@@ -76,12 +76,7 @@ backtrace(errnum)
                return;
        }
        disp = _display;
                return;
        }
        disp = _display;
-       if (errnum == PINTR)
-               fputs("\n\tInterrupted in \"",stderr);
-       else if (errnum == PHALT)
-               fputs("\n\tHalted in \"",stderr);
-       else
-               fputs("\n\tError in \"",stderr);
+       fprintf(stderr, "\n\t%s in \"", type);
        mydp = _dp;
        linum = _lino;
        for (;;) {
        mydp = _dp;
        linum = _lino;
        for (;;) {
@@ -94,7 +89,7 @@ backtrace(errnum)
                *mydp = (ap)->odisp;
                if (mydp <= &_display.frame[1]){
                        _display = disp;
                *mydp = (ap)->odisp;
                if (mydp <= &_display.frame[1]){
                        _display = disp;
-                       psexit(errnum);
+                       return;
                }
                mydp = (ap)->dp;
                linum = (ap)->lino;
                }
                mydp = (ap)->dp;
                linum = (ap)->lino;
@@ -118,3 +113,43 @@ psexit(code)
        stats();
        exit(code);
 }
        stats();
        exit(code);
 }
+
+/*
+ * Routines to field various types of signals
+ *
+ * catch a library error and generate a backtrace
+ */
+liberr()
+{
+       backtrace("Error");
+       psexit(2);
+}
+
+/*
+ * catch an interrupt and generate a backtrace
+ */
+intr()
+{
+       signal(SIGINT, intr);
+       backtrace("Interrupted");
+       psexit(1);
+}
+
+/*
+ * catch memory faults
+ */
+memsize()
+{
+       signal(SIGSEGV, memsize);
+       ERROR("Run time stack overflow\n");
+}
+
+/*
+ * catch random system faults
+ */
+syserr(signum)
+       int signum;
+{
+       signal(signum, syserr);
+       ERROR("Panic: Computational error in interpreter\n");
+}
index 45b0431..2ce4a19 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-/* static char sccsid[] = "@(#)vars.h 1.8 %G%"; */
+/* static char sccsid[] = "@(#)vars.h 1.9 %G%"; */
 
 #include <stdio.h>
 
 
 #include <stdio.h>
 
@@ -27,8 +27,6 @@
  *     interp.c        Driver including main interpreter loop and
  *                     the interpreter instructions grouped by their
  *                     positions in the interpreter table.
  *     interp.c        Driver including main interpreter loop and
  *                     the interpreter instructions grouped by their
  *                     positions in the interpreter table.
- *     except.c        Handlers for interpreter specific errors not
- *                     included in libpc.
  *     utilities.c     Interpreter exit, backtrace, and runtime statistics.
  *
  * In addition there are several headers defining mappings for panic
  *     utilities.c     Interpreter exit, backtrace, and runtime statistics.
  *
  * In addition there are several headers defining mappings for panic
@@ -76,7 +74,6 @@ extern char *malloc();
 extern long time();
 extern intr();
 extern memsize();
 extern long time();
 extern intr();
 extern memsize();
-extern except();
 extern syserr();
 extern liberr();
 
 extern syserr();
 extern liberr();