1: #
   2: /*
   3:  *
   4:  *	UNIX debugger
   5:  *
   6:  */
   7: 
   8: #include "defs.h"
   9: 
  10: 
  11: MSG     BADNAM;
  12: MSG     DIFMAG;
  13: MSG     BADFIL;
  14: 
  15: MAP     txtmap;
  16: MAP     datmap;
  17: SYMSLAVE    *symvec;
  18: INT     wtflag;
  19: INT     kernel;
  20: INT     fcor;
  21: INT     fsym;
  22: L_INT       maxfile;
  23: L_INT       maxstor;
  24: L_INT       txtsiz;
  25: L_INT       datsiz;
  26: L_INT       bss;
  27: L_INT       datbas;
  28: L_INT       stksiz;
  29: STRING      errflg;
  30: INT     magic;
  31: L_INT       symbas;
  32: L_INT       symnum;
  33: L_INT       entrypt;
  34: L_INT       var[];
  35: 
  36: long tell();
  37: INT     argcount;
  38: INT     signo;
  39: POS     corhdr[512];
  40: POS     *uar0 = UAR0;
  41: 
  42: STRING      symfil  "a.out";
  43: STRING      corfil  "core";
  44: 
  45: OVLVEC      ovlseg;
  46: L_INT       ovlsiz;
  47: L_INT       ovloff[8];
  48: OVTAG       startov;
  49: int     overlay;
  50: 
  51: #define TXTHDRSIZ   (sizeof(TXTHDR))
  52: #define OVLHDRSIZ   (sizeof(ovlseg))
  53: 
  54: #define HBIT    0100
  55: 
  56: setsym()
  57: {
  58:     INT     relflg;
  59:     SYMSLAVE    *symptr;
  60:     SYMPTR      symp;
  61:     TXTHDR      txthdr;
  62: 
  63:     fsym=getfile(symfil,1);
  64:     txtmap.ufd=fsym;
  65:     IF read(fsym, txthdr, TXTHDRSIZ)==TXTHDRSIZ
  66:     THEN    magic=txthdr[0];
  67:         txtsiz = txthdr[1];
  68:         datsiz = txthdr[2];
  69:         bss = txthdr[3];
  70:         symnum = txthdr[4]/SYMTABSIZ;
  71:         entrypt = txthdr[5];
  72:         relflg = txthdr[7];
  73:         symbas = txtsiz+datsiz;
  74:         switch (magic)
  75:         {
  76:             INT ovly;
  77: 
  78:             case 0407:
  79:                 txtmap.b1 = txtmap.b2 = 0;
  80:                 txtmap.e1 = txtmap.e2 = txtsiz+datsiz;
  81:                 txtmap.f1 = txtmap.f2 = TXTHDRSIZ;
  82:                 break;
  83: 
  84:             case 0410:
  85:                 txtmap.b1 = 0;
  86:                 txtmap.e1 = txtsiz;
  87:                 txtmap.f1 = TXTHDRSIZ;
  88:                 txtmap.b2 = round(txtsiz, TXTRNDSIZ);
  89:                 txtmap.e2 = txtmap.b2+datsiz;
  90:                 txtmap.f2 = txtsiz+TXTHDRSIZ;
  91:                 break;
  92: 
  93:             case 0405:
  94:             case 0411:
  95:                 txtmap.b1 = 0;
  96:                 txtmap.e1 = txtsiz;
  97:                 txtmap.f1 = TXTHDRSIZ;
  98:                 txtmap.b2 = 0;
  99:                 txtmap.e2 = datsiz;
 100:                 txtmap.f2 = txtsiz+TXTHDRSIZ;
 101:                 break;
 102: 
 103:             case 0430:
 104:             case 0431:
 105:                 IF read(fsym, &ovlseg, OVLHDRSIZ) == OVLHDRSIZ
 106:                 THEN    txtmap.b1 = 0;
 107:                     txtmap.e1 = txtsiz;
 108:                     txtmap.f1 = TXTHDRSIZ+OVLHDRSIZ;
 109:                     txtmap.bo = round(txtsiz, TXTRNDSIZ);
 110:                     txtmap.eo = 0;
 111:                     txtmap.fo = 0;
 112:                     FOR ovly = 0; ovly < 7; ovly++
 113:                     DO  ovloff[ovly] = ovlsiz + txtsiz
 114:                             +TXTHDRSIZ+OVLHDRSIZ;
 115:                         ovlsiz += ovlseg.ov[ovly];
 116:                     OD
 117:                     IF magic == 0430
 118:                     THEN    txtmap.b2 =
 119:                         round(txtmap.bo+(long)ovlseg.max, TXTRNDSIZ);
 120:                     ELSE    txtmap.b2 = 0;
 121:                     FI
 122:                     txtmap.f2 = TXTHDRSIZ+OVLHDRSIZ+txtsiz+ovlsiz;
 123:                     symbas += ovlsiz+OVLHDRSIZ;
 124:                     txtmap.e2 = txtmap.b2 + datsiz;
 125:                     overlay = 1;
 126:                     break;
 127:                 FI
 128: 
 129:             default:    magic = 0;
 130:                     txtsiz = 0;
 131:                     datsiz = 0;
 132:                     bss = 0;
 133:                     symnum = 0;
 134:                     entrypt = 0;
 135:                     relflg = 0;
 136:                     symbas = 0;
 137:         }
 138:         datbas = txtmap.b2;
 139:         IF relflg!=1 THEN symbas =<< 1; FI
 140:         symbas += TXTHDRSIZ;
 141: 
 142:         /* set up symvec */
 143:         symvec=sbrk(shorten((1+symnum))*sizeof (SYMSLAVE));
 144:         IF (symptr=symvec)==-1
 145:         THEN    printf("%s\n",BADNAM);
 146:             symptr=symvec=sbrk(sizeof (SYMSLAVE));
 147:         ELSE if (symnum != 0) {
 148:             symset();
 149:             WHILE (symp=symget()) ANDF errflg==0
 150:             DO  symptr->valslave=symp->symv;
 151:                 symptr->typslave=SYMTYPE(symp->symf);
 152:                 symptr->ovlslave = symp->ovnumb;
 153:                 symptr++;
 154:             OD
 155:             }
 156:         FI
 157:         symptr->typslave=ESYM;
 158:     FI
 159:     IF magic==0 THEN txtmap.e1=maxfile; FI
 160: }
 161: 
 162: 
 163: setcor()
 164: {
 165:     fcor=getfile(corfil,2);
 166:     datmap.ufd=fcor;
 167:     IF read(fcor, corhdr, ctob(USIZE))==ctob(USIZE)
 168:     THEN    IF !kernel
 169:         THEN    txtsiz = corhdr->u_tsize << 6;
 170:             datsiz = corhdr->u_dsize << 6;
 171:             stksiz = corhdr->u_ssize << 6;
 172:             datmap.f1 = ctob(USIZE);
 173:             datmap.b2 = maxstor-stksiz;
 174:             datmap.e2 = maxstor;
 175:         ELSE    datsiz = round(datsiz+bss,64L);
 176:             stksiz = 02000L;
 177:             datmap.f1 = 0;
 178:             datmap.b2 = 0140000L;
 179:             datmap.e2 = 0142000L;
 180:         FI
 181:         switch (magic)
 182:         {
 183:             INT ovly;
 184: 
 185:             case 0407:
 186:                 datmap.b1 = 0;
 187:                 datmap.e1 = txtsiz+datsiz;
 188:                 IF kernel
 189:                 THEN    datmap.f2 = (long)corhdr[KA6] *
 190:                         0100L;
 191:                 ELSE    datmap.f2 = ctob(USIZE)+txtsiz+datsiz;
 192:                 FI
 193:                 break;
 194: 
 195:             case 0410:
 196:                 datmap.b1 = round(txtsiz, TXTRNDSIZ);
 197:                 datmap.e1 = datmap.b1+datsiz;
 198:                 datmap.f2 = datsiz+ctob(USIZE);
 199:                 break;
 200: 
 201:             case 0405:
 202:             case 0411:
 203:             case 0431:
 204:                 datmap.b1 = 0;
 205:                 datmap.e1 = datsiz;
 206:                 IF kernel
 207:                 THEN datmap.f2 = (long)corhdr[KA6] *
 208:                     0100L;
 209:                 ELSE datmap.f2 = datsiz+ctob(USIZE);
 210:                 FI
 211:                 break;
 212: 
 213:             case 0430:
 214:                 datmap.b1 = round(round(txtsiz,
 215:                     TXTRNDSIZ)+ovlseg.max,
 216:                     TXTRNDSIZ);
 217:                 datmap.e1 = datmap.b1+datsiz;
 218:                 IF kernel
 219:                 THEN    datmap.b1 = 0;
 220:                     datmap.f2 = (long)corhdr[KA6] *
 221:                         0100L;
 222:                 ELSE    datmap.f2 = datsiz+ctob(USIZE);
 223:                 FI
 224:                 break;
 225: 
 226:             default:
 227:                 magic = 0;
 228:                 datmap.b1 = 0;
 229:                 datmap.e1 = maxfile;
 230:                 datmap.f1 = 0;
 231:                 datmap.b2 = 0;
 232:                 datmap.e2 = 0;
 233:                 datmap.f2 = 0;
 234:         }
 235:         datbas = datmap.b1;
 236:         if (!kernel) {
 237:             if (magic ANDF magic!=corhdr[0].u_exdata.ux_mag)
 238:                 printf("%s\n",DIFMAG);
 239:             else if (magic) {
 240:               register POS *ar0;
 241:               ar0 = (POS *)(((U *)corhdr)->u_ar0);
 242:               if ((ar0>(POS *)0140000) & (ar0<(POS *)0142000)
 243:                   && !(ar0&01))
 244:                 uar0 = ar0 - 0140000 + (unsigned)corhdr;
 245:               if (overlay) {
 246:                 startov = ((U *)corhdr)->u_ovdata.uo_curov;
 247:                 var[VARC] = (long)startov;
 248:                 setovmap(startov);
 249:             }
 250:             }
 251:             /* else dig out __ovno if overlaid? */
 252:         }
 253:     ELSE    datmap.e1 = maxfile;
 254:     FI
 255: }
 256: 
 257: create(f)
 258: STRING  f;
 259: {   int fd;
 260:     IF (fd=creat(f,0644))>=0
 261:     THEN close(fd); return(open(f,wtflag));
 262:     ELSE return(-1);
 263:     FI
 264: }
 265: 
 266: getfile(filnam,cnt)
 267: STRING  filnam;
 268: {
 269:     REG INT     fsym;
 270: 
 271:     IF !eqstr("-",filnam)
 272:     THEN    fsym=open(filnam,wtflag);
 273:         IF fsym<0 ANDF argcount>cnt
 274:         THEN    IF wtflag
 275:             THEN    fsym=create(filnam);
 276:             FI
 277:             IF fsym<0
 278:             THEN printf("cannot open `%s'\n", filnam);
 279:             FI
 280:         FI
 281:     ELSE    fsym = -1;
 282:     FI
 283:     return(fsym);
 284: }

Defined functions

create defined in line 257; used 1 times
getfile defined in line 266; used 2 times
setcor defined in line 163; used 2 times
setsym defined in line 56; used 1 times

Defined variables

overlay defined in line 49; used 2 times

Defined macros

HBIT defined in line 54; never used
OVLHDRSIZ defined in line 52; used 6 times
TXTHDRSIZ defined in line 51; used 11 times
Last modified: 1983-06-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 946
Valid CSS Valid XHTML 1.0 Strict