Annotation of 43BSDTahoe/lib/old_compiler/pcc/pcc.tahoe/stab.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char *sccsid ="@(#)stab.c       1.4 (Berkeley) 7/31/86";
                      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 "pass1.h"
                     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 (i == NILINDEX && ISARY(t)) {
                    398:            i = p->dimoff;
                    399:        }
                    400:        if (t == basictype) {
                    401:            typeid = typelookup(t, NILINDEX, strindex, strtag);
                    402:        } else {
                    403:            typeid = typelookup(t, i, strindex, strtag);
                    404:        }
                    405:     }
                    406:     if (typeid == nil) {
                    407:        if (strindex == FORWARD) {
                    408:            typeid = typelookup(t, NILINDEX, FORWARD, dimtab[p->sizoff + 3]);
                    409:            if (typeid == nil) {
                    410:                cerror("unbelievable forward reference");
                    411:            }
                    412:            printf("%d", typeid->tnum);
                    413:        } else {
                    414:            genstruct(t, NILINDEX, strindex, p->sname, bsize(p));
                    415:        }
                    416:     } else {
                    417:        printf("%d", typeid->tnum);
                    418:     }
                    419: }
                    420: 
                    421: /*
                    422:  * Generate type information for structures, unions, and enumerations.
                    423:  */
                    424: 
                    425: private genstruct(t, structid, index, name, size)
                    426: TWORD t;
                    427: int structid;
                    428: int index;
                    429: char *name;
                    430: int size;
                    431: {
                    432:     register int i;
                    433:     register struct symtab *field;
                    434:     int id;
                    435: 
                    436:     if (structid == NILINDEX) {
                    437:        id = entertype(t, NILINDEX, index, NILINDEX);
                    438:     } else {
                    439:        id = structid;
                    440:     }
                    441:     switch (t) {
                    442:     case STRTY:
                    443:     case UNIONTY:
                    444:        printf("%d=%c%d", id, t == STRTY ? 's' : 'u', size);
                    445:        i = index;
                    446:        while (dimtab[i] != -1) {
                    447:            field = &stab[dimtab[i]];
                    448:            printf("%s:", field->sname);
                    449:            gentype(field);
                    450:            if (field->sclass > FIELD) {
                    451:                printf(",%d,%d;", field->offset, field->sclass - FIELD);
                    452:            } else {
                    453:                printf(",%d,%d;", field->offset,
                    454:                    tsize(field->stype, field->dimoff, field->sizoff));
                    455:            }
                    456:            ++i;
                    457:        }
                    458:        putchar(';');
                    459:        break;
                    460: 
                    461:     case ENUMTY:
                    462:        printf("%d=e", id);
                    463:        i = index;
                    464:        while (dimtab[i] != -1) {
                    465:            field = &stab[dimtab[i]];
                    466:            printf("%s:%d,", field->sname, field->offset);
                    467:            i++;
                    468:        }
                    469:        putchar(';');
                    470:        break;
                    471: 
                    472:     default:
                    473:        cerror("couldn't find basic type %d for %s\n", t, name);
                    474:        break;
                    475:     }
                    476: }
                    477: 
                    478: /*
                    479:  * Generate offset and size info.
                    480:  */
                    481: 
                    482: private geninfo(p)
                    483: register struct symtab *p;
                    484: {
                    485:     int stabtype;
                    486: 
                    487:     if (p == nil) {
                    488:        printf("\",0x%x,0,0,0\n", N_LSYM);
                    489:     } else {
                    490:        switch (p->sclass) {
                    491:            case EXTERN:
                    492:            case EXTDEF:
                    493:                if (ISFTN(p->stype)) {
                    494:                    printf("\",0x%x,0,%d,_%s\n", N_FUN, bsize(p), p->sname);
                    495:                } else {
                    496:                    printf("\",0x%x,0,%d,0\n", N_GSYM, bsize(p));
                    497:                }
                    498:                break;
                    499: 
                    500:            case STATIC:
                    501:                stabtype = stabLCSYM ? N_LCSYM : N_STSYM;
                    502:                if (ISFTN(p->stype)) {
                    503:                    printf("\",0x%x,0,%d,_%s\n", N_FUN, bsize(p), p->sname);
                    504:                } else if (p->slevel > 1) {
                    505:                    printf("\",0x%x,0,%d,L%d\n", stabtype, bsize(p), p->offset);
                    506:                } else {
                    507:                    printf("\",0x%x,0,%d,_%s\n", stabtype, bsize(p), p->sname);
                    508:                }
                    509:                break;
                    510: 
                    511:            case REGISTER:
                    512:                printf("\",0x%x,0,%d,%d\n", N_RSYM, bsize(p), p->offset);
                    513:                break;
                    514: 
                    515:            case PARAM:
                    516:                printf("\",0x%x,0,%d,%d\n", N_PSYM, bsize(p), bytes(argoff));
                    517:                break;
                    518: 
                    519:            default:
                    520:                printf("\",0x%x,0,%d,%d\n", N_LSYM, bsize(p), bytes(p->offset));
                    521:                break;
                    522:        }
                    523:     }
                    524: }
                    525: 
                    526: /*
                    527:  * Generate information for a newly-defined structure.
                    528:  */
                    529: 
                    530: outstruct(szindex, paramindex)
                    531: int szindex, paramindex;
                    532: {
                    533:     register Typeid typeid;
                    534:     register struct symtab *p;
                    535:     register int i, t, strindex;
                    536: 
                    537:     if (oldway) {
                    538:        /* do nothing */;
                    539:     } else if (gdebug) {
                    540:        i = dimtab[szindex + 3];
                    541:        if (i != NILINDEX && (p = &stab[i])->sname != nil) {
                    542:            strindex = dimtab[p->sizoff + 1];
                    543:            typeid = typelookup(p->stype, NILINDEX, FORWARD, i);
                    544:            if (typeid == nil) {
                    545:                t = 0;
                    546:            } else {
                    547:                t = typeid->tnum;
                    548:                reentertype(typeid, p->stype, NILINDEX, strindex, NILINDEX);
                    549:            }
                    550:            printf("\t.stabs\t\"%s:T", p->sname);
                    551:            genstruct(p->stype, t, strindex, p->sname, bsize(p));
                    552:            geninfo(p);
                    553:        }
                    554:     }
                    555: }
                    556: 
                    557: pstab(name, type)
                    558: char *name;
                    559: int type;
                    560: {
                    561:     register int i;
                    562:     register char c;
                    563: 
                    564:     if (!gdebug) {
                    565:        return;
                    566:     } else if (oldway) {
                    567:        old_pstab(name, type);
                    568:        return;
                    569:     }
                    570:     /* locctr(PROG);  /* .stabs must appear in .text for c2 */
                    571: #ifdef ASSTRINGS
                    572:     if ( name[0] == '\0')
                    573:        printf("\t.stabn\t");
                    574:     else
                    575: #ifndef FLEXNAMES
                    576:        printf("\t.stabs\t\"%.8s\",", name);
                    577: #else
                    578:        printf("\t.stabs\t\"%s\",", name);
                    579: #endif
                    580: #else
                    581:     printf("    .stab   ");
                    582:     for(i=0; i<8; i++) 
                    583:        if (c = name[i]) printf("'%c,", c);
                    584:        else printf("0,");
                    585: #endif
                    586:     printf("0%o,", type);
                    587: }
                    588: 
                    589: #ifdef STABDOT
                    590: pstabdot(type, value)
                    591: int type;
                    592: int value;
                    593: {
                    594:     if ( ! gdebug) {
                    595:        return;
                    596:     } else if (oldway) {
                    597:        old_pstabdot(type, value);
                    598:        return;
                    599:     }
                    600:     /* locctr(PROG);  /* .stabs must appear in .text for c2 */
                    601:     printf("\t.stabd\t");
                    602:     printf("0%o,0,0%o\n",type, value);
                    603: }
                    604: #endif
                    605: 
                    606: extern char NULLNAME[8];
                    607: extern int  labelno;
                    608: extern int  fdefflag;
                    609: 
                    610: psline()
                    611: {
                    612:     static int lastlineno;
                    613:     register char *cp, *cq;
                    614:     register int i;
                    615:     
                    616:     if (!gdebug) {
                    617:        return;
                    618:     } else if (oldway) {
                    619:        old_psline();
                    620:        return;
                    621:     }
                    622: 
                    623:     cq = ititle;
                    624:     cp = ftitle;
                    625: 
                    626:     while ( *cq ) if ( *cp++ != *cq++ ) goto neq;
                    627:     if ( *cp == '\0' ) goto eq;
                    628:     
                    629: neq:    for (i=0; i<100; i++)
                    630:        ititle[i] = '\0';
                    631:     cp = ftitle;
                    632:     cq = ititle;
                    633:     while ( *cp )  
                    634:        *cq++ = *cp++;
                    635:     *cq = '\0';
                    636:     *--cq = '\0';
                    637: #ifndef FLEXNAMES
                    638:     for ( cp = ititle+1; *(cp-1); cp += 8 ) {
                    639:        pstab(cp, N_SOL);
                    640:        if (gdebug) printf("0,0,LL%d\n", labelno);
                    641:     }
                    642: #else
                    643:     pstab(ititle+1, N_SOL);
                    644:     if (gdebug) printf("0,0,LL%d\n", labelno);
                    645: #endif
                    646:     *cq = '"';
                    647:     printf("LL%d:\n", labelno++);
                    648: 
                    649: eq: if (lineno == lastlineno) return;
                    650:     lastlineno = lineno;
                    651: 
                    652:     if (fdefflag) {
                    653: #ifdef STABDOT
                    654:        pstabdot(N_SLINE, lineno);
                    655: #else
                    656:        pstab(NULLNAME, N_SLINE);
                    657:        printf("0,%d,LL%d\n", lineno, labelno);
                    658:        printf("LL%d:\n", labelno++);
                    659: #endif
                    660:     }
                    661: }
                    662:     
                    663: plcstab(level)
                    664: int level;
                    665: {
                    666:     if (!gdebug) {
                    667:        return;
                    668:     } else if (oldway) {
                    669:        old_plcstab(level);
                    670:        return;
                    671:     }
                    672: #ifdef STABDOT
                    673:     pstabdot(N_LBRAC, level);
                    674: #else
                    675:     pstab(NULLNAME, N_LBRAC);
                    676:     printf("0,%d,LL%d\n", level, labelno);
                    677:     printf("LL%d:\n", labelno++);
                    678: #endif
                    679: }
                    680:     
                    681: prcstab(level)
                    682: int level;
                    683: {
                    684:     if (!gdebug) {
                    685:        return;
                    686:     } else if (oldway) {
                    687:        old_prcstab(level);
                    688:        return;
                    689:     }
                    690: #ifdef STABDOT
                    691:     pstabdot(N_RBRAC, level);
                    692: #else
                    693:     pstab(NULLNAME, N_RBRAC);
                    694:     printf("0,%d,LL%d\n", level, labelno);
                    695:     printf("LL%d:\n", labelno++);
                    696: #endif
                    697: }
                    698:     
                    699: pfstab(sname) 
                    700: char *sname;
                    701: {
                    702:     register struct symtab *p;
                    703: 
                    704:     if (gdebug) {
                    705:        if (oldway) {
                    706:            old_pfstab(sname);
                    707:        } else {
                    708:            p = &stab[lookup(sname, 0)];
                    709:            printf("\t.stabs\t\"%s:", p->sname);
                    710:            putchar((p->sclass == STATIC) ? 'f' : 'F');
                    711:            gentype(p);
                    712:            geninfo(p);
                    713:        }
                    714:     }
                    715: }
                    716: 
                    717: /*
                    718:  * Old way of doing things.
                    719:  */
                    720: 
                    721: private old_fixarg(p)
                    722: struct symtab *p; {
                    723:        if (gdebug) {
                    724:                old_pstab(p->sname, N_PSYM);
                    725:                if (gdebug) printf("0,%d,%d\n", p->stype, argoff/SZCHAR);
                    726:                old_poffs(p);
                    727:        }
                    728: }
                    729: 
                    730: private old_outstab(p)
                    731: struct symtab *p; {
                    732:        register TWORD ptype;
                    733:        register char *pname;
                    734:        register char pclass;
                    735:        register int poffset;
                    736: 
                    737:        if (!gdebug) return;
                    738: 
                    739:        ptype = p->stype;
                    740:        pname = p->sname;
                    741:        pclass = p->sclass;
                    742:        poffset = p->offset;
                    743: 
                    744:        if (ISFTN(ptype)) {
                    745:                return;
                    746:        }
                    747:        
                    748:        switch (pclass) {
                    749:        
                    750:        case AUTO:
                    751:                old_pstab(pname, N_LSYM);
                    752:                printf("0,%d,%d\n", ptype, (-poffset)/SZCHAR);
                    753:                old_poffs(p);
                    754:                return;
                    755:        
                    756:        case EXTDEF:
                    757:        case EXTERN:
                    758:                old_pstab(pname, N_GSYM);
                    759:                printf("0,%d,0\n", ptype);
                    760:                old_poffs(p);
                    761:                return;
                    762:                        
                    763:        case STATIC:
                    764: #ifdef LCOMM
                    765:                /* stabLCSYM is 1 during nidcl so we can get stab type right */
                    766:                old_pstab(pname, stabLCSYM ? N_LCSYM : N_STSYM);
                    767: #else
                    768:                old_pstab(pname, N_STSYM);
                    769: #endif
                    770:                if (p->slevel > 1) {
                    771:                        printf("0,%d,L%d\n", ptype, poffset);
                    772:                } else {
                    773:                        printf("0,%d,%s\n", ptype, exname(pname));
                    774:                }
                    775:                old_poffs(p);
                    776:                return;
                    777:        
                    778:        case REGISTER:
                    779:                old_pstab(pname, N_RSYM);
                    780:                printf("0,%d,%d\n", ptype, poffset);
                    781:                old_poffs(p);
                    782:                return;
                    783:        
                    784:        case MOS:
                    785:        case MOU:
                    786:                old_pstab(pname, N_SSYM);
                    787:                printf("0,%d,%d\n", ptype, poffset/SZCHAR);
                    788:                old_poffs(p);
                    789:                return;
                    790:        
                    791:        case PARAM:
                    792:                /* parameter stab entries are processed in dclargs() */
                    793:                return;
                    794:        
                    795:        default:
                    796: #ifndef FLEXNAMES
                    797:                if (ddebug) printf("    No .stab for %.8s\n", pname);
                    798: #else
                    799:                if (ddebug) printf("    No .stab for %s\n", pname);
                    800: #endif
                    801:                
                    802:        }
                    803: }
                    804: 
                    805: private old_pstab(name, type)
                    806: char *name;
                    807: int type; {
                    808:        register int i;
                    809:        register char c;
                    810:        if (!gdebug) return;
                    811:        /* locctr(PROG);  /* .stabs must appear in .text for c2 */
                    812: #ifdef ASSTRINGS
                    813:        if ( name[0] == '\0')
                    814:                printf("\t.stabn\t");
                    815:        else
                    816: #ifndef FLEXNAMES
                    817:                printf("\t.stabs\t\"%.8s\", ", name);
                    818: #else
                    819:                printf("\t.stabs\t\"%s\", ", name);
                    820: #endif
                    821: #else
                    822:        printf("        .stab   ");
                    823:        for(i=0; i<8; i++) 
                    824:                if (c = name[i]) printf("'%c,", c);
                    825:                else printf("0,");
                    826: #endif
                    827:        printf("0%o,", type);
                    828: }
                    829: 
                    830: #ifdef STABDOT
                    831: private old_pstabdot(type, value)
                    832:        int     type;
                    833:        int     value;
                    834: {
                    835:        if ( ! gdebug) return;
                    836:        /* locctr(PROG);  /* .stabs must appear in .text for c2 */
                    837:        printf("\t.stabd\t");
                    838:        printf("0%o,0,0%o\n",type, value);
                    839: }
                    840: #endif
                    841: 
                    842: private old_poffs(p)
                    843: register struct symtab *p; {
                    844:        int s;
                    845:        if (!gdebug) return;
                    846:        if ((s = dimtab[p->sizoff]/SZCHAR) > 1) {
                    847:                old_pstab(p->sname, N_LENG);
                    848:                printf("1,0,%d\n", s);
                    849:        }
                    850: }
                    851: 
                    852: private old_psline() {
                    853:        static int lastlineno;
                    854:        register char *cp, *cq;
                    855:        register int i;
                    856:        
                    857:        if (!gdebug) return;
                    858: 
                    859:        cq = ititle;
                    860:        cp = ftitle;
                    861: 
                    862:        while ( *cq ) if ( *cp++ != *cq++ ) goto neq;
                    863:        if ( *cp == '\0' ) goto eq;
                    864:        
                    865: neq:   for (i=0; i<100; i++)
                    866:                ititle[i] = '\0';
                    867:        cp = ftitle;
                    868:        cq = ititle;
                    869:        while ( *cp )  
                    870:                *cq++ = *cp++;
                    871:        *cq = '\0';
                    872:        *--cq = '\0';
                    873: #ifndef FLEXNAMES
                    874:        for ( cp = ititle+1; *(cp-1); cp += 8 ) {
                    875:                old_pstab(cp, N_SOL);
                    876:                if (gdebug) printf("0,0,LL%d\n", labelno);
                    877:                }
                    878: #else
                    879:        old_pstab(ititle+1, N_SOL);
                    880:        if (gdebug) printf("0,0,LL%d\n", labelno);
                    881: #endif
                    882:        *cq = '"';
                    883:        printf("LL%d:\n", labelno++);
                    884: 
                    885: eq:    if (lineno == lastlineno) return;
                    886:        lastlineno = lineno;
                    887: 
                    888:        if (fdefflag) {
                    889: #ifdef STABDOT
                    890:                old_pstabdot(N_SLINE, lineno);
                    891: #else
                    892:                old_pstab(NULLNAME, N_SLINE);
                    893:                printf("0,%d,LL%d\n", lineno, labelno);
                    894:                printf("LL%d:\n", labelno++);
                    895: #endif
                    896:                }
                    897:        }
                    898:        
                    899: private old_plcstab(level) {
                    900:        if (!gdebug) return;
                    901: #ifdef STABDOT
                    902:        old_pstabdot(N_LBRAC, level);
                    903: #else
                    904:        old_pstab(NULLNAME, N_LBRAC);
                    905:        printf("0,%d,LL%d\n", level, labelno);
                    906:        printf("LL%d:\n", labelno++);
                    907: #endif
                    908:        }
                    909:        
                    910: private old_prcstab(level) {
                    911:        if (!gdebug) return;
                    912: #ifdef STABDOT
                    913:        pstabdot(N_RBRAC, level);
                    914: #else
                    915:        pstab(NULLNAME, N_RBRAC);
                    916:        printf("0,%d,LL%d\n", level, labelno);
                    917:        printf("LL%d:\n", labelno++);
                    918: #endif
                    919:        }
                    920:        
                    921: private old_pfstab(sname) 
                    922: char *sname; {
                    923:        if (!gdebug) return;
                    924:        pstab(sname, N_FUN);
                    925: #ifndef FLEXNAMES
                    926:        printf("0,%d,_%.7s\n", lineno, sname);
                    927: #else
                    928:        printf("0,%d,_%s\n", lineno, sname);
                    929: #endif
                    930: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.