# 2.11BSD#431 - /usr/src/ucb/pascal/px/perror.c

##### Functions

    error             X
    psexit            X
    stmts             X
    stmttime          X

       1: #include "0x.h"
       2: #include "opcode.h"
       3: #include "E.h"
       4: #include <sys/types.h>
       5: #include <sys/times.h>
       6:
       7: extern  int errno;
       8:
       9: /*
      10:  * Routine error is called from onemt when a runtime error occurs.
      11:  * Its argument is the internal number of the error which occurred.
      12:  * See Edata, Emake etc.
      13:  */
      14: error(perrno)
      15:     int perrno;
      16: {
      17:     register int *ap, i;
      18:     register char *cp;
      19:     char *sep;
      20:     int disp[20], *mydp;
      21:     extern long stcnt;
      22:
      23:     i = errno;
      24:     pmflush();
      25:     pmessage();
      26:     errno = i;
      27:     switch (perrno) {
      28:         case EINTR:
      29:             break;
      30:         case ECHR:
      31:             puts("Argument to chr out of range\n");
      32:             break;
      33:         case EDIVCHK:
      34:             puts("Div by zero\n");
      35:             break;
      36:         case EFDIVCHK:
      37:             puts("Floating divide by zero\n");
      38:             break;
      39:         case EFPOVFLO:
      40:             puts("Floating point overflow\n");
      41:             break;
      42:         case EHALT:
      43: /*
      44: 			nodump = 0;
      45: */
      46:             puts("Call to procedure halt\n");
      47:             break;
      48:         case ENILPTR:
      49:             puts("Reference through a nil pointer\n");
      50:             break;
      51:         case EPASTEOF:
      52:             ferror("Tried to read past eof");
      53:             break;
      54:         case EREADIT:
      55:             ferror("Attempt to read, but open for writing");
      56:             break;
      57:         case EWRITEIT:
      58:             ferror("Attempt to write, but open for reading");
      59:             break;
      60:         case ETOODIGITS:
      61:             puts("Too many digits in number\n");
      62:             break;
      63:         case ESQRT:
      64:             puts("Negative argument to sqrt\n");
      65:             break;
      66:         case ESTKNEMP:
      67:             puts("Panic: stack not empty between statements\n");
      68:             break;
      69:         case ESUBSCR:
      70:             puts("Subscript out of range\n");
      71:             break;
      72:         case EREFINAF:
      73:             puts("Reference to an inactive file\n");
      74:             break;
      75:         case EWRITE:
      76:         case EOPEN:
      77:         case ECREATE:
      78:         case EREMOVE:
      79:         case ESEEK:
      80:             perror(file);
      81:             break;
      82:         case ELN:
      83:             puts("Non-positive argument to ln\n");
      84:             break;
      85:         case EBADOP:
      86:             puts("Panic: bad op code\n");
      87:             break;
      88:         case EBADINUM:
      89:             puts("Bad data found on integer read\n");
      90:             break;
      91:         case EBADFNUM:
      92:             puts("Bad data found on real read\n");
      93:             break;
      94:         case EGOTO:
      95:             puts("Panic: active frame not found in goto\n");
      96:             break;
      97:         case ECASE:
      98:             puts("Label not found in case\n");
      99:             break;
     100:         case EOUTOFMEM:
     101:             puts("Ran out of memory\n");
     102:             break;
     103:         case EALLOC:
     104:             puts("Panic: bad arg to alloc\n");
     105:             break;
     106:         case ECTTOT:
     107:             puts("Constructed set argument exceeds set bounds\n");
     108:             break;
     109:         case EMODCHK:
     110:             puts("Mod by zero\n");
     111:             break;
     112:         case ECLOSE:
     113:             ferror("Close failed?");
     114:             break;
     115:         case EARGV:
     116:             puts("Argument to argv out of range\n");
     117:             break;
     118:         case EPACK:
     119:             puts("Bad i to pack(a,i,z)\n");
     120:             break;
     121:         case EUNPACK:
     122:             puts("Bad i to unpack(z,a,i)\n");
     123:             break;
     124:         case ERANGE:
     125:             puts("Value out of range\n");
     126:             break;
     127:         case EASRT:
     128:             puts("Assertion failed\n");
     129:             break;
     130:         case EBIGGIE:
     131:             ferror("Integer number too large");
     132:             break;
     133:         case ESTLIM:
     134:             puts("Statement count limit exceeded\n");
     135:             break;
     136:         case ESTKOVFLO:
     137:             puts("Runtime stack overflow\n");
     138:             break;
     139:         default:
     140:             puts("Panic: unknown error\n");
     141:     }
     142:     if (nodump == 0) {
     143:         for (i = 0; i < 20; i++)
     144:             disp[i] = display[i];
     145:         mydp = dp;
     146:         sep = perrno == EINTR ? "\n\tInterrupted at " : "\n\tError at ";
     147:         if (lino <= 0)
     148:             exit(perrno);
     149:         for(;;) {
     150:             puts(sep);
     151:             sep = "\tCalled by ";
     152:             pputch('"');
     153:             ap = *mydp;
     154:             ap += 3;
     155:             cp = *ap++;
     156:             i = 8;
     157:             do
     158:                 pputch(*cp++);
     159:             while (--i && *cp != ' ');
     160:             cp += i;
     161:             puts("\"+");
     162:             pwrite(O_WRIT2, 2, lino-cp->pint, 0);
     163:             puts(" near line ");
     164:             pwrite(O_WRIT2, 2, lino, 0);
     165:             pputch('\n');
     166:             *mydp = *ap++;
     167:             if (mydp <= &display[1]) {
     168:                 for (i = 0; i < 20; i++)
     169:                     display[i] = disp[i];
     170:                 pmflush();
     171:                 puts("\n");
     172:                 if (discard)
     173:                     puts("Execution terminated abnormally\n");
     174:                 stmts();
     175:                 exit(perrno);
     176:             }
     177:             mydp = *ap++;
     178:             ap++;
     179:             lino = *ap++;
     180:             if (lino <= 0)
     181:                 break;
     182:         }
     183:     }
     184:     exit(perrno);
     185: }
     186:
     187: stmts()
     188: {
     189:     extern long stcnt;
     190:
     191:     pwrite(O_WRIT4, 2, stcnt, 0);
     192:     puts(" statement");
     193:     if (stcnt != 1)
     194:         puts("s");
     195:     puts(" executed in");
     196:     stmttime();
     197: }
     198:
     199: stmttime()
     200: {
     201:     struct tms tbuf;
     202:     long l;
     203:
     204:     times(&tbuf);
     205:     l = tbuf.tms_utime;
     206:     pwrite(O_WRIT82, (2 << 3) | 2, l / HZ + 0.005, 0, 2);
     207:     puts(" seconds cpu time\n");
     208: }
     209:
     210: psexit()
     211: {
     212:
     213:     if (nodump == 1)
     214:         exit(0);
     215:     pmessage();
     216:     if (discard)
     217:         puts("Execution terminated\n");
     218:     stmts();
     219:     exit(0);
     220: }

#### Defined functions

error defined in line 14; used 5 times

- in /usr/src/ucb/pascal/px/00int.s line 6, 90
- in /usr/src/ucb/pascal/px/int.c line 173
- in /usr/src/ucb/pascal/px/palloc.c line 15
- in /usr/src/ucb/pascal/px/pcttot.c line 19

psexit defined in line 210; used 2 times

- in /usr/src/ucb/pascal/px/00int.s line 155-156(2)

stmts defined in line 187; used 2 times

- in line 174, 218

stmttime defined in line 199; used 1 times

- in line 196

Last modified: 1987-03-13 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1214 |