1: #ifndef lint
   2: static  char sccsid[] = "@(#)pcs.c	4.2 8/11/83";
   3: #endif
   4: /*
   5:  *
   6:  *	UNIX debugger
   7:  *
   8:  */
   9: 
  10: #include "defs.h"
  11: 
  12: 
  13: MSG     NOBKPT;
  14: MSG     SZBKPT;
  15: MSG     EXBKPT;
  16: MSG     NOPCS;
  17: MSG     BADMOD;
  18: 
  19: /* breakpoints */
  20: BKPTR       bkpthead;
  21: 
  22: CHAR        *lp;
  23: CHAR        lastc;
  24: 
  25: INT     signo;
  26: L_INT       dot;
  27: INT     pid;
  28: L_INT       cntval;
  29: L_INT       loopcnt;
  30: 
  31: L_INT       entrypt;
  32: INT     adrflg;
  33: 
  34: 
  35: 
  36: /* sub process control */
  37: 
  38: subpcs(modif)
  39: {
  40:     REG INT     check;
  41:     INT     execsig,runmode;
  42:     REG BKPTR   bkptr;
  43:     STRING      comptr;
  44:     execsig=0; loopcnt=cntval;
  45: 
  46:     switch (modif) {
  47: 
  48:         /* delete breakpoint */
  49:         case 'd': case 'D':
  50:         IF (bkptr=scanbkpt(dot))
  51:         THEN bkptr->flag=0; return;
  52:         ELSE error(NOBKPT);
  53:         FI
  54: 
  55:         /* set breakpoint */
  56:         case 'b': case 'B':
  57:         IF (bkptr=scanbkpt(dot))
  58:         THEN bkptr->flag=0;
  59:         FI
  60:         FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
  61:         DO IF bkptr->flag == 0
  62:            THEN break;
  63:            FI
  64:         OD
  65:         IF bkptr==0
  66:         THEN IF (bkptr=sbrk(sizeof *bkptr)) == -1
  67:              THEN error(SZBKPT);
  68:              ELSE bkptr->nxtbkpt=bkpthead;
  69:               bkpthead=bkptr;
  70:              FI
  71:         FI
  72:         bkptr->loc = dot;
  73:         bkptr->initcnt = bkptr->count = cntval;
  74:         bkptr->flag = BKPTSET;
  75:         check=MAXCOM-1; comptr=bkptr->comm; rdc(); lp--;
  76:         REP *comptr++ = readchar();
  77:         PER check-- ANDF lastc!=EOR DONE
  78:         *comptr=0; lp--;
  79:         IF check
  80:         THEN return;
  81:         ELSE error(EXBKPT);
  82:         FI
  83: 
  84:         /* exit */
  85:         case 'k' :case 'K':
  86:         IF pid
  87:         THEN printf("%d: killed", pid); endpcs(); return;
  88:         FI
  89:         error(NOPCS);
  90: 
  91:         /* run program */
  92:         case 'r': case 'R':
  93:         endpcs();
  94:         setup(); runmode=CONTIN;
  95:         IF adrflg
  96:         THEN IF !scanbkpt(dot) THEN loopcnt++; FI
  97:         ELSE IF !scanbkpt(entrypt+2) THEN loopcnt++; FI
  98:         FI
  99:         break;
 100: 
 101:         /* single step */
 102:         case 's': case 'S':
 103:         IF pid
 104:         THEN
 105:             runmode=SINGLE; execsig=getsig(signo);
 106:         ELSE setup(); loopcnt--;
 107:         FI
 108:         break;
 109: 
 110:         /* continue with optional signal */
 111:         case 'c': case 'C': case 0:
 112:         IF pid==0 THEN error(NOPCS); FI
 113:         runmode=CONTIN; execsig=getsig(signo);
 114:         break;
 115: 
 116:         default: error(BADMOD);
 117:     }
 118: 
 119:     IF loopcnt>0 ANDF runpcs(runmode,execsig)
 120:     THEN printf("breakpoint%16t");
 121:     ELSE printf("stopped at%16t");
 122:     FI
 123:     delbp();
 124:     printpc();
 125: }

Defined functions

subpcs defined in line 38; used 1 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1983-08-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 957
Valid CSS Valid XHTML 1.0 Strict