|
|
1.1 ! root 1: #ifndef lint ! 2: static char *sccsid ="@(#)stab.c 1.9 (Berkeley) 8/11/83"; ! 3: #endif ! 4: /* ! 5: * Symbolic debugging info interface. ! 6: * ! 7: * Here we generate pseudo-ops that cause the assembler to put ! 8: * symbolic debugging information into the object file. ! 9: */ ! 10: ! 11: #include "mfile1" ! 12: ! 13: #include <sys/types.h> ! 14: #include <a.out.h> ! 15: #include <stab.h> ! 16: ! 17: #define private static ! 18: #define and && ! 19: #define or || ! 20: #define not ! ! 21: #define div / ! 22: #define mod % ! 23: #define nil 0 ! 24: ! 25: #define bytes(bits) ((bits) / SZCHAR) ! 26: #define bsize(p) bytes(dimtab[p->sizoff]) /* size in bytes of a symbol */ ! 27: ! 28: #define NILINDEX -1 ! 29: #define FORWARD -2 ! 30: ! 31: typedef int Boolean; ! 32: ! 33: #define false 0 ! 34: #define true 1 ! 35: ! 36: extern int ddebug; ! 37: extern int gdebug; ! 38: extern char *malloc(); ! 39: ! 40: int stabLCSYM; ! 41: ! 42: /* ! 43: * Flag for producing either sdb or dbx symbol information. ! 44: */ ! 45: int oldway = false; ! 46: ! 47: /* ! 48: * Generate debugging info for a parameter. ! 49: * The offset isn't known when it is first entered into the symbol table ! 50: * since the types are read later. ! 51: */ ! 52: ! 53: fixarg(p) ! 54: struct symtab *p; ! 55: { ! 56: if (oldway) { ! 57: old_fixarg(p); ! 58: } else if (gdebug) { ! 59: printf("\t.stabs\t\"%s:p", p->sname); ! 60: gentype(p); ! 61: printf("\",0x%x,0,%d,%d\n", N_PSYM, bsize(p), bytes(argoff)); ! 62: } ! 63: } ! 64: ! 65: /* ! 66: * Determine if the given symbol is a global array with dimension 0, ! 67: * which only makes sense if it's dimension is to be given later. ! 68: * We therefore currently do not generate symbol information for ! 69: * such entries. ! 70: */ ! 71: ! 72: #define isglobal(class) ( \ ! 73: class == EXTDEF or class == EXTERN or class == STATIC \ ! 74: ) ! 75: ! 76: private Boolean zero_length_array(p) ! 77: register struct symtab *p; ! 78: { ! 79: Boolean b; ! 80: int t; ! 81: ! 82: if (not isglobal(p->sclass)) { ! 83: b = false; ! 84: } else { ! 85: t = p->stype; ! 86: if (ISFTN(t)) { ! 87: t = DECREF(t); ! 88: } ! 89: b = (Boolean) (ISARY(t) and dimtab[p->dimoff] == 0); ! 90: } ! 91: return b; ! 92: } ! 93: ! 94: /* ! 95: * Generate debugging info for a given symbol. ! 96: */ ! 97: ! 98: outstab(sym) ! 99: struct symtab *sym; ! 100: { ! 101: register struct symtab *p; ! 102: char *classname; ! 103: int offset; ! 104: Boolean ignore; ! 105: static Boolean firsttime = true; ! 106: ! 107: if (oldway) { ! 108: old_outstab(sym); ! 109: } else if (gdebug and not zero_length_array(sym)) { ! 110: if (firsttime) { ! 111: firsttime = false; ! 112: inittypes(); ! 113: } ! 114: ignore = false; ! 115: p = sym; ! 116: offset = bytes(p->offset); ! 117: switch (p->sclass) { ! 118: case REGISTER: ! 119: classname = "r"; ! 120: offset = p->offset; ! 121: break; ! 122: ! 123: /* ! 124: * Locals are the default class. ! 125: */ ! 126: case AUTO: ! 127: classname = ""; ! 128: break; ! 129: ! 130: case STATIC: ! 131: if (ISFTN(p->stype)) { ! 132: ignore = true; ! 133: } else if (p->slevel <= 1) { ! 134: classname = "S"; ! 135: } else { ! 136: classname = "V"; ! 137: } ! 138: break; ! 139: ! 140: case EXTDEF: ! 141: case EXTERN: ! 142: if (ISFTN(p->stype)) { ! 143: ignore = true; ! 144: } else { ! 145: classname = "G"; ! 146: } ! 147: break; ! 148: ! 149: case TYPEDEF: ! 150: classname = "t"; ! 151: break; ! 152: ! 153: case PARAM: ! 154: case MOS: ! 155: case MOU: ! 156: case MOE: ! 157: ignore = true; ! 158: break; ! 159: ! 160: case ENAME: ! 161: case UNAME: ! 162: case STNAME: ! 163: entertype(p->stype, NILINDEX, FORWARD, dimtab[p->sizoff + 3]); ! 164: ignore = true; ! 165: break; ! 166: ! 167: default: ! 168: if ((p->sclass&FIELD) == 0) { ! 169: printf("/* no info for %s (%d) */\n", p->sname, p->sclass); ! 170: } ! 171: ignore = true; ! 172: break; ! 173: } ! 174: if (not ignore) { ! 175: printf("\t.stabs\t\"%s:%s", p->sname, classname); ! 176: gentype(p); ! 177: geninfo(p); ! 178: } ! 179: } ! 180: } ! 181: ! 182: /* ! 183: * Since type names are lost in the travels and because C has ! 184: * structural type equivalence we keep a table of type words that ! 185: * we've already seen. The first time we see a type, it is assigned ! 186: * (inline) a number and future references just list that number. ! 187: * Structures, unions, enums, and arrays must be handled carefully ! 188: * since not all the necessary information is in the type word. ! 189: */ ! 190: ! 191: typedef struct Typeid *Typeid; ! 192: ! 193: struct Typeid { ! 194: TWORD tword; ! 195: int tarray; ! 196: int tstruct; ! 197: int tstrtag; ! 198: int tnum; ! 199: Typeid chain; ! 200: }; ! 201: ! 202: #define TABLESIZE 2003 ! 203: ! 204: private int tcount = 1; ! 205: private int t_int, t_char; ! 206: private Typeid typetable[TABLESIZE]; ! 207: ! 208: /* ! 209: * Look for the given type word in the type table. ! 210: */ ! 211: ! 212: private Typeid typelookup(type, arrindex, strindex, strtag) ! 213: TWORD type; ! 214: int arrindex; ! 215: int strindex; ! 216: int strtag; ! 217: { ! 218: register TWORD tword; ! 219: register int i1, i2; ! 220: Typeid t; ! 221: ! 222: t = typetable[type mod TABLESIZE]; ! 223: while (t != nil) { ! 224: if (t->tword == type and ! 225: strindex == t->tstruct and strtag == t->tstrtag) { ! 226: if (arrindex == NILINDEX) { ! 227: break; ! 228: } else { ! 229: tword = type; ! 230: i1 = arrindex; ! 231: i2 = t->tarray; ! 232: while (ISARY(tword) and dimtab[i1] == dimtab[i2]) { ! 233: ++i1; ! 234: ++i2; ! 235: tword >>= TSHIFT; ! 236: } ! 237: if (!ISARY(tword)) { ! 238: break; ! 239: } ! 240: } ! 241: } ! 242: t = t->chain; ! 243: } ! 244: return t; ! 245: } ! 246: ! 247: /* ! 248: * Enter a type word and associated symtab indices into the type table. ! 249: */ ! 250: ! 251: private int entertype(type, arrindex, strindex, strtag) ! 252: TWORD type; ! 253: int arrindex; ! 254: int strindex; ! 255: int strtag; ! 256: { ! 257: register Typeid t; ! 258: register int i; ! 259: ! 260: t = (Typeid) malloc(sizeof(struct Typeid)); ! 261: t->tword = type; ! 262: t->tarray = arrindex; ! 263: t->tstruct = strindex; ! 264: t->tstrtag = strtag; ! 265: t->tnum = tcount; ! 266: ++tcount; ! 267: i = type mod TABLESIZE; ! 268: t->chain = typetable[i]; ! 269: typetable[i] = t; ! 270: return t->tnum; ! 271: } ! 272: ! 273: /* ! 274: * Change the information associated with a type table entry. ! 275: * Since I'm lazy this just creates a new entry with the number ! 276: * as the old one. ! 277: */ ! 278: ! 279: private reentertype(typeid, type, arrindex, strindex, strtag) ! 280: Typeid typeid; ! 281: TWORD type; ! 282: int arrindex; ! 283: int strindex; ! 284: int strtag; ! 285: { ! 286: register Typeid t; ! 287: register int i; ! 288: ! 289: t = (Typeid) malloc(sizeof(struct Typeid)); ! 290: t->tword = type; ! 291: t->tarray = arrindex; ! 292: t->tstruct = strindex; ! 293: t->tstrtag = strtag; ! 294: t->tnum = typeid->tnum; ! 295: i = type mod TABLESIZE; ! 296: t->chain = typetable[i]; ! 297: typetable[i] = t; ! 298: } ! 299: ! 300: /* ! 301: * Initialize type table with predefined types. ! 302: */ ! 303: ! 304: #define builtintype(type) entertype(type, NILINDEX, NILINDEX, NILINDEX) ! 305: ! 306: private inittypes() ! 307: { ! 308: int t; ! 309: ! 310: t_int = builtintype(INT); ! 311: t_char = builtintype(CHAR); ! 312: maketype("int", t_int, t_int, 0x80000000L, 0x7fffffffL); ! 313: maketype("char", t_char, t_char, 0L, 127L); ! 314: maketype("long", builtintype(LONG), t_int, 0x80000000L, 0x7fffffffL); ! 315: maketype("short", builtintype(SHORT), t_int, 0xffff8000L, 0x7fffL); ! 316: maketype("unsigned char", builtintype(UCHAR), t_int, 0L, 255L); ! 317: maketype("unsigned short", builtintype(USHORT), t_int, 0L, 0xffffL); ! 318: maketype("unsigned long", builtintype(ULONG), t_int, 0L, 0xffffffffL); ! 319: maketype("unsigned int", builtintype(UNSIGNED), t_int, 0L, 0xffffffffL); ! 320: maketype("float", builtintype(FLOAT), t_int, 4L, 0L); ! 321: maketype("double", builtintype(DOUBLE), t_int, 8L, 0L); ! 322: t = builtintype(UNDEF); ! 323: printf("\t.stabs\t\"void:t%d=%d", t, t); ! 324: geninfo(nil); ! 325: t = builtintype(FARG); ! 326: printf("\t.stabs\t\"???:t%d=%d", t, t_int); ! 327: geninfo(nil); ! 328: } ! 329: ! 330: /* ! 331: * Generate info for a new range type. ! 332: */ ! 333: ! 334: private maketype(name, tnum, eqtnum, lower, upper) ! 335: char *name; ! 336: int tnum, eqtnum; ! 337: long lower, upper; ! 338: { ! 339: printf("\t.stabs\t\"%s:t%d=r%d;%d;%d;", name, tnum, eqtnum, lower, upper); ! 340: geninfo(nil); ! 341: } ! 342: ! 343: /* ! 344: * Generate debugging information for the given type of the given symbol. ! 345: */ ! 346: ! 347: private gentype(sym) ! 348: struct symtab *sym; ! 349: { ! 350: register struct symtab *p; ! 351: register TWORD t; ! 352: register TWORD basictype; ! 353: register Typeid typeid; ! 354: int i, arrindex, strindex, strtag; ! 355: ! 356: p = sym; ! 357: t = p->stype; ! 358: if (ISFTN(t)) { ! 359: t = DECREF(t); ! 360: } ! 361: basictype = BTYPE(t); ! 362: if (ISARY(t)) { ! 363: arrindex = p->dimoff; ! 364: } else { ! 365: arrindex = NILINDEX; ! 366: } ! 367: if (basictype == STRTY or basictype == UNIONTY or basictype == ENUMTY) { ! 368: strindex = dimtab[p->sizoff + 1]; ! 369: if (strindex == -1) { ! 370: strindex = FORWARD; ! 371: strtag = dimtab[p->sizoff + 3]; ! 372: } else { ! 373: strtag = NILINDEX; ! 374: } ! 375: } else { ! 376: strindex = NILINDEX; ! 377: strtag = NILINDEX; ! 378: } ! 379: i = arrindex; ! 380: typeid = typelookup(t, arrindex, strindex, strtag); ! 381: while (t != basictype and typeid == nil) { ! 382: printf("%d=", entertype(t, i, strindex, strtag)); ! 383: switch (t&TMASK) { ! 384: case PTR: ! 385: printf("*"); ! 386: break; ! 387: ! 388: case FTN: ! 389: printf("f"); ! 390: break; ! 391: ! 392: case ARY: ! 393: printf("ar%d;0;%d;", t_int, dimtab[i++] - 1); ! 394: break; ! 395: } ! 396: t = DECREF(t); ! 397: if (t == basictype) { ! 398: typeid = typelookup(t, NILINDEX, strindex, strtag); ! 399: } else { ! 400: typeid = typelookup(t, i, strindex, strtag); ! 401: } ! 402: } ! 403: if (typeid == nil) { ! 404: if (strindex == FORWARD) { ! 405: typeid = typelookup(t, NILINDEX, FORWARD, dimtab[p->sizoff + 3]); ! 406: if (typeid == nil) { ! 407: cerror("unbelievable forward reference"); ! 408: } ! 409: printf("%d", typeid->tnum); ! 410: } else { ! 411: genstruct(t, NILINDEX, strindex, p->sname, bsize(p)); ! 412: } ! 413: } else { ! 414: printf("%d", typeid->tnum); ! 415: } ! 416: } ! 417: ! 418: /* ! 419: * Generate type information for structures, unions, and enumerations. ! 420: */ ! 421: ! 422: private genstruct(t, structid, index, name, size) ! 423: TWORD t; ! 424: int structid; ! 425: int index; ! 426: char *name; ! 427: int size; ! 428: { ! 429: register int i; ! 430: register struct symtab *field; ! 431: int id; ! 432: ! 433: if (structid == NILINDEX) { ! 434: id = entertype(t, NILINDEX, index, NILINDEX); ! 435: } else { ! 436: id = structid; ! 437: } ! 438: switch (t) { ! 439: case STRTY: ! 440: case UNIONTY: ! 441: printf("%d=%c%d", id, t == STRTY ? 's' : 'u', size); ! 442: i = index; ! 443: while (dimtab[i] != -1) { ! 444: field = &stab[dimtab[i]]; ! 445: printf("%s:", field->sname); ! 446: gentype(field); ! 447: if (field->sclass > FIELD) { ! 448: printf(",%d,%d;", field->offset, field->sclass - FIELD); ! 449: } else { ! 450: printf(",%d,%d;", field->offset, ! 451: tsize(field->stype, field->dimoff, field->sizoff)); ! 452: } ! 453: ++i; ! 454: } ! 455: putchar(';'); ! 456: break; ! 457: ! 458: case ENUMTY: ! 459: printf("%d=e", id); ! 460: i = index; ! 461: while (dimtab[i] != -1) { ! 462: field = &stab[dimtab[i]]; ! 463: printf("%s:%d,", field->sname, field->offset); ! 464: i++; ! 465: } ! 466: break; ! 467: ! 468: default: ! 469: cerror("couldn't find basic type %d for %s\n", t, name); ! 470: break; ! 471: } ! 472: } ! 473: ! 474: /* ! 475: * Generate offset and size info. ! 476: */ ! 477: ! 478: private geninfo(p) ! 479: register struct symtab *p; ! 480: { ! 481: int stabtype; ! 482: ! 483: if (p == nil) { ! 484: printf("\",0x%x,0,0,0\n", N_LSYM); ! 485: } else { ! 486: switch (p->sclass) { ! 487: case EXTERN: ! 488: case EXTDEF: ! 489: if (ISFTN(p->stype)) { ! 490: printf("\",0x%x,0,%d,_%s\n", N_FUN, bsize(p), p->sname); ! 491: } else { ! 492: printf("\",0x%x,0,%d,0\n", N_GSYM, bsize(p)); ! 493: } ! 494: break; ! 495: ! 496: case STATIC: ! 497: stabtype = stabLCSYM ? N_LCSYM : N_STSYM; ! 498: if (ISFTN(p->stype)) { ! 499: printf("\",0x%x,0,%d,_%s\n", N_FUN, bsize(p), p->sname); ! 500: } else if (p->slevel > 1) { ! 501: printf("\",0x%x,0,%d,L%d\n", stabtype, bsize(p), p->offset); ! 502: } else { ! 503: printf("\",0x%x,0,%d,_%s\n", stabtype, bsize(p), p->sname); ! 504: } ! 505: break; ! 506: ! 507: case REGISTER: ! 508: printf("\",0x%x,0,%d,%d\n", N_RSYM, bsize(p), p->offset); ! 509: break; ! 510: ! 511: case PARAM: ! 512: printf("\",0x%x,0,%d,%d\n", N_PSYM, bsize(p), bytes(argoff)); ! 513: break; ! 514: ! 515: default: ! 516: printf("\",0x%x,0,%d,%d\n", N_LSYM, bsize(p), bytes(p->offset)); ! 517: break; ! 518: } ! 519: } ! 520: } ! 521: ! 522: /* ! 523: * Generate information for a newly-defined structure. ! 524: */ ! 525: ! 526: outstruct(szindex, paramindex) ! 527: int szindex, paramindex; ! 528: { ! 529: register Typeid typeid; ! 530: register struct symtab *p; ! 531: register int i, t, strindex; ! 532: ! 533: if (oldway) { ! 534: /* do nothing */; ! 535: } else if (gdebug) { ! 536: i = dimtab[szindex + 3]; ! 537: p = &stab[i]; ! 538: if (p->sname != nil) { ! 539: strindex = dimtab[p->sizoff + 1]; ! 540: typeid = typelookup(p->stype, NILINDEX, FORWARD, i); ! 541: if (typeid == nil) { ! 542: t = 0; ! 543: } else { ! 544: t = typeid->tnum; ! 545: reentertype(typeid, p->stype, NILINDEX, strindex, NILINDEX); ! 546: } ! 547: printf("\t.stabs\t\"%s:T", p->sname); ! 548: genstruct(p->stype, t, strindex, p->sname, bsize(p)); ! 549: geninfo(p); ! 550: } ! 551: } ! 552: } ! 553: ! 554: pstab(name, type) ! 555: char *name; ! 556: int type; ! 557: { ! 558: register int i; ! 559: register char c; ! 560: ! 561: if (!gdebug) { ! 562: return; ! 563: } else if (oldway) { ! 564: old_pstab(name, type); ! 565: return; ! 566: } ! 567: /* locctr(PROG); /* .stabs must appear in .text for c2 */ ! 568: #ifdef ASSTRINGS ! 569: if ( name[0] == '\0') ! 570: printf("\t.stabn\t"); ! 571: else ! 572: #ifndef FLEXNAMES ! 573: printf("\t.stabs\t\"%.8s\",", name); ! 574: #else ! 575: printf("\t.stabs\t\"%s\",", name); ! 576: #endif ! 577: #else ! 578: printf(" .stab "); ! 579: for(i=0; i<8; i++) ! 580: if (c = name[i]) printf("'%c,", c); ! 581: else printf("0,"); ! 582: #endif ! 583: printf("0%o,", type); ! 584: } ! 585: ! 586: #ifdef STABDOT ! 587: pstabdot(type, value) ! 588: int type; ! 589: int value; ! 590: { ! 591: if ( ! gdebug) { ! 592: return; ! 593: } else if (oldway) { ! 594: old_pstabdot(type, value); ! 595: return; ! 596: } ! 597: /* locctr(PROG); /* .stabs must appear in .text for c2 */ ! 598: printf("\t.stabd\t"); ! 599: printf("0%o,0,0%o\n",type, value); ! 600: } ! 601: #endif ! 602: ! 603: extern char NULLNAME[8]; ! 604: extern int labelno; ! 605: extern int fdefflag; ! 606: ! 607: psline() ! 608: { ! 609: static int lastlineno; ! 610: register char *cp, *cq; ! 611: register int i; ! 612: ! 613: if (!gdebug) { ! 614: return; ! 615: } else if (oldway) { ! 616: old_psline(); ! 617: return; ! 618: } ! 619: ! 620: cq = ititle; ! 621: cp = ftitle; ! 622: ! 623: while ( *cq ) if ( *cp++ != *cq++ ) goto neq; ! 624: if ( *cp == '\0' ) goto eq; ! 625: ! 626: neq: for (i=0; i<100; i++) ! 627: ititle[i] = '\0'; ! 628: cp = ftitle; ! 629: cq = ititle; ! 630: while ( *cp ) ! 631: *cq++ = *cp++; ! 632: *cq = '\0'; ! 633: *--cq = '\0'; ! 634: #ifndef FLEXNAMES ! 635: for ( cp = ititle+1; *(cp-1); cp += 8 ) { ! 636: pstab(cp, N_SOL); ! 637: if (gdebug) printf("0,0,LL%d\n", labelno); ! 638: } ! 639: #else ! 640: pstab(ititle+1, N_SOL); ! 641: if (gdebug) printf("0,0,LL%d\n", labelno); ! 642: #endif ! 643: *cq = '"'; ! 644: printf("LL%d:\n", labelno++); ! 645: ! 646: eq: if (lineno == lastlineno) return; ! 647: lastlineno = lineno; ! 648: ! 649: if (fdefflag) { ! 650: #ifdef STABDOT ! 651: pstabdot(N_SLINE, lineno); ! 652: #else ! 653: pstab(NULLNAME, N_SLINE); ! 654: printf("0,%d,LL%d\n", lineno, labelno); ! 655: printf("LL%d:\n", labelno++); ! 656: #endif ! 657: } ! 658: } ! 659: ! 660: plcstab(level) ! 661: int level; ! 662: { ! 663: if (!gdebug) { ! 664: return; ! 665: } else if (oldway) { ! 666: old_plcstab(level); ! 667: return; ! 668: } ! 669: #ifdef STABDOT ! 670: pstabdot(N_LBRAC, level); ! 671: #else ! 672: pstab(NULLNAME, N_LBRAC); ! 673: printf("0,%d,LL%d\n", level, labelno); ! 674: printf("LL%d:\n", labelno++); ! 675: #endif ! 676: } ! 677: ! 678: prcstab(level) ! 679: int level; ! 680: { ! 681: if (!gdebug) { ! 682: return; ! 683: } else if (oldway) { ! 684: old_prcstab(level); ! 685: return; ! 686: } ! 687: #ifdef STABDOT ! 688: pstabdot(N_RBRAC, level); ! 689: #else ! 690: pstab(NULLNAME, N_RBRAC); ! 691: printf("0,%d,LL%d\n", level, labelno); ! 692: printf("LL%d:\n", labelno++); ! 693: #endif ! 694: } ! 695: ! 696: pfstab(sname) ! 697: char *sname; ! 698: { ! 699: register struct symtab *p; ! 700: ! 701: if (gdebug) { ! 702: if (oldway) { ! 703: old_pfstab(sname); ! 704: } else { ! 705: p = &stab[lookup(sname, 0)]; ! 706: printf("\t.stabs\t\"%s:", p->sname); ! 707: putchar((p->sclass == STATIC) ? 'f' : 'F'); ! 708: gentype(p); ! 709: geninfo(p); ! 710: } ! 711: } ! 712: } ! 713: ! 714: /* ! 715: * Old way of doing things. ! 716: */ ! 717: ! 718: private old_fixarg(p) ! 719: struct symtab *p; { ! 720: if (gdebug) { ! 721: old_pstab(p->sname, N_PSYM); ! 722: if (gdebug) printf("0,%d,%d\n", p->stype, argoff/SZCHAR); ! 723: old_poffs(p); ! 724: } ! 725: } ! 726: ! 727: private old_outstab(p) ! 728: struct symtab *p; { ! 729: register TWORD ptype; ! 730: register char *pname; ! 731: register char pclass; ! 732: register int poffset; ! 733: ! 734: if (!gdebug) return; ! 735: ! 736: ptype = p->stype; ! 737: pname = p->sname; ! 738: pclass = p->sclass; ! 739: poffset = p->offset; ! 740: ! 741: if (ISFTN(ptype)) { ! 742: return; ! 743: } ! 744: ! 745: switch (pclass) { ! 746: ! 747: case AUTO: ! 748: old_pstab(pname, N_LSYM); ! 749: printf("0,%d,%d\n", ptype, (-poffset)/SZCHAR); ! 750: old_poffs(p); ! 751: return; ! 752: ! 753: case EXTDEF: ! 754: case EXTERN: ! 755: old_pstab(pname, N_GSYM); ! 756: printf("0,%d,0\n", ptype); ! 757: old_poffs(p); ! 758: return; ! 759: ! 760: case STATIC: ! 761: #ifdef LCOMM ! 762: /* stabLCSYM is 1 during nidcl so we can get stab type right */ ! 763: old_pstab(pname, stabLCSYM ? N_LCSYM : N_STSYM); ! 764: #else ! 765: old_pstab(pname, N_STSYM); ! 766: #endif ! 767: if (p->slevel > 1) { ! 768: printf("0,%d,L%d\n", ptype, poffset); ! 769: } else { ! 770: printf("0,%d,%s\n", ptype, exname(pname)); ! 771: } ! 772: old_poffs(p); ! 773: return; ! 774: ! 775: case REGISTER: ! 776: old_pstab(pname, N_RSYM); ! 777: printf("0,%d,%d\n", ptype, poffset); ! 778: old_poffs(p); ! 779: return; ! 780: ! 781: case MOS: ! 782: case MOU: ! 783: old_pstab(pname, N_SSYM); ! 784: printf("0,%d,%d\n", ptype, poffset/SZCHAR); ! 785: old_poffs(p); ! 786: return; ! 787: ! 788: case PARAM: ! 789: /* parameter stab entries are processed in dclargs() */ ! 790: return; ! 791: ! 792: default: ! 793: #ifndef FLEXNAMES ! 794: if (ddebug) printf(" No .stab for %.8s\n", pname); ! 795: #else ! 796: if (ddebug) printf(" No .stab for %s\n", pname); ! 797: #endif ! 798: ! 799: } ! 800: } ! 801: ! 802: private old_pstab(name, type) ! 803: char *name; ! 804: int type; { ! 805: register int i; ! 806: register char c; ! 807: if (!gdebug) return; ! 808: /* locctr(PROG); /* .stabs must appear in .text for c2 */ ! 809: #ifdef ASSTRINGS ! 810: if ( name[0] == '\0') ! 811: printf("\t.stabn\t"); ! 812: else ! 813: #ifndef FLEXNAMES ! 814: printf("\t.stabs\t\"%.8s\", ", name); ! 815: #else ! 816: printf("\t.stabs\t\"%s\", ", name); ! 817: #endif ! 818: #else ! 819: printf(" .stab "); ! 820: for(i=0; i<8; i++) ! 821: if (c = name[i]) printf("'%c,", c); ! 822: else printf("0,"); ! 823: #endif ! 824: printf("0%o,", type); ! 825: } ! 826: ! 827: #ifdef STABDOT ! 828: private old_pstabdot(type, value) ! 829: int type; ! 830: int value; ! 831: { ! 832: if ( ! gdebug) return; ! 833: /* locctr(PROG); /* .stabs must appear in .text for c2 */ ! 834: printf("\t.stabd\t"); ! 835: printf("0%o,0,0%o\n",type, value); ! 836: } ! 837: #endif ! 838: ! 839: private old_poffs(p) ! 840: register struct symtab *p; { ! 841: int s; ! 842: if (!gdebug) return; ! 843: if ((s = dimtab[p->sizoff]/SZCHAR) > 1) { ! 844: old_pstab(p->sname, N_LENG); ! 845: printf("1,0,%d\n", s); ! 846: } ! 847: } ! 848: ! 849: private old_psline() { ! 850: static int lastlineno; ! 851: register char *cp, *cq; ! 852: register int i; ! 853: ! 854: if (!gdebug) return; ! 855: ! 856: cq = ititle; ! 857: cp = ftitle; ! 858: ! 859: while ( *cq ) if ( *cp++ != *cq++ ) goto neq; ! 860: if ( *cp == '\0' ) goto eq; ! 861: ! 862: neq: for (i=0; i<100; i++) ! 863: ititle[i] = '\0'; ! 864: cp = ftitle; ! 865: cq = ititle; ! 866: while ( *cp ) ! 867: *cq++ = *cp++; ! 868: *cq = '\0'; ! 869: *--cq = '\0'; ! 870: #ifndef FLEXNAMES ! 871: for ( cp = ititle+1; *(cp-1); cp += 8 ) { ! 872: old_pstab(cp, N_SOL); ! 873: if (gdebug) printf("0,0,LL%d\n", labelno); ! 874: } ! 875: #else ! 876: old_pstab(ititle+1, N_SOL); ! 877: if (gdebug) printf("0,0,LL%d\n", labelno); ! 878: #endif ! 879: *cq = '"'; ! 880: printf("LL%d:\n", labelno++); ! 881: ! 882: eq: if (lineno == lastlineno) return; ! 883: lastlineno = lineno; ! 884: ! 885: if (fdefflag) { ! 886: #ifdef STABDOT ! 887: old_pstabdot(N_SLINE, lineno); ! 888: #else ! 889: old_pstab(NULLNAME, N_SLINE); ! 890: printf("0,%d,LL%d\n", lineno, labelno); ! 891: printf("LL%d:\n", labelno++); ! 892: #endif ! 893: } ! 894: } ! 895: ! 896: private old_plcstab(level) { ! 897: if (!gdebug) return; ! 898: #ifdef STABDOT ! 899: old_pstabdot(N_LBRAC, level); ! 900: #else ! 901: old_pstab(NULLNAME, N_LBRAC); ! 902: printf("0,%d,LL%d\n", level, labelno); ! 903: printf("LL%d:\n", labelno++); ! 904: #endif ! 905: } ! 906: ! 907: private old_prcstab(level) { ! 908: if (!gdebug) return; ! 909: #ifdef STABDOT ! 910: pstabdot(N_RBRAC, level); ! 911: #else ! 912: pstab(NULLNAME, N_RBRAC); ! 913: printf("0,%d,LL%d\n", level, labelno); ! 914: printf("LL%d:\n", labelno++); ! 915: #endif ! 916: } ! 917: ! 918: private old_pfstab(sname) ! 919: char *sname; { ! 920: if (!gdebug) return; ! 921: pstab(sname, N_FUN); ! 922: #ifndef FLEXNAMES ! 923: printf("0,%d,_%.7s\n", lineno, sname); ! 924: #else ! 925: printf("0,%d,_%s\n", lineno, sname); ! 926: #endif ! 927: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.