Changeset 25704 in vbox for trunk/src/VBox/Runtime/common/misc
- Timestamp:
- Jan 10, 2010 8:12:30 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp
r25703 r25704 509 509 #else 510 510 RTAssertMsg2AddWeak("%s%p %s own=%s nest=%u pos={%Rbn(%u) %Rfn %p}%s%s", pszPrefix, 511 pRec->Excl.hLock, pRec->Excl. pszName,511 pRec->Excl.hLock, pRec->Excl.szName, 512 512 rtLockValidatorNameThreadHandle(&pRec->Excl.hThread), cRecursion, 513 513 pSrcPos->pszFile, pSrcPos->uLine, pSrcPos->pszFunction, pSrcPos->uId, … … 518 518 case RTLOCKVALRECSHRD_MAGIC: 519 519 RTAssertMsg2AddWeak("%s%p %s srec=%p%s", pszPrefix, 520 pRec->Shared.hLock, pRec->Shared. pszName, pRec,520 pRec->Shared.hLock, pRec->Shared.szName, pRec, 521 521 pszSuffix); 522 522 break; … … 535 535 #else 536 536 RTAssertMsg2AddWeak("%s%p %s thr=%s nest=%u pos={%Rbn(%u) %Rfn %p}%s%s", pszPrefix, 537 pShared->hLock, pShared-> pszName,537 pShared->hLock, pShared->szName, 538 538 rtLockValidatorNameThreadHandle(&pRec->ShrdOwner.hThread), cRecursion, 539 539 pSrcPos->pszFile, pSrcPos->uLine, pSrcPos->pszFunction, pSrcPos->uId, … … 1024 1024 1025 1025 1026 RTDECL(int) RTLockValidatorClassCreate(PRTLOCKVALCLASS phClass, bool fAutodidact, RT_SRC_POS_DECL )1026 RTDECL(int) RTLockValidatorClassCreate(PRTLOCKVALCLASS phClass, bool fAutodidact, RT_SRC_POS_DECL, const char *pszNameFmt, ...) 1027 1027 { 1028 1028 RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_POS_NO_ID(); 1029 return RTLockValidatorClassCreateEx(phClass, &SrcPos, 1030 fAutodidact, true /*fRecursionOk*/, false /*fStrictReleaseOrder*/, 1031 1 /*cMsMinDeadlock*/, 1 /*cMsMinOrder*/, 1032 NULL /*pszName*/); 1029 va_list va; 1030 va_start(va, pszNameFmt); 1031 int rc = RTLockValidatorClassCreateExV(phClass, &SrcPos, 1032 fAutodidact, true /*fRecursionOk*/, false /*fStrictReleaseOrder*/, 1033 1 /*cMsMinDeadlock*/, 1 /*cMsMinOrder*/, 1034 pszNameFmt, va); 1035 va_end(va); 1036 return rc; 1033 1037 } 1034 1038 … … 1456 1460 { 1457 1461 case RTLOCKVALRECEXCL_MAGIC: 1458 return pRec->Excl. pszName;1462 return pRec->Excl.szName; 1459 1463 case RTLOCKVALRECSHRD_MAGIC: 1460 return pRec->Shared. pszName;1464 return pRec->Shared.szName; 1461 1465 case RTLOCKVALRECSHRDOWN_MAGIC: 1462 return pRec->ShrdOwner.pSharedRec ? pRec->ShrdOwner.pSharedRec-> pszName : "orphaned";1466 return pRec->ShrdOwner.pSharedRec ? pRec->ShrdOwner.pSharedRec->szName : "orphaned"; 1463 1467 case RTLOCKVALRECNEST_MAGIC: 1464 1468 pRec = rtLockValidatorReadRecUnionPtr(&pRec->Nest.pRec); … … 1468 1472 { 1469 1473 case RTLOCKVALRECEXCL_MAGIC: 1470 return pRec->Excl. pszName;1474 return pRec->Excl.szName; 1471 1475 case RTLOCKVALRECSHRD_MAGIC: 1472 return pRec->Shared. pszName;1476 return pRec->Shared.szName; 1473 1477 case RTLOCKVALRECSHRDOWN_MAGIC: 1474 return pRec->ShrdOwner.pSharedRec ? pRec->ShrdOwner.pSharedRec-> pszName : "orphaned";1478 return pRec->ShrdOwner.pSharedRec ? pRec->ShrdOwner.pSharedRec->szName : "orphaned"; 1475 1479 default: 1476 1480 return "unknown-nested"; … … 2798 2802 2799 2803 2800 RTDECL(void) RTLockValidatorRecExclInit (PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,2801 const char *pszName, void *hLock, bool fEnabled)2804 RTDECL(void) RTLockValidatorRecExclInitV(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass, 2805 void *hLock, bool fEnabled, const char *pszNameFmt, va_list va) 2802 2806 { 2803 2807 RTLOCKVAL_ASSERT_PTR_ALIGN(pRec); … … 2816 2820 pRec->cRecursion = 0; 2817 2821 pRec->hLock = hLock; 2818 pRec->pszName = pszName;2819 2822 pRec->pSibling = NULL; 2823 if (pszNameFmt) 2824 RTStrPrintfV(pRec->szName, sizeof(pRec->szName), pszNameFmt, va); 2825 else 2826 { 2827 static uint32_t volatile s_cAnonymous = 0; 2828 uint32_t i = ASMAtomicIncU32(&s_cAnonymous) - 1; 2829 RTStrPrintf(pRec->szName, sizeof(pRec->szName), "anon-excl-%u", i); 2830 } 2820 2831 2821 2832 /* Lazy initialization. */ … … 2825 2836 2826 2837 2827 RTDECL(int) RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, 2828 uint32_t uSubClass, const char *pszName, void *pvLock, bool fEnabled) 2838 RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass, 2839 void *hLock, bool fEnabled, const char *pszNameFmt, ...) 2840 { 2841 va_list va; 2842 va_start(va, pszNameFmt); 2843 RTLockValidatorRecExclInitV(pRec, hClass, uSubClass, hLock, fEnabled, pszNameFmt, va); 2844 va_end(va); 2845 } 2846 2847 2848 RTDECL(int) RTLockValidatorRecExclCreateV(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, 2849 uint32_t uSubClass, void *pvLock, bool fEnabled, 2850 const char *pszNameFmt, va_list va) 2829 2851 { 2830 2852 PRTLOCKVALRECEXCL pRec; … … 2832 2854 if (!pRec) 2833 2855 return VERR_NO_MEMORY; 2834 2835 RTLockValidatorRecExclInit(pRec, hClass, uSubClass, pszName, pvLock, fEnabled); 2836 2856 RTLockValidatorRecExclInitV(pRec, hClass, uSubClass, pvLock, fEnabled, pszNameFmt, va); 2837 2857 return VINF_SUCCESS; 2858 } 2859 2860 2861 RTDECL(int) RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, 2862 uint32_t uSubClass, void *pvLock, bool fEnabled, 2863 const char *pszNameFmt, ...) 2864 { 2865 va_list va; 2866 va_start(va, pszNameFmt); 2867 int rc = RTLockValidatorRecExclCreateV(ppRec, hClass, uSubClass, pvLock, fEnabled, pszNameFmt, va); 2868 va_end(va); 2869 return rc; 2838 2870 } 2839 2871 … … 2866 2898 RTMemFree(pRec); 2867 2899 } 2900 } 2901 2902 2903 RTDECL(uint32_t) RTLockValidatorRecExclSetSubClass(PRTLOCKVALRECEXCL pRec, uint32_t uSubClass) 2904 { 2905 AssertPtrReturn(pRec, RTLOCKVAL_SUB_CLASS_INVALID); 2906 AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, RTLOCKVAL_SUB_CLASS_INVALID); 2907 AssertReturn( uSubClass >= RTLOCKVAL_SUB_CLASS_USER 2908 || uSubClass == RTLOCKVAL_SUB_CLASS_NONE 2909 || uSubClass == RTLOCKVAL_SUB_CLASS_ANY, 2910 RTLOCKVAL_SUB_CLASS_INVALID); 2911 return ASMAtomicXchgU32(&pRec->uSubClass, uSubClass); 2868 2912 } 2869 2913 … … 3180 3224 3181 3225 3182 RTDECL(void) RTLockValidatorRecSharedInit (PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,3183 const char *pszName, void *hLock, bool fSignaller, bool fEnabled)3226 RTDECL(void) RTLockValidatorRecSharedInitV(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass, 3227 void *hLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, va_list va) 3184 3228 { 3185 3229 RTLOCKVAL_ASSERT_PTR_ALIGN(pRec); … … 3190 3234 pRec->hClass = rtLockValidatorClassValidateAndRetain(hClass); 3191 3235 pRec->hLock = hLock; 3192 pRec->pszName = pszName;3193 3236 pRec->fEnabled = fEnabled && RTLockValidatorIsEnabled(); 3194 3237 pRec->fSignaller = fSignaller; … … 3202 3245 pRec->fPadding = false; 3203 3246 pRec->papOwners = NULL; 3204 #if HC_ARCH_BITS == 32 3205 pRec->u32Alignment = UINT32_MAX; 3206 #endif 3247 3248 /* the name */ 3249 if (pszNameFmt) 3250 RTStrPrintfV(pRec->szName, sizeof(pRec->szName), pszNameFmt, va); 3251 else 3252 { 3253 static uint32_t volatile s_cAnonymous = 0; 3254 uint32_t i = ASMAtomicIncU32(&s_cAnonymous) - 1; 3255 RTStrPrintf(pRec->szName, sizeof(pRec->szName), "anon-shrd-%u", i); 3256 } 3257 } 3258 3259 3260 RTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass, 3261 void *hLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, ...) 3262 { 3263 va_list va; 3264 va_start(va, pszNameFmt); 3265 RTLockValidatorRecSharedInitV(pRec, hClass, uSubClass, hLock, fSignaller, fEnabled, pszNameFmt, va); 3266 va_end(va); 3207 3267 } 3208 3268
Note:
See TracChangeset
for help on using the changeset viewer.