Annotation of cci/usr/src/bin/cdb/var.c, revision 1.1.1.1

1.1       root        1: static char sccsid[] = "@(#)var.c      2.10";
                      2: 
                      3: #include "macdefs.h"
                      4: #include "cdb.h"
                      5: 
                      6: export int     vilvMax;
                      7: int    vilvMac;
                      8: pTYR vrgTyLv;  /* allocated at in InitSpc */
                      9: 
                     10: #ifdef BSD41
                     11: #define        SbCrock(x) ((int)x)
                     12: #else
                     13: #define        SbCrock(x)      x
                     14: #endif
                     15: 
                     16: #ifndef M68000
                     17: TYR    vrgTySpc[] = {  /* array of register special variables */
                     18: #ifndef VAX
                     19: #ifndef TAHOE
                     20:        {
                     21:                SbCrock("$cBad"),stSpc, false, 0, btInt, 0,0,0,0,0,0,(ulong)&vcBadMax   }
                     22:        ,
                     23: #endif
                     24: #endif
                     25:        {
                     26:                SbCrock("$lang"),       stSpc, false, 0, btInt,0,0,0,0,0,0,(ulong)&vlc  }
                     27:        ,
                     28:        {
                     29:                SbCrock("$signal"),stSpc, false, 0, btInt, 0,0,0,0,0,0, (ulong)&vsig    }
                     30:        ,
                     31:        /* name,st,fConstant,unused,desc,value */
                     32:        {
                     33:                SbCrock("$r0"), stReg, false, 0, btInt, 0,0,0,0,0,0, u0 }
                     34:        ,
                     35:        {
                     36:                SbCrock("$r1"), stReg, false, 0, btInt, 0,0,0,0,0,0, u1 }
                     37:        ,
                     38:        {
                     39:                SbCrock("$r2"), stReg, false, 0, btInt, 0,0,0,0,0,0, u2 }
                     40:        ,
                     41:        {
                     42:                SbCrock("$r3"), stReg, false, 0, btInt, 0,0,0,0,0,0, u3 }
                     43:        ,
                     44:        {
                     45:                SbCrock("$r4"), stReg, false, 0, btInt, 0,0,0,0,0,0, u4 }
                     46:        ,
                     47:        {
                     48:                SbCrock("$r5"), stReg, false, 0, btInt, 0,0,0,0,0,0, u5 }
                     49:        ,
                     50:        {
                     51:                SbCrock("$r6"), stReg, false, 0, btInt, 0,0,0,0,0,0, u6 }
                     52:        ,
                     53:        {
                     54:                SbCrock("$r7"), stReg, false, 0, btInt, 0,0,0,0,0,0, u7 }
                     55:        ,
                     56:        {
                     57:                SbCrock("$r8"), stReg, false, 0, btInt, 0,0,0,0,0,0, u8 }
                     58:        ,
                     59:        {
                     60:                SbCrock("$r9"), stReg, false, 0, btInt, 0,0,0,0,0,0, u9 }
                     61:        ,
                     62:        {
                     63:                SbCrock("$r10"),        stReg, false, 0, btInt, 0,0,0,0,0,0, u10        }
                     64:        ,
                     65:        {
                     66:                SbCrock("$r11"),        stReg, false, 0, btInt, 0,0,0,0,0,0, u11        }
                     67:        ,
                     68:        {
                     69:                SbCrock("$r12"),        stReg, false, 0, btInt, 0,0,0,0,0,0, u12        }
                     70:        ,
                     71: #ifndef TAHOE
                     72:        {
                     73:                SbCrock("$r13"),        stReg, false, 0, btInt, 0,0,0,0,0,0, u13        }
                     74:        ,
                     75: #endif
                     76: #ifdef ONYX
                     77:        {
                     78:                SbCrock("$r14"),        stReg, false, 0, btInt, 0,0,0,0,0,0, u14        }
                     79:        ,
                     80:        {
                     81:                SbCrock("$r15"),        stReg, false, 0, btInt, 0,0,0,0,0,0, u15        }
                     82:        ,
                     83:        {
                     84:                SbCrock("$fcw"),        stReg, false, 0, btInt, 0,0,0,0,0,0, ufcw       }
                     85:        ,
                     86:        {
                     87:                SbCrock("$long"),       stReg, false, 0, btLong,0,0,0,0,0,0, u6 }
                     88:        ,
                     89:        {
                     90:                SbCrock("$short"),      stReg, false, 0, btShort,0,0,0,0,0,0,u7 }
                     91:        ,
                     92:        {
                     93:                SbCrock("$result"),stReg, false, 0, btInt, 0,0,0,0,0,0, u7      }
                     94:        ,
                     95: #endif
                     96:        {
                     97:                SbCrock("$fp"), stReg, false, 0, btInt, 0,0,0,0,0,0, ufp        }
                     98:        ,
                     99:        {
                    100:                SbCrock("$sp"), stReg, false, 0, btInt, 0,0,0,0,0,0, usp        }
                    101:        ,
                    102:        {
                    103:                SbCrock("$pc"), stReg, false, 0, btInt, 0,0,0,0,0,0, upc        }
                    104:        ,
                    105: #ifdef BSD41
                    106: #ifndef TAHOE
                    107:        {
                    108:                SbCrock("$ap"), stReg, false, 0, btInt, 0,0,0,0,0,0, uap        }
                    109:        ,
                    110: #endif
                    111:        {
                    112:                SbCrock("$long"),       stReg, false, 0, btLong, 0,0,0,0,0,0,u0 }
                    113:        ,
                    114:        {
                    115:                SbCrock("$short"),      stReg, false, 0, btShort,0,0,0,0,0,0,u0 }
                    116:        ,
                    117:        {
                    118:                SbCrock("$result"),stReg, false, 0, btInt, 0,0,0,0,0,0, u0      }
                    119:        ,
                    120:        /* following allows us to diddle certain internal variables */
                    121: #endif
                    122: };
                    123: #endif
                    124: 
                    125: #ifdef M68000
                    126: TYR    vrgTySpc[] = {  /* array of register special variables */
                    127:        /* the following allows us to diddle certain internal variables */
                    128:        {
                    129:                SbCrock("$lang"),       stSpc,false,  0, 0,0,0,0,0,0,btInt,(ulong)&vlc  }
                    130:        ,
                    131:        {
                    132:                SbCrock("$cBad"),stSpc,false,0,0,0,0,0,0,0,btInt,(ulong)&vcBadMax       }
                    133:        ,
                    134:        /* and now the registers */
                    135:        {
                    136:                SbCrock("$result"),stReg, false, 0, 0,0,0,0,0,0, btLong, ud0    }
                    137:        ,
                    138:        {
                    139:                SbCrock("$long"),       stReg, false, 0, 0,0,0,0,0,0, btLong, ud0       }
                    140:        ,
                    141:        {
                    142:                SbCrock("$short"),      stReg, false, 0, 0,0,0,0,0,0, btLong, ud0       }
                    143:        ,
                    144:        {
                    145:                SbCrock("$a0"), stReg, false, 0, 0,0,0,0,0,0, btLong, ua0       }
                    146:        ,
                    147:        {
                    148:                SbCrock("$a1"), stReg, false, 0, 0,0,0,0,0,0, btLong, ua1       }
                    149:        ,
                    150:        {
                    151:                SbCrock("$a2"), stReg, false, 0, 0,0,0,0,0,0, btLong, ua2       }
                    152:        ,
                    153:        {
                    154:                SbCrock("$a3"), stReg, false, 0, 0,0,0,0,0,0, btLong, ua3       }
                    155:        ,
                    156:        {
                    157:                SbCrock("$a4"), stReg, false, 0, 0,0,0,0,0,0, btLong, ua4       }
                    158:        ,
                    159:        {
                    160:                SbCrock("$a5"), stReg, false, 0, 0,0,0,0,0,0, btLong, ua5       }
                    161:        ,
                    162:        {
                    163:                SbCrock("$a6"), stReg, false, 0, 0,0,0,0,0,0, btLong, ua6       }
                    164:        ,
                    165:        {
                    166:                SbCrock("$a7"), stReg, false, 0, 0,0,0,0,0,0, btLong, ua7       }
                    167:        ,
                    168:        {
                    169:                SbCrock("$d0"), stReg, false, 0, 0,0,0,0,0,0, btLong, ud0       }
                    170:        ,
                    171:        {
                    172:                SbCrock("$d1"), stReg, false, 0, 0,0,0,0,0,0, btLong, ud1       }
                    173:        ,
                    174:        {
                    175:                SbCrock("$d2"), stReg, false, 0, 0,0,0,0,0,0, btLong, ud2       }
                    176:        ,
                    177:        {
                    178:                SbCrock("$d3"), stReg, false, 0, 0,0,0,0,0,0, btLong, ud3       }
                    179:        ,
                    180:        {
                    181:                SbCrock("$d4"), stReg, false, 0, 0,0,0,0,0,0, btLong, ud4       }
                    182:        ,
                    183:        {
                    184:                SbCrock("$d5"), stReg, false, 0, 0,0,0,0,0,0, btLong, ud5       }
                    185:        ,
                    186:        {
                    187:                SbCrock("$d6"), stReg, false, 0, 0,0,0,0,0,0, btLong, ud6       }
                    188:        ,
                    189:        {
                    190:                SbCrock("$d7"), stReg, false, 0, 0,0,0,0,0,0, btLong, ud7       }
                    191:        ,
                    192:        {
                    193:                SbCrock("$fp"), stReg, false, 0, 0,0,0,0,0,0, btLong, ufp       }
                    194:        ,
                    195:        {
                    196:                SbCrock("$sp"), stReg, false, 0, 0,0,0,0,0,0, btLong, usp       }
                    197:        ,
                    198:        {
                    199:                SbCrock("$pc"), stReg, false, 0, 0,0,0,0,0,0, btLong, upc       }
                    200:        ,
                    201:        {
                    202:                SbCrock("$ps"), stReg, false, 0, 0,0,0,0,0,0, btLong, ups       }
                    203:        ,
                    204: };
                    205: #endif
                    206: int    vispcMac = sizeof(vrgTySpc) / cbTYR;
                    207: 
                    208: 
                    209: /* I N I T   S P C */
                    210: 
                    211: export void InitSpc()
                    212: {
                    213:        int             i;
                    214:        TYR             aty;
                    215: 
                    216:        vrgTyLv = (pTYR) malloc((vilvMax+1)*cbTYR);     /* KLUDGE!! */
                    217:        vcbTot += vilvMax * cbTYR;
                    218:        aty = *vtyLong; /* they are all basically long */
                    219:        aty.td.st = stSpc;
                    220:        for (i=0; i< vilvMax; i++)
                    221:                CopyTy(vrgTyLv+i, &aty); /* init various fields in the specials */
                    222: #ifdef BSD41
                    223:        /* this crock is due to string space/pointer problem */
                    224:        for (i=0; i < vispcMac; i++)
                    225:                vrgTySpc[i].sbVar |= bitHigh;
                    226: #endif
                    227: } /* InitSpc */
                    228: 
                    229: 
                    230: /* F   A D R   F   S P E C I A L */
                    231: 
                    232: export FLAGT FAdrFSpecial(sbSpc, rgTy, padr)
                    233: char   *sbSpc;
                    234: TYR    rgTy[];
                    235: pADRT  padr;
                    236: {
                    237:        int     i;
                    238: 
                    239:        /* first check the predefined specials */
                    240:        for (i=0; i < vispcMac; i++) {
                    241:                if (FSbCmp(SbInCore(vrgTySpc[i].sbVar), sbSpc)) {
                    242:                        CopyTy(rgTy, vrgTySpc+i);
                    243:                        *padr = vrgTySpc[i].valTy;
                    244:                        return(true);
                    245:                } /* if */
                    246:        } /* for */
                    247: 
                    248:        /* next check the user defined specials */
                    249:        for (i=0; i < vilvMac; i++) {
                    250:                if (FSbCmp(SbInCore(vrgTyLv[i].sbVar), sbSpc)) {
                    251:                        CopyTy(rgTy, vrgTyLv+i);
                    252:                        *padr = (ADRT) &(vrgTyLv[i].valTy);
                    253:                        return(true);
                    254:                } /* if */
                    255:        } /* for */
                    256: 
                    257:        /* no luck = try to define a new special with this name */
                    258:        if (vilvMac >= vilvMax)
                    259:                UError("No room to define local - %s", sbSpc);
                    260:        i = vilvMac++;
                    261: #ifdef SYSIII
                    262:        strncpy(vrgTyLv[i].sbVar, sbSpc, cbVarMax);
                    263: #endif
                    264: #ifdef BSD41
                    265:        vrgTyLv[i].sbVar = (int) malloc(strlen(sbSpc)+2);
                    266:        strcpy(vrgTyLv[i].sbVar, sbSpc);
                    267:        vrgTyLv[i].sbVar |= bitHigh;
                    268: #endif
                    269: 
                    270:        CopyTy(rgTy, vrgTyLv+i);
                    271:        *padr = (ADRT) &(vrgTyLv[i].valTy);
                    272:        return(true);
                    273: } /* FAdrFSpecial */
                    274: 
                    275: 
                    276: /* A D R   F   L O C A L */
                    277: 
                    278: export ADRT AdrFLocal(ipd, cnt, sbVar, rgTy)
                    279: int    ipd, cnt;
                    280: char   *sbVar;
                    281: TYR    rgTy[];
                    282: {
                    283:        ADRT    fp, ap;
                    284:        ADRT    adr;
                    285: 
                    286:        FpApFIpd(&fp, &ap, ipd, cnt);
                    287:        if (fp == 0)
                    288:                return(adrNil);
                    289: 
                    290:        SetNext(vrgPd[ipd].isym+1);
                    291:        if (!FNextLocal(true, true, sbVar)) {
                    292:                return(adrNil);
                    293:        } /* if */
                    294: 
                    295: #ifdef SYSIII
                    296:        if ((vsymCur->type == N_ABS) AND (vsymCur->value == 1))
                    297:                UError("Compiler wart involving register parameters - sorry");
                    298: #endif
                    299:        adr = vsymCur->value;
                    300:        TyFLocal(rgTy, sbVar, visym);
                    301: 
                    302: #ifdef BSD41
                    303:        if (vsymCur->type == stParam)
                    304:                adr = ap + adr;
                    305:        else if (vsymCur->type == stLocal)
                    306:                adr = fp - abs(adr);
                    307: #endif
                    308: #ifdef SYSIII
                    309:        adr += fp;
                    310: #endif
                    311:        /* things of type stReg do NOT get modified - may want to do look up
                    312:             * some day, but this is almost impossible on ONYX
                    313:             */
                    314:        return(adr);
                    315: } /* AdrFLocal */
                    316: 
                    317: 
                    318: /* A D R   F   G L O B A L */
                    319: 
                    320: export ADRT AdrFGlobal(sbVar, rgTy)
                    321: char   *sbVar;
                    322: TYR    rgTy[];
                    323: {
                    324:        ADRT    adrRet;
                    325:        char    sbTemp[cbVarMax+3];
                    326: 
                    327:        adrRet = adrNil;
                    328:        /* first we check for `_foo' */
                    329:        sbTemp[0] = '_';
                    330:        strcpy((sbTemp+1), sbVar);
                    331:        sbTemp[cbVarMax] = chNull;
                    332:        SetNext(visymGlobal);
                    333:        if (FNextSym(N_DATA, N_BSS, 0, sbTemp, FProcCmp)) {
                    334:                adrRet = vsymCur->value;
                    335:        } 
                    336:        else {
                    337:                /* no luck, try just plain `foo' */
                    338:                sbVar[cbVarMax] = chNull;
                    339:                SetNext(visymGlobal);
                    340:                if (FNextSym(N_DATA, N_BSS, 0, sbVar, FProcCmp)) {
                    341:                        adrRet = vsymCur->value;
                    342:                } /* if */
                    343:        } /* if */
                    344:        if (adrRet != adrNil)
                    345:                TyFGlobal(rgTy, sbVar);
                    346:        return(adrRet);
                    347: } /* AdrFGlobal */
                    348: 
                    349: 
                    350: /* A D R   F   L A B E L */
                    351: 
                    352: export ADRT AdrFLabel(sbVar)
                    353: char   *sbVar;
                    354: {
                    355:        char    sbTemp[cbVarMax+2];
                    356: 
                    357:        /* first we check for `_foo' */
                    358:        sbTemp[0] = '_';
                    359:        strcpy((sbTemp+1), sbVar);
                    360:        sbTemp[cbVarMax] = chNull;
                    361:        SetNext(visymGlobal);
                    362:        if (FNextSym(N_TEXT, 0, 0, sbTemp, FProcCmp)) {
                    363:                return(vsymCur->value);
                    364:        } 
                    365:        else {
                    366:                /* no luck, try just plain `foo' */
                    367:                sbVar[cbVarMax] = chNull;
                    368:                SetNext(visymGlobal);
                    369:                if (FNextSym(N_TEXT, 0, 0, sbVar, FProcCmp))
                    370:                        return(vsymCur->value);
                    371:        } /* if */
                    372:        return(adrNil);
                    373: } /* AdrFLabel */
                    374: 
                    375: 
                    376: /* C B   F   L O C A L */
                    377: 
                    378: export int CbFLocal(isym)
                    379: long   isym;
                    380: {
                    381: #ifdef BSD41
                    382:        SYMR    rgSym[2];
                    383: 
                    384:        SetSym(isym);
                    385:        rgSym[0] = *vsymCur;
                    386:        SetSym(isym+1); /* second one might not be in core */
                    387:        rgSym[1] = *vsymCur;
                    388:        return(CbFTy(rgSym));   /* sort of a hack, but it IS correct */
                    389: #endif
                    390: #ifdef SYSIII
                    391:        int             cb, val;
                    392:        long    isymSave;
                    393: 
                    394:        /* boy is this section MACHINE DEPENDENT !! */
                    395:        isymSave = isym;
                    396:        SetSym(isym);
                    397:        val = vsymCur->value;
                    398:        if (FOdd(val))
                    399:                cb = 1; /* this assumes that only one byte entities have odd adresses */
                    400:        else if (val > 0) {
                    401:                /* it's a parameter */
                    402:                do {
                    403:                        SetSym(++isym); /* we need to look at the next one */
                    404:                } 
                    405:                while (vsymCur->type == N_REG);
                    406:                if ((vsymCur->type != N_ABS) OR ((int) (vsymCur->value) < 0))
                    407:                        /* this means we don't know size of last param. kludge! */
                    408:                        cb = CBINT;
                    409:                else cb = vsymCur->value - val;
                    410:        } 
                    411:        else {
                    412:                /* it's a local */
                    413:                SetSym(isym-1); /* we need to look at the previous one */
                    414:                if ((vsymCur->type != N_ABS) OR ((int) (vsymCur->value) >= 0))
                    415: #ifdef REGULUS
                    416:                        cb = 0 - val;
                    417: #else
                    418:                cb = -12 - val;
                    419: #endif
                    420:                else cb = vsymCur->value - val;
                    421:        } /* if */
                    422: 
                    423:        SetSym(isymSave);
                    424:        return(cb);
                    425: #endif
                    426: } /* CbFLocal */
                    427: 
                    428: 
                    429: /* F P   A P   F   I P D */
                    430: 
                    431: export void FpApFIpd(pfp, pap, ipd, cnt)
                    432: pADRT  pfp, pap;
                    433: int    ipd, cnt;
                    434: {
                    435:        int             depth, ipdX;
                    436:        ADRT    pc;
                    437:        FLAGT   fDontCare;
                    438: 
                    439:        if (fDontCare = (cnt == -1))
                    440:                cnt = 10000;
                    441: 
                    442:        depth = 0;
                    443:        *pfp = vfp;
                    444:        *pap = vap;
                    445:        pc = vpc;
                    446:        while (*pfp != 0) {
                    447:                ipdX = IpdFAdr(pc);
                    448:                if (ipdX == ipd) {
                    449:                        if ((fDontCare) OR (cnt == depth))
                    450:                                return;
                    451:                } /* if */
                    452:                if (cnt < depth)
                    453:                        UError("Procedure '%s' is not at that stack depth",
                    454:                        vrgPd[ipd].sbProc);
                    455:                depth++;
                    456:                NextFrame(pfp, pap, &pc);
                    457:        } /* for */
                    458:        return;
                    459: } /* FpApFIpd */
                    460: 
                    461: 
                    462: /* N E X T   F R A M E */
                    463: 
                    464: export void NextFrame(pfp, pap, ppc)
                    465: ADRT   *pfp, *pap, *ppc;
                    466: {
                    467:        /* we either give them the vbalues for the next frame
                    468:                 * OR we give them a new fp of 0
                    469:                 */
                    470: #ifdef ONYX
                    471:        *ppc = GetWord(*pfp+CBINT, spaceData);
                    472:        *pfp = GetWord(*pfp, spaceData);
                    473:        *pap = *pfp;    /* they are the same for most non-vax systems */
                    474: #endif
                    475: #ifdef M68000
                    476: #ifndef SUN
                    477:        *ppc = GetWord(*pfp+CBLONG, spaceData);
                    478:        *pfp = GetWord(*pfp, spaceData);
                    479:        *pap = *pfp;    /* they are the same for most non-vax systems */
                    480: #endif
                    481: #endif
                    482: #ifdef BSD41
                    483: #ifdef SUN
                    484:        *ppc = GetWord(*pfp+CBLONG, spaceData);
                    485:        *pfp = GetWord(*pfp, spaceData);
                    486:        *pap = *pfp;    /* they are the same for most non-vax systems */
                    487: #endif
                    488: 
                    489: #ifdef TAHOE
                    490:        *ppc = GetWord(*pfp-8, spaceData);
                    491:        *pap = GetWord(*pfp, spaceData);
                    492:        *pfp = GetWord(*pfp, spaceData) ;       /* force to even byte */
                    493: #endif
                    494: 
                    495: #ifdef VAX
                    496:        *ppc = GetWord(*pfp+16, spaceData);
                    497:        *pap = GetWord(*pfp+8, spaceData);
                    498:        *pfp = GetWord(*pfp+12, spaceData) & ~1;        /* force to even byte */
                    499:        if (*ppc > 0x70000000) {
                    500:                /* it looks like we have some error handler magic here */
                    501:                *ppc = GetWord(*pfp+64, spaceData) - 1; /* back up pc by 1 */
                    502:                *pap = GetWord(*pfp+8, spaceData);
                    503:                *pfp = GetWord(*pfp+12, spaceData) & ~1;        /* force to even byte */
                    504:        }
                    505: #endif
                    506:        if (*pfp & 0xf0000000 != 0x70000000)
                    507:                Panic("Non-kosher frame pointer");
                    508:        /* see if this is the 'start' frame */
                    509:        if (vrgFd[0].adrStart > *ppc) {
                    510:                *pfp = 0;
                    511:        } /* if */
                    512:        if ((vfPascal)
                    513:            AND (*ppc > vadrMain)
                    514:            AND (*ppc < vadrStart)) {
                    515:                *pfp = 0;       /* this is pascal's version of the start code */
                    516:        }
                    517: #endif
                    518: } /* NextFrame */
                    519: 
                    520: 
                    521: /* D I S P   F R A M E */
                    522: 
                    523: export void DispFrame(pc, ipd, fp, ap, cnt, fDoLocals, fDoVal)
                    524: ADRT   pc;
                    525: int    ipd, cnt;
                    526: ADRT   fp, ap;
                    527: FLAGT  fDoLocals, fDoVal;
                    528: {
                    529:        int             ifd, ln, slop, i;
                    530:        char    sbName[50];
                    531:        long    val, isymSave, isym, adrLong;
                    532:        TYR             rgTy[cTyMax];
                    533: 
                    534:        printf("%s(", vrgPd[ipd].sbProc);
                    535:        SetNext(vrgPd[ipd].isym+1);
                    536:        i = 0;
                    537:        while (FNextLocal(false, true, sbNil)) {
                    538:                isymSave = visym;
                    539:                val = vsymCur->value;
                    540:                TyFLocal(rgTy, SbInCore(vsymCur->sbSym+vcbVarHdr), visym);
                    541:                if (i++)
                    542:                        printf(", ");
                    543:                if (fDoVal) {
                    544: #ifdef BSD41
                    545:                        printf("%s=", SbInCore(rgTy[0].sbVar));
                    546: #else
                    547:                        printf("%.8s=", SbInCore(rgTy[0].sbVar));
                    548: #endif
                    549:                        adrLong = val + ap;
                    550:                        DispVal(adrLong, rgTy, modeNil, false, true, false);
                    551:                } 
                    552:                else {
                    553:                        /* they just want to know what the args are */
                    554:                        PxTy(rgTy);
                    555:                } /* if */
                    556:                visym = isymSave;
                    557:        } /* while */
                    558:        printf(")");
                    559:        if (pc != adrNil) {
                    560:                isymSave = visym;
                    561:                isym = vrgPd[ipd].isym;
                    562:                IfdLnFAdr(pc, isym, &ifd, &ln, &slop);
                    563:                printf("    [%s:%d]", vrgFd[ifd].sbFile, ln);
                    564:                visym = isymSave;
                    565:        } /* if */
                    566:        if (fDoLocals) {
                    567:                SetNext(visym);
                    568:                vcNest++;       /* in case we have structure to indent */
                    569:                while (FNextLocal(true, false, sbNil)) {
                    570:                        strcpy(sbName, SbInCore(vsymCur->sbSym+vcbVarHdr));
                    571:                        isym = visym;
                    572:                        adrLong = AdrFLocal(ipd, cnt, sbName, rgTy);
                    573:                        printf("\n      ");
                    574:                        DispVal(adrLong, rgTy, modeNil, true, true, true);
                    575:                        SetSym(isym);
                    576:                } /* while */
                    577:                vcNest--;
                    578:        } /* if */
                    579:        printf("\n");
                    580: } /* DispFrame */
                    581: 
                    582: 
                    583: /* D I S P   U N K N O W N */
                    584: 
                    585: export void DispUnknown(pc, fp, ap)
                    586: ADRT   pc, fp, ap;
                    587: {
                    588:        int             i;
                    589: #ifdef TAHOE
                    590:        int     real_no_args;
                    591: #endif
                    592: 
                    593:        LabelFAdr(pc);  /* sets vsymCur to nearest label */
                    594:        printf("%s", SbInCore(vsymCur->sbSym));
                    595:        if (vsymCur->value != pc)
                    596:                printf("+%s",SbFAdr(lengthen(pc-vsymCur->value), true));
                    597:        /* we print what LOOK like the first N parameters */
                    598:        printf("(");
                    599: #ifdef ONYX
                    600:        ap += 4;
                    601: #endif
                    602: #ifdef TAHOE
                    603:        real_no_args = ( (GetWord(fp-4, spaceData) & 0xffff) -4) /4;
                    604: #endif
                    605: #ifdef VAX
                    606:        ap += 4;
                    607: #endif
                    608: #ifdef M68000
                    609:        ap += 4;
                    610: #endif
                    611: #define cArgsMax 5
                    612: 
                    613: #ifdef TAHOE
                    614:        for (i=0; i<real_no_args; i++) {
                    615: #else
                    616:                for (i=0; i<cArgsMax; i++) {
                    617: #endif
                    618:                        printf("%d%s", GetWord(ap, spaceData), (i<cArgsMax-1) ? ", " : "");
                    619:                        ap += CBINT;
                    620:                }
                    621:                printf(")\n");
                    622:        } /* DispUnknown */
                    623: 
                    624: 
                    625:        /* S T A C K   T R A C E */
                    626: 
                    627:        export void StackTrace(cnt, fDoLocals)
                    628:                int     cnt;
                    629:        FLAGT   fDoLocals;
                    630:        {
                    631:                int     ipd, i;
                    632:                ADRT    pc, fp, ap;
                    633: 
                    634:                fp = vfp;
                    635:                pc = vpc;
                    636:                ap = vap;
                    637:                for (i=0; ((i < cnt) AND (fp != 0)); i++) {
                    638:                        ipd = IpdFAdr(pc);
                    639:                        if (ipd == ipdNil) {
                    640:                                printf("%2d ", i);
                    641:                                DispUnknown(pc, fp, ap);
                    642:                        } 
                    643:                        else {
                    644:                                printf("%2d ", i);
                    645:                                DispFrame(pc, ipd, fp, ap, i, fDoLocals, true);
                    646:                        } /* if */
                    647:                        NextFrame(&fp, &ap, &pc);
                    648:                } /* for */
                    649:        } /* StackTrace */
                    650: 
                    651: 
                    652:        /* L I S T   R E G S */
                    653: 
                    654:        export void ListRegs(sbRegs)
                    655:                char    *sbRegs;
                    656:        {
                    657:                int             i;
                    658:                long    adr;
                    659:                TYR             ty;
                    660: 
                    661:                /* first check the predefined specials */
                    662:                for (i=0; i < vispcMac; i++) {
                    663:                        if ((vrgTySpc[i].td.st != stReg)
                    664:                            OR (sbRegs != sbNil)
                    665:                            AND (!FHdrCmp(sbRegs, SbInCore(vrgTySpc[i].sbVar)))) 
                    666:                                continue;       /* not interesting */
                    667:                        ty = vrgTySpc[i];
                    668:                        adr = vrgTySpc[i].valTy;
                    669:                        DispVal(adr, &ty, modeNil, true, true, true);
                    670:                        printf("\n");
                    671:                } /* for */
                    672:        } /* ListRegs */
                    673: 
                    674: 
                    675:        /* L I S T   S P E C I A L */
                    676: 
                    677:        export void ListSpecial(sbSpecial)
                    678:                char    *sbSpecial;
                    679:        {
                    680:                int             i;
                    681:                long    adr;
                    682:                TYR             ty;
                    683: 
                    684:                /* first check the predefined specials */
                    685:                for (i=0; i < vispcMac; i++) {
                    686:                        if ((vrgTySpc[i].td.st == stReg)
                    687:                            OR (sbSpecial != sbNil)
                    688:                            AND (!FHdrCmp(sbSpecial, SbInCore(vrgTySpc[i].sbVar)))) 
                    689:                                continue;       /* not interesting */
                    690:                        ty = vrgTySpc[i];
                    691:                        adr = vrgTySpc[i].valTy;
                    692:                        DispVal(adr, &ty, modeNil, true, true, true);
                    693:                        printf("\n");
                    694:                } /* for */
                    695: 
                    696:                /* next do user defined stuff */
                    697:                for (i=0; i<vilvMac ; i++) {
                    698:                        if ((sbSpecial != sbNil)
                    699:                            AND (!FHdrCmp(sbSpecial, SbInCore(vrgTyLv[i].sbVar))))
                    700:                                continue;       /* not interesting */
                    701:                        adr = (long) &(vrgTyLv[i].valTy);
                    702:                        DispVal(adr, vrgTyLv+i, modeNil, true, true, true);
                    703:                        printf("\n");
                    704:                } /* for */
                    705:        } /* ListSpecial */
                    706: 
                    707: 
                    708:        /* L A B E L   F   A D R */
                    709: 
                    710:        export void LabelFAdr(adr)
                    711:                ADRT    adr;
                    712:        {
                    713:                long    isymNearest;
                    714:                ADRT    adrLabel, adrNearest;
                    715:                /* returns isym of nearest TEXT Label <= adr */
                    716: 
                    717:                adrNearest = 0;
                    718:                SetNext(visymGlobal);
                    719:                while (FNextSym(N_TEXT, 0, 0, sbNil, nil)) {
                    720:                        if ((vsymCur->type & N_EXT) == 0)
                    721:                                continue;
                    722:                        adrLabel = vsymCur->value;
                    723:                        if ( (adrLabel <= adr)
                    724:                            AND (adrLabel >= adrNearest) ) {
                    725:                                isymNearest = visym;
                    726:                                adrNearest = adrLabel;
                    727:                        } /* if */
                    728:                } /* while */
                    729:                SetSym(isymNearest);
                    730:        } /* LabelFAdr */
                    731: 
                    732: 
                    733:        /* O P E N   S T A C K */
                    734: 
                    735:        export void OpenStack(cnt)
                    736:                int     cnt;
                    737:        {
                    738:                int             cntIn;
                    739:                ADRT    pc, fp, ap;
                    740: 
                    741:                cntIn = cnt;
                    742:                fp = vfp;
                    743:                ap = vap;
                    744:                pc = vpc;
                    745:                while (cnt-- AND fp)
                    746:                        NextFrame(&fp, &ap, &pc);
                    747:                if (fp == 0)
                    748:                        UError("Stack isn't that deep!");
                    749: 
                    750: #ifdef VAX
                    751:                if (cntIn != 0)
                    752:                        pc -= 1;
                    753: #endif
                    754:                PrintPos(pc, fmtFile+fmtProc+fmtLn+fmtPrint);
                    755:        } /* OpenStack */

unix.superglobalmegacorp.com

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