Changeset 46204 in vbox for trunk/src/VBox/Runtime/common/dbg
- Timestamp:
- May 22, 2013 12:28:12 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 85923
- Location:
- trunk/src/VBox/Runtime/common/dbg
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp
r46164 r46204 35 35 #include <iprt/err.h> 36 36 #include <iprt/mem.h> 37 #define RTDBGMODCNT_WITH_MEM_CACHE 38 #ifdef RTDBGMODCNT_WITH_MEM_CACHE 39 # include <iprt/memcache.h> 40 #endif 37 41 #include <iprt/string.h> 38 42 #include <iprt/strcache.h> … … 135 139 /** The next line number ordinal. */ 136 140 uint32_t iNextLineOrdinal; 141 #ifdef RTDBGMODCNT_WITH_MEM_CACHE 142 /** Line number allocator. 143 * Using a cache is a bit overkill since we normally won't free them, but 144 * it's a construct that exists and does the job relatively efficiently. */ 145 RTMEMCACHE hLineNumAllocator; 146 #endif 137 147 } RTDBGMODCTN; 138 148 /** Pointer to instance data for the debug info container. */ … … 251 261 * Create a new entry. 252 262 */ 263 #ifdef RTDBGMODCNT_WITH_MEM_CACHE 264 PRTDBGMODCTNLINE pLine = (PRTDBGMODCTNLINE)RTMemCacheAlloc(pThis->hLineNumAllocator); 265 #else 253 266 PRTDBGMODCTNLINE pLine = (PRTDBGMODCTNLINE)RTMemAllocZ(sizeof(*pLine)); 267 #endif 254 268 if (!pLine) 255 269 return VERR_NO_MEMORY; … … 625 639 static DECLCALLBACK(int) rtDbgModContainer_DestroyTreeLineNode(PAVLU32NODECORE pNode, void *pvUser) 626 640 { 641 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pvUser; 627 642 PRTDBGMODCTNLINE pLine = RT_FROM_MEMBER(pNode, RTDBGMODCTNLINE, OrdinalCore); 628 643 RTStrCacheRelease(g_hDbgModStrCache, pLine->pszFile); 629 644 pLine->pszFile = NULL; 630 RTMemFree(pLine); 631 NOREF(pvUser); 645 #ifdef RTDBGMODCNT_WITH_MEM_CACHE 646 RTMemCacheFree(pThis->hLineNumAllocator, pLine); 647 #else 648 RTMemFree(pLine); NOREF(pThis); 649 #endif 632 650 return 0; 633 651 } … … 664 682 pThis->Names = NULL; 665 683 666 RTAvlU32Destroy(&pThis->LineOrdinalTree, rtDbgModContainer_DestroyTreeLineNode, NULL); 684 #ifdef RTDBGMODCNT_WITH_MEM_CACHE 685 RTMemCacheDestroy(pThis->hLineNumAllocator); 686 pThis->hLineNumAllocator = NIL_RTMEMCACHE; 687 #else 688 RTAvlU32Destroy(&pThis->LineOrdinalTree, rtDbgModContainer_DestroyTreeLineNode, pThis); 689 #endif 667 690 668 691 RTMemFree(pThis->paSegs); … … 755 778 pThis->paSegs[iSeg].LineAddrTree = NULL; 756 779 757 RTAvlU32Destroy(&pThis->LineOrdinalTree, rtDbgModContainer_DestroyTreeLineNode, NULL);780 RTAvlU32Destroy(&pThis->LineOrdinalTree, rtDbgModContainer_DestroyTreeLineNode, pThis); 758 781 Assert(pThis->LineOrdinalTree == NULL); 759 782 … … 817 840 pMod->pvDbgPriv = pThis; 818 841 819 /* 820 * Add the initial segment. 821 */ 822 if (cbSeg) 823 { 824 int rc = rtDbgModContainer_SegmentAdd(pMod, 0, cbSeg, "default", sizeof("default") - 1, 0, NULL); 825 if (RT_FAILURE(rc)) 826 { 827 RTMemFree(pThis); 828 pMod->pDbgVt = NULL; 829 pMod->pvDbgPriv = NULL; 842 #ifdef RTDBGMODCNT_WITH_MEM_CACHE 843 int rc = RTMemCacheCreate(&pThis->hLineNumAllocator, sizeof(RTDBGMODCTNLINE), sizeof(void *), UINT32_MAX, 844 NULL /*pfnCtor*/, NULL /*pfnDtor*/, NULL /*pvUser*/, 0 /*fFlags*/); 845 #else 846 int rc = VINF_SUCCESS; 847 #endif 848 if (RT_SUCCESS(rc)) 849 { 850 /* 851 * Add the initial segment. 852 */ 853 if (cbSeg) 854 rc = rtDbgModContainer_SegmentAdd(pMod, 0, cbSeg, "default", sizeof("default") - 1, 0, NULL); 855 if (RT_SUCCESS(rc)) 830 856 return rc; 831 } 832 } 833 834 return VINF_SUCCESS; 835 } 836 857 858 #ifdef RTDBGMODCNT_WITH_MEM_CACHE 859 RTMemCacheDestroy(pThis->hLineNumAllocator); 860 #endif 861 } 862 863 RTMemFree(pThis); 864 pMod->pDbgVt = NULL; 865 pMod->pvDbgPriv = NULL; 866 return rc; 867 } 868 -
trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp
r46166 r46204 5 5 6 6 /* 7 * Copyright (C) 2011-201 2Oracle Corporation7 * Copyright (C) 2011-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 39 39 #include <iprt/log.h> 40 40 #include <iprt/mem.h> 41 #define RTDBGMODDWARF_WITH_MEM_CACHE 42 #ifdef RTDBGMODDWARF_WITH_MEM_CACHE 43 # include <iprt/memcache.h> 44 #endif 41 45 #include <iprt/path.h> 42 46 #include <iprt/string.h> … … 473 477 /** Pointer to segments if iWatcomPass isn't -1. */ 474 478 PRTDBGDWARFSEG paSegs; 479 #ifdef RTDBGMODDWARF_WITH_MEM_CACHE 480 /** DIE allocators. */ 481 struct 482 { 483 RTMEMCACHE hMemCache; 484 uint32_t cbMax; 485 } aDieAllocators[2]; 486 #endif 475 487 } RTDBGMODDWARF; 476 488 /** Pointer to instance data of the DWARF reader. */ … … 646 658 /** The number of unknown or otherwise unhandled attributes. */ 647 659 uint8_t cUnhandledAttrs; 648 /** The date tag, indicating which union structure to use. */ 660 #ifdef RTDBGMODDWARF_WITH_MEM_CACHE 661 /** The allocator index. */ 662 uint8_t iAllocator; 663 #endif 664 /** The die tag, indicating which union structure to use. */ 649 665 uint16_t uTag; 650 666 /** Offset of the abbreviation specification (within debug_abbrev). */ … … 3804 3820 NOREF(pThis); 3805 3821 Assert(pDieDesc->cbDie >= sizeof(RTDWARFDIE)); 3822 #ifdef RTDBGMODDWARF_WITH_MEM_CACHE 3823 uint32_t iAllocator = pDieDesc->cbDie > pThis->aDieAllocators[0].cbMax; 3824 Assert(pDieDesc->cbDie <= pThis->aDieAllocators[iAllocator].cbMax); 3825 PRTDWARFDIE pDie = (PRTDWARFDIE)RTMemCacheAlloc(pThis->aDieAllocators[iAllocator].hMemCache); 3826 #else 3806 3827 PRTDWARFDIE pDie = (PRTDWARFDIE)RTMemAllocZ(pDieDesc->cbDie); 3828 #endif 3807 3829 if (pDie) 3808 3830 { 3831 #ifdef RTDBGMODDWARF_WITH_MEM_CACHE 3832 RT_BZERO(pDie, pDieDesc->cbDie); 3833 pDie->iAllocator = iAllocator; 3834 #endif 3809 3835 rtDwarfInfo_InitDie(pDie, pDieDesc); 3810 3836 … … 4105 4131 { 4106 4132 RTListNodeRemove(&pChild->SiblingNode); 4133 #ifdef RTDBGMODDWARF_WITH_MEM_CACHE 4134 RTMemCacheFree(pThis->aDieAllocators[pChild->iAllocator].hMemCache, pChild); 4135 #else 4107 4136 RTMemFree(pChild); 4137 #endif 4108 4138 } 4109 4139 } … … 4337 4367 pThis->pNestedMod = NULL; 4338 4368 } 4369 4370 #ifdef RTDBGMODDWARF_WITH_MEM_CACHE 4371 uint32_t i = RT_ELEMENTS(pThis->aDieAllocators); 4372 while (i-- > 0) 4373 { 4374 RTMemCacheDestroy(pThis->aDieAllocators[i].hMemCache); 4375 pThis->aDieAllocators[i].hMemCache = NIL_RTMEMCACHE; 4376 } 4377 #endif 4378 4339 4379 RTMemFree(pThis); 4340 4380 … … 4476 4516 RTListInit(&pThis->CompileUnitList); 4477 4517 4518 #ifdef RTDBGMODDWARF_WITH_MEM_CACHE 4519 AssertCompile(RT_ELEMENTS(pThis->aDieAllocators) == 2); 4520 pThis->aDieAllocators[0].cbMax = sizeof(RTDWARFDIE); 4521 pThis->aDieAllocators[1].cbMax = sizeof(RTDWARFDIECOMPILEUNIT); 4522 for (uint32_t i = 0; i < RT_ELEMENTS(g_aTagDescs); i++) 4523 if (g_aTagDescs[i].pDesc && g_aTagDescs[i].pDesc->cbDie > pThis->aDieAllocators[1].cbMax) 4524 pThis->aDieAllocators[1].cbMax = g_aTagDescs[i].pDesc->cbDie; 4525 pThis->aDieAllocators[1].cbMax = RT_ALIGN_32(pThis->aDieAllocators[1].cbMax, sizeof(uint64_t)); 4526 4527 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aDieAllocators); i++) 4528 { 4529 int rc = RTMemCacheCreate(&pThis->aDieAllocators[i].hMemCache, pThis->aDieAllocators[i].cbMax, sizeof(uint64_t), 4530 UINT32_MAX, NULL /*pfnCtor*/, NULL /*pfnDtor*/, NULL /*pvUser*/, 0 /*fFlags*/); 4531 if (RT_FAILURE(rc)) 4532 { 4533 while (i-- > 0) 4534 RTMemCacheDestroy(pThis->aDieAllocators[i].hMemCache); 4535 RTMemFree(pThis); 4536 return rc; 4537 } 4538 } 4539 #endif 4478 4540 4479 4541 /* … … 4529 4591 &pThis->aSections[iSect].pv); 4530 4592 4531 4593 /** @todo Kill pThis->CompileUnitList and the alloc caches. */ 4532 4594 return VINF_SUCCESS; 4533 4595 } … … 4541 4603 rc = VERR_DBG_NO_MATCHING_INTERPRETER; 4542 4604 } 4605 4543 4606 RTMemFree(pThis->paCachedAbbrevs); 4607 4608 #ifdef RTDBGMODDWARF_WITH_MEM_CACHE 4609 uint32_t i = RT_ELEMENTS(pThis->aDieAllocators); 4610 while (i-- > 0) 4611 { 4612 RTMemCacheDestroy(pThis->aDieAllocators[i].hMemCache); 4613 pThis->aDieAllocators[i].hMemCache = NIL_RTMEMCACHE; 4614 } 4615 #endif 4616 4544 4617 RTMemFree(pThis); 4545 4618
Note:
See TracChangeset
for help on using the changeset viewer.