Changeset 74980 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Oct 22, 2018 7:48:02 PM (6 years ago)
- Location:
- trunk/src/VBox/Runtime/common/dbg
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgas.cpp
r73359 r74980 1276 1276 * @param Addr The address of the symbol. 1277 1277 * @param cb The size of the symbol. 1278 * @param fFlags Symbol flags .1278 * @param fFlags Symbol flags, RTDBGSYMBOLADD_F_XXX. 1279 1279 * @param piOrdinal Where to return the symbol ordinal on success. If 1280 1280 * the interpreter doesn't do ordinals, this will be set to -
trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp
r73494 r74980 1840 1840 VERR_DBG_INVALID_SEGMENT_INDEX); 1841 1841 AssertMsgReturn(off + cb >= off, ("off=%RTptr cb=%RTptr\n", off, cb), VERR_DBG_ADDRESS_WRAP); 1842 AssertReturn(! fFlags, VERR_INVALID_PARAMETER); /* currently reserved. */1842 AssertReturn(!(fFlags & ~RTDBGSYMBOLADD_F_VALID_MASK), VERR_INVALID_FLAGS); 1843 1843 1844 1844 RTDBGMOD_LOCK(pDbgMod); -
trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp
r73494 r74980 396 396 397 397 398 /** 399 * Worker for rtDbgModContainer_SymbolAdd that removes a symbol to resolve 400 * address conflicts. 401 * 402 * We don't shift ordinals up as that could be very expensive, instead we move 403 * the last one up to take the place of the one we're removing. Caller must 404 * take this into account. 405 * 406 * @param pThis The container. 407 * @param pAddrTree The address tree to remove from. 408 * @param pToRemove The conflicting symbol to be removed. 409 */ 410 static void rtDbgModContainer_SymbolReplace(PRTDBGMODCTN pThis, PAVLRUINTPTRTREE pAddrTree, PRTDBGMODCTNSYMBOL pToRemove) 411 { 412 /* Unlink it. */ 413 PRTSTRSPACECORE pRemovedName = RTStrSpaceRemove(&pThis->Names, pToRemove->NameCore.pszString); 414 Assert(pRemovedName); RT_NOREF_PV(pRemovedName); 415 pToRemove->NameCore.pszString = NULL; 416 417 PAVLRUINTPTRNODECORE pRemovedAddr = RTAvlrUIntPtrRemove(pAddrTree, pToRemove->AddrCore.Key); 418 Assert(pRemovedAddr); RT_NOREF_PV(pRemovedAddr); 419 pToRemove->AddrCore.Key = 0; 420 pToRemove->AddrCore.KeyLast = 0; 421 422 uint32_t const iOrdinal = pToRemove->OrdinalCore.Key; 423 PAVLU32NODECORE pRemovedOrdinal = RTAvlU32Remove(&pThis->SymbolOrdinalTree, iOrdinal); 424 Assert(pRemovedOrdinal); RT_NOREF_PV(pRemovedOrdinal); 425 426 RTMemFree(pToRemove); 427 428 /* Jump the last symbol ordinal to take its place. */ 429 PAVLU32NODECORE pLastOrdinal = RTAvlU32Remove(&pThis->SymbolOrdinalTree, pThis->iNextSymbolOrdinal - 1); 430 AssertReturnVoid(pLastOrdinal); 431 432 pThis->iNextSymbolOrdinal -= 1; 433 pLastOrdinal->Key = iOrdinal; 434 bool fInsert = RTAvlU32Insert(&pThis->SymbolOrdinalTree, pLastOrdinal); 435 Assert(fInsert); RT_NOREF_PV(fInsert); 436 } 437 438 398 439 /** @copydoc RTDBGMODVTDBG::pfnSymbolAdd */ 399 440 static DECLCALLBACK(int) rtDbgModContainer_SymbolAdd(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol, … … 448 489 if (RTAvlU32Insert(&pThis->SymbolOrdinalTree, &pSymbol->OrdinalCore)) 449 490 { 491 /* 492 * Success. 493 */ 450 494 if (piOrdinal) 451 495 *piOrdinal = pThis->iNextSymbolOrdinal; … … 457 501 rc = VERR_INTERNAL_ERROR_5; 458 502 RTAvlrUIntPtrRemove(pAddrTree, pSymbol->AddrCore.Key); 503 } 504 /* 505 * Did the caller specify a conflict resolution method? 506 */ 507 else if (fFlags & ( RTDBGSYMBOLADD_F_REPLACE_SAME_ADDR 508 | RTDBGSYMBOLADD_F_REPLACE_ANY 509 | RTDBGSYMBOLADD_F_ADJUST_SIZES_ON_CONFLICT)) 510 { 511 /* 512 * Handle anything at or before the start address first: 513 */ 514 AssertCompileMemberOffset(RTDBGMODCTNSYMBOL, AddrCore, 0); 515 PRTDBGMODCTNSYMBOL pConflict = (PRTDBGMODCTNSYMBOL)RTAvlrUIntPtrRangeGet(pAddrTree, pSymbol->AddrCore.Key); 516 if (pConflict) 517 { 518 if (pConflict->AddrCore.Key == pSymbol->AddrCore.Key) 519 { 520 /* Same address, only option is replacing it. */ 521 if (fFlags & (RTDBGSYMBOLADD_F_REPLACE_SAME_ADDR | RTDBGSYMBOLADD_F_REPLACE_ANY)) 522 rtDbgModContainer_SymbolReplace(pThis, pAddrTree, pConflict); 523 else 524 rc = VERR_DBG_ADDRESS_CONFLICT; 525 } 526 else if (fFlags & RTDBGSYMBOLADD_F_ADJUST_SIZES_ON_CONFLICT) 527 { 528 /* Reduce the size of the symbol before us, adopting the size if we've got none. */ 529 Assert(pConflict->AddrCore.Key < pSymbol->AddrCore.Key); 530 if (!pSymbol->cb) 531 { 532 pSymbol->AddrCore.KeyLast = pSymbol->AddrCore.KeyLast; 533 pSymbol->cb = pSymbol->AddrCore.KeyLast - pConflict->AddrCore.Key + 1; 534 rc = VINF_DBG_ADJUSTED_SYM_SIZE; 535 } 536 pConflict->AddrCore.KeyLast = pSymbol->AddrCore.Key - 1; 537 pConflict->cb = pSymbol->AddrCore.Key - pConflict->AddrCore.Key; 538 } 539 else if (fFlags & RTDBGSYMBOLADD_F_REPLACE_ANY) 540 rtDbgModContainer_SymbolReplace(pThis, pAddrTree, pConflict); 541 else 542 rc = VERR_DBG_ADDRESS_CONFLICT; 543 } 544 545 /* 546 * Try insert again and deal with symbols in the range. 547 */ 548 while (RT_SUCCESS(rc)) 549 { 550 if (RTAvlrUIntPtrInsert(pAddrTree, &pSymbol->AddrCore)) 551 { 552 pSymbol->OrdinalCore.Key = pThis->iNextSymbolOrdinal; 553 if (RTAvlU32Insert(&pThis->SymbolOrdinalTree, &pSymbol->OrdinalCore)) 554 { 555 /* 556 * Success. 557 */ 558 if (piOrdinal) 559 *piOrdinal = pThis->iNextSymbolOrdinal; 560 pThis->iNextSymbolOrdinal++; 561 return rc; 562 } 563 564 rc = VERR_INTERNAL_ERROR_5; 565 RTAvlrUIntPtrRemove(pAddrTree, pSymbol->AddrCore.Key); 566 break; 567 } 568 569 /* Get the first symbol above us and see if we can do anything about it (or ourselves). */ 570 AssertCompileMemberOffset(RTDBGMODCTNSYMBOL, AddrCore, 0); 571 pConflict = (PRTDBGMODCTNSYMBOL)RTAvlrUIntPtrGetBestFit(pAddrTree, pSymbol->AddrCore.Key, true /*fAbove*/); 572 AssertBreakStmt(pConflict, rc = VERR_DBG_ADDRESS_CONFLICT); 573 Assert(pSymbol->AddrCore.Key != pConflict->AddrCore.Key); 574 Assert(pSymbol->AddrCore.KeyLast >= pConflict->AddrCore.Key); 575 576 if (fFlags & RTDBGSYMBOLADD_F_ADJUST_SIZES_ON_CONFLICT) 577 { 578 Assert(pSymbol->cb > 0); 579 pSymbol->AddrCore.Key = pConflict->AddrCore.Key - 1; 580 pSymbol->cb = pConflict->AddrCore.Key - pSymbol->AddrCore.Key; 581 rc = VINF_DBG_ADJUSTED_SYM_SIZE; 582 } 583 else if (fFlags & RTDBGSYMBOLADD_F_REPLACE_ANY) 584 rtDbgModContainer_SymbolReplace(pThis, pAddrTree, pConflict); 585 else 586 rc = VERR_DBG_ADDRESS_CONFLICT; 587 } 459 588 } 460 589 else … … 676 805 RTStrCacheRelease(g_hDbgModStrCache, pSym->NameCore.pszString); 677 806 pSym->NameCore.pszString = NULL; 807 808 #if 0 809 //PRTDBGMODCTN pThis = (PRTDBGMODCTN)pvUser; 810 //PAVLU32NODECORE pRemoved = RTAvlU32Remove(&pThis->SymbolOrdinalTree, pSym->OrdinalCore.Key); 811 //Assert(pRemoved == &pSym->OrdinalCore); RT_NOREF_PV(pRemoved); 812 #else 813 RT_NOREF_PV(pvUser); 814 #endif 815 678 816 RTMemFree(pSym); 679 NOREF(pvUser);680 817 return 0; 681 818 } … … 692 829 for (uint32_t iSeg = 0; iSeg < pThis->cSegs; iSeg++) 693 830 { 694 RTAvlrUIntPtrDestroy(&pThis->paSegs[iSeg].SymAddrTree, rtDbgModContainer_DestroyTreeNode, NULL);831 RTAvlrUIntPtrDestroy(&pThis->paSegs[iSeg].SymAddrTree, rtDbgModContainer_DestroyTreeNode, pThis); 695 832 RTStrCacheRelease(g_hDbgModStrCache, pThis->paSegs[iSeg].pszName); 696 833 pThis->paSegs[iSeg].pszName = NULL; 697 834 } 698 835 699 RTAvlrUIntPtrDestroy(&pThis->AbsAddrTree, rtDbgModContainer_DestroyTreeNode, NULL); 836 RTAvlrUIntPtrDestroy(&pThis->AbsAddrTree, rtDbgModContainer_DestroyTreeNode, pThis); 837 700 838 pThis->Names = NULL; 701 839
Note:
See TracChangeset
for help on using the changeset viewer.