Changeset 20756 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Jun 22, 2009 1:59:33 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp
r20744 r20756 75 75 /** The segment size. */ 76 76 RTUINTPTR cb; 77 /** The segment flags. */ 78 uint32_t fFlags; 77 79 /** The segment name. */ 78 80 const char *pszName; … … 365 367 366 368 pSymbol->AddrCore.Key = off; 367 pSymbol->AddrCore.KeyLast = off + RT_M IN(cb, 1);369 pSymbol->AddrCore.KeyLast = off + RT_MAX(cb, 1); 368 370 pSymbol->OrdinalCore.Key = pThis->iNextSymbolOrdinal; 369 371 pSymbol->iSeg = iSeg; … … 405 407 RTMemFree(pSymbol); 406 408 return rc; 409 } 410 411 412 /** @copydoc RTDBGMODVTDBG::pfnSegmentByIndex */ 413 static DECLCALLBACK(int) rtDbgModContainer_SegmentByIndex(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, PRTDBGSEGMENT pSegInfo) 414 { 415 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv; 416 if (iSeg >= pThis->cSegs) 417 return VERR_DBG_INVALID_SEGMENT_INDEX; 418 pSegInfo->Address = RTUINTPTR_MAX; 419 pSegInfo->uRva = pThis->paSegs[iSeg].off; 420 pSegInfo->cb = pThis->paSegs[iSeg].cb; 421 pSegInfo->fFlags = pThis->paSegs[iSeg].fFlags; 422 pSegInfo->iSeg = iSeg; 423 strcpy(pSegInfo->szName, pThis->paSegs[iSeg].pszName); 424 return VINF_SUCCESS; 425 } 426 427 428 /** @copydoc RTDBGMODVTDBG::pfnSegmentCount */ 429 static DECLCALLBACK(RTDBGSEGIDX) rtDbgModContainer_SegmentCount(PRTDBGMODINT pMod) 430 { 431 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv; 432 return pThis->cSegs; 433 } 434 435 436 /** @copydoc RTDBGMODVTDBG::pfnSegmentAdd */ 437 static DECLCALLBACK(int) rtDbgModContainer_SegmentAdd(PRTDBGMODINT pMod, RTUINTPTR uRva, RTUINTPTR cb, const char *pszName, size_t cchName, 438 uint32_t fFlags, PRTDBGSEGIDX piSeg) 439 { 440 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv; 441 442 /* 443 * Input validation (the bits the caller cannot do). 444 */ 445 /* Overlapping segments are not yet supported. Will use flags to deal with it if it becomes necessary. */ 446 RTUINTPTR uRvaLast = uRva + RT_MAX(cb, 1) - 1; 447 RTUINTPTR uRvaLastMax = uRvaLast; 448 RTDBGSEGIDX iSeg = pThis->cSegs; 449 while (iSeg-- > 0) 450 { 451 RTUINTPTR uCurRva = pThis->paSegs[iSeg].off; 452 RTUINTPTR uCurRvaLast = uCurRva + RT_MAX(pThis->paSegs[iSeg].cb, 1) - 1; 453 if ( uRva <= uCurRvaLast 454 && uRvaLast >= uCurRva) 455 AssertMsgFailedReturn(("uRva=%RTptr uRvaLast=%RTptr (cb=%RTptr) \"%s\";\n" 456 "uRva=%RTptr uRvaLast=%RTptr (cb=%RTptr) \"%s\" iSeg=%#x\n", 457 uRva, uRvaLast, cb, pszName, 458 uCurRva, uCurRvaLast, pThis->paSegs[iSeg].cb, pThis->paSegs[iSeg].pszName, iSeg), 459 VERR_DBG_SEGMENT_INDEX_CONFLICT); 460 if (uRvaLastMax < uCurRvaLast) 461 uRvaLastMax = uCurRvaLast; 462 } 463 /* Strict ordered segment addition at the moment. */ 464 iSeg = pThis->cSegs; 465 AssertMsgReturn(!piSeg || *piSeg == NIL_RTDBGSEGIDX || *piSeg == iSeg, 466 ("iSeg=%#x *piSeg=%#x\n", iSeg, *piSeg), 467 VERR_DBG_INVALID_SEGMENT_INDEX); 468 469 /* 470 * Add an entry to the segment table, extending it if necessary. 471 */ 472 if (!(iSeg % 8)) 473 { 474 void *pvSegs = RTMemRealloc(pThis->paSegs, sizeof(RTDBGMODCTNSEGMENT) * (iSeg + 8)); 475 if (!pvSegs) 476 return VERR_NO_MEMORY; 477 pThis->paSegs = (PRTDBGMODCTNSEGMENT)pvSegs; 478 } 479 480 pThis->paSegs[iSeg].SymAddrTree = NULL; 481 pThis->paSegs[iSeg].LineAddrTree = NULL; 482 pThis->paSegs[iSeg].off = uRva; 483 pThis->paSegs[iSeg].cb = cb; 484 pThis->paSegs[iSeg].fFlags = fFlags; 485 pThis->paSegs[iSeg].pszName = RTStrCacheEnterN(g_hDbgModStrCache, pszName, cchName); 486 if (pThis->paSegs[iSeg].pszName) 487 { 488 if (piSeg) 489 *piSeg = iSeg; 490 pThis->cSegs++; 491 pThis->cb = uRvaLastMax + 1; 492 if (!pThis->cb) 493 pThis->cb = RTUINTPTR_MAX; 494 return VINF_SUCCESS; 495 } 496 return VERR_NO_MEMORY; 497 } 498 499 500 /** @copydoc RTDBGMODVTDBG::pfnRvaToSegOff */ 501 static DECLCALLBACK(RTUINTPTR) rtDbgModContainer_ImageSize(PRTDBGMODINT pMod) 502 { 503 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv; 504 return pThis->cb; 407 505 } 408 506 … … 519 617 { 520 618 /*.u32Magic = */ RTDBGMODVTDBG_MAGIC, 521 /*.fSupports = */ 0, / //@todo iprt/types.h isn't up to date...619 /*.fSupports = */ 0, /* (Don't call my TryOpen, please.) */ 522 620 /*.pszName = */ "container", 523 621 /*.pfnTryOpen = */ rtDbgModContainer_TryOpen, 524 622 /*.pfnClose = */ rtDbgModContainer_Close, 623 525 624 /*.pfnRvaToSegOff = */ rtDbgModContainer_RvaToSegOff, 526 527 /*.pfnSegmentAdd = */ NULL,//rtDbgModContainer_SegmentAdd, 528 /*.pfnSegmentCount = */ NULL,//rtDbgModContainer_SegmentCount, 529 /*.pfnSegmentByIndex = */ NULL,//rtDbgModContainer_SegmentByIndex, 625 /*.pfnImageSize = */ rtDbgModContainer_ImageSize, 626 627 /*.pfnSegmentAdd = */ rtDbgModContainer_SegmentAdd, 628 /*.pfnSegmentCount = */ rtDbgModContainer_SegmentCount, 629 /*.pfnSegmentByIndex = */ rtDbgModContainer_SegmentByIndex, 530 630 531 631 /*.pfnSymbolAdd = */ rtDbgModContainer_SymbolAdd,
Note:
See TracChangeset
for help on using the changeset viewer.