VirtualBox

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


Ignore:
Timestamp:
Dec 18, 2009 12:58:10 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56147
Message:

IPRT,PDMCritSect: More lock validator refactoring.

Location:
trunk/src/VBox/Runtime
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp

    r25467 r25478  
    6363
    6464
     65/**
     66 * Copy a source position record.
     67 *
     68 * @param   pDst                The destination.
     69 * @param   pSrc                The source.
     70 */
     71DECL_FORCE_INLINE(void) rtLockValidatorCopySrcPos(PRTLOCKVALIDATORSRCPOS pDst, PCRTLOCKVALIDATORSRCPOS pSrc)
     72{
     73    ASMAtomicUoWriteU32(&pDst->uLine,                           pSrc->uLine);
     74    ASMAtomicUoWritePtr((void * volatile *)&pDst->pszFile,      pSrc->pszFile);
     75    ASMAtomicUoWritePtr((void * volatile *)&pDst->pszFunction,  pSrc->pszFunction);
     76    ASMAtomicUoWritePtr((void * volatile *)&pDst->uId,          (void *)pSrc->uId);
     77}
     78
     79
     80/**
     81 * Init a source position record.
     82 *
     83 * @param   pSrcPos             The source position record.
     84 */
     85DECL_FORCE_INLINE(void) rtLockValidatorInitSrcPos(PRTLOCKVALIDATORSRCPOS pSrcPos)
     86{
     87    pSrcPos->pszFile        = NULL;
     88    pSrcPos->pszFunction    = NULL;
     89    pSrcPos->uId            = 0;
     90    pSrcPos->uLine          = 0;
     91#if HC_ARCH_BITS == 64
     92    pSrcPos->u32Padding     = 0;
     93#endif
     94}
     95
    6596
    6697/**
     
    113144{
    114145    pRec->u32Magic      = RTLOCKVALIDATORREC_MAGIC;
    115     pRec->uLine         = 0;
    116     pRec->pszFile       = NULL;
    117     pRec->pszFunction   = NULL;
    118     pRec->uId           = 0;
     146    rtLockValidatorInitSrcPos(&pRec->SrcPos);
    119147    pRec->hThread       = NIL_RTTHREAD;
    120148    pRec->pDown         = NULL;
     
    179207
    180208
    181 RTDECL(int) RTLockValidatorCheckOrder(PRTLOCKVALIDATORREC pRec, RTTHREAD hThread, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     209RTDECL(int) RTLockValidatorCheckOrder(PRTLOCKVALIDATORREC pRec, RTTHREAD hThread, PCRTLOCKVALIDATORSRCPOS pSrcPos)
    182210{
    183211    AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     
    205233
    206234
    207 RTDECL(int) RTLockValidatorRecordRecursion(PRTLOCKVALIDATORREC pRec, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     235RTDECL(int) RTLockValidatorRecordRecursion(PRTLOCKVALIDATORREC pRec, PCRTLOCKVALIDATORSRCPOS pSrcPos)
    208236{
    209237    AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     
    227255
    228256
    229 RTDECL(RTTHREAD) RTLockValidatorSetOwner(PRTLOCKVALIDATORREC pRec, RTTHREAD hThread, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     257RTDECL(RTTHREAD) RTLockValidatorSetOwner(PRTLOCKVALIDATORREC pRec, RTTHREAD hThread, PCRTLOCKVALIDATORSRCPOS pSrcPos)
    230258{
    231259    AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, NIL_RTTHREAD);
     
    248276         * Update the record.
    249277         */
    250         ASMAtomicUoWriteU32(&pRec->uLine, iLine);
    251         ASMAtomicUoWritePtr((void * volatile *)&pRec->pszFile,      pszFile);
    252         ASMAtomicUoWritePtr((void * volatile *)&pRec->pszFunction,  pszFunction);
    253         ASMAtomicUoWritePtr((void * volatile *)&pRec->uId,          (void *)uId);
     278        rtLockValidatorCopySrcPos(&pRec->SrcPos, pSrcPos);
    254279        ASMAtomicUoWriteU32(&pRec->cRecursion, 1);
    255 
    256280        ASMAtomicWriteHandle(&pRec->hThread, hThread);
    257281
     
    369393 * @param   pCur            The thread we're deadlocking with.
    370394 * @param   enmState        The sleep state.
    371  * @param   RT_SRC_POS_DECL Where we are going to deadlock.
    372  * @param   uId             Where we are going to deadlock.
     395 * @param   pSrcPos         Where we are going to deadlock.
    373396 */
    374397static void rtLockValidatorComplainAboutDeadlock(PRTLOCKVALIDATORREC pRec, PRTTHREADINT pThread, RTTHREADSTATE enmState,
    375                                                  PRTTHREADINT pCur, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    376 {
    377     AssertMsg1(pCur == pThread ? "!!Deadlock detected!!" : "!!Deadlock exists!!", iLine, pszFile, pszFunction);
     398                                                 PRTTHREADINT pCur, PCRTLOCKVALIDATORSRCPOS pSrcPos)
     399{
     400    AssertMsg1(pCur == pThread ? "!!Deadlock detected!!" : "!!Deadlock exists!!", pSrcPos->uLine, pSrcPos->pszFile, pSrcPos->pszFunction);
    378401
    379402    /*
     
    390413        AssertMsg2(" #%u: %RTthrd/%RTnthrd %s: %s(%u) %RTptr\n",
    391414                   iEntry, pCur, pCur->Core.Key, pCur->szName,
    392                    pCur->LockValidator.pszBlockFile, pCur->LockValidator.uBlockLine,
    393                    pCur->LockValidator.pszBlockFunction, pCur->LockValidator.uBlockId);
     415                   pCur->LockValidator.SrcPos.pszFile, pCur->LockValidator.SrcPos.uLine,
     416                   pCur->LockValidator.SrcPos.pszFunction, pCur->LockValidator.SrcPos.uId);
    394417        PRTTHREADINT  pNext       = NULL;
    395418        RTTHREADSTATE enmCurState = rtThreadGetState(pCur);
     
    418441                    AssertMsg2("     Waiting on %s %p [%s]: Entered %s(%u) %s %p\n",
    419442                               RTThreadStateName(enmCurState), pCurRec->hLock, pCurRec->pszName,
    420                                pCurRec->pszFile, pCurRec->uLine, pCurRec->pszFunction, pCurRec->uId);
     443                               pCurRec->SrcPos.pszFile, pCurRec->SrcPos.uLine, pCurRec->SrcPos.pszFunction, pCurRec->SrcPos.uId);
    421444                    pNext = pCurRec->hThread;
    422445                }
     
    461484RTDECL(int) RTLockValidatorCheckBlocking(PRTLOCKVALIDATORREC pRec, RTTHREAD hThread,
    462485                                         RTTHREADSTATE enmState, bool fRecursiveOk,
    463                                          RTHCUINTPTR uId, RT_SRC_POS_DECL)
     486                                         PCRTLOCKVALIDATORSRCPOS pSrcPos)
    464487{
    465488    /*
     
    482505     * performing deadlock detection.
    483506     */
    484     /** @todo This has to be serialized! The deadlock detection isn't 100% safe!!! */
    485     pThread->LockValidator.pRec             = pRec;
    486     pThread->LockValidator.pszBlockFunction = pszFunction;
    487     pThread->LockValidator.pszBlockFile     = pszFile;
    488     pThread->LockValidator.uBlockLine       = iLine;
    489     pThread->LockValidator.uBlockId         = uId;
    490 
    491     RTThreadBlocking(hThread, enmState);
     507    pThread->LockValidator.pRec = pRec;
     508    rtLockValidatorCopySrcPos(&pThread->LockValidator.SrcPos, pSrcPos);
    492509
    493510    /*
     
    604621     * Ok, if we ever get here, it's most likely a genuine deadlock.
    605622     */
    606     rtLockValidatorComplainAboutDeadlock(pRec, pThread, enmState, pCur, uId, RT_SRC_POS_ARGS);
     623    rtLockValidatorComplainAboutDeadlock(pRec, pThread, enmState, pCur, pSrcPos);
    607624
    608625    rtLockValidatorSerializeDetectionLeave();
  • trunk/src/VBox/Runtime/generic/critsect-generic.cpp

    r25467 r25478  
    244244    ASMAtomicWriteHandle(&pCritSect->NativeThreadOwner, NativeThreadSelf);
    245245#ifdef RTCRITSECT_STRICT
    246     RTLockValidatorSetOwner(pCritSect->pValidatorRec, ThreadSelf, uId, RT_SRC_POS_ARGS);
     246    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     247    RTLockValidatorSetOwner(pCritSect->pValidatorRec, ThreadSelf, &SrcPos);
    247248#endif
    248249
     
    283284    RTNATIVETHREAD  NativeThreadSelf = RTThreadNativeSelf();
    284285#ifdef RTCRITSECT_STRICT
    285     RTTHREAD        hThreadSelf = RTThreadSelfAutoAdopt();
    286     RTLockValidatorCheckOrder(pCritSect->pValidatorRec, hThreadSelf, uId, RT_SRC_POS_ARGS);
     286    RTTHREAD                hThreadSelf = RTThreadSelfAutoAdopt();
     287    RTLOCKVALIDATORSRCPOS   SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     288    RTLockValidatorCheckOrder(pCritSect->pValidatorRec, hThreadSelf, &SrcPos);
    287289#endif
    288290
     
    324326            int rc9 = RTLockValidatorCheckBlocking(pCritSect->pValidatorRec, hThreadSelf, RTTHREADSTATE_CRITSECT,
    325327                                                   !(pCritSect->fFlags & RTCRITSECT_FLAGS_NO_NESTING),
    326                                                    uId, RT_SRC_POS_ARGS);
     328                                                   &SrcPos);
    327329            if (RT_FAILURE(rc9))
    328330            {
     
    330332                return rc9;
    331333            }
    332 #else
     334#endif
    333335            RTThreadBlocking(hThreadSelf, RTTHREADSTATE_CRITSECT);
    334 #endif
    335336
    336337            int rc = RTSemEventWait(pCritSect->EventSem, RT_INDEFINITE_WAIT);
     
    352353    ASMAtomicWriteHandle(&pCritSect->NativeThreadOwner, NativeThreadSelf);
    353354#ifdef RTCRITSECT_STRICT
    354     RTLockValidatorSetOwner(pCritSect->pValidatorRec, hThreadSelf, uId, RT_SRC_POS_ARGS);
     355    RTLockValidatorSetOwner(pCritSect->pValidatorRec, hThreadSelf, &SrcPos);
    355356#endif
    356357
  • trunk/src/VBox/Runtime/include/internal/lockvalidator.h

    r25436 r25478  
    4848    /** What we're blocking on. */
    4949    PRTLOCKVALIDATORREC     pRec;
    50     /** Where we're blocking. */
    51     const char volatile    *pszBlockFunction;
    52     /** Where we're blocking. */
    53     const char volatile    *pszBlockFile;
    54     /** Where we're blocking. */
    55     uint32_t volatile       uBlockLine;
    56     /** Where we're blocking. */
    57     RTHCUINTPTR volatile    uBlockId;
    58 
     50    /** Where we are blocking. */
     51    RTLOCKVALIDATORSRCPOS   SrcPos;
    5952    /** Number of registered write locks, mutexes and critsects that this thread owns. */
    6053    int32_t volatile        cWriteLocks;
  • trunk/src/VBox/Runtime/include/internal/strict.h

    r25467 r25478  
    5858#endif
    5959
    60 #ifdef RTSEMMUTEX_STRICT
    61 # define RTSEMMUTEX_STRICT_POS_DECL             RTHCUINTPTR uId, RT_SRC_POS_DECL
    62 # define RTSEMMUTEX_STRICT_POS_ARGS             uId, RT_SRC_POS_ARGS
    63 #else
    64 # define RTSEMMUTEX_STRICT_POS_DECL             int iDummy
    65 # define RTSEMMUTEX_STRICT_POS_ARGS             0
    66 #endif
    67 
    6860
    6961/** @def RTSEMRW_STRICT
     
    7466#endif
    7567
    76 #ifdef RTSEMRW_STRICT
    77 # define RTSEMRW_STRICT_POS_DECL                RTHCUINTPTR uId, RT_SRC_POS_DECL
    78 # define RTSEMRW_STRICT_POS_ARGS                uId, RT_SRC_POS_ARGS
    79 #else
    80 # define RTSEMRW_STRICT_POS_DECL                int iDummy
    81 # define RTSEMRW_STRICT_POS_ARGS                0
    82 #endif
    83 
    8468
    8569
  • trunk/src/VBox/Runtime/r3/linux/semmutex-linux.cpp

    r25467 r25478  
    167167
    168168
    169 DECL_FORCE_INLINE(int) rtSemMutexRequest(RTSEMMUTEX MutexSem, unsigned cMillies, bool fAutoResume, RTSEMMUTEX_STRICT_POS_DECL)
     169DECL_FORCE_INLINE(int) rtSemMutexRequest(RTSEMMUTEX MutexSem, unsigned cMillies, bool fAutoResume, PCRTLOCKVALIDATORSRCPOS pSrcPos)
    170170{
    171171    /*
     
    178178#ifdef RTSEMMUTEX_STRICT
    179179    RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    180     RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, RTSEMMUTEX_STRICT_POS_ARGS);
     180    RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    181181#endif
    182182
     
    232232#ifdef RTSEMMUTEX_STRICT
    233233                int rc9 = RTLockValidatorCheckBlocking(&pThis->ValidatorRec, hThreadSelf,
    234                                                        RTTHREADSTATE_MUTEX, true, uId, RT_SRC_POS_ARGS);
     234                                                       RTTHREADSTATE_MUTEX, true, pSrcPos);
    235235                if (RT_FAILURE(rc9))
    236236                    return rc9;
    237 #else
     237#endif
    238238                RTThreadBlocking(hThreadSelf, RTTHREADSTATE_MUTEX);
    239 #endif
    240239            }
    241240
     
    300299    ASMAtomicWriteU32(&pThis->cNesting, 1);
    301300#ifdef RTSEMMUTEX_STRICT
    302     RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, RTSEMMUTEX_STRICT_POS_ARGS);
     301    RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    303302#endif
    304303    return VINF_SUCCESS;
     
    309308{
    310309#ifndef RTSEMMUTEX_STRICT
    311     int rc = rtSemMutexRequest(MutexSem, cMillies, true, RTSEMMUTEX_STRICT_POS_ARGS);
     310    int rc = rtSemMutexRequest(MutexSem, cMillies, true, NULL);
     311#else
     312    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API();
     313    int rc = rtSemMutexRequest(MutexSem, cMillies, true, &SrcPos);
     314#endif
    312315    Assert(rc != VERR_INTERRUPTED);
    313316    return rc;
    314 #else
    315     return RTSemMutexRequestDebug(MutexSem, cMillies, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);
    316 #endif
    317317}
    318318
     
    320320RTDECL(int) RTSemMutexRequestDebug(RTSEMMUTEX MutexSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    321321{
    322 #ifdef RTSEMMUTEX_STRICT
    323     int rc = rtSemMutexRequest(MutexSem, cMillies, true, RTSEMMUTEX_STRICT_POS_ARGS);
     322    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     323    int rc = rtSemMutexRequest(MutexSem, cMillies, true, &SrcPos);
    324324    Assert(rc != VERR_INTERRUPTED);
    325325    return rc;
     326}
     327
     328
     329RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies)
     330{
     331#ifndef RTSEMMUTEX_STRICT
     332    return rtSemMutexRequest(MutexSem, cMillies, false, NULL);
    326333#else
    327     return RTSemMutexRequest(MutexSem, cMillies);
    328 #endif
    329 }
    330 
    331 
    332 RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies)
    333 {
    334 #ifndef RTSEMMUTEX_STRICT
    335     return rtSemMutexRequest(MutexSem, cMillies, false, RTSEMMUTEX_STRICT_POS_ARGS);
    336 #else
    337     return RTSemMutexRequestNoResumeDebug(MutexSem, cMillies, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);
     334    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API();
     335    return rtSemMutexRequest(MutexSem, cMillies, false, &SrcPos);
    338336#endif
    339337}
     
    342340RTDECL(int) RTSemMutexRequestNoResumeDebug(RTSEMMUTEX MutexSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    343341{
    344 #ifdef RTSEMMUTEX_STRICT
    345     return rtSemMutexRequest(MutexSem, cMillies, false, RTSEMMUTEX_STRICT_POS_ARGS);
    346 #else
    347     return RTSemMutexRequest(MutexSem, cMillies);
    348 #endif
     342    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     343    return rtSemMutexRequest(MutexSem, cMillies, false, &SrcPos);
    349344}
    350345
  • trunk/src/VBox/Runtime/r3/posix/semmutex-posix.cpp

    r25467 r25478  
    155155
    156156
    157 DECL_FORCE_INLINE(int) rtSemMutexRequest(RTSEMMUTEX MutexSem, unsigned cMillies, RTSEMMUTEX_STRICT_POS_DECL)
     157DECL_FORCE_INLINE(int) rtSemMutexRequest(RTSEMMUTEX MutexSem, unsigned cMillies, PCRTLOCKVALIDATORSRCPOS pSrcPos)
    158158{
    159159    /*
     
    166166#ifdef RTSEMMUTEX_STRICT
    167167    RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    168     RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, RTSEMMUTEX_STRICT_POS_ARGS);
     168    RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    169169#endif
    170170
     
    190190#ifdef RTSEMMUTEX_STRICT
    191191        int rc9 = RTLockValidatorCheckBlocking(&pThis->ValidatorRec, hThreadSelf,
    192                                                RTTHREADSTATE_MUTEX, true, uId, RT_SRC_POS_ARGS);
     192                                               RTTHREADSTATE_MUTEX, true, pSrcPos);
    193193        if (RT_FAILURE(rc9))
    194194            return rc9;
    195 #else
     195#endif
    196196        RTThreadBlocking(hThreadSelf, RTTHREADSTATE_MUTEX);
    197 #endif
    198197    }
    199198
     
    248247    ASMAtomicWriteU32(&pThis->cNesting, 1);
    249248#ifdef RTSEMMUTEX_STRICT
    250     RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, RTSEMMUTEX_STRICT_POS_ARGS);
     249    RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    251250#endif
    252251
     
    258257{
    259258#ifndef RTSEMMUTEX_STRICT
    260     return rtSemMutexRequest(MutexSem, cMillies, RTSEMMUTEX_STRICT_POS_ARGS);
     259    return rtSemMutexRequest(MutexSem, cMillies, NULL);
    261260#else
    262     return RTSemMutexRequestDebug(MutexSem, cMillies, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);
     261    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API();
     262    return rtSemMutexRequest(MutexSem, cMillies, &SrcPos);
    263263#endif
    264264}
     
    267267RTDECL(int) RTSemMutexRequestDebug(RTSEMMUTEX MutexSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    268268{
    269 #ifdef RTSEMMUTEX_STRICT
    270     return rtSemMutexRequest(MutexSem, cMillies, RTSEMMUTEX_STRICT_POS_ARGS);
     269    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     270    return rtSemMutexRequest(MutexSem, cMillies, &SrcPos);
     271}
     272
     273
     274RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies)
     275{
     276    /* (EINTR isn't returned by the wait functions we're using.) */
     277#ifndef RTSEMMUTEX_STRICT
     278    return rtSemMutexRequest(MutexSem, cMillies, NULL);
    271279#else
    272     return RTSemMutexRequest(MutexSem, cMillies);
    273 #endif
    274 }
    275 
    276 
    277 RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies)
    278 {
    279     /* EINTR isn't returned by the wait functions we're using. */
    280 #ifndef RTSEMMUTEX_STRICT
    281     return RTSemMutexRequest(MutexSem, cMillies);
    282 #else
    283     return RTSemMutexRequestDebug(MutexSem, cMillies, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);
     280    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API();
     281    return rtSemMutexRequest(MutexSem, cMillies, &SrcPos);
    284282#endif
    285283}
     
    288286RTDECL(int) RTSemMutexRequestNoResumeDebug(RTSEMMUTEX MutexSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    289287{
    290     /* EINTR isn't returned by the wait functions we're using. */
    291 #ifdef RTSEMMUTEX_STRICT
    292     return RTSemMutexRequestDebug(MutexSem, cMillies, RTSEMMUTEX_STRICT_POS_ARGS);
    293 #else
    294     return RTSemMutexRequest(MutexSem, cMillies);
    295 #endif
     288    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     289    return rtSemMutexRequest(MutexSem, cMillies, &SrcPos);
    296290}
    297291
  • trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp

    r25467 r25478  
    315315
    316316
    317 DECL_FORCE_INLINE(int) rtSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies, RTSEMRW_STRICT_POS_DECL)
     317DECL_FORCE_INLINE(int) rtSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies, PCRTLOCKVALIDATORSRCPOS pSrcPos)
    318318{
    319319    /*
     
    327327#ifdef RTSEMRW_STRICT
    328328    RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    329     RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, RTSEMRW_STRICT_POS_ARGS);
     329    RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    330330#endif
    331331
     
    339339    {
    340340#ifdef RTSEMRW_STRICT
    341         int rc9 = RTLockValidatorRecordRecursion(&pThis->ValidatorRec, RTSEMRW_STRICT_POS_ARGS);
     341        int rc9 = RTLockValidatorRecordRecursion(&pThis->ValidatorRec, pSrcPos);
    342342        if (RT_FAILURE(rc9))
    343343            return rc9;
     
    357357    {
    358358#ifdef RTSEMRW_STRICT
    359         int rc9 = RTLockValidatorCheckBlocking(&pThis->ValidatorRec, hThreadSelf, RTTHREADSTATE_RW_WRITE, true, uId, RT_SRC_POS_ARGS);
     359        int rc9 = RTLockValidatorCheckBlocking(&pThis->ValidatorRec, hThreadSelf, RTTHREADSTATE_RW_WRITE, true, pSrcPos);
    360360        if (RT_FAILURE(rc9))
    361361            return rc9;
    362 #else
     362#endif
    363363        RTThreadBlocking(hThreadSelf, RTTHREADSTATE_RW_WRITE);
    364 #endif
    365364    }
    366365
     
    412411    pThis->cWrites = 1;
    413412#ifdef RTSEMRW_STRICT
    414     RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, RTSEMRW_STRICT_POS_ARGS);
     413    RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    415414#endif
    416415    return VINF_SUCCESS;
     
    421420{
    422421#ifndef RTSEMRW_STRICT
    423     return rtSemRWRequestWrite(RWSem, cMillies, RTSEMRW_STRICT_POS_ARGS);
     422    return rtSemRWRequestWrite(RWSem, cMillies, NULL);
    424423#else
    425     return RTSemRWRequestWriteDebug(RWSem, cMillies, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);
     424    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API();
     425    return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
    426426#endif
    427427}
     
    430430RTDECL(int) RTSemRWRequestWriteDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    431431{
    432 #ifdef RTSEMRW_STRICT
    433     return rtSemRWRequestWrite(RWSem, cMillies, RTSEMRW_STRICT_POS_ARGS);
    434 #else
    435     return RTSemRWRequestWrite(RWSem, cMillies);
    436 #endif
     432    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     433    return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
    437434}
    438435
     
    442439    /* EINTR isn't returned by the wait functions we're using. */
    443440#ifndef RTSEMRW_STRICT
    444     return RTSemRWRequestWrite(RWSem, cMillies);
     441    return rtSemRWRequestWrite(RWSem, cMillies, NULL);
    445442#else
    446     return RTSemRWRequestWriteDebug(RWSem, cMillies, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);
     443    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API();
     444    return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
    447445#endif
    448446}
     
    452450{
    453451    /* EINTR isn't returned by the wait functions we're using. */
    454 #ifdef RTSEMRW_STRICT
    455     return RTSemRWRequestWriteDebug(RWSem, cMillies, RTSEMRW_STRICT_POS_ARGS);
    456 #else
    457     return RTSemRWRequestWrite(RWSem, cMillies);
    458 #endif
     452    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     453    return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
    459454}
    460455
  • trunk/src/VBox/Runtime/r3/win/semmutex-win.cpp

    r25467 r25478  
    138138 *
    139139 * @returns Same as RTSEmMutexRequestNoResume
    140  * @param   MutexSem                    The mutex handle.
    141  * @param   cMillies                    The number of milliseconds to wait.
    142  * @param   TSEMMUTEX_STRICT_POS_DECL   The source position of the caller.
     140 * @param   MutexSem            The mutex handle.
     141 * @param   cMillies            The number of milliseconds to wait.
     142 * @param   pSrcPos             The source position of the caller.
    143143 */
    144 DECL_FORCE_INLINE(int) rtSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies, RTSEMMUTEX_STRICT_POS_DECL)
     144DECL_FORCE_INLINE(int) rtSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies, PCRTLOCKVALIDATORSRCPOS pSrcPos)
    145145{
    146146    /*
     
    153153#ifdef RTSEMMUTEX_STRICT
    154154    RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    155     RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, RTSEMMUTEX_STRICT_POS_ARGS);
     155    RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    156156#else
    157157    RTTHREAD hThreadSelf = RTThreadSelf();
     
    165165#ifdef RTSEMMUTEX_STRICT
    166166        int rc9 = RTLockValidatorCheckBlocking(&pThis->ValidatorRec, hThreadSelf,
    167                                                RTTHREADSTATE_MUTEX, true, uId, RT_SRC_POS_ARGS);
     167                                               RTTHREADSTATE_MUTEX, true, pSrcPos);
    168168        if (RT_FAILURE(rc9))
    169169            return rc9;
    170 #else
     170#endif
    171171        RTThreadBlocking(hThreadSelf, RTTHREADSTATE_MUTEX);
    172 #endif
    173172    }
    174173    int rc = WaitForSingleObjectEx(pThis->hMtx,
     
    180179        case WAIT_OBJECT_0:
    181180#ifdef RTSEMMUTEX_STRICT
    182             RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, RTSEMMUTEX_STRICT_POS_ARGS);
     181            RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    183182#endif
    184183            return VINF_SUCCESS;
     
    204203{
    205204#ifndef RTSEMMUTEX_STRICT
    206     return rtSemMutexRequestNoResume(MutexSem, cMillies, RTSEMMUTEX_STRICT_POS_ARGS);
     205    return rtSemMutexRequestNoResume(MutexSem, cMillies, NULL);
    207206#else
    208     return RTSemMutexRequestNoResumeDebug(MutexSem, cMillies, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);
     207    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API();
     208    return rtSemMutexRequestNoResume(MutexSem, cMillies, &SrcPos);
    209209#endif
    210210}
     
    213213RTDECL(int) RTSemMutexRequestNoResumeDebug(RTSEMMUTEX MutexSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    214214{
    215 #ifdef RTSEMMUTEX_STRICT
    216     return rtSemMutexRequestNoResume(MutexSem, cMillies, RTSEMMUTEX_STRICT_POS_ARGS);
    217 #else
    218     return RTSemMutexRequestNoResume(MutexSem, cMillies);
    219 #endif
     215    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     216    return rtSemMutexRequestNoResume(MutexSem, cMillies, &SrcPos);
    220217}
    221218
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