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

Defined functions

command defined in line 49; used 2 times

Defined variables

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