Changeset 25833 in vbox
- Timestamp:
- Jan 14, 2010 3:56:16 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp
r25791 r25833 498 498 499 499 /** 500 * Helper for getting the class name. 501 * @returns Class name string. 502 * @param pClass The class. 503 */ 504 static const char *rtLockValComplainGetClassName(RTLOCKVALCLASSINT *pClass) 505 { 506 if (!pClass) 507 return "<nil-class>"; 508 if (!VALID_PTR(pClass)) 509 return "<bad-class-ptr>"; 510 if (pClass->u32Magic != RTLOCKVALCLASS_MAGIC) 511 return "<bad-class-magic>"; 512 if (!pClass->pszName) 513 return "<no-class-name>"; 514 return pClass->pszName; 515 } 516 517 /** 518 * Formats the sub-class. 519 * 520 * @returns Stringified sub-class. 521 * @param uSubClass The name. 522 * @param pszBuf Buffer that is big enough. 523 */ 524 static const char *rtLockValComplainGetSubClassName(uint32_t uSubClass, char *pszBuf) 525 { 526 if (uSubClass < RTLOCKVAL_SUB_CLASS_USER) 527 switch (uSubClass) 528 { 529 case RTLOCKVAL_SUB_CLASS_NONE: return "none"; 530 case RTLOCKVAL_SUB_CLASS_ANY: return "any"; 531 default: 532 RTStrPrintf(pszBuf, 32, "invl-%u", uSubClass); 533 break; 534 } 535 else 536 RTStrPrintf(pszBuf, 32, "%x", uSubClass); 537 return pszBuf; 538 } 539 540 541 /** 500 542 * Helper for rtLockValComplainAboutLock. 501 543 */ 502 544 DECL_FORCE_INLINE(void) rtLockValComplainAboutLockHlp(const char *pszPrefix, PRTLOCKVALRECUNION pRec, const char *pszSuffix, 503 545 uint32_t u32Magic, PCRTLOCKVALSRCPOS pSrcPos, uint32_t cRecursion, 504 const char *pszSuffix2) 505 { 546 const char *pszFrameType) 547 { 548 char szBuf[32]; 506 549 switch (u32Magic) 507 550 { 508 551 case RTLOCKVALRECEXCL_MAGIC: 509 552 #ifdef RTLOCKVAL_WITH_VERBOSE_DUMPS 510 RTAssertMsg2AddWeak("%s%p %s xrec=%p own=%s nest=%u pos={%Rbn(%u) %Rfn %p}%s%s", pszPrefix,553 RTAssertMsg2AddWeak("%s%p %s xrec=%p own=%s r=%u cls=%s/%s pos={%Rbn(%u) %Rfn %p} [x%s]%s", pszPrefix, 511 554 pRec->Excl.hLock, pRec->Excl.pszName, pRec, 512 555 rtLockValidatorNameThreadHandle(&pRec->Excl.hThread), cRecursion, 556 rtLockValComplainGetClassName(pRec->Excl.hClass), 557 rtLockValComplainGetSubClassName(pRec->Excl.uSubClass, szBuf), 513 558 pSrcPos->pszFile, pSrcPos->uLine, pSrcPos->pszFunction, pSrcPos->uId, 514 psz Suffix2, pszSuffix);559 pszFrameType, pszSuffix); 515 560 #else 516 RTAssertMsg2AddWeak("%s%p %s own=%s nest=%u pos={%Rbn(%u) %Rfn %p}%s%s", pszPrefix,561 RTAssertMsg2AddWeak("%s%p %s own=%s r=%u cls=%s/%s pos={%Rbn(%u) %Rfn %p} [x%s]%s", pszPrefix, 517 562 pRec->Excl.hLock, pRec->Excl.szName, 518 563 rtLockValidatorNameThreadHandle(&pRec->Excl.hThread), cRecursion, 564 rtLockValComplainGetClassName(pRec->Excl.hClass), 565 rtLockValComplainGetSubClassName(pRec->Excl.uSubClass, szBuf), 519 566 pSrcPos->pszFile, pSrcPos->uLine, pSrcPos->pszFunction, pSrcPos->uId, 520 psz Suffix2, pszSuffix);567 pszFrameType, pszSuffix); 521 568 #endif 522 569 break; 523 570 524 571 case RTLOCKVALRECSHRD_MAGIC: 525 RTAssertMsg2AddWeak("%s %p %s srec=%p%s", pszPrefix,572 RTAssertMsg2AddWeak("%ss %p %s srec=%p cls=%s/%s [s%s]%s", pszPrefix, 526 573 pRec->Shared.hLock, pRec->Shared.szName, pRec, 527 pszSuffix); 574 rtLockValComplainGetClassName(pRec->Shared.hClass), 575 rtLockValComplainGetSubClassName(pRec->Shared.uSubClass, szBuf), 576 pszFrameType, pszSuffix); 528 577 break; 529 578 … … 534 583 && pShared->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC) 535 584 #ifdef RTLOCKVAL_WITH_VERBOSE_DUMPS 536 RTAssertMsg2AddWeak("%s%p %s srec=%p trec=%p thr=%s nest=%u pos={%Rbn(%u) %Rfn %p}%s%s", pszPrefix,585 RTAssertMsg2AddWeak("%s%p %s srec=%p trec=%p own=%s r=%u cls=%s/%s pos={%Rbn(%u) %Rfn %p} [o%s]%s", pszPrefix, 537 586 pShared->hLock, pShared->pszName, pShared, 538 587 pRec, rtLockValidatorNameThreadHandle(&pRec->ShrdOwner.hThread), cRecursion, 588 rtLockValComplainGetClassName(pShared->hClass), 589 rtLockValComplainGetSubClassName(pShared->uSubClass, szBuf), 539 590 pSrcPos->pszFile, pSrcPos->uLine, pSrcPos->pszFunction, pSrcPos->uId, 540 591 pszSuffix2, pszSuffix); 541 592 #else 542 RTAssertMsg2AddWeak("%s%p %s thr=%s nest=%u pos={%Rbn(%u) %Rfn %p}%s%s", pszPrefix,593 RTAssertMsg2AddWeak("%s%p %s own=%s r=%u cls=%s/%s pos={%Rbn(%u) %Rfn %p} [o%s]%s", pszPrefix, 543 594 pShared->hLock, pShared->szName, 544 595 rtLockValidatorNameThreadHandle(&pRec->ShrdOwner.hThread), cRecursion, 596 rtLockValComplainGetClassName(pShared->hClass), 597 rtLockValComplainGetSubClassName(pShared->uSubClass, szBuf), 545 598 pSrcPos->pszFile, pSrcPos->uLine, pSrcPos->pszFunction, pSrcPos->uId, 546 psz Suffix2, pszSuffix);599 pszFrameType, pszSuffix); 547 600 #endif 548 601 else 549 RTAssertMsg2AddWeak("%sbad srec=%p trec=%p thr=%s nest=%u pos={%Rbn(%u) %Rfn %p}%s%s", pszPrefix,602 RTAssertMsg2AddWeak("%sbad srec=%p trec=%p own=%s r=%u pos={%Rbn(%u) %Rfn %p} [x%s]%s", pszPrefix, 550 603 pShared, 551 604 pRec, rtLockValidatorNameThreadHandle(&pRec->ShrdOwner.hThread), cRecursion, 552 605 pSrcPos->pszFile, pSrcPos->uLine, pSrcPos->pszFunction, pSrcPos->uId, 553 psz Suffix2, pszSuffix);606 pszFrameType, pszSuffix); 554 607 break; 555 608 } … … 570 623 static void rtLockValComplainAboutLock(const char *pszPrefix, PRTLOCKVALRECUNION pRec, const char *pszSuffix) 571 624 { 625 #ifdef RTLOCKVAL_WITH_RECURSION_RECORDS 626 # define FIX_REC(r) 1 627 #else 628 # define FIX_REC(r) (r) 629 #endif 572 630 if ( VALID_PTR(pRec) 573 631 && !ASMAtomicUoReadBool(&g_fLockValidatorQuiet)) … … 577 635 case RTLOCKVALRECEXCL_MAGIC: 578 636 rtLockValComplainAboutLockHlp(pszPrefix, pRec, pszSuffix, RTLOCKVALRECEXCL_MAGIC, 579 &pRec->Excl.SrcPos, pRec->Excl.cRecursion, "");637 &pRec->Excl.SrcPos, FIX_REC(pRec->Excl.cRecursion), ""); 580 638 break; 581 639 … … 586 644 case RTLOCKVALRECSHRDOWN_MAGIC: 587 645 rtLockValComplainAboutLockHlp(pszPrefix, pRec, pszSuffix, RTLOCKVALRECSHRDOWN_MAGIC, 588 &pRec->ShrdOwner.SrcPos, pRec->ShrdOwner.cRecursion, "");646 &pRec->ShrdOwner.SrcPos, FIX_REC(pRec->ShrdOwner.cRecursion), ""); 589 647 break; 590 648 … … 599 657 ) 600 658 rtLockValComplainAboutLockHlp(pszPrefix, pRealRec, pszSuffix, u32Magic, 601 &pRec->Nest.SrcPos, pRec->Nest.cRecursion, " [recursion]");659 &pRec->Nest.SrcPos, pRec->Nest.cRecursion, "/r"); 602 660 else 603 RTAssertMsg2AddWeak("%sbad rrec=%p nrec=%p nest=%u pos={%Rbn(%u) %Rfn %p}%s", pszPrefix,661 RTAssertMsg2AddWeak("%sbad rrec=%p nrec=%p r=%u pos={%Rbn(%u) %Rfn %p}%s", pszPrefix, 604 662 pRealRec, pRec, pRec->Nest.cRecursion, 605 663 pRec->Nest.SrcPos.pszFile, pRec->Nest.SrcPos.uLine, pRec->Nest.SrcPos.pszFunction, pRec->Nest.SrcPos.uId, … … 613 671 } 614 672 } 673 #undef FIX_REC 615 674 } 616 675
Note:
See TracChangeset
for help on using the changeset viewer.