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

Defined functions

getreg defined in line 384; used 2 times
printfregs defined in line 342; used 1 times
printmap defined in line 314; used 2 times
printpc defined in line 405; used 2 times
printregs defined in line 359; used 1 times
printtrace defined in line 67; used 1 times
sigprint defined in line 412; used 3 times

Defined variables

A68BAD defined in line 6; used 1 times
A68LNK defined in line 7; used 1 times
BADMOD defined in line 8; used 1 times
LONGFIL defined in line 4; used 1 times
NOTOPEN defined in line 5; used 1 times
adrflg defined in line 37; used 5 times
adrval defined in line 36; used 4 times
bkpthead defined in line 24; used 1 times
callpc defined in line 16; used 2 times
cntflg defined in line 39; used 2 times
cntval defined in line 38; used 5 times
corfil defined in line 34; used 1 times
corhdr defined in line 26; used 5 times
curov defined in line 11; used 6 times
datmap defined in line 10; used 1 times
dot defined in line 31; used 3 times
errflg defined in line 29; used 4 times
fcor defined in line 28; used 1 times
infile defined in line 17; used 6 times
kernel defined in line 15; used 5 times
kregs defined in line 54; used 2 times
  • in line 365(2)
lastc defined in line 25; used 1 times
lastframe defined in line 14; used 2 times
localval defined in line 23; used 1 times
lp defined in line 19; used 4 times
maxoff defined in line 20; used 4 times
maxpos defined in line 21; used 1 times
octal defined in line 22; used 2 times
outfile defined in line 18; used 2 times
overlay defined in line 40; used 2 times
pid defined in line 35; used 2 times
reglist defined in line 42; used 4 times
signo defined in line 30; used 4 times
symfil defined in line 33; used 1 times
txtmap defined in line 9; used 1 times
uar0 defined in line 27; used 6 times
var defined in line 32; used 5 times
Last modified: 1998-04-22
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 141
Valid CSS Valid XHTML 1.0 Strict