Changeset 22113 in vbox
- Timestamp:
- Aug 9, 2009 10:36:25 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgas.cpp
r22111 r22113 68 68 /** Pointer to the next module with an identical name. */ 69 69 PRTDBGASMOD pNextName; 70 /** The index into RTDBGASINT::papModules. */ 71 uint32_t iOrdinal; 70 72 } RTDBGASMOD; 71 73 … … 112 114 /** Pointer to the module table. 113 115 * The valid array length is given by cModules. */ 114 PRTDBGASMOD paModules;116 PRTDBGASMOD *papModules; 115 117 /** AVL tree translating module handles to module entries. */ 116 118 AVLPVTREE ModTree; … … 209 211 pDbgAs->hLock = NIL_RTSEMRW; 210 212 pDbgAs->cModules = 0; 211 pDbgAs->pa Modules= NULL;213 pDbgAs->papModules = NULL; 212 214 pDbgAs->ModTree = NULL; 213 215 pDbgAs->MapTree = NULL; … … 332 334 while (i-- > 0) 333 335 { 334 RTDbgModRelease((RTDBGMOD)pDbgAs->paModules[i].Core.Key); 335 pDbgAs->paModules[i].Core.Key = NIL_RTDBGMOD; 336 } 337 RTMemFree(pDbgAs->paModules); 338 pDbgAs->paModules = NULL; 336 PRTDBGASMOD pMod = pDbgAs->papModules[i]; 337 AssertPtr(pMod); 338 if (VALID_PTR(pMod)) 339 { 340 Assert(pMod->iOrdinal == i); 341 RTDbgModRelease((RTDBGMOD)pMod->Core.Key); 342 pMod->Core.Key = NIL_RTDBGMOD; 343 pMod->iOrdinal = UINT32_MAX; 344 RTMemFree(pMod); 345 } 346 pDbgAs->papModules[i] = NULL; 347 } 348 RTMemFree(pDbgAs->papModules); 349 pDbgAs->papModules = NULL; 339 350 340 351 RTMemFree(pDbgAs); … … 521 532 if (!(pDbgAs->cModules % 32)) 522 533 { 523 void *pvNew = RTMemRealloc(pDbgAs->pa Modules, sizeof(pDbgAs->paModules[0]) * (pDbgAs->cModules + 32));534 void *pvNew = RTMemRealloc(pDbgAs->papModules, sizeof(pDbgAs->papModules[0]) * (pDbgAs->cModules + 32)); 524 535 if (!pvNew) 525 536 return VERR_NO_MEMORY; 526 pDbgAs->paModules = (PRTDBGASMOD)pvNew; 527 528 /** @todo this rebuilding of the tree gets a bit silly... */ 529 pDbgAs->ModTree = NULL; 530 for (uint32_t iMod = 0; iMod < pDbgAs->cModules; iMod++) 531 { 532 bool fRc = RTAvlPVInsert(&pDbgAs->ModTree, &pDbgAs->paModules[iMod].Core); 533 Assert(fRc); NOREF(fRc); 534 } 537 pDbgAs->papModules = (PRTDBGASMOD *)pvNew; 535 538 } 536 pMod = &pDbgAs->paModules[pDbgAs->cModules];537 pDbgAs->cModules++;538 539 pMod = (PRTDBGASMOD)RTMemAlloc(sizeof(*pMod)); 540 if (!pMod) 541 return VERR_NO_MEMORY; 539 542 pMod->Core.Key = hDbgMod; 540 543 pMod->pMapHead = NULL; 541 544 pMod->pNextName = NULL; 542 if ( !RTAvlPVInsert(&pDbgAs->ModTree, &pMod->Core))545 if (RT_UNLIKELY(!RTAvlPVInsert(&pDbgAs->ModTree, &pMod->Core))) 543 546 { 544 547 AssertFailed(); 545 548 pDbgAs->cModules--; 549 RTMemFree(pMod); 546 550 return VERR_INTERNAL_ERROR; 547 551 } 552 pMod->iOrdinal = pDbgAs->cModules; 553 pDbgAs->papModules[pDbgAs->cModules] = pMod; 554 pDbgAs->cModules++; 548 555 RTDbgModRetain(hDbgMod); 549 556 … … 558 565 if (!pName) 559 566 { 567 RTDbgModRelease(hDbgMod); 560 568 pDbgAs->cModules--; 561 569 RTAvlPVRemove(&pDbgAs->ModTree, hDbgMod); 562 RT DbgModRelease(hDbgMod);570 RTMemFree(pMod); 563 571 return VERR_NO_MEMORY; 564 572 } … … 759 767 * Remove it from the module table by replacing it by the last entry. 760 768 */ 761 uint32_t iMod = pMod - &pDbgAs->paModules[0];762 Assert(iMod < pDbgAs->cModules);763 769 pDbgAs->cModules--; 764 if (iMod <= pDbgAs->cModules) 765 { 766 pNode = RTAvlPVRemove(&pDbgAs->ModTree, pDbgAs->paModules[pDbgAs->cModules].Core.Key); 767 Assert(pNode); 768 pDbgAs->paModules[iMod] = pDbgAs->paModules[pDbgAs->cModules]; 769 bool fRc = RTAvlPVInsert(&pDbgAs->ModTree, &pMod->Core); 770 Assert(fRc); NOREF(fRc); 771 } 770 uint32_t iMod = pMod->iOrdinal; 771 Assert(iMod <= pDbgAs->cModules); 772 if (iMod != pDbgAs->cModules) 773 { 774 PRTDBGASMOD pTailMod = pDbgAs->papModules[pDbgAs->cModules]; 775 pTailMod->iOrdinal = iMod; 776 pDbgAs->papModules[iMod] = pTailMod; 777 } 778 pMod->iOrdinal = UINT32_MAX; 779 780 /* 781 * Free it. 782 */ 783 RTMemFree(pMod); 772 784 } 773 785 … … 789 801 /* unlink */ 790 802 PRTDBGASMOD pMod = pMap->pMod; 791 if (pMod->pMapHead )803 if (pMod->pMapHead == pMap) 792 804 pMod->pMapHead = pMap->pNext; 793 805 else … … 942 954 * Get, retain and return it. 943 955 */ 944 RTDBGMOD hMod = (RTDBGMOD)pDbgAs->pa Modules[iModule].Core.Key;956 RTDBGMOD hMod = (RTDBGMOD)pDbgAs->papModules[iModule]->Core.Key; 945 957 RTDbgModRetain(hMod); 946 958 … … 1321 1333 1322 1334 uint32_t iMod = *pcModules = pDbgAs->cModules; 1323 PRTDBGMOD pa Modules = (PRTDBGMOD)RTMemTmpAlloc(sizeof(paModules[0]) * RT_MAX(iMod, 1));1324 if (pa Modules)1335 PRTDBGMOD pahModules = (PRTDBGMOD)RTMemTmpAlloc(sizeof(pahModules[0]) * RT_MAX(iMod, 1)); 1336 if (pahModules) 1325 1337 { 1326 1338 while (iMod-- > 0) 1327 1339 { 1328 RTDBGMOD hMod = (RTDBGMOD)pDbgAs->pa Modules[iMod].Core.Key;1329 pa Modules[iMod] = hMod;1340 RTDBGMOD hMod = (RTDBGMOD)pDbgAs->papModules[iMod]->Core.Key; 1341 pahModules[iMod] = hMod; 1330 1342 RTDbgModRetain(hMod); 1331 1343 } … … 1333 1345 1334 1346 RTDBGAS_UNLOCK_READ(pDbgAs); 1335 return pa Modules;1347 return pahModules; 1336 1348 } 1337 1349 … … 1448 1460 */ 1449 1461 uint32_t cModules; 1450 PRTDBGMOD pa Modules = rtDbgAsSnapshotModuleTable(pDbgAs, &cModules);1451 if (!pa Modules)1462 PRTDBGMOD pahModules = rtDbgAsSnapshotModuleTable(pDbgAs, &cModules); 1463 if (!pahModules) 1452 1464 return VERR_NO_TMP_MEMORY; 1453 1465 … … 1455 1467 { 1456 1468 if ( cchModPat == 0 1457 || RTStrSimplePatternNMatch(pachModPat, cchModPat, RTDbgModName(pa Modules[i]), RTSTR_MAX))1469 || RTStrSimplePatternNMatch(pachModPat, cchModPat, RTDbgModName(pahModules[i]), RTSTR_MAX)) 1458 1470 { 1459 int rc = RTDbgModSymbolByName(pa Modules[i], pszSymbol, pSymbol);1471 int rc = RTDbgModSymbolByName(pahModules[i], pszSymbol, pSymbol); 1460 1472 if (RT_SUCCESS(rc)) 1461 1473 { 1462 if (rtDbgAsFindMappingAndAdjustSymbolValue(pDbgAs, pa Modules[i], pSymbol))1474 if (rtDbgAsFindMappingAndAdjustSymbolValue(pDbgAs, pahModules[i], pSymbol)) 1463 1475 { 1464 1476 if (phMod) 1465 RTDbgModRetain(*phMod = pa Modules[i]);1477 RTDbgModRetain(*phMod = pahModules[i]); 1466 1478 for (; i < cModules; i++) 1467 RTDbgModRelease(pa Modules[i]);1468 RTMemTmpFree(pa Modules);1479 RTDbgModRelease(pahModules[i]); 1480 RTMemTmpFree(pahModules); 1469 1481 return rc; 1470 1482 } 1471 1483 } 1472 1484 } 1473 RTDbgModRelease(pa Modules[i]);1474 } 1475 1476 RTMemTmpFree(pa Modules);1485 RTDbgModRelease(pahModules[i]); 1486 } 1487 1488 RTMemTmpFree(pahModules); 1477 1489 return VERR_SYMBOL_NOT_FOUND; 1478 1490 } … … 1523 1535 */ 1524 1536 uint32_t cModules; 1525 PRTDBGMOD pa Modules = rtDbgAsSnapshotModuleTable(pDbgAs, &cModules);1526 if (!pa Modules)1537 PRTDBGMOD pahModules = rtDbgAsSnapshotModuleTable(pDbgAs, &cModules); 1538 if (!pahModules) 1527 1539 return VERR_NO_TMP_MEMORY; 1528 1540 … … 1530 1542 { 1531 1543 if ( cchModPat == 0 1532 || RTStrSimplePatternNMatch(pachModPat, cchModPat, RTDbgModName(pa Modules[i]), RTSTR_MAX))1544 || RTStrSimplePatternNMatch(pachModPat, cchModPat, RTDbgModName(pahModules[i]), RTSTR_MAX)) 1533 1545 { 1534 int rc = RTDbgModSymbolByNameA(pa Modules[i], pszSymbol, ppSymbol);1546 int rc = RTDbgModSymbolByNameA(pahModules[i], pszSymbol, ppSymbol); 1535 1547 if (RT_SUCCESS(rc)) 1536 1548 { 1537 if (rtDbgAsFindMappingAndAdjustSymbolValue(pDbgAs, pa Modules[i], *ppSymbol))1549 if (rtDbgAsFindMappingAndAdjustSymbolValue(pDbgAs, pahModules[i], *ppSymbol)) 1538 1550 { 1539 1551 if (phMod) 1540 RTDbgModRetain(*phMod = pa Modules[i]);1552 RTDbgModRetain(*phMod = pahModules[i]); 1541 1553 for (; i < cModules; i++) 1542 RTDbgModRelease(pa Modules[i]);1543 RTMemTmpFree(pa Modules);1554 RTDbgModRelease(pahModules[i]); 1555 RTMemTmpFree(pahModules); 1544 1556 return rc; 1545 1557 } 1546 1558 } 1547 1559 } 1548 RTDbgModRelease(pa Modules[i]);1549 } 1550 1551 RTMemTmpFree(pa Modules);1560 RTDbgModRelease(pahModules[i]); 1561 } 1562 1563 RTMemTmpFree(pahModules); 1552 1564 return VERR_SYMBOL_NOT_FOUND; 1553 1565 }
Note:
See TracChangeset
for help on using the changeset viewer.