# 2.11BSD#431 - /usr/src/bin/adb/command.c

##### Functions

    command           X

##### Variables

    BADCOM            X
    BADEQ             X
    BADVAR            X
    NOMATCH           X
    adrflg            X
    adrval            X
    cntflg            X
    cntval            X
    corhdr            X
    curov             X
    datmap            X
    ditto             X
    dot               X
    dotinc            X
    eqformat          X
    errflg            X
    executing         X
    expv              X
    fcor              X
    fsym              X
    lastc             X
    lastcom           X
    lastsymov         X
    locmsk            X
    locval            X
    lp                X
    mkfault           X
    pid               X
    stformat          X
    symov             X
    txtmap            X
    uar0              X
    var               X

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

#### Defined functions

command defined in line 38; used 2 times

- in /usr/src/bin/adb/main.c line 148
- in /usr/src/bin/adb/runpcs.c line 64

#### Defined variables

BADCOM defined in line 6; used 1 times

- in line 211

BADEQ defined in line 3; used 3 times

- in line 102, 122, 142

BADVAR defined in line 5; used 1 times

- in line 186

NOMATCH defined in line 4; used 1 times

- in line 134

adrflg defined in line 31; used 3 times

- in line 57, 68, 217

adrval defined in line 30; used 1 times

- in line 60

cntflg defined in line 33; used 2 times

- in line 62-63(2)

cntval defined in line 32; used 3 times

- in line 62-63(2), 171

corhdr defined in line 20; used 2 times

- in line 179-181(2)

curov defined in line 10; used 1 times

- in line 162

datmap defined in line 8; used 1 times

- in line 103

ditto defined in line 22; used 1 times

- in line 58

dot defined in line 21; used 24 times

- in line 58-60(3), 68, 123-136(5), 144-154(7), 163-168(2), 178-185(5), 217

dotinc defined in line 23; used 3 times

- in line 68, 123, 131

eqformat defined in line 18; used 2 times

- in line 160, 171

errflg defined in line 16; used 5 times

- in line 130-134(3), 145, 153

executing defined in line 11; used 3 times

- in line 199-202(3)

expv defined in line 29; used 7 times

- in line 58-62(2), 110, 124-125(2), 147-149(2)

fcor defined in line 13; used 1 times

- in line 112

fsym defined in line 14; used 1 times

- in line 111

lastc defined in line 17; used 3 times

- in line 67, 112, 143

lastcom defined in line 24; used 10 times

- in line 67-72(3), 87-93(3), 176, 191-195(2), 203

lastsymov defined in line 10; used 1 times

- in line 58

locmsk defined in line 27; used 3 times

- in line 125-130(3)

locval defined in line 26; used 2 times

- in line 124, 130

lp defined in line 12; used 9 times

- in line 47-52(2), 63, 69, 87, 113, 159, 216(2)

mkfault defined in line 15; used 1 times

- in line 130

pid defined in line 28; used 1 times

- in line 179

stformat defined in line 19; used 3 times

- in line 160, 167-171(2)

symov defined in line 10; used 5 times

- in line 58, 162-165(4)

txtmap defined in line 7; used 2 times

- in line 103, 163

uar0 defined in line 20; used 4 times

- in line 178-181(4)

var defined in line 25; used 3 times

- in line 165, 182-184(2)

Last modified: 1998-04-22 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1100 |