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

Defined functions

subpcs defined in line 38; used 1 times

Defined variables

overlay defined in line 31; used 1 times
  • in line 83
Last modified: 1982-08-13
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 829
Valid CSS Valid XHTML 1.0 Strict