VirtualBox

Changeset 73412 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Jul 31, 2018 4:50:04 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/dbgmoddeferred: Fixed debug close method using the wrong instance data pointer (img instead of dbg).

Location:
trunk/src/VBox/Runtime/common/dbg
Files:
2 edited

Legend:

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

    r73401 r73412  
    5252{
    5353    AssertPtr(pThis);
     54    Assert(pThis->u32Magic == RTDBGMODDEFERRED_MAGIC);
    5455    uint32_t cRefs = ASMAtomicDecU32(&pThis->cRefs); Assert(cRefs < 8);
    5556    if (!cRefs)
     
    5758        RTDbgCfgRelease(pThis->hDbgCfg);
    5859        pThis->hDbgCfg = NIL_RTDBGCFG;
    59         pThis->uMagic = UINT32_C(0xdeadf00d);
     60        pThis->u32Magic = RTDBGMODDEFERRED_MAGIC_DEAD;
    6061        RTMemFree(pThis);
    6162    }
     
    155156                                                        PRTINTPTR poffDisp, PRTDBGLINE pLineInfo)
    156157{
     158    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    157159    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    158160    if (RT_SUCCESS(rc))
     
    165167static DECLCALLBACK(int) rtDbgModDeferredDbg_LineByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGLINE pLineInfo)
    166168{
     169    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    167170    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    168171    if (RT_SUCCESS(rc))
     
    175178static DECLCALLBACK(uint32_t) rtDbgModDeferredDbg_LineCount(PRTDBGMODINT pMod)
    176179{
     180    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    177181    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    178182    if (RT_SUCCESS(rc))
     
    186190                                                     uint32_t iSeg, RTUINTPTR off, uint32_t *piOrdinal)
    187191{
     192    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    188193    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    189194    if (RT_SUCCESS(rc))
     
    237242                                                          PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo)
    238243{
     244    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    239245    if (   (fFlags & RTDBGSYMADDR_FLAGS_SKIP_ABS_IN_DEFERRED)
    240246        && iSeg == RTDBGSEGIDX_ABS)
     
    264270                                                          PRTDBGSYMBOL pSymInfo)
    265271{
     272    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    266273    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    267274    if (RT_SUCCESS(rc))
     
    286293static DECLCALLBACK(int) rtDbgModDeferredDbg_SymbolByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo)
    287294{
     295    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    288296    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    289297    if (RT_SUCCESS(rc))
     
    306314static DECLCALLBACK(uint32_t) rtDbgModDeferredDbg_SymbolCount(PRTDBGMODINT pMod)
    307315{
     316    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    308317    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    309318    if (RT_SUCCESS(rc))
     
    318327                                                       uint32_t *piOrdinal)
    319328{
     329    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    320330    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    321331    if (RT_SUCCESS(rc))
     
    328338static DECLCALLBACK(int) rtDbgModDeferredDbg_SegmentByIndex(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, PRTDBGSEGMENT pSegInfo)
    329339{
     340    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    330341    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    331342    if (RT_SUCCESS(rc))
     
    351362static DECLCALLBACK(RTDBGSEGIDX) rtDbgModDeferredDbg_SegmentCount(PRTDBGMODINT pMod)
    352363{
     364    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    353365    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    354366    if (RT_SUCCESS(rc))
     
    362374                                                        size_t cchName, uint32_t fFlags, PRTDBGSEGIDX piSeg)
    363375{
     376    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    364377    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    365378    if (RT_SUCCESS(rc))
     
    373386{
    374387    PRTDBGMODDEFERRED pThis = (PRTDBGMODDEFERRED)pMod->pvDbgPriv;
     388    Assert(pThis->u32Magic == RTDBGMODDEFERRED_MAGIC);
    375389    return pThis->cbImage;
    376390}
     
    380394static DECLCALLBACK(RTDBGSEGIDX) rtDbgModDeferredDbg_RvaToSegOff(PRTDBGMODINT pMod, RTUINTPTR uRva, PRTUINTPTR poffSeg)
    381395{
     396    Assert(((PRTDBGMODDEFERRED)pMod->pvDbgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    382397    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    383398    if (RT_SUCCESS(rc))
     
    390405static DECLCALLBACK(int) rtDbgModDeferredDbg_Close(PRTDBGMODINT pMod)
    391406{
    392     rtDbgModDeferredReleaseInstanceData((PRTDBGMODDEFERRED)pMod->pvImgPriv);
     407    rtDbgModDeferredReleaseInstanceData((PRTDBGMODDEFERRED)pMod->pvDbgPriv);
    393408    return VINF_SUCCESS;
    394409}
     
    449464rtDbgModDeferredImg_QueryProp(PRTDBGMODINT pMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf, size_t *pcbRet)
    450465{
     466    Assert(((PRTDBGMODDEFERRED)pMod->pvImgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    451467    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    452468    if (RT_SUCCESS(rc))
     
    459475static DECLCALLBACK(RTLDRARCH) rtDbgModDeferredImg_GetArch(PRTDBGMODINT pMod)
    460476{
     477    Assert(((PRTDBGMODDEFERRED)pMod->pvImgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
     478
    461479    RTLDRARCH enmArch;
    462480    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
     
    472490static DECLCALLBACK(RTLDRFMT) rtDbgModDeferredImg_GetFormat(PRTDBGMODINT pMod)
    473491{
     492    Assert(((PRTDBGMODDEFERRED)pMod->pvImgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
     493
    474494    RTLDRFMT enmFmt;
    475495    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
     
    485505static DECLCALLBACK(int) rtDbgModDeferredImg_ReadAt(PRTDBGMODINT pMod, uint32_t iDbgInfoHint, RTFOFF off, void *pvBuf, size_t cb)
    486506{
     507    Assert(((PRTDBGMODDEFERRED)pMod->pvImgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    487508    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    488509    if (RT_SUCCESS(rc))
     
    495516static DECLCALLBACK(int) rtDbgModDeferredImg_UnmapPart(PRTDBGMODINT pMod, size_t cb, void const **ppvMap)
    496517{
     518    Assert(((PRTDBGMODDEFERRED)pMod->pvImgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    497519    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    498520    if (RT_SUCCESS(rc))
     
    505527static DECLCALLBACK(int) rtDbgModDeferredImg_MapPart(PRTDBGMODINT pMod, uint32_t iDbgInfo, RTFOFF off, size_t cb, void const **ppvMap)
    506528{
     529    Assert(((PRTDBGMODDEFERRED)pMod->pvImgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    507530    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    508531    if (RT_SUCCESS(rc))
     
    516539{
    517540    PRTDBGMODDEFERRED pThis = (PRTDBGMODDEFERRED)pMod->pvImgPriv;
     541    Assert(pThis->u32Magic == RTDBGMODDEFERRED_MAGIC);
    518542    return pThis->cbImage;
    519543}
     
    524548                                                            PRTDBGSEGIDX piSeg, PRTLDRADDR poffSeg)
    525549{
     550    Assert(((PRTDBGMODDEFERRED)pMod->pvImgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    526551    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    527552    if (RT_SUCCESS(rc))
     
    535560                                                                    PRTDBGSEGIDX piSeg, PRTLDRADDR poffSeg)
    536561{
     562    Assert(((PRTDBGMODDEFERRED)pMod->pvImgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    537563    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    538564    if (RT_SUCCESS(rc))
     
    546572                                                         PFNRTLDRENUMSYMS pfnCallback, void *pvUser)
    547573{
     574    Assert(((PRTDBGMODDEFERRED)pMod->pvImgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    548575    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    549576    if (RT_SUCCESS(rc))
     
    556583static DECLCALLBACK(int) rtDbgModDeferredImg_EnumSegments(PRTDBGMODINT pMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser)
    557584{
     585    Assert(((PRTDBGMODDEFERRED)pMod->pvImgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    558586    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    559587    if (RT_SUCCESS(rc))
     
    566594static DECLCALLBACK(int) rtDbgModDeferredImg_EnumDbgInfo(PRTDBGMODINT pMod, PFNRTLDRENUMDBG pfnCallback, void *pvUser)
    567595{
     596    Assert(((PRTDBGMODDEFERRED)pMod->pvImgPriv)->u32Magic == RTDBGMODDEFERRED_MAGIC);
    568597    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
    569598    if (RT_SUCCESS(rc))
     
    639668        return VERR_NO_MEMORY;
    640669
     670    pDeferred->u32Magic    = RTDBGMODDEFERRED_MAGIC;
     671    pDeferred->cRefs       = 1 + (pDbgMod->pImgVt == NULL);
    641672    pDeferred->cbImage     = cbImage;
    642     pDeferred->cRefs       = 1 + (pDbgMod->pImgVt == NULL);
    643     pDeferred->uMagic      = UINT32_C(0xbeef0001);
    644673    if (hDbgCfg != NIL_RTDBGCFG)
    645674        RTDbgCfgRetain(hDbgCfg);
  • trunk/src/VBox/Runtime/common/dbg/dbgmodldr.cpp

    r73375 r73412  
    5353typedef struct RTDBGMODLDR
    5454{
     55    /** Magic value (RTDBGMODLDR_MAGIC). */
     56    uint32_t        u32Magic;
    5557    /** The loader handle. */
    5658    RTLDRMOD        hLdrMod;
     
    6567{
    6668    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     69    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    6770    return RTLdrQueryPropEx(pThis->hLdrMod, enmProp, NULL /*pvBits*/, pvBuf, cbBuf, pcbRet);
    6871}
     
    7376{
    7477    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     78    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    7579    return RTLdrGetArch(pThis->hLdrMod);
    7680}
     
    8185{
    8286    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     87    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    8388    return RTLdrGetFormat(pThis->hLdrMod);
    8489}
     
    8994{
    9095    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     96    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    9197    RT_NOREF_PV(iDbgInfoHint);
    9298    return rtLdrReadAt(pThis->hLdrMod, pvBuf, UINT32_MAX /** @todo iDbgInfo*/, off, cb);
     
    97103static DECLCALLBACK(int) rtDbgModLdr_UnmapPart(PRTDBGMODINT pMod, size_t cb, void const **ppvMap)
    98104{
     105    Assert(((PRTDBGMODLDR)pMod->pvImgPriv)->u32Magic == RTDBGMODLDR_MAGIC);
    99106    NOREF(pMod); NOREF(cb);
    100107    RTMemFree((void *)*ppvMap);
     
    108115{
    109116    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     117    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    110118
    111119    void *pvMap = RTMemAlloc(cb);
     
    129137{
    130138    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     139    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    131140    return RTLdrSize(pThis->hLdrMod);
    132141}
     
    137146{
    138147    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     148    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    139149    return RTLdrRvaToSegOffset(pThis->hLdrMod, Rva, piSeg, poffSeg);
    140150}
     
    146156{
    147157    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     158    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    148159    return RTLdrLinkAddressToSegOffset(pThis->hLdrMod, LinkAddress, piSeg, poffSeg);
    149160}
     
    155166{
    156167    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     168    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    157169    return RTLdrEnumSymbols(pThis->hLdrMod, fFlags, NULL /*pvBits*/, BaseAddress, pfnCallback, pvUser);
    158170}
     
    163175{
    164176    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     177    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    165178    return RTLdrEnumSegments(pThis->hLdrMod, pfnCallback, pvUser);
    166179}
     
    171184{
    172185    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     186    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    173187    return RTLdrEnumDbgInfo(pThis->hLdrMod, NULL, pfnCallback, pvUser);
    174188}
     
    180194    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
    181195    AssertPtr(pThis);
     196    Assert(pThis->u32Magic == RTDBGMODLDR_MAGIC);
    182197
    183198    int rc = RTLdrClose(pThis->hLdrMod); AssertRC(rc);
    184     pThis->hLdrMod = NIL_RTLDRMOD;
     199    pThis->hLdrMod  = NIL_RTLDRMOD;
     200    pThis->u32Magic = RTDBGMODLDR_MAGIC_DEAD;
    185201
    186202    RTMemFree(pThis);
     
    243259        return VERR_NO_MEMORY;
    244260
     261    pThis->u32Magic    = RTDBGMODLDR_MAGIC;
    245262    pThis->hLdrMod     = hLdrMod;
    246263    pDbgMod->pvImgPriv = pThis;
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