1: #
   2: /*
   3:  *
   4:  *	UNIX debugger
   5:  *
   6:  */
   7: 
   8: #include "defs.h"
   9: 
  10: 
  11: MSG     LONGFIL;
  12: MSG     NOTOPEN;
  13: MSG     A68BAD;
  14: MSG     A68LNK;
  15: MSG     BADMOD;
  16: 
  17: MAP     txtmap;
  18: MAP     datmap;
  19: OVTAG       curov;
  20: int     overlay;
  21: 
  22: SYMTAB      symbol;
  23: INT     lastframe;
  24: INT     kernel;
  25: INT     callpc;
  26: 
  27: INT     infile;
  28: INT     outfile;
  29: CHAR        *lp;
  30: INT     maxoff;
  31: INT     maxpos;
  32: INT     octal;
  33: 
  34: /* symbol management */
  35: L_INT       localval;
  36: 
  37: /* breakpoints */
  38: BKPTR       bkpthead;
  39: 
  40: REGLIST reglist [] {
  41:         "ps", RPS,
  42:         "pc", PC,
  43:         "sp", R6,
  44:         "r5", R5,
  45:         "r4", R4,
  46:         "r3", R3,
  47:         "r2", R2,
  48:         "r1", R1,
  49:         "r0", R0
  50: };
  51: 
  52: REGLIST kregs[] = {
  53:         "sp", KSP,
  54:         "r5", KR5,
  55:         "r4", KR4,
  56:         "r3", KR3,
  57:         "r2", KR2,
  58:         "r1", KR1,
  59:         "r0", KR0
  60: };
  61: 
  62: STRING  ovname  "ov";   /* not in reglist (not from kernel stack) */
  63: INT     frnames[] { 0, 3, 4, 5, 1, 2 };
  64: 
  65: char        lastc;
  66: POS     corhdr[];
  67: POS     *uar0;
  68: 
  69: INT     fcor;
  70: STRING      errflg;
  71: INT     signo;
  72: 
  73: 
  74: L_INT       dot;
  75: L_INT       var[];
  76: STRING      symfil;
  77: STRING      corfil;
  78: INT     pid;
  79: L_INT       adrval;
  80: INT     adrflg;
  81: L_INT       cntval;
  82: INT     cntflg;
  83: int     overlay;
  84: 
  85: STRING      signals[] {
  86:         "",
  87:         "hangup",
  88:         "interrupt",
  89:         "quit",
  90:         "illegal instruction",
  91:         "trace/BPT",
  92:         "IOT",
  93:         "EMT",
  94:         "floating exception",
  95:         "killed",
  96:         "bus error",
  97:         "memory fault",
  98:         "bad system call",
  99:         "broken pipe",
 100:         "alarm call",
 101:         "terminated",
 102:         "<unused 16 >",
 103: #ifdef  MENLO_JCL
 104:         "stopped (signal)",
 105:         "stopped from tty",
 106:         "continued",        /* adb should never see this */
 107:         "child stopped",
 108:         "stopped (input)",
 109:         "stopped (output)",
 110:         "input available"
 111: #endif
 112: };
 113: 
 114: int nsig = sizeof(signals)/sizeof(signal[0]);
 115: 
 116: 
 117: /* general printing routines ($) */
 118: 
 119: printtrace(modif)
 120: {
 121:     INT     narg, i, stat, name, limit;
 122:     POS     dynam;
 123:     REG BKPTR   bkptr;
 124:     CHAR        hi, lo;
 125:     INT     word;
 126:     STRING      comptr;
 127:     L_INT       argp, frame, link;
 128:     SYMPTR      symp;
 129:     OVTAG       savov;
 130: 
 131:     IF cntflg==0 THEN cntval = -1; FI
 132: 
 133:     switch (modif) {
 134: 
 135:         case '<':
 136:         case '>':
 137:         {CHAR       file[64];
 138:         INT     index;
 139: 
 140:         index=0;
 141:         IF modif=='<'
 142:         THEN    iclose();
 143:         ELSE    oclose();
 144:         FI
 145:         IF rdc()!=EOR
 146:         THEN    REP file[index++]=lastc;
 147:                 IF index>=63 THEN error(LONGFIL); FI
 148:             PER readchar()!=EOR DONE
 149:             file[index]=0;
 150:             IF modif=='<'
 151:             THEN    infile=open(file,0);
 152:                 IF infile<0
 153:                 THEN    infile=0; error(NOTOPEN);
 154:                 FI
 155:             ELSE    outfile=open(file,1);
 156:                 IF outfile<0
 157:                 THEN    outfile=creat(file,0644);
 158:                 ELSE    lseek(outfile,0L,2);
 159:                 FI
 160:             FI
 161: 
 162:         FI
 163:         lp--;
 164:         }
 165:         break;
 166: 
 167:         case 'o':
 168:         octal = TRUE; break;
 169: 
 170:         case 'd':
 171:         octal = FALSE; break;
 172: 
 173:         case 'q': case 'Q': case '%':
 174:         done();
 175: 
 176:         case 'w': case 'W':
 177:         maxpos=(adrflg?adrval:MAXPOS);
 178:         break;
 179: 
 180:         case 's': case 'S':
 181:         maxoff=(adrflg?adrval:MAXOFF);
 182:         break;
 183: 
 184:         case 'v':
 185:         prints("variables\n");
 186:         FOR i=0;i<=35;i++
 187:         DO IF var[i]
 188:            THEN printc((i<=9 ? '0' : 'a'-10) + i);
 189:             printf(" = %Q\n",var[i]);
 190:            FI
 191:         OD
 192:         break;
 193: 
 194:         case 'm': case 'M':
 195:         printmap("? map",&txtmap);
 196:         printmap("/ map",&datmap);
 197:         break;
 198: 
 199:         case 0: case '?':
 200:         IF pid
 201:         THEN printf("pcs id = %d\n",pid);
 202:         ELSE prints("no process\n");
 203:         FI
 204:         sigprint(); flushbuf();
 205: 
 206:         case 'r': case 'R':
 207:         printregs();
 208:         return;
 209: 
 210:         case 'f': case 'F':
 211:         printfregs(modif=='F');
 212:         return;
 213: 
 214:         case 'c': case 'C':
 215:         frame=(adrflg?adrval:(kernel?corhdr[KR5]:uar0[R5]))&EVEN;
 216:         lastframe=0;
 217:         savov = curov;
 218:         callpc=(adrflg?get(frame+2,DSP):(kernel?(-2):uar0[PC]));
 219:         WHILE cntval--
 220:         DO  chkerr();
 221:             narg = findroutine(frame);
 222:             printf("%.8s(", symbol.symc);
 223:             argp = frame+4;
 224:             IF --narg >= 0
 225:             THEN    printf("%o", get(argp, DSP));
 226:             FI
 227:             WHILE --narg >= 0
 228:             DO  argp += 2;
 229:                 printf(",%o", get(argp, DSP));
 230:             OD
 231:             prints(")\n");
 232: 
 233:             IF modif=='C'
 234:             THEN WHILE localsym(frame)
 235:                  DO word=get(localval,DSP);
 236:                 printf("%8t%.8s:%10t", symbol.symc);
 237:                 IF errflg THEN prints("?\n"); errflg=0; ELSE printf("%o\n",word); FI
 238:                  OD
 239:             FI
 240: 
 241:             lastframe=frame;
 242:             frame=get(frame, DSP)&EVEN;
 243:             IF kernel? ((unsigned)frame>(unsigned)0142000):
 244:                 (frame==0)
 245:                 THEN break; FI
 246:         OD
 247:         if (overlay)
 248:             setovmap(savov);
 249:         break;
 250: 
 251:         /*print externals*/
 252:         case 'e': case 'E':
 253:         symset();
 254:         WHILE (symp=symget())
 255:         DO chkerr();
 256:            IF (symp->symf)==043 ORF (symp->symf)==044
 257:            THEN printf("%.8s:%12t%o\n", symp->symc, get(leng(symp->symv),DSP));
 258:            FI
 259:         OD
 260:         break;
 261: 
 262:         case 'a': case 'A':
 263:         frame=(adrflg ? adrval : uar0[R4]);
 264: 
 265:         WHILE cntval--
 266:         DO chkerr();
 267:            stat=get(frame,DSP); dynam=get(frame+2,DSP); link=get(frame+4,DSP);
 268:            IF modif=='A'
 269:            THEN printf("%8O:%8t%-8o,%-8o,%-8o",frame,stat,dynam,link);
 270:            FI
 271:            IF stat==1 THEN break; FI
 272:            IF errflg THEN error(A68BAD); FI
 273: 
 274:            IF get(link-4,ISP)!=04767
 275:            THEN IF get(link-2,ISP)!=04775
 276:             THEN error(A68LNK);
 277:             ELSE /*compute entry point of routine*/
 278:                  prints(" ? ");
 279:             FI
 280:            ELSE printf("%8t");
 281:                 valpr(name=shorten(link)+get(link-2,ISP),ISYM);
 282:             name=get(leng(name-2),ISP);
 283:             printf("%8t\""); limit=8;
 284:             REP word=get(leng(name),DSP); name += 2;
 285:                 lo=word&LOBYTE; hi=(word>>8)&LOBYTE;
 286:                 printc(lo); printc(hi);
 287:             PER lo ANDF hi ANDF limit-- DONE
 288:             printc('"');
 289:            FI
 290:            limit=4; i=6; printf("%24targs:%8t");
 291:            WHILE limit--
 292:            DO printf("%8t%o",get(frame+i,DSP)); i += 2; OD
 293:            printc(EOR);
 294: 
 295:            frame=dynam;
 296:         OD
 297:         errflg=0;
 298:         flushbuf();
 299:         break;
 300: 
 301:         /*set default c frame*/
 302:         /*print breakpoints*/
 303:         case 'b': case 'B':
 304:         printf("breakpoints\ncount%8tbkpt%24tcommand\n");
 305:         savov = curov;
 306:         FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
 307:         DO IF bkptr->flag
 308:            THEN printf("%-8.8d",bkptr->count);
 309:             curov = bkptr->ovly;
 310:             psymoff(leng(bkptr->loc),ISYM,"%24t");
 311:             comptr=bkptr->comm;
 312:             WHILE *comptr DO printc(*comptr++); OD
 313:            FI
 314:         OD
 315:         curov = savov;
 316:         break;
 317: 
 318:         default: error(BADMOD);
 319:     }
 320: 
 321: }
 322: 
 323: printmap(s,amap)
 324: STRING  s; MAP *amap;
 325: {
 326:     int file;
 327:     file=amap->ufd;
 328:     printf("%s%12t`%s'\n",s,(file<0 ? "-" : (file==fcor ? corfil : symfil)));
 329:     printf("b1 = %-16Q",amap->b1);
 330:     printf("e1 = %-16Q",amap->e1);
 331:     printf("f1 = %-16Q",amap->f1);
 332:     IF amap->bo
 333:     THEN    printf("\n\t{ bo = %-16Q",amap->bo);
 334:         printf("eo = %-16Q",amap->eo);
 335:         printf("fo = %-16Q}",amap->fo);
 336:     FI
 337:     printf("\nb2 = %-16Q",amap->b2);
 338:     printf("e2 = %-16Q",amap->e2);
 339:     printf("f2 = %-16Q",amap->f2);
 340:     printc(EOR);
 341: }
 342: 
 343: printfregs(longpr)
 344: {
 345: #ifndef NONFP
 346:     REG i;
 347:     L_REAL f;
 348:     struct Lfp *pfp;
 349: 
 350:     pfp = (struct Lfp *)&(struct user *)corhdr->u_fpsr;
 351:     printf("fpsr	%o\n", pfp->fpsr);
 352:     FOR i=0; i<FRMAX; i++
 353:     DO  IF ((U *)corhdr)->u_fpsr&FD ORF longpr /* long mode */
 354:         THEN    f = pfp->Lfr[frnames[i]];
 355:         ELSE    f = ((struct Sfp *)pfp)->Sfr[frnames[i]];
 356:         FI
 357:         printf("fr%-8d%-32.18f\n", i, f);
 358:     OD
 359: #endif
 360: }
 361: 
 362: printregs()
 363: {
 364:     REG REGPTR  p;
 365:     INT     v;
 366: 
 367:     IF kernel
 368:     THEN    FOR p=kregs; p<&kregs[7]; p++
 369:         DO  printf("%s%8t%o%8t", p->rname, v=corhdr[p->roffs]);
 370:             valpr(v,DSYM);
 371:             printc(EOR);
 372:         OD
 373:     ELSE    FOR p=reglist; p < &reglist[NREG]; p++
 374:         DO  printf("%s%8t%o%8t", p->rname, v=uar0[p->roffs]);
 375:             valpr(v,(p->roffs==PC?ISYM:DSYM));
 376:             printc(EOR);
 377:         OD
 378:         IF overlay
 379:         THEN    setovmap(((U *)corhdr)->u_ovdata.uo_curov);
 380:             var[VARC] = curov;
 381:             printf("%s%8t%o\n", ovname, curov);
 382:         FI
 383:         printpc();
 384:     FI
 385: }
 386: 
 387: getreg(regnam)
 388: {
 389:     REG REGPTR  p;
 390:     REG STRING  regptr;
 391:     CHAR        regnxt;
 392: 
 393:     IF kernel THEN return(NOREG); FI    /* not supported */
 394:     regnxt=readchar();
 395:     FOR p=reglist; p<&reglist[NREG]; p++
 396:     DO  regptr=p->rname;
 397:         IF (regnam == *regptr++) ANDF (regnxt == *regptr)
 398:         THEN    return(p->roffs);
 399:         FI
 400:     OD
 401:     IF regnam==ovname[0] ANDF regnxt==ovname[1]
 402:     THEN    return((POS *)&(((U *)corhdr)->u_ovdata.uo_curov) - uar0);
 403:     FI
 404:     lp--;
 405:     return(NOREG);
 406: }
 407: 
 408: printpc()
 409: {
 410:     dot=uar0[PC];
 411:     psymoff(dot,ISYM,":%16t"); printins(0,ISP,chkget(dot,ISP));
 412:     printc(EOR);
 413: }
 414: 
 415: sigprint()
 416: {
 417:     if ((unsigned) signo < nsig)
 418:         prints(signals[signo]);
 419:     else
 420:         prints("unknown signal");
 421: }

Defined functions

getreg defined in line 387; used 2 times
printfregs defined in line 343; used 1 times
printmap defined in line 323; used 2 times
printpc defined in line 408; used 2 times
printregs defined in line 362; used 1 times
printtrace defined in line 119; used 1 times
sigprint defined in line 415; used 3 times

Defined variables

lastc defined in line 65; used 1 times
nsig defined in line 114; used 1 times
overlay defined in line 83; used 2 times
Last modified: 1983-03-23
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1345
Valid CSS Valid XHTML 1.0 Strict