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

1.1     ! root        1: static char sccsid[] = "@(#)list.c     2.5";
        !             2: 
        !             3: #include "cdb.h"
        !             4: 
        !             5: extern char *vmpBtSb[];
        !             6: #define cScreenMax 21
        !             7: 
        !             8: /* L I S T   F I L E S */
        !             9: 
        !            10: local void ListFiles(sbFile)
        !            11: char   *sbFile;
        !            12: {
        !            13:        short   i, c;
        !            14: 
        !            15:        printf("   name        address\n");
        !            16:        c = 0;
        !            17:        for (i=0; i<vifdMac-2; i++) { /* don't show vifdNil, vifdTemp */
        !            18:                if ((sbFile != sbNil)
        !            19:                    AND (!FHdrCmp(sbFile, vrgFd[i].sbFile)))
        !            20:                        continue;
        !            21:                printf("%2d: %-15s  %s", i, vrgFd[i].sbFile,
        !            22:                SbFAdr(lengthen(vrgFd[i].adrStart), true));
        !            23:                printf("\n");
        !            24:                if (++c >= cScreenMax) {
        !            25:                        if (YesNo("Quit? (<cr> for more, y<cr> to stop)  "))
        !            26:                                return;
        !            27:                        c = 0;
        !            28:                }
        !            29:        } /* for */
        !            30: } /* ListFiles */
        !            31: 
        !            32: 
        !            33: /* L I S T   P R O C S */
        !            34: 
        !            35: local void ListProcs(sbProc)
        !            36: char   *sbProc;
        !            37: {
        !            38:        short   i, c;
        !            39: 
        !            40:        printf("   name        address\n");
        !            41:        c = 0;
        !            42:        for (i=0; i<vipdMac; i++) {
        !            43:                if ((sbProc != sbNil)
        !            44:                    AND (!FHdrCmp(sbProc, vrgPd[i].sbProc)))
        !            45:                        continue;
        !            46:                printf("%2d: %-15s  %s\n", i, vrgPd[i].sbProc,
        !            47:                SbFAdr(lengthen(vrgPd[i].adrStart), true));
        !            48:                if (++c >= cScreenMax) {
        !            49:                        if (YesNo("Quit? (<cr> for more, y<cr> to stop)  "))
        !            50:                                return;
        !            51:                        c = 0;
        !            52:                }
        !            53:        } /* for */
        !            54: } /* ListProcs */
        !            55: 
        !            56: 
        !            57: /* L I S T   L A B E L S */
        !            58: 
        !            59: local void ListLabels(sbLabel)
        !            60: char   *sbLabel;
        !            61: {
        !            62:        int             c;
        !            63:        long    adrLong;
        !            64:        char    *sb;
        !            65: 
        !            66:        c = 0;
        !            67:        SetNext(visymGlobal);
        !            68:        while (FNextSym(N_TEXT, 0, 0, sbNil, nil)) {
        !            69:                sb = SbInCore(vsymCur->sbSym);
        !            70:                if ((sbLabel != sbNil)
        !            71:                    AND !FHdrCmp(sbLabel, sb)
        !            72:                    AND !FHdrCmp(sbLabel, sb+1))
        !            73:                        continue;
        !            74:                adrLong = vsymCur->value;
        !            75:                if (*sb == '_')
        !            76:                        sb++;
        !            77: #ifdef BSD41
        !            78:                printf("%-15s %s", sb, SbFAdr(adrLong, true));
        !            79: #else
        !            80:                printf("%-12.8s %s", sb, SbFAdr(adrLong, true));
        !            81: #endif
        !            82:                printf("\n");
        !            83:                if (++c >= cScreenMax) {
        !            84:                        if (YesNo("Quit? (<cr> for more, y<cr> to stop)  "))
        !            85:                                return;
        !            86:                        c = 0;
        !            87:                }
        !            88:        } /* while */
        !            89: } /* ListLabels */
        !            90: 
        !            91: 
        !            92: /* L I S T   G L O B A L S */
        !            93: 
        !            94: local void ListGlobals(sbGlobal)
        !            95: char   *sbGlobal;
        !            96: {
        !            97:        int             c;
        !            98:        long    adrLong;
        !            99:        FLAGT   fData;
        !           100:        char    *sb, ch;
        !           101:        TYR             rgTy[cTyMax];
        !           102: 
        !           103:        SetNext(visymGlobal);
        !           104: 
        !           105:        if (vpid == pidNil AND vfnCore == fnNil) {
        !           106:                fData = false;
        !           107:                ch = '@';
        !           108:                printf("No data available - here are the names\n");
        !           109:        } 
        !           110:        else {
        !           111:                ch = '=';
        !           112:                fData = true;
        !           113:        }
        !           114:        c = 0;
        !           115:        while (FNextSym(N_DATA, N_BSS, 0, sbNil, nil)) {
        !           116:                sb = SbInCore(vsymCur->sbSym);
        !           117:                if ((sbGlobal != sbNil)
        !           118:                    AND (!FHdrCmp(sbGlobal, sb))
        !           119:                    AND (!FHdrCmp(sbGlobal, sb+1)))
        !           120:                        continue;
        !           121:                adrLong = vsymCur->value;
        !           122:                if (*sb == '_')
        !           123:                        sb++;
        !           124: #ifdef BSD41
        !           125:                printf("%-15s %c ", sb, ch);
        !           126: #else
        !           127:                printf("%-12.8s %c ", sb, ch);
        !           128: #endif
        !           129:                if (!fData) {
        !           130:                        printf("%s", SbFAdr(adrLong, true));
        !           131:                } 
        !           132:                else {
        !           133:                        TyFGlobal(rgTy, sb);
        !           134:                        DispVal(adrLong, rgTy, modeNil, false, true, false);
        !           135:                } /* if */
        !           136:                printf("\n");
        !           137:                if (++c >= cScreenMax) {
        !           138:                        if (YesNo("Quit? (<cr> for more, y<cr> to stop)  "))
        !           139:                                return;
        !           140:                        c = 0;
        !           141:                }
        !           142:        } /* while */
        !           143: } /* ListGlobals */
        !           144: 
        !           145: 
        !           146: /* L I S T   L O C A L S */
        !           147: 
        !           148: local void ListLocals(sbProc, cnt)
        !           149: char   *sbProc;
        !           150: int    cnt;
        !           151: {
        !           152:        short   ipd;
        !           153:        long    isym, adrLong;
        !           154:        char    sbName[50];
        !           155:        TYR             rgTy[cTyMax];
        !           156: 
        !           157:        if (sbProc != sbNil) {
        !           158:                ipd = IpdFName(sbProc);
        !           159:        } 
        !           160:        else {
        !           161:                if (vipd < 0)
        !           162:                        Panic("ListLocals: vipd = %d",vipd);
        !           163:                ipd = vipd;
        !           164:        } /* if */
        !           165:        if (ipd == -1)
        !           166:                UError("No such procedure `%s'", sbProc);
        !           167: 
        !           168:        SetNext(vrgPd[ipd].isym+1);
        !           169:        while (FNextLocal(true, true, sbNil)) {
        !           170:                strcpy(sbName, SbInCore(vsymCur->sbSym+vcbVarHdr));
        !           171:                isym = visym;
        !           172:                adrLong = AdrFLocal(ipd, cnt, sbName, rgTy);
        !           173:                DispVal(adrLong, rgTy, modeNil, true, true, true);
        !           174:                printf("\n");
        !           175:                SetSym(isym);
        !           176:        } /* while */
        !           177: } /* ListLocals */
        !           178: 
        !           179: 
        !           180: /* L I S T   S O M E T H I N G */
        !           181: 
        !           182: export void ListSomething()
        !           183: {
        !           184:        short   cnt;
        !           185:        char    chCmd, *sbArg, sbName[20];
        !           186:        TKE             tk;
        !           187:        FLAGT   fDidit;
        !           188: 
        !           189:        vipd = IpdFAdr(AdrFIfdLn(vifd, viln));
        !           190:        tk = TkNext();
        !           191:        if (vcbTok == 1) {
        !           192:                fDidit = false;
        !           193:                sbArg = sbNil;
        !           194:                chCmd = vsbTok[0];
        !           195:                if (tkStr == TkPeek()) {
        !           196:                        tk = TkNext();
        !           197:                        sbArg = vsbTok;
        !           198:                } /* if */
        !           199:                fDidit = true;
        !           200:                switch (chCmd) {
        !           201:                default:        
        !           202:                        fDidit = false;
        !           203:                case 'a':   
        !           204:                        ListAssert(); 
        !           205:                        break;
        !           206:                case 'd':   
        !           207:                        ListDir(); 
        !           208:                        break;
        !           209:                case 'f':   
        !           210:                        ListFiles(sbArg); 
        !           211:                        break;
        !           212:                case 'g':   
        !           213:                        ListGlobals(sbArg); 
        !           214:                        break;
        !           215:                case 'l':   
        !           216:                        ListLabels(sbArg); 
        !           217:                        break;
        !           218:                case 'p':   
        !           219:                        ListProcs(sbArg); 
        !           220:                        break;
        !           221:                case 'r':   
        !           222:                        ListRegs(sbArg); 
        !           223:                        break;
        !           224:                case 's':   
        !           225:                        ListSpecial(sbArg); 
        !           226:                        break;
        !           227:                case 'z':   
        !           228:                        ListSa(); 
        !           229:                        break;
        !           230:                } /* switch */
        !           231:                if (fDidit)
        !           232:                        return;
        !           233:        } /* if */
        !           234:        if (tk == tkStr) {
        !           235:                strcpy(sbName, vsbTok);
        !           236:                cnt = -1;
        !           237:                if ((TkNext() == tkDot)
        !           238:                    AND (TkNext() == tkNumber))
        !           239:                        cnt = atoi(vsbTok);
        !           240:                ListLocals(sbName, cnt);
        !           241:        } 
        !           242:        else {
        !           243:                ListLocals(sbNil, -1);
        !           244:        } /* if */
        !           245: } /* ListSomething */

unix.superglobalmegacorp.com

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