VirtualBox

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


Ignore:
Timestamp:
Jan 14, 2010 7:47:44 PM (15 years ago)
Author:
vboxsync
Message:

lockvalidator.cpp: Made it possible to configure it via the enviornment. Added a soft lock order mode.

File:
1 edited

Legend:

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

    r25833 r25844  
    3737#include <iprt/asm.h>
    3838#include <iprt/assert.h>
     39#include <iprt/env.h>
    3940#include <iprt/err.h>
    4041#include <iprt/mem.h>
     
    240241 */
    241242static RTSEMXROADS      g_hLockValidatorXRoads   = NIL_RTSEMXROADS;
     243/** Serializing class tree insert and lookups. */
     244static RTSEMRW          g_hLockValClassTreeRWLock= NIL_RTSEMRW;
     245/** Class tree. */
     246static PAVLLU32NODECORE g_LockValClassTree       = NULL;
     247/** Critical section serializing the teaching new rules to the classes. */
     248static RTCRITSECT       g_LockValClassTeachCS;
     249
    242250/** Whether the lock validator is enabled or disabled.
    243251 * Only applies to new locks.  */
     
    255263static bool volatile    g_fLockValidatorMayPanic = false;
    256264#endif
    257 /** Serializing class tree insert and lookups. */
    258 static RTSEMRW          g_hLockValClassTreeRWLock= NIL_RTSEMRW;
    259 /** Class tree. */
    260 static PAVLLU32NODECORE g_LockValClassTree       = NULL;
    261 /** Critical section serializing the teaching new rules to the classes. */
    262 static RTCRITSECT       g_LockValClassTeachCS;
     265/** Whether to return an error status on wrong locking order. */
     266static bool volatile    g_fLockValSoftWrongOrder = false;
    263267
    264268
     
    278282    if (ASMAtomicCmpXchgU32(&s_fInitializing, true, false))
    279283    {
     284        /*
     285         * The locks.
     286         */
    280287        if (!RTCritSectIsInitialized(&g_LockValClassTeachCS))
    281288            RTCritSectInitEx(&g_LockValClassTeachCS, RTCRITSECT_FLAGS_NO_LOCK_VAL, NIL_RTLOCKVALCLASS,
     
    298305        }
    299306
     307#ifdef IN_RING3
     308        /*
     309         * Check the environment for our config variables.
     310         */
     311        if (RTEnvExist("IPRT_LOCK_VALIDATOR_ENABLED"))
     312            ASMAtomicWriteBool(&g_fLockValidatorEnabled, true);
     313        if (RTEnvExist("IPRT_LOCK_VALIDATOR_DISABLED"))
     314            ASMAtomicWriteBool(&g_fLockValidatorEnabled, false);
     315
     316        if (RTEnvExist("IPRT_LOCK_VALIDATOR_MAY_PANIC"))
     317            ASMAtomicWriteBool(&g_fLockValidatorMayPanic, true);
     318        if (RTEnvExist("IPRT_LOCK_VALIDATOR_MAY_NOT_PANIC"))
     319            ASMAtomicWriteBool(&g_fLockValidatorMayPanic, false);
     320
     321        if (RTEnvExist("IPRT_LOCK_VALIDATOR_NOT_QUIET"))
     322            ASMAtomicWriteBool(&g_fLockValidatorQuiet, false);
     323        if (RTEnvExist("IPRT_LOCK_VALIDATOR_QUIET"))
     324            ASMAtomicWriteBool(&g_fLockValidatorQuiet, true);
     325
     326        if (RTEnvExist("IPRT_LOCK_VALIDATOR_STRICT_ORDER"))
     327            ASMAtomicWriteBool(&g_fLockValSoftWrongOrder, false);
     328        if (RTEnvExist("IPRT_LOCK_VALIDATOR_SOFT_ORDER"))
     329            ASMAtomicWriteBool(&g_fLockValSoftWrongOrder, true);
     330#endif
     331
     332        /*
     333         * Register cleanup
     334         */
    300335        /** @todo register some cleanup callback if we care. */
    301336
     
    14481483    }
    14491484    else
    1450         rc = VERR_SEM_LV_WRONG_ORDER;
     1485        rc = !g_fLockValSoftWrongOrder ? VERR_SEM_LV_WRONG_ORDER : VINF_SUCCESS;
    14511486
    14521487    if (RT_SUCCESS(rcLock))
     
    21332168    rtLockValComplainAboutLockStack(pThreadSelf, 0, 0, pRec2);
    21342169    rtLockValComplainPanic();
    2135     return VERR_SEM_LV_WRONG_ORDER;
     2170    return !g_fLockValSoftWrongOrder ? VERR_SEM_LV_WRONG_ORDER : VINF_SUCCESS;
    21362171}
    21372172
     
    24422477    rtLockValComplainFirst("Wrong release order!", NULL, pThreadSelf, pRec, true);
    24432478    rtLockValComplainPanic();
    2444     return VERR_SEM_LV_WRONG_RELEASE_ORDER;
     2479    return !g_fLockValSoftWrongOrder ? VERR_SEM_LV_WRONG_RELEASE_ORDER : VINF_SUCCESS;
    24452480}
    24462481
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