VirtualBox

Changeset 46934 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jul 3, 2013 1:26:47 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86939
Message:

dbgmodcodeview.cpp: Forced the code to deal with the bios symbol files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/dbg/dbgmodcodeview.cpp

    r46282 r46934  
    1313 *  - "High Level Languages Debug Table Documentation", aka HLLDBG.HTML, aka
    1414 *     IBMHLL.HTML, last changed 1996-07-08.
     15 *
     16 * Testcases using RTLdrFlt:
     17 *     - VBoxPcBios.sym at 0xf0000.
     18 *     - NT4 kernel PE image (coff syms).
    1519 */
    1620
     
    446450
    447451
     452/**
     453 * Directory sorting order.
     454 */
     455typedef enum RTCVDIRORDER
     456{
     457    RTCVDIRORDER_INVALID = 0,
     458    /** Ordered by module. */
     459    RTCVDIRORDER_BY_MOD,
     460    /** Ordered by module, but 0 modules at the end. */
     461    RTCVDIRORDER_BY_MOD_0,
     462    /** Ordered by section, with global modules at the end. */
     463    RTCVDIRORDER_BY_SST_MOD
     464} RTCVDIRORDER;
    448465
    449466
     
    487504    /** The offset of the subsection directory (relative to offBase). */
    488505    uint32_t        offDir;
     506    /** The directory order. */
     507    RTCVDIRORDER    enmDirOrder;
    489508    /** @}  */
    490509
     
    511530    /** Indicates that we've loaded segments intot he container already. */
    512531    bool            fHaveLoadedSegments;
     532    /** Alternative address translation method for DOS frames. */
     533    bool            fHaveDosFrames;
    513534
    514535    /** @name Codeview Parsing state.
     
    566587            Log(("RTDbgCv: Check failed on line %d: " #a_Expr "\n", __LINE__)); \
    567588            Log(a_LogArgs); \
    568             return VERR_CV_BAD_FORMAT; \
     589            /*return VERR_CV_BAD_FORMAT;*/ \
    569590        } \
    570591    } while (0)
     
    577598        { \
    578599            Log(("RTDbgCv: Check failed on line %d: " #a_Expr "\n", __LINE__)); \
    579             return VERR_CV_BAD_FORMAT; \
     600            /*return VERR_CV_BAD_FORMAT;*/ \
    580601        } \
    581602    } while (0)
     
    705726        return VERR_NO_STR_MEMORY;
    706727#if 1
     728    Log2(("CV Sym: %04x:%08x %.*s\n", iSeg, off, cchName, pchName));
    707729    if (iSeg == 0)
    708730        iSeg = RTDBGSEGIDX_ABS;
    709731    else if (pThis->pSegMap)
    710732    {
    711         if (   iSeg > pThis->pSegMap->Hdr.cSegs
    712             || iSeg == 0
    713             || off > pThis->pSegMap->aDescs[iSeg - 1].cb)
     733        if (pThis->fHaveDosFrames)
    714734        {
    715             Log(("Invalid segment index/offset %#06x:%08x for symbol %.*s\n", iSeg, off, cchName, pchName));
    716             return VERR_CV_BAD_FORMAT;
     735            if (   iSeg > pThis->pSegMap->Hdr.cSegs
     736                || iSeg == 0)
     737            {
     738                Log(("Invalid segment index/offset %#06x:%08x for symbol %.*s\n", iSeg, off, cchName, pchName));
     739                return VERR_CV_BAD_FORMAT;
     740            }
     741            if (off <= pThis->pSegMap->aDescs[iSeg - 1].cb + pThis->pSegMap->aDescs[iSeg - 1].off)
     742                off -= pThis->pSegMap->aDescs[iSeg - 1].off;
     743            else
     744            {
     745                /* Workaround for VGABIOS where _DATA symbols like vgafont8 are
     746                   reported in the VGAROM segment. */
     747                uint64_t uAddrSym = off + ((uint32_t)pThis->pSegMap->aDescs[iSeg - 1].iFrame << 4);
     748                uint16_t j = pThis->pSegMap->Hdr.cSegs;
     749                while (j-- > 0)
     750                {
     751                    uint64_t uAddrFirst = (uint64_t)pThis->pSegMap->aDescs[j].off
     752                                        + ((uint32_t)pThis->pSegMap->aDescs[j].iFrame << 4);
     753                    if (uAddrSym - uAddrFirst < pThis->pSegMap->aDescs[j].cb)
     754                    {
     755                        Log(("CV addr fix: %04x:%08x -> %04x:%08x\n", iSeg, off, j + 1, uAddrSym - uAddrFirst));
     756                        off  = uAddrSym - uAddrFirst;
     757                        iSeg = j + 1;
     758                        break;
     759                    }
     760                }
     761                if (j == UINT16_MAX)
     762                {
     763                    Log(("Invalid segment index/offset %#06x:%08x for symbol %.*s [2]\n", iSeg, off, cchName, pchName));
     764                    return VERR_CV_BAD_FORMAT;
     765                }
     766            }
    717767        }
    718         off += pThis->pSegMap->aDescs[iSeg - 1].off;
     768        else
     769        {
     770            if (   iSeg > pThis->pSegMap->Hdr.cSegs
     771                || iSeg == 0
     772                || off > pThis->pSegMap->aDescs[iSeg - 1].cb)
     773            {
     774                Log(("Invalid segment index/offset %#06x:%08x for symbol %.*s\n", iSeg, off, cchName, pchName));
     775                return VERR_CV_BAD_FORMAT;
     776            }
     777            off += pThis->pSegMap->aDescs[iSeg - 1].off;
     778        }
    719779        if (pThis->pSegMap->aDescs[iSeg - 1].fFlags & RTCVSEGMAPDESC_F_ABS)
    720780            iSeg = RTDBGSEGIDX_ABS;
     
    938998
    939999    /*
     1000     * The PE image has an extra section/segment for the headers, the others
     1001     * doesn't.  PE images doesn't have DOS frames. So, figure the image type now.
     1002     */
     1003    RTLDRFMT enmImgFmt = RTLDRFMT_INVALID;
     1004    if (pThis->pMod->pImgVt)
     1005        enmImgFmt = pThis->pMod->pImgVt->pfnGetFormat(pThis->pMod);
     1006
     1007    /*
    9401008     * Validate and display it all.
    9411009     */
     
    9461014
    9471015    Log2(("Logical segment descriptors: %u\n", pHdr->cLogSegs));
     1016
     1017    bool fHaveDosFrames = false;
    9481018    for (i = 0; i < pHdr->cSegs; i++)
    9491019    {
     
    9971067        {
    9981068            RTDBGMODCV_CHECK_NOMSG_RET_BF(paDescs[i].iGroup == 0);
    999             RTDBGMODCV_CHECK_NOMSG_RET_BF(paDescs[i].off == 0);
     1069            if (   !fHaveDosFrames
     1070                && paDescs[i].iFrame != 0
     1071                && (paDescs[i].fFlags & (RTCVSEGMAPDESC_F_SEL | RTCVSEGMAPDESC_F_ABS))
     1072                && paDescs[i].iOverlay == 0
     1073                && enmImgFmt != RTLDRFMT_PE
     1074                && enmImgFmt != RTCVFILETYPE_DBG)
     1075                fHaveDosFrames = true; /* BIOS, only groups with frames. */
    10001076        }
     1077    }
     1078
     1079    /*
     1080     * Further valiations based on fHaveDosFrames or not.
     1081     */
     1082    if (fNoGroups)
     1083    {
     1084        if (fHaveDosFrames)
     1085            for (i = 0; i < pHdr->cSegs; i++)
     1086            {
     1087                RTDBGMODCV_CHECK_NOMSG_RET_BF(paDescs[i].iOverlay == 0);
     1088                RTDBGMODCV_CHECK_NOMSG_RET_BF(      (paDescs[i].fFlags & (RTCVSEGMAPDESC_F_SEL | RTCVSEGMAPDESC_F_ABS))
     1089                                                 == RTCVSEGMAPDESC_F_SEL
     1090                                              ||    (paDescs[i].fFlags & (RTCVSEGMAPDESC_F_SEL | RTCVSEGMAPDESC_F_ABS))
     1091                                                 == RTCVSEGMAPDESC_F_ABS);
     1092                RTDBGMODCV_CHECK_NOMSG_RET_BF(!(paDescs[i].fFlags & RTCVSEGMAPDESC_F_ABS));
     1093            }
     1094        else
     1095            for (i = 0; i < pHdr->cSegs; i++)
     1096                RTDBGMODCV_CHECK_NOMSG_RET_BF(paDescs[i].off == 0);
    10011097    }
    10021098
     
    10101106    const char *pszGroup0 = NULL;
    10111107    uint64_t    cbGroup0  = 0;
    1012     if (!fNoGroups)
     1108    if (!fNoGroups && !fHaveDosFrames)
    10131109    {
    10141110        for (i = 0; i < pHdr->cSegs; i++)
     
    10301126    if (!pThis->fHaveLoadedSegments)
    10311127    {
    1032         Assert(!pThis->pMod->pImgVt); Assert(pThis->enmType != RTCVFILETYPE_DBG);
    10331128        uint16_t iSeg = 0;
    1034         uint64_t uRva = 0;
    1035         if (cbGroup0 && !fNoGroups)
     1129        if (!fHaveDosFrames)
    10361130        {
    1037             rc = RTDbgModSegmentAdd(pThis->hCnt, 0, cbGroup0, pszGroup0 ? pszGroup0 : "Seg00", 0 /*fFlags*/, NULL);
    1038             uRva += cbGroup0;
    1039             iSeg++;
     1131            Assert(!pThis->pMod->pImgVt); Assert(pThis->enmType != RTCVFILETYPE_DBG);
     1132            uint64_t uRva = 0;
     1133            if (cbGroup0 && !fNoGroups)
     1134            {
     1135                rc = RTDbgModSegmentAdd(pThis->hCnt, 0, cbGroup0, pszGroup0 ? pszGroup0 : "Seg00", 0 /*fFlags*/, NULL);
     1136                uRva += cbGroup0;
     1137                iSeg++;
     1138            }
     1139
     1140            for (i = 0; RT_SUCCESS(rc) && i < pHdr->cSegs; i++)
     1141                if ((paDescs[i].fFlags & RTCVSEGMAPDESC_F_GROUP) || fNoGroups)
     1142                {
     1143                    char szName[16];
     1144                    char *pszName = szName;
     1145                    if (paDescs[i].offSegName != UINT16_MAX)
     1146                        pszName = pThis->pszzSegNames + paDescs[i].offSegName;
     1147                    else
     1148                        RTStrPrintf(szName, sizeof(szName), "Seg%02u", iSeg);
     1149                    rc = RTDbgModSegmentAdd(pThis->hCnt, uRva, paDescs[i].cb, pszName, 0 /*fFlags*/, NULL);
     1150                    uRva += paDescs[i].cb;
     1151                    iSeg++;
     1152                }
    10401153        }
    1041 
    1042         for (i = 0; RT_SUCCESS(rc) && i < pHdr->cSegs; i++)
    1043             if ((paDescs[i].fFlags & RTCVSEGMAPDESC_F_GROUP) || fNoGroups)
    1044             {
     1154        else
     1155        {
     1156            /* The map is not sorted by RVA, very annoying, but I'm countering
     1157               by being lazy and slow about it. :-) Btw. this is the BIOS case. */
     1158            Assert(fNoGroups);
     1159#if 1 /** @todo need more inputs */
     1160
     1161            /* Figure image base address. */
     1162            uint64_t uImageBase = UINT64_MAX;
     1163            for (i = 0; RT_SUCCESS(rc) && i < pHdr->cSegs; i++)
     1164            {
     1165                uint64_t uAddr = (uint64_t)paDescs[i].off + ((uint32_t)paDescs[i].iFrame << 4);
     1166                if (uAddr < uImageBase)
     1167                    uImageBase = uAddr;
     1168            }
     1169
     1170            /* Add the segments. */
     1171            uint64_t uMinAddr = uImageBase;
     1172            for (i = 0; RT_SUCCESS(rc) && i < pHdr->cSegs; i++)
     1173            {
     1174                /* Figure out the next one. */
     1175                uint16_t cOverlaps = 0;
     1176                uint16_t iBest     = UINT16_MAX;
     1177                uint64_t uBestAddr = UINT64_MAX;
     1178                for (uint16_t j = 0; j < pHdr->cSegs; j++)
     1179                {
     1180                    uint64_t uAddr = (uint64_t)paDescs[j].off + ((uint32_t)paDescs[j].iFrame << 4);
     1181                    if (uAddr >= uMinAddr && uAddr < uBestAddr)
     1182                    {
     1183                        uBestAddr = uAddr;
     1184                        iBest     = j;
     1185                    }
     1186                    else if (uAddr == uBestAddr)
     1187                    {
     1188                        cOverlaps++;
     1189                        if (paDescs[j].cb > paDescs[iBest].cb)
     1190                        {
     1191                            uBestAddr = uAddr;
     1192                            iBest     = j;
     1193                        }
     1194                    }
     1195                }
     1196                if (iBest == UINT16_MAX && RT_SUCCESS(rc))
     1197                {
     1198                    rc = VERR_CV_IPE;
     1199                    break;
     1200                }
     1201
     1202                /* Add it. */
    10451203                char szName[16];
    10461204                char *pszName = szName;
    1047                 if (paDescs[i].offSegName != UINT16_MAX)
    1048                     pszName = pThis->pszzSegNames + paDescs[i].offSegName;
     1205                if (paDescs[iBest].offSegName != UINT16_MAX)
     1206                    pszName = pThis->pszzSegNames + paDescs[iBest].offSegName;
    10491207                else
    10501208                    RTStrPrintf(szName, sizeof(szName), "Seg%02u", iSeg);
    1051                 rc = RTDbgModSegmentAdd(pThis->hCnt, uRva, paDescs[i].cb, pszName, 0 /*fFlags*/, NULL);
    1052                 uRva += paDescs[i].cb;
     1209                Log(("CV: %#010x LB %#010x %s uRVA=%#010x iBest=%u cOverlaps=%u\n",
     1210                     uBestAddr, paDescs[iBest].cb, szName, uBestAddr - uImageBase, iBest, cOverlaps));
     1211                rc = RTDbgModSegmentAdd(pThis->hCnt, uBestAddr - uImageBase, paDescs[iBest].cb, pszName, 0 /*fFlags*/, NULL);
     1212
     1213                /* Update translations. */
     1214                paDescs[iBest].iGroup = iSeg;
     1215                if (cOverlaps > 0)
     1216                {
     1217                    for (uint16_t j = 0; j < pHdr->cSegs; j++)
     1218                        if ((uint64_t)paDescs[j].off + ((uint32_t)paDescs[j].iFrame << 4) == uBestAddr)
     1219                            paDescs[iBest].iGroup = iSeg;
     1220                    i += cOverlaps;
     1221                }
     1222
     1223                /* Advance. */
     1224                uMinAddr = uBestAddr + 1;
    10531225                iSeg++;
    10541226            }
     1227
     1228            pThis->fHaveDosFrames = true;
     1229#else
     1230            uint32_t iFrameFirst = UINT32_MAX;
     1231            uint16_t iSeg        = 0;
     1232            uint32_t iFrameMin   = 0;
     1233            do
     1234            {
     1235                /* Find next frame. */
     1236                uint32_t iFrame = UINT32_MAX;
     1237                for (uint16_t j = 0; j < pHdr->cSegs; j++)
     1238                    if (paDescs[j].iFrame >= iFrameMin && paDescs[j].iFrame < iFrame)
     1239                        iFrame = paDescs[j].iFrame;
     1240                if (iFrame == UINT32_MAX)
     1241                    break;
     1242
     1243                /* Figure the frame span. */
     1244                uint32_t offFirst = UINT32_MAX;
     1245                uint64_t offEnd   = 0;
     1246                for (uint16_t j = 0; j < pHdr->cSegs; j++)
     1247                    if (paDescs[j].iFrame == iFrame)
     1248                    {
     1249                        uint64_t offThisEnd = paDescs[j].off + paDescs[j].cb;
     1250                        if (offThisEnd > offEnd)
     1251                            offEnd   = offThisEnd;
     1252                        if (paDescs[j].off < offFirst)
     1253                            offFirst = paDescs[j].off;
     1254                    }
     1255
     1256                if (offFirst < offEnd)
     1257                {
     1258                    /* Add it. */
     1259                    char szName[16];
     1260                    RTStrPrintf(szName, sizeof(szName), "Frame_%04x", iFrame);
     1261                    Log(("CV: %s offEnd=%#x offFirst=%#x\n", szName, offEnd, offFirst));
     1262                    if (iFrameFirst == UINT32_MAX)
     1263                        iFrameFirst = iFrame;
     1264                    rc = RTDbgModSegmentAdd(pThis->hCnt, (iFrame - iFrameFirst) << 4, offEnd, szName, 0 /*fFlags*/, NULL);
     1265
     1266                    /* Translation updates. */
     1267                    for (uint16_t j = 0; j < pHdr->cSegs; j++)
     1268                        if (paDescs[j].iFrame == iFrame)
     1269                        {
     1270                            paDescs[j].iGroup = iSeg;
     1271                            paDescs[j].off    = 0;
     1272                            paDescs[j].cb     = offEnd > UINT32_MAX ? UINT32_MAX : (uint32_t)offEnd;
     1273                        }
     1274
     1275                    iSeg++;
     1276                }
     1277
     1278                iFrameMin = iFrame + 1;
     1279            } while (RT_SUCCESS(rc));
     1280#endif
     1281        }
    10551282
    10561283        if (RT_FAILURE(rc))
     
    10611288
    10621289        pThis->fHaveLoadedSegments = true;
    1063     }
    1064 
    1065     /* The PE image has an extra section/segment for the headers, the others doesn't. */
    1066     RTLDRFMT enmImgFmt = RTLDRFMT_INVALID;
    1067     if (pThis->pMod->pImgVt)
    1068         enmImgFmt = pThis->pMod->pImgVt->pfnGetFormat(pThis->pMod);
     1290
     1291        /* Skip the stuff below if we have DOS frames since we did it all above. */
     1292        if (fHaveDosFrames)
     1293            return VINF_SUCCESS;
     1294    }
    10691295
    10701296    /* Pass one: Fixate the group segment indexes. */
    10711297    uint16_t iSeg0 = enmImgFmt == RTLDRFMT_PE || pThis->enmType == RTCVFILETYPE_DBG ? 1 : 0;
    1072     uint16_t iSeg = iSeg0 + cbGroup0 > 0;
     1298    uint16_t iSeg = iSeg0 + (cbGroup0 > 0); /** @todo probably wrong... */
    10731299    for (i = 0; i < pHdr->cSegs; i++)
    10741300        if (paDescs[i].fFlags & RTCVSEGMAPDESC_F_ABS)
     
    12021428    }
    12031429
    1204     /*
    1205      * Validate the information in the directory a little.
    1206      */
    12071430    if (RT_SUCCESS(rc))
    12081431    {
    1209         uint16_t       iMod      = 0;
    1210         uint32_t const cbDbgInfo = pThis->cbDbgInfo;
    1211         uint32_t const cDirEnts  = pThis->cDirEnts;
     1432        /*
     1433         * Basic info validation and determining the directory ordering.
     1434         */
     1435        bool           fWatcom      = 0;
     1436        uint16_t       cGlobalMods  = 0;
     1437        uint16_t       cNormalMods  = 0;
     1438        uint16_t       iModLast     = 0;
     1439        uint32_t const cbDbgInfo    = pThis->cbDbgInfo;
     1440        uint32_t const cDirEnts     = pThis->cDirEnts;
    12121441        Log2(("RTDbgModCv: %u (%#x) directory entries:\n", cDirEnts, cDirEnts));
    12131442        for (uint32_t i = 0; i < cDirEnts; i++)
     
    12331462                rc = VERR_CV_BAD_FORMAT;
    12341463            }
    1235             if (   pDirEnt->iMod < iMod
    1236                 && (   pDirEnt->iMod != 0
    1237                     || (   pThis->u32CvMagic != RTCVHDR_MAGIC_NB00 /* May be first, maybe last. */
    1238                         && pThis->u32CvMagic != RTCVHDR_MAGIC_NB02
    1239                         && pThis->u32CvMagic != RTCVHDR_MAGIC_NB04) ) )
    1240             {
    1241                 Log(("CV directory entry #%u is out of module order, this mod %u, prev mod %#u\n", i, pDirEnt->iMod, iMod));
    1242                 rc = VERR_CV_BAD_FORMAT;
    1243             }
    1244             if (pDirEnt->iMod != iMod)
    1245             {
    1246                 iMod = pDirEnt->iMod;
    1247                 if (   iMod != 0
    1248                     && iMod != 0xffff
    1249                     && pDirEnt->uSubSectType != kCvSst_Module
    1250                     && pDirEnt->uSubSectType != kCvSst_OldModule)
     1464            if (pDirEnt->iMod == 0 || pDirEnt->iMod == 0xffff)
     1465                cGlobalMods++;
     1466            else
     1467            {
     1468                if (pDirEnt->iMod > iModLast)
    12511469                {
    1252                     Log(("CV directory entry #%u: expected module subsection first, found %s (%#x)\n",
    1253                          i, rtDbgModCvGetSubSectionName(pDirEnt->uSubSectType), pDirEnt->uSubSectType));
    1254                     rc = VERR_CV_BAD_FORMAT;
     1470                    if (   pDirEnt->uSubSectType != kCvSst_Module
     1471                        && pDirEnt->uSubSectType != kCvSst_OldModule)
     1472                    {
     1473                        Log(("CV directory entry #%u: expected module subsection first, found %s (%#x)\n",
     1474                             i, rtDbgModCvGetSubSectionName(pDirEnt->uSubSectType), pDirEnt->uSubSectType));
     1475                        rc = VERR_CV_BAD_FORMAT;
     1476                    }
     1477                    if (pDirEnt->iMod != iModLast + 1)
     1478                    {
     1479                        Log(("CV directory entry #%u: skips from mod %#x to %#x modules\n", iModLast, pDirEnt->iMod));
     1480                        rc = VERR_CV_BAD_FORMAT;
     1481                    }
     1482                    iModLast = pDirEnt->iMod;
    12551483                }
     1484                else if (pDirEnt->iMod < iModLast)
     1485                    fWatcom = true;
     1486                cNormalMods++;
    12561487            }
    12571488        }
     1489        if (cGlobalMods == 0)
     1490        {
     1491            Log(("CV directory contains no global modules\n"));
     1492            rc = VERR_CV_BAD_FORMAT;
     1493        }
     1494        if (RT_SUCCESS(rc))
     1495        {
     1496            if (fWatcom)
     1497                pThis->enmDirOrder = RTCVDIRORDER_BY_SST_MOD;
     1498            else if (pThis->paDirEnts[0].iMod == 0)
     1499                pThis->enmDirOrder = RTCVDIRORDER_BY_MOD_0;
     1500            else
     1501                pThis->enmDirOrder = RTCVDIRORDER_BY_MOD;
     1502            Log(("CV dir stats: %u total, %u normal, %u special, iModLast=%#x (%u), enmDirOrder=%d\n",
     1503                 cDirEnts, cNormalMods, cGlobalMods, iModLast, iModLast, pThis->enmDirOrder));
     1504
     1505
     1506            /*
     1507             * Validate the directory ordering.
     1508             */
     1509            uint16_t i = 0;
     1510
     1511            /* Old style with special modules up front. */
     1512            if (pThis->enmDirOrder == RTCVDIRORDER_BY_MOD_0)
     1513                while (i < cGlobalMods)
     1514                {
     1515                    if (pThis->paDirEnts[i].iMod != 0)
     1516                    {
     1517                        Log(("CV directory entry #%u: Expected iMod=%x instead of %x\n", i, 0, pThis->paDirEnts[i].iMod));
     1518                        rc = VERR_CV_BAD_FORMAT;
     1519                    }
     1520                    i++;
     1521                }
     1522
     1523            /* Normal modules. */
     1524            if (pThis->enmDirOrder != RTCVDIRORDER_BY_SST_MOD)
     1525            {
     1526                uint16_t iEndNormalMods = cNormalMods + (pThis->enmDirOrder == RTCVDIRORDER_BY_MOD_0 ? cGlobalMods : 0);
     1527                while (i < iEndNormalMods)
     1528                {
     1529                    if (pThis->paDirEnts[i].iMod == 0 || pThis->paDirEnts[i].iMod == 0xffff)
     1530                    {
     1531                        Log(("CV directory entry #%u: Unexpected global module entry.\n", i));
     1532                        rc = VERR_CV_BAD_FORMAT;
     1533                    }
     1534                    i++;
     1535                }
     1536            }
     1537            else
     1538            {
     1539                uint32_t fSeen = RT_BIT_32(kCvSst_Module      - kCvSst_Module)
     1540                               | RT_BIT_32(kCvSst_Libraries   - kCvSst_Module)
     1541                               | RT_BIT_32(kCvSst_GlobalSym   - kCvSst_Module)
     1542                               | RT_BIT_32(kCvSst_GlobalPub   - kCvSst_Module)
     1543                               | RT_BIT_32(kCvSst_GlobalTypes - kCvSst_Module)
     1544                               | RT_BIT_32(kCvSst_SegName     - kCvSst_Module)
     1545                               | RT_BIT_32(kCvSst_SegMap      - kCvSst_Module)
     1546                               | RT_BIT_32(kCvSst_StaticSym   - kCvSst_Module)
     1547                               | RT_BIT_32(kCvSst_FileIndex   - kCvSst_Module)
     1548                               | RT_BIT_32(kCvSst_MPC         - kCvSst_Module);
     1549                uint16_t iMod = 0;
     1550                uint16_t uSst = kCvSst_Module;
     1551                while (i < cNormalMods)
     1552                {
     1553                    PCRTCVDIRENT32 pDirEnt = &pThis->paDirEnts[i];
     1554                    if (pDirEnt->iMod > iMod)
     1555                    {
     1556                        if (pDirEnt->uSubSectType != uSst)
     1557                        {
     1558                            Log(("CV directory entry #%u: Expected %s (%#x), found %s (%#x).\n",
     1559                                 i, rtDbgModCvGetSubSectionName(uSst), uSst,
     1560                                 rtDbgModCvGetSubSectionName(pDirEnt->uSubSectType), pDirEnt->uSubSectType));
     1561                            rc = VERR_CV_BAD_FORMAT;
     1562                        }
     1563                    }
     1564                    else
     1565                    {
     1566                        uint32_t iBit = pDirEnt->uSubSectType - kCvSst_Module;
     1567                        if (iBit >= 32U || (fSeen & RT_BIT_32(iBit)))
     1568                        {
     1569                            Log(("CV directory entry #%u: SST %s (%#x) has already been seen or is for globals.\n",
     1570                                 i, rtDbgModCvGetSubSectionName(pDirEnt->uSubSectType), pDirEnt->uSubSectType));
     1571                            rc = VERR_CV_BAD_FORMAT;
     1572                        }
     1573                        fSeen |= RT_BIT_32(iBit);
     1574                    }
     1575
     1576                    uSst = pDirEnt->uSubSectType;
     1577                    iMod = pDirEnt->iMod;
     1578                    i++;
     1579                }
     1580            }
     1581
     1582            /* New style with special modules at the end. */
     1583            if (pThis->enmDirOrder != RTCVDIRORDER_BY_MOD_0)
     1584                while (i < cDirEnts)
     1585                {
     1586                    if (pThis->paDirEnts[i].iMod != 0 && pThis->paDirEnts[i].iMod != 0xffff)
     1587                    {
     1588                        Log(("CV directory entry #%u: Expected global module entry, not %#x.\n", i,
     1589                             pThis->paDirEnts[i].iMod));
     1590                        rc = VERR_CV_BAD_FORMAT;
     1591                    }
     1592                    i++;
     1593                }
     1594        }
     1595
    12581596    }
    12591597
     
    20162354    {
    20172355        pDbgMod->pvDbgPriv = pThis;
    2018         pThis->enmType    = enmFileType;
    2019         pThis->hFile      = hFile;
    2020         pThis->pMod       = pDbgMod;
     2356        pThis->enmType          = enmFileType;
     2357        pThis->hFile            = hFile;
     2358        pThis->pMod             = pDbgMod;
     2359        pThis->offBase          = UINT32_MAX;
     2360        pThis->offCoffDbgInfo   = UINT32_MAX;
    20212361        *ppThis = pThis;
    20222362        return VINF_SUCCESS;
     
    23862726    if (!pThis)
    23872727        return RT_SUCCESS_NP(rc) ? VERR_DBG_NO_MATCHING_INTERPRETER : rc;
    2388     Assert(pThis->offBase || pThis->offCoffDbgInfo);
     2728    Assert(pThis->offBase  != UINT32_MAX || pThis->offCoffDbgInfo != UINT32_MAX);
    23892729
    23902730    /*
     
    23962736        pThis->fHaveLoadedSegments = true;
    23972737    }
    2398     if (RT_SUCCESS(rc) && pThis->offBase)
     2738    if (RT_SUCCESS(rc) && pThis->offBase != UINT32_MAX)
    23992739        rc = rtDbgModCvLoadCodeViewInfo(pThis);
    2400     if (RT_SUCCESS(rc) && pThis->offCoffDbgInfo)
     2740    if (RT_SUCCESS(rc) && pThis->offCoffDbgInfo != UINT32_MAX)
    24012741        rc = rtDbgModCvLoadCoffInfo(pThis);
    24022742    if (RT_SUCCESS(rc))
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette