VirtualBox

Changeset 59974 in vbox


Ignore:
Timestamp:
Mar 9, 2016 8:10:28 PM (9 years ago)
Author:
vboxsync
Message:

rtDbgModCvLoadDirectory: Sort the directory the way we like it, stop being uptight about how it is sorted by the linker or debug info packer.

File:
1 edited

Legend:

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

    r59973 r59974  
    5757#include <iprt/param.h>
    5858#include <iprt/path.h>
     59#include <iprt/sort.h>
    5960#include <iprt/string.h>
    6061#include <iprt/strcache.h>
     
    6970*   Structures and Typedefs                                                                                                      *
    7071*********************************************************************************************************************************/
    71 /**
    72  * Directory sorting order.
    73  */
    74 typedef enum RTCVDIRORDER
    75 {
    76     RTCVDIRORDER_INVALID = 0,
    77     /** Ordered by module. */
    78     RTCVDIRORDER_BY_MOD,
    79     /** Ordered by module, but 0 modules at the end. */
    80     RTCVDIRORDER_BY_MOD_0,
    81     /** Ordered by section, with global modules at the end. */
    82     RTCVDIRORDER_BY_SST_MOD
    83 } RTCVDIRORDER;
    84 
    85 
    8672/**
    8773 * File type.
     
    123109    /** The offset of the subsection directory (relative to offBase). */
    124110    uint32_t        offDir;
    125     /** The directory order. */
    126     RTCVDIRORDER    enmDirOrder;
    127111    /** @}  */
    128112
     
    13751359
    13761360/**
     1361 * @callback_method_impl{PFNRTSORTCMP,
     1362 *      Used by rtDbgModCvLoadDirectory to sort the directory.}
     1363 */
     1364static DECLCALLBACK(int) rtDbgModCvDirEntCmp(void const *pvElement1, void const *pvElement2, void *pvUser)
     1365{
     1366    PRTCVDIRENT32 pEntry1 = (PRTCVDIRENT32)pvElement1;
     1367    PRTCVDIRENT32 pEntry2 = (PRTCVDIRENT32)pvElement2;
     1368    if (pEntry1->iMod < pEntry2->iMod)
     1369        return -1;
     1370    if (pEntry1->iMod > pEntry2->iMod)
     1371        return 1;
     1372    if (pEntry1->uSubSectType < pEntry2->uSubSectType)
     1373        return -1;
     1374    if (pEntry1->uSubSectType > pEntry2->uSubSectType)
     1375        return 1;
     1376    return 0;
     1377}
     1378
     1379
     1380/**
    13771381 * Loads the directory into memory (RTDBGMODCV::paDirEnts and
    13781382 * RTDBGMODCV::cDirEnts).
     
    14851489    if (RT_SUCCESS(rc))
    14861490    {
     1491        uint32_t const cbDbgInfo    = pThis->cbDbgInfo;
     1492        uint32_t const cDirEnts     = pThis->cDirEnts;
     1493
    14871494        /*
    1488          * Basic info validation and determining the directory ordering.
     1495         * Just sort the directory in a way we like, no need to make
     1496         * complicated demands on the linker output.
    14891497         */
    1490         bool           fWatcom      = 0;
     1498        RTSortShell(pThis->paDirEnts, cDirEnts, sizeof(pThis->paDirEnts[0]), rtDbgModCvDirEntCmp, NULL);
     1499
     1500        /*
     1501         * Basic info validation.
     1502         */
    14911503        uint16_t       cGlobalMods  = 0;
    14921504        uint16_t       cNormalMods  = 0;
    14931505        uint16_t       iModLast     = 0;
    1494         uint32_t const cbDbgInfo    = pThis->cbDbgInfo;
    1495         uint32_t const cDirEnts     = pThis->cDirEnts;
    14961506        Log2(("RTDbgModCv: %u (%#x) directory entries:\n", cDirEnts, cDirEnts));
    14971507        for (uint32_t i = 0; i < cDirEnts; i++)
     
    15371547                    iModLast = pDirEnt->iMod;
    15381548                }
    1539                 else if (pDirEnt->iMod < iModLast)
    1540                     fWatcom = true;
    15411549                cNormalMods++;
    15421550            }
     
    15491557        if (RT_SUCCESS(rc))
    15501558        {
    1551             if (fWatcom)
    1552                 pThis->enmDirOrder = RTCVDIRORDER_BY_SST_MOD;
    1553             else if (pThis->paDirEnts[0].iMod == 0)
    1554                 pThis->enmDirOrder = RTCVDIRORDER_BY_MOD_0;
    1555             else
    1556                 pThis->enmDirOrder = RTCVDIRORDER_BY_MOD;
    1557             Log(("CV dir stats: %u total, %u normal, %u special, iModLast=%#x (%u), enmDirOrder=%d\n",
    1558                  cDirEnts, cNormalMods, cGlobalMods, iModLast, iModLast, pThis->enmDirOrder));
    1559 
    1560 
     1559            Log(("CV dir stats: %u total, %u normal, %u special, iModLast=%#x (%u)\n",
     1560                 cDirEnts, cNormalMods, cGlobalMods, iModLast, iModLast));
     1561
     1562#if 0 /* skip this stuff */
    15611563            /*
    15621564             * Validate the directory ordering.
    15631565             */
    15641566            uint16_t i = 0;
    1565 
    1566             /* Old style with special modules up front. */
    1567             if (pThis->enmDirOrder == RTCVDIRORDER_BY_MOD_0)
    1568                 while (i < cGlobalMods)
    1569                 {
    1570                     if (pThis->paDirEnts[i].iMod != 0)
    1571                     {
    1572                         Log(("CV directory entry #%u: Expected iMod=%x instead of %x\n", i, 0, pThis->paDirEnts[i].iMod));
    1573                         rc = VERR_CV_BAD_FORMAT;
    1574                     }
    1575                     i++;
    1576                 }
    15771567
    15781568            /* Normal modules. */
     
    16481638                    i++;
    16491639                }
    1650         }
    1651 
     1640#endif
     1641        }
    16521642    }
    16531643
Note: See TracChangeset for help on using the changeset viewer.

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