|
|
1.1 ! root 1: static char sccsid[] = "@(#)sym.c 2.11"; ! 2: ! 3: #include "cdb.h" ! 4: ! 5: ! 6: #ifdef BSD41 ! 7: /* these are used for caching string space info */ ! 8: export int vcbSbCache; ! 9: char *vsbCache; ! 10: char *vsbSs; ! 11: export int vcbSbFirst, vissLo, vissLim, vissMax; ! 12: #define cbProcMax 20 ! 13: #define iCacheMax 1000 /* number of symbols in cache */ ! 14: ! 15: #else ! 16: ! 17: export char *vsbProcHdr; ! 18: export char *vsbLHdr; ! 19: export char *vsbLnHdr; ! 20: export char *vsbLeHdr; ! 21: #define cbProcMax 7 ! 22: #define iCacheMax 256 /* number of symbols in cache */ ! 23: #endif ! 24: ! 25: export int vcbVarHdr, vcbProcHdr, vcbLHdr, vcbLeHdr, vcbLnHdr; ! 26: ! 27: ! 28: ! 29: #ifdef SYSIII ! 30: #define cbVarHdr 1 ! 31: #define cbProcHdr 2 ! 32: #define cbLHdr 3 ! 33: #define cbLnHdr 4 ! 34: #define cbLeHdr 4 ! 35: #endif ! 36: ! 37: #ifdef BSD41 ! 38: #define cbVarHdr 0 ! 39: #define cbProcHdr 0 ! 40: #define cbLHdr 0 ! 41: #define cbLnHdr 0 ! 42: #define cbLeHdr 0 ! 43: #endif ! 44: ! 45: export long visym; /* last symbol index used */ ! 46: export long visymGlobal; /* isym of first global */ ! 47: export pSYMR vsymCur; /* the `current' symbol */ ! 48: export char *vsbCorefile, *vsbSymfile; ! 49: export int vcaseMod; /* has 0 or 040 for case sensitive search */ ! 50: export int vfnSym, vfnCore; /* the symbol file and core file numbers */ ! 51: ! 52: export long visymMax; /* number of symbols */ ! 53: export long vcbSymFirst; /* byte offset to first symbol */ ! 54: static SYMR vsymCache[iCacheMax]; /* symbol cache */ ! 55: #define cbSymCache sizeof(vsymCache) ! 56: export long visymLo, visymLim; /* min/max values for what is in cache */ ! 57: ! 58: ! 59: /* F S B C M P */ ! 60: ! 61: export FLAGT FSbCmp(sb1, sb2) ! 62: char *sb1, *sb2; ! 63: { ! 64: while ((*sb1|vcaseMod) == (*sb2|vcaseMod)) { ! 65: if (*sb1 == chNull) ! 66: return(true); ! 67: sb1++; ! 68: sb2++; ! 69: } /* while */ ! 70: #ifdef BSD42 ! 71: if ((*sb1 == chNull AND *sb2 == ':') ! 72: OR (*sb2 == chNull AND *sb1 == ':')) ! 73: return(true); ! 74: #endif ! 75: return(false); ! 76: } /* FSbCmp */ ! 77: ! 78: ! 79: /* F H D R C M P */ ! 80: ! 81: export FLAGT FHdrCmp(sbHdr, sb2) ! 82: char *sbHdr, *sb2; ! 83: { ! 84: for ( ; (*sbHdr|vcaseMod) == (*sb2|vcaseMod) ; sbHdr++, sb2++) ! 85: if (*sbHdr == chNull) ! 86: return(true); ! 87: return(*sbHdr == chNull); ! 88: } /* FHdrCmp */ ! 89: ! 90: ! 91: /* F P R O C C M P */ ! 92: ! 93: export FLAGT FProcCmp(sbProc, sbCheck) ! 94: char *sbProc, *sbCheck; ! 95: { ! 96: char *sbSave; ! 97: ! 98: /* this is ALMOST like FHdrCmp. If sbProc <= cbProcMax chars in length, ! 99: * an exact match is required, else it is like FHdrCmp. ! 100: * This allows us to have '1234567' match '1234567*' ! 101: * BUT '1234' does NOT match '12345' (or 6 or 7 or *) ! 102: */ ! 103: sbSave = sbProc; ! 104: for ( ; (*sbProc|vcaseMod)==(*sbCheck|vcaseMod); sbProc++, sbCheck++) { ! 105: if (*sbProc == chNull) ! 106: return(true); /* exact match */ ! 107: } /* for */ ! 108: #ifdef BSD42 ! 109: if ( ((*sbProc == ':') AND (*sbCheck == chNull)) ! 110: OR ((*sbProc == chNull) AND (*sbCheck == ':')) ) ! 111: return(true); ! 112: #else ! 113: if ( (*sbProc == chNull) ! 114: AND (sbProc-sbSave == cbProcMax) ) ! 115: return(true); ! 116: #endif ! 117: return(false); ! 118: } /* FProcCmp */ ! 119: ! 120: ! 121: /* S E T C A C H E */ ! 122: ! 123: local void SetCache(isym) ! 124: long isym; ! 125: { ! 126: int cRead; ! 127: long offset; ! 128: ! 129: if (isym >= visymLo AND isym < visymLim) ! 130: return; /* it is already in there, somewhere */ ! 131: offset = vcbSymFirst + (isym * cbSYMR); ! 132: if (lseek(vfnSym, offset, 0) < 0L) ! 133: Panic("Bad seek in SetCache"); ! 134: cRead = read(vfnSym, vsymCache, cbSymCache); ! 135: if (cRead < 0) ! 136: Panic("Bad read in SetCache (cRead: %d)", cRead); ! 137: visymLo = isym; ! 138: visymLim = isym + (cRead/cbSYMR); ! 139: if (visymLim > visymMax) ! 140: visymLim = visymMax; ! 141: } /* SetCache */ ! 142: ! 143: ! 144: /* S E T S Y M */ ! 145: ! 146: export void SetSym(isym) ! 147: long isym; ! 148: { ! 149: if (isym < 0 OR isym >= visymMax) ! 150: Panic("isym out of bounds in SetSym - %d", isym); ! 151: visym = isym; ! 152: SetCache(isym); ! 153: vsymCur = &(vsymCache[isym-visymLo]); ! 154: } /* SetSym */ ! 155: ! 156: ! 157: /* S E T N E X T */ ! 158: ! 159: export void SetNext(isym) ! 160: long isym; ! 161: { ! 162: if (isym < 0 OR isym >= visymMax) ! 163: Panic("isym out of bounds in SetNext - %d", isym); ! 164: visym = isym - 1; ! 165: if (visym < 0) ! 166: vsymCur = symNil; ! 167: else SetSym(visym); ! 168: } /* SetNext */ ! 169: ! 170: ! 171: /* F N E X T S Y M */ ! 172: ! 173: export FLAGT FNextSym(typHit1, typHit2, typStop, sbHit, Cmp) ! 174: int typHit1, typHit2, typStop; ! 175: char *sbHit; ! 176: FLAGT (* Cmp)(); ! 177: { ! 178: int typ, i; ! 179: long isym; ! 180: ! 181: isym = visym + 1; ! 182: while (isym < visymMax) { ! 183: SetCache(isym); ! 184: for (i=(isym-visymLo); isym<visymLim; i++, isym++) { ! 185: vsymCur = &(vsymCache[i]); ! 186: #ifdef REGULUS ! 187: typ = vsymCur->type & N_TYPE; ! 188: #else ! 189: typ = vsymCur->type & ~N_EXT; ! 190: #endif ! 191: if ( ((typ == typHit1) ! 192: OR (typ == typHit2)) ! 193: AND ((sbHit == sbNil) ! 194: OR ((*Cmp)(sbHit, SbInCore(vsymCur->sbSym)))) ) { ! 195: visym = isym; ! 196: return(true); ! 197: } ! 198: else if (typ == typStop) { ! 199: return(false); ! 200: } /* if */ ! 201: } /* for */ ! 202: } /* while */ ! 203: return(false); /* off the end of the symbol table */ ! 204: } /* FNextSym */ ! 205: ! 206: ! 207: /* I L N F I S Y M */ ! 208: ! 209: export int IlnFIsym(isym) ! 210: long isym; ! 211: { ! 212: ADRT adr; ! 213: ! 214: SetNext(isym); ! 215: #ifdef SYSIII ! 216: if (FNextSym(N_TEXT, N_ABS, N_FN, vsbLnHdr, FHdrCmp)) ! 217: return(atoi(vsymCur->sbSym+vcbLnHdr)); ! 218: #endif ! 219: #ifdef BSD41 ! 220: if (FNextSym(stLine, 0, stProc, sbNil, nil)) { ! 221: adr = vsymCur->value; ! 222: isym = visym; ! 223: /* see if there are any more lines w/ same address, take highest */ ! 224: while (FNextSym(stLine, 0, stProc, sbNil, nil)) { ! 225: if (vsymCur->value > adr) ! 226: break; ! 227: isym = visym; ! 228: } /* while */ ! 229: SetSym(isym); ! 230: return(vsymCur->desc); ! 231: } /* if */ ! 232: #endif ! 233: return(ilnNil); ! 234: } /* IlnFIsym */ ! 235: ! 236: ! 237: /* F N E X T L O C A L */ ! 238: ! 239: export FLAGT FNextLocal(fLocal, fParam, sbVar) ! 240: FLAGT fLocal, fParam; ! 241: char *sbVar; ! 242: { ! 243: int value; ! 244: long isymSave; ! 245: char *sbSym; ! 246: /* set vsymCur to point to next local (or param) and return true, ! 247: * return false if no more, leaving symbol advanced by one. ! 248: */ ! 249: ! 250: isymSave = visym; ! 251: #ifdef SYSIII ! 252: while (FNextSym(N_ABS, N_TEXT, 0, "~", FHdrCmp)) { ! 253: sbSym = SbInCore(vsymCur->sbSym); ! 254: if (sbSym[1] == '~') ! 255: break; /* it's the strart of another procedure, bail out */ ! 256: value = vsymCur->value; ! 257: if ( ((value < 0) AND (!fLocal)) ! 258: OR ((value > 0) AND (!fParam)) ) ! 259: continue; /* wrong value */ ! 260: if (sbVar != sbNil) { ! 261: if (!FProcCmp(sbSym+vcbVarHdr, sbVar)) ! 262: continue; /* wrong name */ ! 263: } ! 264: else { ! 265: /* a non-specific request */ ! 266: if (FHdrCmp(vsbLHdr, sbSym)) ! 267: continue; /* we aren't interested in line numbers */ ! 268: } /* if */ ! 269: return(true); ! 270: } /* while */ ! 271: #endif ! 272: #ifdef BSD41 ! 273: while (FNextSym(stLocal, stParam, stProc, sbNil, nil)) { ! 274: /* we have a param OR a local */ ! 275: if ( ((vsymCur->type == stParam) AND (!fParam)) ! 276: OR ((vsymCur->type == stLocal) AND (!fLocal)) ) { ! 277: if (fParam AND !fLocal) { ! 278: SetSym(isymSave+1); ! 279: return(false); /* NEVER any params after locals */ ! 280: } /* if */ ! 281: continue; ! 282: } /* if */ ! 283: sbSym = SbInCore(vsymCur->sbSym); ! 284: if ( (sbVar != sbNil) ! 285: AND (!FProcCmp(sbSym, sbVar)) ) ! 286: continue; /* wrong name */ ! 287: #ifdef BSD42 ! 288: if (FSbCmp(sbSym, "int")) ! 289: return(false); /* we ran into the next file */ ! 290: #endif ! 291: return(true); ! 292: } /* while */ ! 293: #endif ! 294: SetSym(isymSave+1); /* we failed, sigh..... */ ! 295: return(false); ! 296: } /* FNextLocal */ ! 297: ! 298: ! 299: /* A D R F E N D O F P R O C */ ! 300: ! 301: export ADRT AdrFEndOfProc(ipd) ! 302: int ipd; ! 303: { ! 304: long isym; ! 305: ! 306: SetNext(vrgPd[ipd].isym); ! 307: #ifdef SYSIII ! 308: if (FNextSym(N_TEXT, N_ABS, N_FN, vsbLeHdr, FHdrCmp)) ! 309: return(vsymCur->value); ! 310: UError("Can't find end of '%s'", vrgPd[ipd].sbProc); ! 311: #endif ! 312: #ifdef BSD41 ! 313: SetNext(vrgPd[ipd].isym+1); ! 314: FNextSym(stProc, 0, stSource, sbNil, nil); /* don't care about true/false */ ! 315: isym = visym; ! 316: /* now we back up to first stLine we can find - that should be it! */ ! 317: while (true) { ! 318: SetSym(--isym); ! 319: if (vsymCur->type == stLine) ! 320: return(vsymCur->value); ! 321: } /* while */ ! 322: #endif ! 323: } /* AdrFEndOfProc */ ! 324: ! 325: ! 326: /* A D R F I F D L N */ ! 327: ! 328: export ADRT AdrFIfdLn(ifd, iln) ! 329: int ifd, iln; ! 330: { ! 331: long isym, isymLast, ilnCur; ! 332: ADRT adr; ! 333: ! 334: SetNext(vrgFd[ifd].isym+1); /* start just AFTER the file symbol */ ! 335: ! 336: isym = isymLast = isymNil; ! 337: #ifdef SYSIII ! 338: while (FNextSym(N_TEXT, N_ABS, N_FN, vsbLnHdr, FHdrCmp)) { ! 339: if ((ilnCur=atoi(vsymCur->sbSym+vcbLnHdr)) >= iln) { ! 340: #endif ! 341: #ifdef BSD41 ! 342: while (FNextSym(stLine, 0, 0, sbNil, nil)) { ! 343: if ((ilnCur=vsymCur->desc) >= iln) { ! 344: #endif ! 345: isym = (ilnCur == iln) ? visym : isymLast; ! 346: break; ! 347: } /* if */ ! 348: isymLast = visym; ! 349: } /* while */ ! 350: ! 351: if (isym != isymNil) { ! 352: SetSym(isym); ! 353: adr = vsymCur->value; ! 354: } ! 355: else { ! 356: adr = adrNil; ! 357: } /* if */ ! 358: return(adr); ! 359: } /* AdrFIfdLn */ ! 360: ! 361: ! 362: /* I F D L N F A D R */ ! 363: ! 364: export void IfdLnFAdr(adr, isym, pifd, piln, pslop) ! 365: ADRT adr; ! 366: long isym; ! 367: int *pifd, *piln, *pslop; ! 368: { ! 369: int ifd; ! 370: long isymLast; ! 371: ! 372: *pifd = ifd = IfdFAdr(adr); ! 373: if (ifd == vifdNil) ! 374: return; ! 375: ! 376: /* we now have the file, try to get the line number */ ! 377: if (isym == 0) ! 378: isym = vrgFd[ifd].isym+1; /* start just AFTER the file symbol */ ! 379: SetNext(isym); ! 380: ! 381: isym = isymNil; ! 382: isymLast = isymNil; ! 383: #ifndef BSD41 ! 384: while (FNextSym(N_TEXT, N_ABS, N_FN, vsbLnHdr, FHdrCmp)) { ! 385: if ((vsymCur->value) >= adr) { ! 386: isym = (vsymCur->value == adr) ? visym : isymLast; ! 387: break; ! 388: } /* if */ ! 389: isymLast = visym; ! 390: } /* while */ ! 391: #else ! 392: /* we want the HIGHEST line number that applies to a given address */ ! 393: while (FNextSym(stLine, 0, stSource, sbNil, nil)) { ! 394: if ((vsymCur->value) >= adr) { ! 395: if ((vsymCur->value > adr) ! 396: AND (isym != isymNil)) ! 397: break; ! 398: isym = (vsymCur->value == adr) ? visym : isymLast; ! 399: } /* if */ ! 400: isymLast = visym; ! 401: } /* while */ ! 402: #endif ! 403: ! 404: *pslop = -1; ! 405: if (isym != isymNil) { ! 406: SetSym(isym); ! 407: #ifdef BSD41 ! 408: *piln = vsymCur->desc; ! 409: #else ! 410: *piln = atoi(vsymCur->sbSym+vcbLnHdr); ! 411: #endif ! 412: *pslop = adr - vsymCur->value; ! 413: } ! 414: else { ! 415: *piln = ilnNil; ! 416: } /* if */ ! 417: } /* IfdLnFAdr */ ! 418: ! 419: ! 420: #ifdef BSD41 ! 421: /* I N I T S S */ ! 422: ! 423: export void InitSs() ! 424: { ! 425: if (vcbSbCache == 0) { ! 426: /* we will read the whole thing in. This means that we ! 427: * aren't really using the cacheing mechanism, but we ! 428: * leave it for compatibility with systems where we can't ! 429: * get away with this. ! 430: */ ! 431: vcbSbCache = vissMax; ! 432: } /* if */ ! 433: vsbCache = malloc(vcbSbCache); ! 434: SetIss(0); /* force read first section */ ! 435: } /* InitSs */ ! 436: ! 437: ! 438: /* S B I N C O R E */ ! 439: ! 440: /* neither export NOR local - it is a macro for NON-BSD systems */ ! 441: char * SbInCore(sb) ! 442: char *sb; ! 443: { ! 444: long iss; ! 445: ! 446: iss = (long) sb; ! 447: if (iss == -1) ! 448: return(sbNil); ! 449: if (iss & bitHigh) ! 450: return((char *)(iss & ~bitHigh)); /* a cdb string */ ! 451: /* an a.out string */ ! 452: SetIss(iss); ! 453: return(vsbSs); ! 454: } /* SbInCore */ ! 455: ! 456: ! 457: /* S E T I S S */ ! 458: ! 459: export void SetIss(iss) ! 460: int iss; ! 461: { ! 462: long ret, offset, cRead, issSave; ! 463: char *sbTest; ! 464: ! 465: /* printf("SetIss entered with iss=%d\n",iss); */ ! 466: if (iss < 0 OR iss >= vissMax) ! 467: Panic("Iss out of bounds"); ! 468: if (iss >= vissLo AND iss < vissLim) { ! 469: /* make sure the WHOLE string is in the cache */ ! 470: issSave = iss; ! 471: sbTest = vsbCache + (iss - vissLo); ! 472: while ((iss < vissLim) AND (*sbTest != chNull)) { ! 473: sbTest++; ! 474: iss++; ! 475: } /* while */ ! 476: iss = issSave; ! 477: if (*sbTest == chNull) { ! 478: vsbSs = vsbCache + (iss - vissLo); ! 479: return; ! 480: } ! 481: } /* if */ ! 482: ! 483: /* not in (or not ALL in) the cache - make it the first thing */ ! 484: offset = vcbSbFirst + iss; ! 485: /* printf("Seeking in symbols file at offset %d\n", offset); */ ! 486: if ((ret=lseek(vfnSym, offset, 0)) < 0L) ! 487: Panic("Bad seek in SetIss"); ! 488: cRead = read(vfnSym, vsbCache, vcbSbCache); ! 489: if (cRead < 0) ! 490: Panic("Bad read in SetIss (cRead: %d)", cRead); ! 491: vissLo = iss; ! 492: vissLim = iss + cRead; ! 493: vsbSs = vsbCache + (iss - vissLo); ! 494: } /* SetIss */ ! 495: #endif ! 496: ! 497: ! 498: /* I N I T F D P D */ ! 499: ! 500: export void InitFdPd() ! 501: { ! 502: short ipd, i; ! 503: FLAGT fGotit, fStop; ! 504: ADRT adr; ! 505: char *sbTemp, *sbDot; ! 506: char sbWorking[cbVarMax+5]; /* used for non-bsd41 stuff */ ! 507: pFDR fd; ! 508: pPDR pd; ! 509: ! 510: #ifdef SYSIII ! 511: /* set up line number names */ ! 512: vsbLHdr = "~_l"; ! 513: vsbLnHdr = "~_lN"; ! 514: vsbLeHdr = "~_lE"; ! 515: vsbProcHdr = "~~"; ! 516: vityMac = 0; ! 517: #endif ! 518: vcbVarHdr = cbVarHdr; ! 519: vcbProcHdr = cbProcHdr; ! 520: vcbLHdr = cbLHdr; ! 521: vcbLeHdr = cbLeHdr; ! 522: vcbLnHdr = cbLnHdr; ! 523: ! 524: visymLo = 0; ! 525: visymLim = -1; ! 526: ! 527: /* first we have to see how big file and proc arrays should be */ ! 528: vifdMac = 0; ! 529: vipdMac = 0; ! 530: SetNext(isym0); ! 531: fStop = false; /* goes true when we are processing 'end.o' */ ! 532: #ifdef SYSIII ! 533: while (FNextSym(N_FN, N_TEXT, 0, sbNil, nil)) { ! 534: if (vsymCur->type == N_FN) { ! 535: if (fStop) ! 536: break; ! 537: ++vifdMac; ! 538: } ! 539: else if (FHdrCmp(vsbProcHdr, SbInCore(vsymCur->sbSym))) { ! 540: ++vipdMac; ! 541: if (FSbCmp(SbInCore(vsymCur->sbSym+vcbProcHdr), "_end_")) ! 542: fStop = true; /* will stop on next file symbol */ ! 543: } /* if */ ! 544: } /* while */ ! 545: #ifndef REGULUS ! 546: vifdMac -= 1; /* ignore crt0.o */ ! 547: #endif ! 548: #endif ! 549: #ifdef BSD41 ! 550: while (FNextSym(stSource, stProc, 0, sbNil, nil)) { ! 551: if (vsymCur->type == stSource) { ! 552: /* a file {ning */ ! 553: if (fStop) ! 554: break; ! 555: ++vifdMac; ! 556: } ! 557: else { ! 558: /* a procedure */ ! 559: ++vipdMac; ! 560: if (FSbCmp(SbInCore(vsymCur->sbSym), "_end_")) ! 561: fStop = true; /* will stop on next file symbol */ ! 562: } /* if */ ! 563: } /* while */ ! 564: #endif ! 565: if (vipdMac == 0) ! 566: UError("It appears that NO files have debugging information"); ! 567: if (!fStop) ! 568: printf("WARNING! 'end.o' was not loaded with this program\n"); ! 569: vifdTemp = vifdMac++; ! 570: vifd = vifdNil = vifdMac++; ! 571: vrgFd = (pFDR) malloc(vifdMac * cbFDR); /* allocate the arrays */ ! 572: vcbTot += vifdMac * cbFDR; ! 573: vrgPd = (pPDR) malloc(vipdMac * cbPDR); ! 574: vcbTot += vipdMac * cbPDR; ! 575: ! 576: /* we scan through again, filling the arrays */ ! 577: fd = vrgFd; ! 578: pd = vrgPd; ! 579: ipd = 0; ! 580: SetNext(isym0); ! 581: fStop = false; ! 582: #ifdef SYSIII ! 583: while (FNextSym(N_FN, N_TEXT, 0, sbNil, nil)) { ! 584: if (vsymCur->type == N_FN) { ! 585: #ifndef REGULUS ! 586: if (FSbCmp(vsymCur->sbSym, "crt0.o")) ! 587: continue; ! 588: #endif ! 589: #endif ! 590: #ifdef BSD41 ! 591: while (FNextSym(stSource, stProc, 0, sbNil, nil)) { ! 592: if (vsymCur->type == stSource) { ! 593: #endif ! 594: if (fStop) ! 595: break; /* we have finished processing end.c */ ! 596: fd->adrStart = vsymCur->value; ! 597: fd->isym = visym; ! 598: fd->ipd = ipd; ! 599: fd->ilnMac = ilnNil; ! 600: fd->rgLn = (uint *) 0; ! 601: fd->fHasDecl = true; /* will go false if none - IfdFOpen */ ! 602: fd->fWarned = false; ! 603: #ifdef SYSIII ! 604: sbTemp = sbWorking; ! 605: strncpy(sbTemp, vsymCur->sbSym, cbVarMax); ! 606: sbTemp[cbVarMax] = chNull; /* make sure we have a clean buffer */ ! 607: sbDot = strrchr(sbTemp, '.'); /* find last period */ ! 608: if (sbDot != nil) { ! 609: sbDot[1] = 'c'; /* somewhat presumptuous, but I write in C */ ! 610: sbDot[2] = 0; ! 611: } ! 612: else { ! 613: /* this will help if name is `01234567' and lost the `.c' */ ! 614: sbTemp[cbVarMax] = '.'; ! 615: sbTemp[cbVarMax+1] = 'c'; ! 616: sbTemp[cbVarMax+2] = 0; ! 617: } /* if */ ! 618: fd->sbFile = malloc(cbVarMax+5); ! 619: vcbTot += cbVarMax + 5; ! 620: #endif ! 621: #ifdef BSD41 ! 622: #ifdef BSD42 ! 623: sbTemp = SbInCore(SbSafe(SbInCore(vsymCur->sbSym))); ! 624: #else ! 625: sbTemp = SbInCore(vsymCur->sbSym); ! 626: #endif ! 627: fd->sbFile = malloc(strlen(sbTemp)+2); ! 628: #endif ! 629: strcpy(fd->sbFile, sbTemp); ! 630: fd++; ! 631: #ifdef SYSIII ! 632: } ! 633: else if (FHdrCmp(vsbProcHdr, vsymCur->sbSym)) { ! 634: #endif ! 635: #ifdef BSD41 ! 636: } ! 637: else { ! 638: #endif ! 639: adr = vsymCur->value; ! 640: pd->adrStart = adr; ! 641: pd->isym = visym; ! 642: #ifdef SYSIII ! 643: sbTemp = sbWorking; ! 644: /* given ~~foo, copy ~foo */ ! 645: strncpy(sbTemp, vsymCur->sbSym+1, cbVarMax-1); ! 646: /* make it _foo */ ! 647: sbTemp[0] = '_'; ! 648: sbTemp[7] = chNull; ! 649: pd->sbProc = malloc(cbVarMax+2); ! 650: vcbTot += cbVarMax + 2; ! 651: #endif ! 652: #ifdef BSD41 ! 653: #ifdef BSD42 ! 654: sbTemp = SbInCore(SbSafe(SbInCore(vsymCur->sbSym))); ! 655: #else ! 656: sbTemp = SbInCore(vsymCur->sbSym); ! 657: #endif ! 658: pd->sbProc = malloc(strlen(sbTemp)+2); ! 659: #endif ! 660: strcpy(pd->sbProc, sbTemp); ! 661: pd++; ! 662: ipd++; ! 663: #ifdef BSD41 ! 664: if (FSbCmp(sbTemp, "_end_")) { ! 665: fStop = true; /* causes us to stop on next file symbol */ ! 666: } ! 667: #else ! 668: if (FSbCmp(sbTemp, "__end_")) ! 669: fStop = true; /* causes us to stop on next file symbol */ ! 670: #endif ! 671: } /* if */ ! 672: } /* while */ ! 673: visymGlobal = visym; ! 674: vipd = ipdNil; ! 675: printf("%d source files, %d procedures\n", vifdMac-2, vipdMac); ! 676: ! 677: fd = vrgFd + vifdTemp; ! 678: fd->adrStart = 0; /* we use vifdTemp for `other' files */ ! 679: fd->sbFile = sbNil; ! 680: fd->fHasDecl = false; ! 681: fd->fWarned = true; /* we assume warning here isn't important */ ! 682: fd->isym = isym0; ! 683: fd->ipd = ipdNil; ! 684: fd->ilnMac = ilnNil; ! 685: fd->rgLn = (uint *) 0; ! 686: ! 687: fd = vrgFd + vifdNil; /* we use vifdNil as a `catchall' */ ! 688: fd->adrStart = 0; ! 689: fd->sbFile = "no src file"; ! 690: fd->fHasDecl = false; ! 691: fd->fWarned = true; ! 692: fd->isym = isym0; ! 693: fd->ipd = ipdNil; ! 694: fd->ilnMac = ilnNil; ! 695: fd->rgLn = (uint *) 0; ! 696: ! 697: #ifdef SYSIII ! 698: /* the following gives us one more char in procedure name, if it's there */ ! 699: SetNext(visymGlobal); ! 700: for (i=0; i<vipdMac; i++) { ! 701: fGotit = false; ! 702: while (FNextSym(N_TEXT, 0, 0, vrgPd[i].sbProc, FProcCmp)) { ! 703: if (vsymCur->value == vrgPd[i].adrStart) { ! 704: fGotit = true; ! 705: break; ! 706: } /* if */ ! 707: } /* while */ ! 708: if (!fGotit) { ! 709: /* try it from the top of globals again */ ! 710: SetNext(visymGlobal); ! 711: while (FNextSym(N_TEXT, 0, 0, vrgPd[i].sbProc, FProcCmp)) { ! 712: if (vsymCur->value == vrgPd[i].adrStart) { ! 713: fGotit = true; ! 714: break; ! 715: } /* if */ ! 716: } /* while */ ! 717: } /* if */ ! 718: if (!fGotit) { ! 719: /* Can't find it, I hope it is a static, else oooops! */ ! 720: strncpy(vrgPd[i].sbProc, vrgPd[i].sbProc+1, 6); ! 721: vrgPd[i].sbProc[6] = 0; ! 722: } ! 723: else { ! 724: /* we found _foo, copy foo into name area */ ! 725: strncpy(vrgPd[i].sbProc, vsymCur->sbSym+1, 7); ! 726: vrgPd[i].sbProc[7] = 0; ! 727: } /* if */ ! 728: } /* for */ ! 729: #endif ! 730: } /* InitFdPd */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.