1: #
   2: /*
   3:  *
   4:  *	UNIX debugger
   5:  *
   6:  */
   7: 
   8: long lseek();
   9: #include "defs.h"
  10: 
  11: 
  12: MSG     BADFIL;
  13: 
  14: SYMTAB      symbol;
  15: BOOL        localok;
  16: INT     lastframe;
  17: SYMSLAVE        *symvec;
  18: POS     maxoff;
  19: L_INT       maxstor;
  20: MAP     txtmap;
  21: OVTAG       curov;
  22: int     overlay;
  23: 
  24: /* symbol management */
  25: L_INT       symbas;
  26: L_INT       symcnt;
  27: L_INT       symnum;
  28: L_INT       localval;
  29: char        symrqd -1;
  30: SYMTAB      symbuf[SYMSIZ];
  31: SYMPTR      symnxt;
  32: SYMPTR      symend;
  33: 
  34: 
  35: INT     fsym;
  36: STRING      errflg;
  37: POS     findsym();
  38: 
  39: 
  40: /* symbol table and file handling service routines */
  41: 
  42: longseek(f, a)
  43: L_INT a;
  44: {
  45:     return(lseek(f,a,0) != -1L);
  46: }
  47: 
  48: valpr(v,idsp)
  49: {
  50:     POS     d;
  51:     d = findsym(v,idsp);
  52:     IF d < maxoff
  53:     THEN    printf("%.8s", symbol.symc);
  54:         IF d
  55:         THEN    printf(OFFMODE, d);
  56:         FI
  57:     FI
  58: }
  59: 
  60: localsym(cframe)
  61: L_INT cframe;
  62: {
  63:     INT symflg;
  64:     WHILE nextsym() ANDF localok
  65:         ANDF symbol.symc[0]!='~'
  66:         ANDF (symflg=(int)symbol.symf)!=037
  67:     DO IF symflg>=2 ANDF symflg<=4
  68:        THEN localval=symbol.symv;
  69:         return(TRUE);
  70:        ELIF symflg==1
  71:        THEN localval=leng(shorten(cframe)+symbol.symv);
  72:         return(TRUE);
  73:        ELIF symflg==20 ANDF lastframe
  74:        THEN localval=leng(lastframe+2*symbol.symv-(overlay?12:10));
  75:         return(TRUE);
  76:        FI
  77:     OD
  78:     return(FALSE);
  79: }
  80: psymoff(v,type,s)
  81: L_INT v; int type; char *s;
  82: {
  83:     POS     w;
  84:     w = findsym(shorten(v),type);
  85:     IF w >= maxoff
  86:     THEN printf(LPRMODE,v);
  87:     ELSE printf("%.8s", symbol.symc);
  88:          IF w THEN printf(OFFMODE,w); FI
  89:     FI
  90:     printf(s);
  91: }
  92: 
  93: POS findsym(svalue,type)
  94: POS svalue;
  95: INT type;
  96: {
  97:     L_INT       diff, value, symval, offset;
  98:     SYMFLG      symtyp;
  99:     REG SYMSLAVE    *symptr;
 100:     SYMSLAVE    *symsav;
 101:     OVTAG       ov = 0;
 102:     IF txtmap.bo ANDF type==ISYM ANDF svalue>=txtmap.bo
 103:     THEN    ov=curov; FI
 104:     value=svalue; diff = 0377777L; symsav=0;
 105:     IF type!=NSYM ANDF (symptr=symvec)
 106:     THEN    WHILE diff ANDF (symtyp=symptr->typslave)!=ESYM
 107:         DO  IF symtyp==type ANDF (!ov ORF ov==symptr->ovlslave)
 108:             THEN symval=leng(symptr->valslave);
 109:              IF value-symval<diff
 110:                 ANDF value>=symval
 111:              THEN diff = value-symval;
 112:                   symsav=symptr;
 113:              FI
 114:             FI
 115:             symptr++;
 116:         OD
 117:         IF symsav
 118:         THEN    offset=leng(symsav-symvec);
 119:             symcnt=symnum-offset;
 120:             longseek(fsym, symbas+offset*SYMTABSIZ);
 121:             read(fsym,&symbol,SYMTABSIZ);
 122:         FI
 123:     FI
 124: /*
 125: printf("name=%s,type=%d,ovl=%d,value=%o\n",symbol.symc,symbol.symf,symbol.ovnumb,symbol.symv);
 126: */
 127:     return(shorten(diff));
 128: }
 129: 
 130: nextsym()
 131: {
 132:     IF (--symcnt)<0
 133:     THEN    return(FALSE);
 134:     ELSE    return(longseek(fsym, symbas+(symnum-symcnt)*SYMTABSIZ)!=0 ANDF
 135:             read(fsym,&symbol,SYMTABSIZ)==SYMTABSIZ);
 136:     FI
 137: }
 138: 
 139: 
 140: 
 141: /* sequential search through file */
 142: symset()
 143: {
 144:     symcnt = symnum;
 145:     symnxt = symbuf;
 146:     IF symrqd
 147:     THEN    longseek(fsym, symbas);
 148:         symread(); symrqd=FALSE;
 149:     ELSE    longseek(fsym, symbas+sizeof symbuf);
 150:     FI
 151: }
 152: 
 153: SYMPTR  symget()
 154: {
 155:     REG INT rc;
 156:     IF symnxt >= symend
 157:     THEN    rc=symread(); symrqd=TRUE;
 158:     ELSE    rc=TRUE;
 159:     FI
 160:     IF --symcnt>0 ANDF rc==0 THEN errflg=BADFIL; FI
 161:     return( (symcnt>=0 && rc) ? symnxt++ : 0);
 162: }
 163: 
 164: symread()
 165: {
 166:     INT     symlen;
 167: 
 168:     IF (symlen=read(fsym,symbuf,sizeof symbuf))>=SYMTABSIZ
 169:     THEN    symnxt = symbuf;
 170:         symend = &symbuf[symlen/SYMTABSIZ];
 171:         return(TRUE);
 172:     ELSE    return(FALSE);
 173:     FI
 174: }

Defined functions

findsym defined in line 93; used 5 times
localsym defined in line 60; used 2 times
longseek defined in line 42; used 5 times
nextsym defined in line 130; used 1 times
  • in line 64
symread defined in line 164; used 2 times
symset defined in line 142; used 3 times
valpr defined in line 48; used 3 times

Defined variables

overlay defined in line 22; used 1 times
  • in line 74
symrqd defined in line 29; used 3 times
Last modified: 1982-03-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1034
Valid CSS Valid XHTML 1.0 Strict