From: VMware, Inc <> Date: Thu, 18 Nov 2010 22:13:16 +0000 (-0800) Subject: lib/lock: concentrate the MXUSER_DEBUG code X-Git-Tag: 2010.11.17-327185~34 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb699a591aa7c1d07930e9c9395e4adeebbdd2ea;p=thirdparty%2Fopen-vm-tools.git lib/lock: concentrate the MXUSER_DEBUG code Group the debug code together, all under the same ifdefs. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/include/userlock.h b/open-vm-tools/lib/include/userlock.h index bddeaea76..77255a1f5 100644 --- a/open-vm-tools/lib/include/userlock.h +++ b/open-vm-tools/lib/include/userlock.h @@ -214,7 +214,7 @@ MXUserRecLock *MXUser_InitFromMXRec(const char *name, #endif -#if defined(VMX86_DEBUG) +#if defined(VMX86_DEBUG) && !defined(DISABLE_MXUSER_DEBUG) #define MXUSER_DEBUG // debugging "everywhere" when requested #endif diff --git a/open-vm-tools/lib/lock/ul.c b/open-vm-tools/lib/lock/ul.c index 25f60fb4b..6a02ffff6 100644 --- a/open-vm-tools/lib/lock/ul.c +++ b/open-vm-tools/lib/lock/ul.c @@ -69,7 +69,7 @@ static Atomic_Ptr hashTableMem; *----------------------------------------------------------------------------- */ -MXUserPerThread * +static MXUserPerThread * MXUserGetPerThread(void *tid, // IN: native thread ID Bool mayAlloc) // IN: alloc perThread if not present? { @@ -109,6 +109,43 @@ MXUserGetPerThread(void *tid, // IN: native thread ID } +/* + *----------------------------------------------------------------------------- + * + * MXUserListLocks + * + * Allow a caller to list, via warnings, the list of locks the caller + * has acquired. Ensure that no memory for lock tracking is allocated + * if no locks have been taken. + * + * Results: + * The list is printed + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +void +MXUserListLocks(void) +{ + MXUserPerThread *perThread = MXUserGetPerThread(MXUserGetNativeTID(), + FALSE); + + if (perThread != NULL) { + uint32 i; + + for (i = 0; i < perThread->locksHeld; i++) { + MXUserHeader *hdr = perThread->lockArray[i]; + + Warning("\tMXUser lock %s (@%p) rank 0x%x\n", hdr->name, hdr, + hdr->rank); + } + } +} + + /* *----------------------------------------------------------------------------- * @@ -161,10 +198,6 @@ MXUserAcquisitionTracking(MXUserHeader *header, // IN: ASSERT_NOT_IMPLEMENTED(perThread->locksHeld < MXUSER_MAX_LOCKS_PER_THREAD); -#if defined(DISABLE_MXUSER_LOCK_RANKS) - checkRank = FALSE; -#endif - /* Rank checking anyone? */ if (checkRank && (header->rank != RANK_UNRANKED)) { uint32 i; @@ -500,42 +533,3 @@ MXUserInstallMxHooks(void (*theLockListFunc)(void), ); } } - - -/* - *----------------------------------------------------------------------------- - * - * MXUserListLocks - * - * Allow a caller to list, via warnings, the list of locks the caller - * has acquired. Ensure that no memory for lock tracking is allocated - * if no locks have been taken. - * - * Results: - * The list is printed - * - * Side effects: - * None - * - *----------------------------------------------------------------------------- - */ - -void -MXUserListLocks(void) -{ -#if defined(MXUSER_DEBUG) - MXUserPerThread *perThread = MXUserGetPerThread(MXUserGetNativeTID(), - FALSE); - - if (perThread != NULL) { - uint32 i; - - for (i = 0; i < perThread->locksHeld; i++) { - MXUserHeader *hdr = perThread->lockArray[i]; - - Warning("\tMXUser lock %s (@%p) rank 0x%x\n", hdr->name, hdr, - hdr->rank); - } - } -#endif -} diff --git a/open-vm-tools/lib/lock/ulIntShared.h b/open-vm-tools/lib/lock/ulIntShared.h index 9e2d439c4..a20036ca4 100644 --- a/open-vm-tools/lib/lock/ulIntShared.h +++ b/open-vm-tools/lib/lock/ulIntShared.h @@ -19,7 +19,16 @@ #ifndef _ULINTSHARED_H_ #define _ULINTSHARED_H_ + +#if defined(MXUSER_DEBUG) extern void MXUserListLocks(void); +#else +static INLINE void +MXUserListLocks(void) +{ + return; +} +#endif extern void MXUserInstallMxHooks(void (*theLockListFunc)(void), MX_Rank (*theRankFunc)(void), diff --git a/open-vm-tools/lib/lock/ulRW.c b/open-vm-tools/lib/lock/ulRW.c index a61979ef7..da201f973 100644 --- a/open-vm-tools/lib/lock/ulRW.c +++ b/open-vm-tools/lib/lock/ulRW.c @@ -868,11 +868,7 @@ MXUser_IsCurThreadHoldingRWLock(MXUserRWLock *lock, // IN: return myContext->state != RW_UNLOCKED; default: -#if defined(MXUSER_DEBUG) Panic("%s: unknown query type %d\n", __FUNCTION__, queryType); -#else - return FALSE; -#endif } }