Annotation of cci/usr/src/usr.bin/cdb/transBsd/print.c, revision 1.1

1.1     ! root        1: /* $Header: print.c,v 1.1 86/03/24 16:19:21 rcs Exp $ */
        !             2: /* (C) Copyright 1985 Third Eye Software, Inc. - All Rights Reserved */
        !             3: 
        !             4: #include "tes42.h"
        !             5: 
        !             6: int    vindent;
        !             7: #define SbFIss(iss) (vsbNewStr + iss)
        !             8: 
        !             9: 
        !            10: /* P R I N T   T Q */
        !            11: 
        !            12: local void PrintTq(tq)
        !            13: int    tq;
        !            14: {
        !            15:     switch (tq) {
        !            16:        case tqArray:   printf("Array of "); break;
        !            17:        case tqPtr:     printf("Pointer to "); break;
        !            18:        case tqProc:    printf("Function returning "); break;
        !            19:     } /* switch */
        !            20: } /* PrintTq */
        !            21: 
        !            22: 
        !            23: /* P R I N T   B T */
        !            24: 
        !            25: local void PrintBt(bt)
        !            26: int    bt;
        !            27: {
        !            28:     switch (bt) {
        !            29:        default:        printf("Unknown-bt(%d)", bt);   break;
        !            30:        case btNil:     printf("btNil ");               break;
        !            31:        case btAdr:     printf("Adr ");                 break;
        !            32:        case btChar:    printf("Char ");                break;
        !            33:        case btUChar:   printf("UChar ");               break;
        !            34:        case btShort:   printf("Short ");               break;
        !            35:        case btUShort:  printf("UShort ");              break;
        !            36:        case btInt:     printf("Int ");                 break;
        !            37:        case btUInt:    printf("UInt ");                break;
        !            38:        case btLong:    printf("Long ");                break;
        !            39:        case btULong:   printf("ULong ");               break;
        !            40:        case btFloat:   printf("Float ");               break;
        !            41:        case btDouble:  printf("Double ");              break;
        !            42:        case btStruct:  printf("Struct ");              break;
        !            43:        case btUnion:   printf("Union ");               break;
        !            44:        case btEnum:    printf("Enum ");                break;
        !            45:        case btTypedef: printf("User type ");   break;
        !            46:     } /* switch */
        !            47: } /* PrintBt */
        !            48: 
        !            49: 
        !            50: /* I A U X   F   P R I N T   T Y P E */
        !            51: 
        !            52: local void IauxFPrintType(iaux)
        !            53: int4   iaux;
        !            54: {
        !            55:     TIR                ati;
        !            56:     AUXU       aaux, aaux2;
        !            57:     DIMR       adim;
        !            58: 
        !            59:     aaux = AuxFIaux(iaux++);
        !            60:     PrintTq(aaux.ti.tq0);
        !            61:     PrintTq(aaux.ti.tq1);
        !            62:     PrintTq(aaux.ti.tq2);
        !            63:     PrintTq(aaux.ti.tq3);
        !            64:     PrintTq(aaux.ti.tq4);
        !            65:     PrintTq(aaux.ti.tq5);
        !            66:     PrintBt(aaux.ti.bt);
        !            67: 
        !            68:     if (FComplexBt(aaux.ti.bt))
        !            69:        printf("ref = %ld ", AuxFIaux(iaux++));
        !            70: 
        !            71: #define PRINTDIM(tq)\
        !            72:     if (tq == tqArray) {\
        !            73:            aaux2 = AuxFIaux(iaux++); \
        !            74:            printf("[%d, %d] ", aaux2.dim.dnLow, aaux2.dim.dnMac); \
        !            75:     } /* if */
        !            76:     PRINTDIM(aaux.ti.tq5);
        !            77:     PRINTDIM(aaux.ti.tq4);
        !            78:     PRINTDIM(aaux.ti.tq3);
        !            79:     PRINTDIM(aaux.ti.tq2);
        !            80:     PRINTDIM(aaux.ti.tq1);
        !            81:     PRINTDIM(aaux.ti.tq0);
        !            82: 
        !            83:     return(iaux);
        !            84: } /* IauxFPrintType */
        !            85: 
        !            86: 
        !            87: /* P R I N T   S Y M */
        !            88: 
        !            89: local void PrintSym(sym)
        !            90: pSYMR  sym;
        !            91: {
        !            92:     int4       iaux;
        !            93: 
        !            94:     if (sym->iss != issNil)
        !            95:        printf("\"%s\": ", SbFIss(sym->iss));
        !            96:     else
        !            97:        printf("\"\": ");
        !            98: 
        !            99:     switch (sym->st) {
        !           100:        case stParam:
        !           101:        case stLocal:
        !           102:        case stTypedef:
        !           103:        case stNil:     printf("%ld, ", sym->value);
        !           104:                        break;
        !           105:        case stProc:    if (sym->index != viauxProcPhony)
        !           106:                            vindent++;
        !           107:        case stLabel:
        !           108:        case stEnd:
        !           109:        case stFile:
        !           110:        case stBlock:
        !           111:        case stStatic:
        !           112:        case stGlobal:  printf("%#lx, ", sym->value);
        !           113:                        break;
        !           114:        case stMember:  printf("offset %ld, ", sym->value);
        !           115:                        break;
        !           116:     } /* switch */
        !           117: 
        !           118:     switch (sym->st) {
        !           119:        case stNil:     printf("stNil "); break;
        !           120:        case stGlobal:  printf("Extern "); break;
        !           121:        case stStatic:  printf("Static "); break;
        !           122:        case stParam:   printf("Param "); break;
        !           123:        case stLocal:   printf("Local "); break;
        !           124:        case stLabel:   printf("Label "); break;
        !           125:        case stBlock:   printf("Block "); vindent++; break;
        !           126:        case stProc:    printf("Procedure "); break;
        !           127:        case stMember:  printf("Member "); break;
        !           128:        case stEnd:     printf("End "); break;
        !           129:        case stTypedef: printf("Typedef "); break;
        !           130:        case stFile:    printf("File name "); vindent++; break;
        !           131:     } /* switch */
        !           132: 
        !           133:     switch (sym->sc) {
        !           134:        case scNil:             printf("scNil "); break;
        !           135:        case scText:            printf("Text "); break;
        !           136:        case scData:            printf("Data "); break;
        !           137:        case scBss:             printf("Bss "); break;
        !           138:        case scRegister:        printf("Register "); break;
        !           139:        case scAbs:             /* printf("Absolute "); */ break;
        !           140:        case scUndefined:       printf("scUndefined "); break;
        !           141:        case scInfo:            printf("Info "); break;
        !           142:        case scBits:            printf("BitField "); break;
        !           143:     } /* switch */
        !           144: 
        !           145:     iaux = sym->index;
        !           146:     switch (sym->st) {
        !           147:        default: printf("ref = %ld ", iaux);    break;
        !           148: 
        !           149:        case stProc:
        !           150:                printf("ref = %ld ", AuxFIaux(iaux++));
        !           151:                /* fall through */
        !           152: 
        !           153:        case stMember:
        !           154:                if (iaux == 0)  /* it MUST be an ENUM name */
        !           155:                    break;
        !           156:                /* fall through */
        !           157: 
        !           158:        case stGlobal:
        !           159:        case stLocal:
        !           160:        case stParam:
        !           161:        case stTypedef:
        !           162:                iaux = IauxFPrintType(iaux);
        !           163:                if (sym->sc == scBits)
        !           164:                    printf("width = %ld ", AuxFIaux(iaux));
        !           165:                break;
        !           166:     } /* switch */
        !           167:     printf("\n");
        !           168: 
        !           169: } /* PrintSym */
        !           170: 
        !           171: 
        !           172: /* P R I N T   I N D E N T */
        !           173: 
        !           174: local void PrintIndent()
        !           175: {
        !           176:     register int       i;
        !           177: 
        !           178:     for (i = 0; i < vindent; i++)
        !           179:        printf("    ");
        !           180: } /* PrintIndent */
        !           181: 
        !           182: 
        !           183: /* P R I N T   L I N E S */
        !           184: 
        !           185: local void PrintLines(iline)
        !           186: register int   iline;
        !           187: {
        !           188:     int                i;
        !           189:     ADRT       dadr, dadrLast;
        !           190: 
        !           191:     dadrLast = 0;
        !           192:     for (i = 0; iline < vilineMac; i++, iline++) {
        !           193:        dadr = vrgLine[iline].dadr;
        !           194:        if (vrgLine[iline].dadr < dadrLast)
        !           195:            break;
        !           196:        printf("%s%3d %3d: 0x%lx", (i % 4) ? "\t" : "\n\t",
        !           197:                        iline, vrgLine[iline].iln, dadr);
        !           198:        dadrLast = dadr;
        !           199:     } /* for */
        !           200: } /* PrintLines */
        !           201: 
        !           202: 
        !           203: /* P R I N T   F I L E S */
        !           204: 
        !           205: local void PrintFiles()
        !           206: {
        !           207:     register int       ifd;
        !           208:     register pFDR      fd;
        !           209:     
        !           210:     for (ifd = 0, fd = vrgFd; ifd < vifdMac; ifd++, fd++) {
        !           211:        printf("%3d: \"%s\" %#lx", ifd, SbFIss(fd->iss), fd->adr);
        !           212:        if (fd->ipd != ipdNil)
        !           213:            printf("\t\"%s\"", SbFIss(SymFIsym(vrgPd[fd->ipd].isym)->iss) );
        !           214:        printf("\n");
        !           215:     } /* for */
        !           216: } /* PrintFiles */
        !           217: 
        !           218: 
        !           219: /* P R I N T   P R O C S */
        !           220: 
        !           221: local void PrintProcs()
        !           222: {
        !           223:     register int       ipd;
        !           224:     pSYMR      sym;
        !           225:     pPDR       pd;
        !           226: 
        !           227:     pd = vrgPd;
        !           228:     for (ipd = 0; ipd < vipdMac; ipd++, pd++) {
        !           229:        sym =  vrgSym + pd->isym;
        !           230:        printf("%3d: \"%s\" addr: %#lx  isym: %ld",
        !           231:                ipd, SbFIss(SymFIsym(pd->isym)->iss), pd->adr, pd->isym);
        !           232:        if (pd->iline > 0)
        !           233:            PrintLines(pd->iline);
        !           234:        printf("\n");
        !           235:     } /* for */
        !           236: } /* PrintProcs */
        !           237: 
        !           238: 
        !           239: /* P R I N T   A L L */
        !           240: 
        !           241: export void PrintAll() 
        !           242: {
        !           243:     register int       i;
        !           244: 
        !           245:     printf("Header infomation:\n");
        !           246: 
        !           247:     printf("   vstamp:         %8ld\n", vahdr.vstamp);
        !           248:     printf("   cbText:         %8ld\n", vahdr.cbText);
        !           249:     printf("   cbData:         %8ld\n", vahdr.cbData);
        !           250:     printf("   cbBss:          %8ld\n", vahdr.cbBss);
        !           251:     printf("   ipdMax:         %8ld\n", vahdr.ipdMax);
        !           252:     printf("   cbPdOffset:     %8ld\n", vahdr.cbPdOffset);
        !           253:     printf("   ifdMax:         %8ld\n", vahdr.ifdMax);
        !           254:     printf("   cbFdOffset:     %8ld\n", vahdr.cbFdOffset);
        !           255:     printf("   ilineMax:       %8ld\n", vahdr.ilineMax);
        !           256:     printf("   cbLineOffset:   %8ld\n", vahdr.cbLineOffset);
        !           257:     printf("   issMax:         %8ld\n", vahdr.issMax);
        !           258:     printf("   cbSsOffset:     %8ld\n", vahdr.cbSsOffset);
        !           259:     printf("   isymMax:        %8ld\n", vahdr.isymMax);
        !           260:     printf("   cbSymOffset:    %8ld\n", vahdr.cbSymOffset);
        !           261:     printf("   isymGl:         %8ld\n", vahdr.isymGl);
        !           262:     printf("   isymGlMax:      %8ld\n", vahdr.isymGlMax);
        !           263:     printf("   iauxMax:        %8ld\n", vahdr.iauxMax);
        !           264:     printf("   cbAuxOffset:    %8ld\n", vahdr.cbAuxOffset);
        !           265: 
        !           266:     vindent = 0;
        !           267:     printf("\n\nSYMBOLS:\n\n");
        !           268:     for (i = 0 ; i < visymMac; i++) {
        !           269:        if (vrgSym[i].st == stEnd)
        !           270:            vindent--;
        !           271:        PrintIndent();
        !           272:        printf("%d. ", i);
        !           273:        PrintSym(vrgSym + i);
        !           274:     } /* for */
        !           275: 
        !           276:     printf("\n\nGLOBALS:\n\n");
        !           277:     for (i= 0 ; i < visymGlMac; i++)
        !           278:        PrintSym(vrgSymGlobal + i);
        !           279: 
        !           280:     printf("\n\nPROCS:\n\n");
        !           281:     PrintProcs();
        !           282: 
        !           283:     printf("\n\nFILES:\n\n");
        !           284:     PrintFiles();
        !           285: } /* PrintAll */

unix.superglobalmegacorp.com

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