1: #
   2: /*
   3:  *
   4:  *	UNIX debugger
   5:  *
   6:  */
   7: 
   8: #include "defs.h"
   9: 
  10: 
  11: MSG     BADEQ;
  12: MSG     NOMATCH;
  13: MSG     BADVAR;
  14: MSG     BADCOM;
  15: 
  16: MAP     txtmap;
  17: MAP     datmap;
  18: OVTAG       symov, lastsymov, curov;
  19: INT     executing;
  20: CHAR        *lp;
  21: INT     fcor;
  22: INT     fsym;
  23: INT     mkfault;
  24: STRING      errflg;
  25: 
  26: CHAR        lastc;
  27: CHAR        eqformat[128] "o";
  28: CHAR        stformat[128] "o\"= \"^i";
  29: POS     *corhdr, *uar0;
  30: 
  31: L_INT       dot;
  32: L_INT       ditto;
  33: INT     dotinc;
  34: INT     lastcom '=';
  35: L_INT       var[];
  36: L_INT       locval;
  37: L_INT       locmsk;
  38: INT     pid;
  39: L_INT       expv;
  40: L_INT       adrval;
  41: INT     adrflg;
  42: L_INT       cntval;
  43: INT     cntflg;
  44: 
  45: 
  46: 
  47: 
  48: /* command decoding */
  49: 
  50: command(buf,defcom)
  51: STRING      buf;
  52: CHAR        defcom;
  53: {
  54:     INT     itype, ptype, modifier, regptr;
  55:     BOOL        longpr, eqcom;
  56:     CHAR        wformat[1];
  57:     CHAR        savc;
  58:     L_INT       w, savdot;
  59:     STRING      savlp=lp;
  60:     IF buf
  61:     THEN IF *buf==EOR
  62:          THEN return(FALSE);
  63:          ELSE lp=buf;
  64:          FI
  65:     FI
  66: 
  67:     REP
  68:     IF adrflg=expr(0)
  69:     THEN dot=expv; ditto=dot; symov=lastsymov;
  70:     FI
  71:     adrval=dot;
  72:     IF rdc()==',' ANDF expr(0)
  73:     THEN cntflg=TRUE; cntval=expv;
  74:     ELSE cntflg=FALSE; cntval=1; lp--;
  75:     FI
  76: 
  77:     IF !eol(rdc())
  78:     THEN lastcom=lastc;
  79:     ELSE IF adrflg==0 THEN dot=inkdot(dotinc); FI
  80:          lp--; lastcom=defcom;
  81:     FI
  82: 
  83:     switch(lastcom&STRIP) {
  84: 
  85:         case '/':
  86:         itype=DSP; ptype=DSYM;
  87:         goto trystar;
  88: 
  89:         case '=':
  90:         itype=NSP; ptype=ASYM;
  91:         goto trypr;
  92: 
  93:         case '?':
  94:         itype=ISP; ptype=ISYM;
  95:         goto trystar;
  96: 
  97:         trystar:
  98:         IF rdc()=='*' THEN lastcom |= QUOTE; ELSE lp--; FI
  99:         IF lastcom&QUOTE
 100:         THEN itype |= STAR; ptype = (DSYM+ISYM)-ptype;
 101:         FI
 102: 
 103:         trypr:
 104:         longpr=FALSE; eqcom=lastcom=='=';
 105:         switch (rdc()) {
 106: 
 107:             case 'm':
 108:                 {/*reset map data*/
 109:                 INT     fcount;
 110:                 MAPPTR  smap;
 111:                 L_INT   *mp;
 112: 
 113:                 IF eqcom THEN error(BADEQ); FI
 114:                 smap=(itype&DSP?&datmap:&txtmap);
 115:                 fcount=3;
 116:                 IF itype&STAR
 117:                 THEN mp = &(smap->b2);
 118:                 ELSE mp = &(smap->b1);
 119:                 FI
 120:                 WHILE fcount-- ANDF expr(0)
 121:                 DO *(mp)++ = expv; OD
 122:                 IF rdc()=='?' THEN smap->ufd=fsym;
 123:                 ELIF lastc == '/' THEN smap->ufd=fcor;
 124:                 ELSE lp--;
 125:                 FI
 126:                 }
 127:                 break;
 128: 
 129:             case 'L':
 130:                 longpr=TRUE;
 131:             case 'l':
 132:                 /*search for exp*/
 133:                 IF eqcom THEN error(BADEQ); FI
 134:                 dotinc=2; savdot=dot;
 135:                 expr(1); locval=expv;
 136:                 IF expr(0) THEN locmsk=expv; ELSE locmsk = -1L; FI
 137:                 LOOP w=leng(get(dot,itype));
 138:                  IF longpr
 139:                  THEN w=itol(w,get(inkdot(2),itype));
 140:                  FI
 141:                  IF errflg ORF mkfault ORF (w&locmsk)==locval THEN break; FI
 142:                  dot=inkdot(dotinc);
 143:                 POOL
 144:                 IF errflg
 145:                 THEN dot=savdot; errflg=NOMATCH;
 146:                 FI
 147:                 psymoff(dot,ptype,"");
 148:                 break;
 149: 
 150:             case 'W':
 151:                 longpr=TRUE;
 152:             case 'w':
 153:                 IF eqcom THEN error(BADEQ); FI
 154:                 wformat[0]=lastc; expr(1);
 155:                 REP  savdot=dot; psymoff(dot,ptype,":%16t"); exform(1,wformat,itype,ptype);
 156:                  errflg=0; dot=savdot;
 157:                  IF longpr
 158:                  THEN put(dot,itype,expv);
 159:                  FI
 160:                  put((longpr?inkdot(2):dot),itype,shorten(expv));
 161:                  savdot=dot;
 162:                  printf("=%8t"); exform(1,wformat,itype,ptype);
 163:                  newline();
 164:                 PER  expr(0) ANDF errflg==0 DONE
 165:                 dot=savdot;
 166:                 chkerr();
 167:                 break;
 168: 
 169:             default:
 170:                 lp--;
 171:                 getformat(eqcom ? eqformat : stformat);
 172:                 IF !eqcom
 173:                 THEN IF symov ANDF symov!=curov ANDF
 174:                 ptype == ISYM ANDF dot>=txtmap.bo
 175:                  THEN setovmap(symov);
 176:                       var[VARC]=symov;
 177:                  FI
 178:                  IF *stformat!='a'
 179:                      THEN psymoff(dot,ptype,":%16t");
 180:                      FI
 181:                 FI
 182:                 scanform(cntval,(eqcom?eqformat:stformat),itype,ptype);
 183:         }
 184:         break;
 185: 
 186:         case '>':
 187:         lastcom=0; savc=rdc();
 188:         IF (regptr=getreg(savc)) != NOREG
 189:         THEN uar0[regptr]=shorten(dot);
 190:              ptrace(WUREGS,pid,(int)&uar0[regptr]-(int)&corhdr,
 191:             uar0[regptr]);
 192:              IF (uar0+regptr) == &(((U*)corhdr)->u_ovdata.uo_curov)
 193:              THEN var[VARC]=dot; setovmap((OVTAG)dot); FI
 194:         ELIF (modifier=varchk(savc)) != -1
 195:         THEN    var[modifier]=dot;
 196:             IF modifier == VARC THEN setovmap((OVTAG)dot); FI
 197:         ELSE    error(BADVAR);
 198:         FI
 199:         break;
 200: 
 201:         case '!':
 202:         lastcom=0;
 203:         unox(); break;
 204: 
 205:         case '$':
 206:         lastcom=0;
 207:         printtrace(nextchar()); break;
 208: 
 209:         case ':':
 210:         IF !executing
 211:         THEN executing=TRUE;
 212:              subpcs(nextchar());
 213:              executing=FALSE;
 214:              lastcom=0;
 215:         FI
 216:         break;
 217: 
 218:         case 0:
 219:         prints(DBNAME);
 220:         break;
 221: 
 222:         default: error(BADCOM);
 223:     }
 224: 
 225:     flushbuf();
 226:     PER rdc()==';' DONE
 227:     IF buf THEN lp=savlp; ELSE lp--; FI
 228:     return(adrflg ANDF dot!=0);
 229: }

Defined functions

command defined in line 50; used 2 times
Last modified: 1982-02-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 895
Valid CSS Valid XHTML 1.0 Strict