- Timestamp:
- May 19, 2013 4:58:01 PM (12 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp
r46161 r46164 413 413 pDbgMod->pDbgVt = pCur->pVt; 414 414 pDbgMod->pvDbgPriv = NULL; 415 rc = pCur->pVt->pfnTryOpen(pDbgMod );415 rc = pCur->pVt->pfnTryOpen(pDbgMod, RTLDRARCH_WHATEVER); 416 416 if (RT_SUCCESS(rc)) 417 417 { … … 476 476 pDbgMod->pDbgVt = pDbg->pVt; 477 477 pDbgMod->pvDbgPriv = NULL; 478 rc = pDbg->pVt->pfnTryOpen(pDbgMod );478 rc = pDbg->pVt->pfnTryOpen(pDbgMod, pDbgMod->pImgVt->pfnGetArch(pDbgMod)); 479 479 if (RT_SUCCESS(rc)) 480 480 { … … 506 506 Assert(!pDbgMod->pvDbgPriv); 507 507 Assert(!pDbgMod->pszDbgFile); 508 Assert(pDbgMod->pImgVt); 508 509 509 510 /* … … 519 520 pDbgMod->pDbgVt = pDbg->pVt; 520 521 pDbgMod->pvDbgPriv = NULL; 521 rc = pDbg->pVt->pfnTryOpen(pDbgMod );522 rc = pDbg->pVt->pfnTryOpen(pDbgMod, pDbgMod->pImgVt->pfnGetArch(pDbgMod)); 522 523 if (RT_SUCCESS(rc)) 523 524 { … … 674 675 Assert(!pDbgMod->pvDbgPriv); 675 676 Assert(!pDbgMod->pszDbgFile); 677 Assert(pDbgMod->pImgVt); 676 678 677 679 /* … … 687 689 pDbgMod->pDbgVt = pDbg->pVt; 688 690 pDbgMod->pvDbgPriv = NULL; 689 rc = pDbg->pVt->pfnTryOpen(pDbgMod );691 rc = pDbg->pVt->pfnTryOpen(pDbgMod, pDbgMod->pImgVt->pfnGetArch(pDbgMod)); 690 692 if (RT_SUCCESS(rc)) 691 693 { … … 867 869 pDbgMod->pDbgVt = pDbg->pVt; 868 870 pDbgMod->pvDbgPriv = NULL; 869 rc = pDbg->pVt->pfnTryOpen(pDbgMod );871 rc = pDbg->pVt->pfnTryOpen(pDbgMod, enmArch); 870 872 if (RT_SUCCESS(rc)) 871 873 { -
trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp
r46149 r46164 676 676 677 677 /** @copydoc RTDBGMODVTDBG::pfnTryOpen */ 678 static DECLCALLBACK(int) rtDbgModContainer_TryOpen(PRTDBGMODINT pMod )679 { 680 NOREF(pMod); 678 static DECLCALLBACK(int) rtDbgModContainer_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch) 679 { 680 NOREF(pMod); NOREF(enmArch); 681 681 return VERR_INTERNAL_ERROR_5; 682 682 } -
trunk/src/VBox/Runtime/common/dbg/dbgmoddbghelp.cpp
r46127 r46164 386 386 387 387 /** @interface_method_impl{RTDBGMODVTDBG,pfnTryOpen} */ 388 static DECLCALLBACK(int) rtDbgModDbgHelp_TryOpen(PRTDBGMODINT pMod) 389 { 388 static DECLCALLBACK(int) rtDbgModDbgHelp_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch) 389 { 390 NOREF(enmArch); 391 390 392 /* 391 393 * Currently only support external files with a executable already present. -
trunk/src/VBox/Runtime/common/dbg/dbgmoddeferred.cpp
r46161 r46164 391 391 392 392 /** @interface_method_impl{RTDBGMODVTDBG,pfnTryOpen} */ 393 static DECLCALLBACK(int) rtDbgModDeferredDbg_TryOpen(PRTDBGMODINT pMod) 394 { 393 static DECLCALLBACK(int) rtDbgModDeferredDbg_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch) 394 { 395 NOREF(enmArch); 395 396 return rtDbgModDeferredDoIt(pMod, true /*fForceRetry*/); 396 397 } … … 438 439 * 439 440 */ 441 442 443 /** @interface_method_impl{RTDBGMODVTIMG,pfnGetArch} */ 444 static DECLCALLBACK(RTLDRARCH) rtDbgModDeferredImg_GetArch(PRTDBGMODINT pMod) 445 { 446 RTLDRARCH enmArch; 447 int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/); 448 if (RT_SUCCESS(rc)) 449 enmArch = pMod->pImgVt->pfnGetArch(pMod); 450 else 451 enmArch = RTLDRARCH_WHATEVER; 452 return enmArch; 453 } 440 454 441 455 … … 567 581 /*.pfnUnmapPart = */ rtDbgModDeferredImg_UnmapPart, 568 582 /*.pfnGetFormat = */ rtDbgModDeferredImg_GetFormat, 583 /*.pfnGetArch = */ rtDbgModDeferredImg_GetArch, 569 584 570 585 /*.u32EndMagic = */ RTDBGMODVTIMG_MAGIC -
trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp
r46149 r46164 41 41 #include <iprt/path.h> 42 42 #include <iprt/string.h> 43 #include <iprt/strcache.h> 43 44 #include "internal/dbgmod.h" 44 45 … … 420 421 /** The debug container containing doing the real work. */ 421 422 RTDBGMOD hCnt; 422 /** Pointer to back to the debug info module (no reference ofc). */ 423 PRTDBGMODINT pMod; 423 /** The image module (no reference). */ 424 PRTDBGMODINT pImgMod; 425 /** The debug info module (no reference). */ 426 PRTDBGMODINT pDbgInfoMod; 427 /** Nested image module (with reference ofc). */ 428 PRTDBGMODINT pNestedMod; 424 429 425 430 /** DWARF debug info sections. */ … … 1192 1197 * @returns IPRT status code. 1193 1198 * @param pThis The DWARF instance. 1194 * @param pMod The debug module. 1195 */ 1196 static int rtDbgModDwarfAddSegmentsFromImage(PRTDBGMODDWARF pThis, PRTDBGMODINT pMod) 1197 { 1198 AssertReturn(pMod->pImgVt, VERR_INTERNAL_ERROR_2); 1199 */ 1200 static int rtDbgModDwarfAddSegmentsFromImage(PRTDBGMODDWARF pThis) 1201 { 1202 AssertReturn(pThis->pImgMod && pThis->pImgMod->pImgVt, VERR_INTERNAL_ERROR_2); 1199 1203 Assert(!pThis->cSegs); 1200 int rc = p Mod->pImgVt->pfnEnumSegments(pMod, rtDbgModDwarfScanSegmentsCallback, pThis);1204 int rc = pThis->pImgMod->pImgVt->pfnEnumSegments(pThis->pImgMod, rtDbgModDwarfScanSegmentsCallback, pThis); 1201 1205 if (RT_SUCCESS(rc)) 1202 1206 { … … 1207 1211 pThis->cSegs = 0; 1208 1212 pThis->iWatcomPass = -1; 1209 rc = p Mod->pImgVt->pfnEnumSegments(pMod, rtDbgModDwarfAddSegmentsCallback, pThis);1213 rc = pThis->pImgMod->pImgVt->pfnEnumSegments(pThis->pImgMod, rtDbgModDwarfAddSegmentsCallback, pThis); 1210 1214 } 1211 1215 } … … 1382 1386 * Do the job. 1383 1387 */ 1384 return pThis->p Mod->pImgVt->pfnMapPart(pThis->pMod,1385 pThis->aSections[enmSect].iDbgInfo,1386 pThis->aSections[enmSect].offFile,1387 pThis->aSections[enmSect].cb,1388 &pThis->aSections[enmSect].pv);1388 return pThis->pDbgInfoMod->pImgVt->pfnMapPart(pThis->pDbgInfoMod, 1389 pThis->aSections[enmSect].iDbgInfo, 1390 pThis->aSections[enmSect].offFile, 1391 pThis->aSections[enmSect].cb, 1392 &pThis->aSections[enmSect].pv); 1389 1393 } 1390 1394 … … 1403 1407 return VINF_SUCCESS; 1404 1408 1405 int rc = pThis->p Mod->pImgVt->pfnUnmapPart(pThis->pMod, pThis->aSections[enmSect].cb, &pThis->aSections[enmSect].pv);1409 int rc = pThis->pDbgInfoMod->pImgVt->pfnUnmapPart(pThis->pDbgInfoMod, pThis->aSections[enmSect].cb, &pThis->aSections[enmSect].pv); 1406 1410 AssertRC(rc); 1407 1411 return rc; … … 1451 1455 } 1452 1456 1453 return pThis->p Mod->pImgVt->pfnRvaToSegOffset(pThis->pMod, LinkAddress, piSeg, poffSeg);1454 //return pThis->p Mod->pImgVt->pfnLinkAddressToSegOffset(pThis->pMod, LinkAddress, piSeg, poffSeg);1457 return pThis->pImgMod->pImgVt->pfnRvaToSegOffset(pThis->pImgMod, LinkAddress, piSeg, poffSeg); 1458 //return pThis->pImgMod->pImgVt->pfnLinkAddressToSegOffset(pThis->pImgMod, LinkAddress, piSeg, poffSeg); 1455 1459 } 1456 1460 … … 4301 4305 PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv; 4302 4306 RTUINTPTR cb1 = RTDbgModImageSize(pThis->hCnt); 4303 RTUINTPTR cb2 = p Mod->pImgVt->pfnImageSize(pMod);4307 RTUINTPTR cb2 = pThis->pImgMod->pImgVt->pfnImageSize(pMod); 4304 4308 return RT_MAX(cb1, cb2); 4305 4309 } … … 4321 4325 for (unsigned iSect = 0; iSect < RT_ELEMENTS(pThis->aSections); iSect++) 4322 4326 if (pThis->aSections[iSect].pv) 4323 pThis->p Mod->pImgVt->pfnUnmapPart(pThis->pMod, pThis->aSections[iSect].cb, &pThis->aSections[iSect].pv);4327 pThis->pDbgInfoMod->pImgVt->pfnUnmapPart(pThis->pDbgInfoMod, pThis->aSections[iSect].cb, &pThis->aSections[iSect].pv); 4324 4328 4325 4329 RTDbgModRelease(pThis->hCnt); 4326 4330 RTMemFree(pThis->paCachedAbbrevs); 4331 if (pThis->pNestedMod) 4332 { 4333 pThis->pNestedMod->pImgVt->pfnClose(pThis->pNestedMod); 4334 RTStrCacheRelease(g_hDbgModStrCache, pThis->pNestedMod->pszName); 4335 RTStrCacheRelease(g_hDbgModStrCache, pThis->pNestedMod->pszDbgFile); 4336 RTMemFree(pThis->pNestedMod); 4337 pThis->pNestedMod = NULL; 4338 } 4327 4339 RTMemFree(pThis); 4328 4340 … … 4401 4413 4402 4414 4415 static int rtDbgModDwarfTryOpenDbgFile(PRTDBGMODINT pDbgMod, PRTDBGMODDWARF pThis, RTLDRARCH enmArch) 4416 { 4417 if ( !pDbgMod->pszDbgFile 4418 || RTPathIsSame(pDbgMod->pszDbgFile, pDbgMod->pszImgFile) == true /* returns VERR too */) 4419 return VERR_DBG_NO_MATCHING_INTERPRETER; 4420 4421 /* 4422 * Only open the image. 4423 */ 4424 PRTDBGMODINT pDbgInfoMod = (PRTDBGMODINT)RTMemAllocZ(sizeof(*pDbgInfoMod)); 4425 if (!pDbgInfoMod) 4426 return VERR_NO_MEMORY; 4427 4428 int rc; 4429 pDbgInfoMod->u32Magic = RTDBGMOD_MAGIC; 4430 pDbgInfoMod->cRefs = 1; 4431 if (RTStrCacheRetain(pDbgMod->pszDbgFile) != UINT32_MAX) 4432 { 4433 pDbgInfoMod->pszImgFile = pDbgMod->pszDbgFile; 4434 if (RTStrCacheRetain(pDbgMod->pszName) != UINT32_MAX) 4435 { 4436 pDbgInfoMod->pszName = pDbgMod->pszName; 4437 pDbgInfoMod->pImgVt = &g_rtDbgModVtImgLdr; 4438 rc = pDbgInfoMod->pImgVt->pfnTryOpen(pDbgInfoMod, enmArch); 4439 if (RT_SUCCESS(rc)) 4440 { 4441 pThis->pDbgInfoMod = pDbgInfoMod; 4442 pThis->pNestedMod = pDbgInfoMod; 4443 return VINF_SUCCESS; 4444 } 4445 4446 RTStrCacheRelease(g_hDbgModStrCache, pDbgInfoMod->pszName); 4447 } 4448 else 4449 rc = VERR_NO_STR_MEMORY; 4450 RTStrCacheRelease(g_hDbgModStrCache, pDbgInfoMod->pszImgFile); 4451 } 4452 else 4453 rc = VERR_NO_STR_MEMORY; 4454 RTMemFree(pDbgInfoMod); 4455 return rc; 4456 } 4457 4458 4403 4459 /** @interface_method_impl{RTDBGMODVTDBG,pfnTryOpen} */ 4404 static DECLCALLBACK(int) rtDbgModDwarf_TryOpen(PRTDBGMODINT pMod )4460 static DECLCALLBACK(int) rtDbgModDwarf_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch) 4405 4461 { 4406 4462 /* … … 4411 4467 4412 4468 /* 4413 * Enumerate the debug info in the module, looking for DWARF bits.4469 * Create the module instance data. 4414 4470 */ 4415 4471 PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)RTMemAllocZ(sizeof(*pThis)); 4416 4472 if (!pThis) 4417 4473 return VERR_NO_MEMORY; 4418 pThis->pMod = pMod; 4474 pThis->pDbgInfoMod = pMod; 4475 pThis->pImgMod = pMod; 4419 4476 RTListInit(&pThis->CompileUnitList); 4420 4477 4421 int rc = pMod->pImgVt->pfnEnumDbgInfo(pMod, rtDbgModDwarfEnumCallback, pThis); 4478 4479 /* 4480 * If the debug file name is set, let's see if it's an ELF image with DWARF 4481 * inside it. In that case we'll have to deal with two image modules, one 4482 * for segments and address translation and one for the debug information. 4483 */ 4484 if (pMod->pszDbgFile != NULL) 4485 rtDbgModDwarfTryOpenDbgFile(pMod, pThis, enmArch); 4486 4487 /* 4488 * Enumerate the debug info in the module, looking for DWARF bits. 4489 */ 4490 int rc = pThis->pDbgInfoMod->pImgVt->pfnEnumDbgInfo(pThis->pDbgInfoMod, rtDbgModDwarfEnumCallback, pThis); 4422 4491 if (RT_SUCCESS(rc)) 4423 4492 { … … 4433 4502 pMod->pvDbgPriv = pThis; 4434 4503 4435 rc = rtDbgModDwarfAddSegmentsFromImage(pThis , pMod);4504 rc = rtDbgModDwarfAddSegmentsFromImage(pThis); 4436 4505 if (RT_SUCCESS(rc)) 4437 4506 rc = rtDwarfInfo_LoadAll(pThis); … … 4457 4526 for (unsigned iSect = 0; iSect < RT_ELEMENTS(pThis->aSections); iSect++) 4458 4527 if (pThis->aSections[iSect].pv) 4459 pThis->p Mod->pImgVt->pfnUnmapPart(pThis->pMod, pThis->aSections[iSect].cb,4460 &pThis->aSections[iSect].pv);4528 pThis->pDbgInfoMod->pImgVt->pfnUnmapPart(pThis->pDbgInfoMod, pThis->aSections[iSect].cb, 4529 &pThis->aSections[iSect].pv); 4461 4530 4462 4531 -
trunk/src/VBox/Runtime/common/dbg/dbgmodldr.cpp
r46161 r46164 59 59 typedef RTDBGMODLDR *PRTDBGMODLDR; 60 60 61 62 63 /** @interface_method_impl{RTDBGMODVTIMG,pfnGetArch} */ 64 static DECLCALLBACK(RTLDRARCH) rtDbgModLdr_GetArch(PRTDBGMODINT pMod) 65 { 66 PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv; 67 return RTLdrGetArch(pThis->hLdrMod); 68 } 61 69 62 70 … … 198 206 /*.pfnUnmapPart = */ rtDbgModLdr_UnmapPart, 199 207 /*.pfnGetFormat = */ rtDbgModLdr_GetFormat, 208 /*.pfnGetArch = */ rtDbgModLdr_GetArch, 200 209 201 210 /*.u32EndMagic = */ RTDBGMODVTIMG_MAGIC -
trunk/src/VBox/Runtime/common/dbg/dbgmodnm.cpp
r44529 r46164 478 478 479 479 /** @interface_method_impl{RTDBGMODVTDBG,pfnTryOpen} */ 480 static DECLCALLBACK(int) rtDbgModNm_TryOpen(PRTDBGMODINT pMod) 481 { 480 static DECLCALLBACK(int) rtDbgModNm_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch) 481 { 482 NOREF(enmArch); 483 482 484 /* 483 485 * Fend off images. -
trunk/src/VBox/Runtime/common/ldr/ldr.cpp
r46161 r46164 121 121 122 122 123 RTDECL(RTLDRARCH) RTLdrGetArch(RTLDRMOD hLdrMod) 124 { 125 AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), RTLDRARCH_INVALID); 126 PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod; 127 return pMod->enmArch; 128 } 129 RT_EXPORT_SYMBOL(RTLdrGetArch); 130 131 123 132 RTDECL(int) RTLdrClose(RTLDRMOD hLdrMod) 124 133 { -
trunk/src/VBox/Runtime/common/ldr/ldrELFRelocatable.cpp.h
r46161 r46164 1440 1440 pModElf->Core.enmType = RTLDRTYPE_OBJECT; 1441 1441 pModElf->Core.enmEndian = RTLDRENDIAN_LITTLE; 1442 #if ELF_MODE == 32 1443 pModElf->Core.enmArch = RTLDRARCH_X86_32; 1444 #else 1445 pModElf->Core.enmArch = RTLDRARCH_AMD64; 1446 #endif 1442 1447 //pModElf->pvBits = NULL; 1443 1448 //pModElf->Ehdr = {0}; -
trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp
r46161 r46164 140 140 pMod->Core.enmEndian = RTLDRENDIAN_LITTLE; 141 141 #endif 142 #ifdef RT_ARCH_AMD64 143 pMod->Core.enmArch = RTLDRARCH_AMD64; 144 #elif defined(RT_ARCH_X86) 145 pMod->Core.enmArch = RTLDRARCH_X86_32; 146 #else 147 pMod->Core.enmArch = RTLDRARCH_HOST; 148 #endif 142 149 pMod->hNative = ~(uintptr_t)0; 143 150 -
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r46161 r46164 2293 2293 : RTLDRTYPE_SHARED_LIBRARY_RELOCATABLE; 2294 2294 pModPe->Core.enmEndian= RTLDRENDIAN_LITTLE; 2295 pModPe->Core.enmArch = FileHdr.Machine == IMAGE_FILE_MACHINE_I386 2296 ? RTLDRARCH_X86_32 2297 : FileHdr.Machine == IMAGE_FILE_MACHINE_AMD64 2298 ? RTLDRARCH_AMD64 2299 : RTLDRARCH_WHATEVER; 2295 2300 pModPe->pvBits = NULL; 2296 2301 pModPe->offNtHdrs = offNtHdrs; -
trunk/src/VBox/Runtime/common/ldr/ldrkStuff.cpp
r46161 r46164 618 618 case KLDRDBGINFOTYPE_DWARF: 619 619 DbgInfo.enmType = RTLDRDBGINFOTYPE_DWARF; 620 if (pszExtFile) 620 if (!pszExtFile) 621 DbgInfo.u.Dwarf.pszSection = pszPartNm; 622 else 623 { 621 624 DbgInfo.enmType = RTLDRDBGINFOTYPE_DWARF_DWO; 625 DbgInfo.u.Dwo.uCrc32 = 0; 626 } 622 627 break; 623 628 case KLDRDBGINFOTYPE_CODEVIEW: … … 922 927 break; 923 928 } 929 switch (pMod->enmArch) 930 { 931 case KCPUARCH_X86_32: pNewMod->Core.enmArch = RTLDRARCH_X86_32; break; 932 case KCPUARCH_AMD64: pNewMod->Core.enmArch = RTLDRARCH_AMD64; break; 933 default: 934 AssertMsgFailed(("%d\n", pMod->enmArch)); 935 pNewMod->Core.enmArch = RTLDRARCH_WHATEVER; 936 break; 937 } 924 938 pNewMod->pMod = pMod; 925 939 *phLdrMod = &pNewMod->Core; -
trunk/src/VBox/Runtime/include/internal/dbgmod.h
r46161 r46164 198 198 199 199 /** 200 * Gets the loaderformat.201 * 202 * @returns Valid loaderformat on success, RTLDRFMT_INVALID if not supported.200 * Gets the image format. 201 * 202 * @returns Valid image format on success, RTLDRFMT_INVALID if not supported. 203 203 * @param pMod Pointer to the module structure. 204 204 */ 205 205 DECLCALLBACKMEMBER(RTLDRFMT, pfnGetFormat)(PRTDBGMODINT pMod); 206 207 /** 208 * Gets the image architecture. 209 * 210 * @returns Valid image architecutre on success, RTLDRARCH_WHATEVER if not 211 * supported. 212 * @param pMod Pointer to the module structure. 213 */ 214 DECLCALLBACKMEMBER(RTLDRARCH, pfnGetArch)(PRTDBGMODINT pMod); 206 215 207 216 /** For catching initialization errors (RTDBGMODVTIMG_MAGIC). */ … … 244 253 * Upon successful return the method is expected to 245 254 * initialize pDbgOps and pvDbgPriv. 246 */ 247 DECLCALLBACKMEMBER(int, pfnTryOpen)(PRTDBGMODINT pMod); 255 * @param enmArch The desired architecture. 256 */ 257 DECLCALLBACKMEMBER(int, pfnTryOpen)(PRTDBGMODINT pMod, RTLDRARCH enmArch); 248 258 249 259 /** -
trunk/src/VBox/Runtime/include/internal/ldr.h
r46161 r46164 429 429 /** Image endianness. */ 430 430 RTLDRENDIAN enmEndian; 431 /** Image target architecture. */ 432 RTLDRARCH enmArch; 431 433 } RTLDRMODINTERNAL; 432 434
Note:
See TracChangeset
for help on using the changeset viewer.