VirtualBox

Ignore:
Timestamp:
Dec 20, 2009 4:41:19 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56192
Message:

iprt/lockvalidator.h: Added a enabled setting to assist testing.

File:
1 edited

Legend:

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

    r25508 r25519  
    6161 */
    6262static RTSEMXROADS g_hLockValidatorXRoads = NIL_RTSEMXROADS;
     63/** Whether the lock validator is enabled or disabled.
     64 * Only applies to new locks.  */
     65static bool volatile g_fLockValidatorEnabled = true;
    6366
    6467
     
    144147{
    145148    pRec->u32Magic      = RTLOCKVALIDATORREC_MAGIC;
     149    pRec->fEnabled      = RTLockValidatorIsEnabled();
     150    pRec->afReserved[0] = 0;
     151    pRec->afReserved[1] = 0;
     152    pRec->afReserved[2] = 0;
    146153    rtLockValidatorInitSrcPos(&pRec->SrcPos);
    147154    pRec->hThread       = NIL_RTTHREAD;
     
    215222    pRec->hLock         = hLock;
    216223    pRec->pszName       = pszName;
     224    pRec->fEnabled      = RTLockValidatorIsEnabled();
    217225
    218226    /* the table */
     
    223231    pRec->afPadding[0]  = false;
    224232    pRec->afPadding[1]  = false;
    225     pRec->afPadding[2]  = false;
    226233    pRec->papOwners     = NULL;
    227234    pRec->u64Alignment  = UINT64_MAX;
     
    500507{
    501508    AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     509    if (!pRec->fEnabled)
     510        return VINF_SUCCESS;
    502511
    503512    /*
     
    517526{
    518527    AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     528    if (!pRec->fEnabled)
     529        return VINF_SUCCESS;
    519530    AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
    520531
     
    527538{
    528539    AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     540    if (!pRead->fEnabled)
     541        return VINF_SUCCESS;
    529542    AssertReturn(hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
    530543
     
    560573{
    561574    AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     575    if (!pRec->fEnabled)
     576        return VINF_SUCCESS;
    562577    AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
    563578
     
    572587{
    573588    AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     589    if (!pRec->fEnabled)
     590        return VINF_SUCCESS;
    574591    AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
    575592    AssertReturn(pRec->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
     
    584601{
    585602    AssertReturn(pWrite->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     603    AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     604    AssertReturn(pRead->fEnabled == pWrite->fEnabled, VERR_SEM_LV_INVALID_PARAMETER);
     605    if (!pWrite->fEnabled)
     606        return VINF_SUCCESS;
    586607    AssertReturn(pWrite->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
    587608    AssertReturn(pWrite->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
    588     AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    589609
    590610    Assert(pWrite->cRecursion < _1M);
     
    598618{
    599619    AssertReturn(pWrite->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     620    AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     621    AssertReturn(pRead->fEnabled == pWrite->fEnabled, VERR_SEM_LV_INVALID_PARAMETER);
     622    if (!pWrite->fEnabled)
     623        return VINF_SUCCESS;
    600624    AssertReturn(pWrite->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
    601625    AssertReturn(pWrite->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
    602     AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    603626
    604627    Assert(pWrite->cRecursion);
     
    611634{
    612635    AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, NIL_RTTHREAD);
    613 
     636    if (!pRec->fEnabled)
     637        return VINF_SUCCESS;
    614638    if (hThread == NIL_RTTHREAD)
    615639    {
     
    646670{
    647671    AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, NIL_RTTHREAD);
     672    if (!pRec->fEnabled)
     673        return VINF_SUCCESS;
    648674    RTTHREADINT *pThread = pRec->hThread;
    649675    AssertReturn(pThread != NIL_RTTHREAD, pThread);
     
    671697{
    672698    AssertReturnVoid(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC);
     699    if (!pRead->fEnabled)
     700        return;
    673701    AssertReturnVoid(hThread != NIL_RTTHREAD);
    674702
     
    700728{
    701729    AssertReturnVoid(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC);
     730    if (!pRead->fEnabled)
     731        return;
    702732    AssertReturnVoid(hThread != NIL_RTTHREAD);
     733
    703734    AssertMsgFailed(("Not implemented"));
    704735}
     
    879910     * Fend off wild life.
    880911     */
    881     AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER);
    882912    AssertPtrReturn(pWrite, VERR_SEM_LV_INVALID_PARAMETER);
    883913    AssertReturn(pWrite->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    884914    AssertPtrReturn(pRead, VERR_SEM_LV_INVALID_PARAMETER);
    885915    AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     916    AssertReturn(pRead->fEnabled == pWrite->fEnabled, VERR_SEM_LV_INVALID_PARAMETER);
     917    if (!pWrite->fEnabled)
     918        return VINF_SUCCESS;
     919    AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER);
    886920    PRTTHREADINT pThread = hThread;
    887921    AssertPtrReturn(pThread, VERR_SEM_LV_INVALID_PARAMETER);
     
    918952     * Fend off wild life.
    919953     */
    920     AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER);
    921954    AssertPtrReturn(pRead, VERR_SEM_LV_INVALID_PARAMETER);
    922955    AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    923956    AssertPtrReturn(pWrite, VERR_SEM_LV_INVALID_PARAMETER);
    924957    AssertReturn(pWrite->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     958    AssertReturn(pRead->fEnabled == pWrite->fEnabled, VERR_SEM_LV_INVALID_PARAMETER);
     959    if (!pRead->fEnabled)
     960        return VINF_SUCCESS;
     961    AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER);
    925962    PRTTHREADINT pThread = hThread;
    926963    AssertPtrReturn(pThread, VERR_SEM_LV_INVALID_PARAMETER);
     
    945982     * Fend off wild life.
    946983     */
    947     AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER);
    948984    AssertPtrReturn(pRec, VERR_SEM_LV_INVALID_PARAMETER);
    949985    AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     986    if (!pRec->fEnabled)
     987        return VINF_SUCCESS;
     988    AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER);
    950989    PRTTHREADINT pThread = hThread;
    951990    AssertPtrReturn(pThread, VERR_SEM_LV_INVALID_PARAMETER);
     
    10831122    return VERR_SEM_LV_DEADLOCK;
    10841123}
    1085 RT_EXPORT_SYMBOL(RTThreadBlocking);
    1086 
     1124RT_EXPORT_SYMBOL(RTLockValidatorCheckBlocking);
     1125
     1126
     1127RTDECL(bool) RTLockValidatorSetEnabled(bool fEnabled)
     1128{
     1129    return ASMAtomicXchgBool(&g_fLockValidatorEnabled, fEnabled);
     1130}
     1131RT_EXPORT_SYMBOL(RTLockValidatorSetEnabled);
     1132
     1133
     1134RTDECL(bool) RTLockValidatorIsEnabled(void)
     1135{
     1136    return ASMAtomicUoReadBool(&g_fLockValidatorEnabled);
     1137}
     1138RT_EXPORT_SYMBOL(RTLockValidatorIsEnabled);
     1139
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