Changeset 46113 in vbox
- Timestamp:
- May 15, 2013 10:39:43 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/ldr.h
r46083 r46113 371 371 * @{ */ 372 372 /** Returns ALL kinds of symbols. The default is to only return public/exported symbols. */ 373 #define RTLDR_ENUM_SYMBOL_FLAGS_ALL RT_BIT(1) 373 #define RTLDR_ENUM_SYMBOL_FLAGS_ALL RT_BIT(1) 374 /** Ignore forwarders (for use with RTLDR_ENUM_SYMBOL_FLAGS_ALL). */ 375 #define RTLDR_ENUM_SYMBOL_FLAGS_NO_FWD RT_BIT(2) 374 376 /** @} */ 375 377 -
trunk/src/VBox/Runtime/common/dbg/dbgmoddeferred.cpp
r46109 r46113 478 478 479 479 480 /** @interface_method_impl{RTDBGMODVTIMG,pfnEnumSymbols} */ 481 static DECLCALLBACK(int) rtDbgModDeferredImg_EnumSymbols(PRTDBGMODINT pMod, uint32_t fFlags, RTLDRADDR BaseAddress, 482 PFNRTLDRENUMSYMS pfnCallback, void *pvUser) 483 { 484 int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/); 485 if (RT_SUCCESS(rc)) 486 rc = pMod->pImgVt->pfnEnumSymbols(pMod, fFlags, BaseAddress, pfnCallback, pvUser); 487 return rc; 488 } 489 490 480 491 /** @interface_method_impl{RTDBGMODVTIMG,pfnEnumSegments} */ 481 492 static DECLCALLBACK(int) rtDbgModDeferredImg_EnumSegments(PRTDBGMODINT pMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser) … … 523 534 /*.pfnEnumDbgInfo = */ rtDbgModDeferredImg_EnumDbgInfo, 524 535 /*.pfnEnumSegments = */ rtDbgModDeferredImg_EnumSegments, 536 /*.pfnEnumSymbols = */ rtDbgModDeferredImg_EnumSymbols, 525 537 /*.pfnGetLoadedSize = */ rtDbgModDeferredImg_ImageSize, 526 538 /*.pfnLinkAddressToSegOffset = */ rtDbgModDeferredImg_LinkAddressToSegOffset, -
trunk/src/VBox/Runtime/common/dbg/dbgmodexports.cpp
r45997 r46113 29 29 * Header Files * 30 30 *******************************************************************************/ 31 #define LOG_GROUP RTLOGGROUP_DBG 31 32 #include <iprt/dbg.h> 32 33 #include "internal/iprt.h" 33 34 35 #include <iprt/alloca.h> 34 36 #include <iprt/assert.h> 35 37 #include <iprt/err.h> 38 #include <iprt/log.h> 36 39 #include <iprt/string.h> 37 40 #include "internal/dbgmod.h" 38 41 39 42 43 /******************************************************************************* 44 * Structures and Typedefs * 45 *******************************************************************************/ 46 typedef struct RTDBGMODEXPORTARGS 47 { 48 PRTDBGMODINT pDbgMod; 49 RTLDRADDR uImageBase; 50 } RTDBGMODEXPORTARGS; 51 /** Pointer to an argument package. */ 52 typedef RTDBGMODEXPORTARGS *PRTDBGMODEXPORTARGS; 40 53 41 54 55 /** @callback_method_impl{FNRTLDRENUMSYMS, 56 * Copies the symbols over into the container.} */ 57 static DECLCALLBACK(int) rtDbgModExportsAddSymbolCallback(RTLDRMOD hLdrMod, const char *pszSymbol, unsigned uSymbol, 58 RTLDRADDR Value, void *pvUser) 59 { 60 PRTDBGMODEXPORTARGS pArgs = (PRTDBGMODEXPORTARGS)pvUser; 61 NOREF(hLdrMod); 62 63 if (Value >= pArgs->uImageBase) 64 { 65 int rc = RTDbgModSymbolAdd(pArgs->pDbgMod, pszSymbol, RTDBGSEGIDX_RVA, Value - pArgs->uImageBase, 66 0 /*cb*/, 0 /* fFlags */, NULL /*piOrdinal*/); 67 Log(("Symbol #%05u %#018x %s [%Rrc]\n", uSymbol, Value, pszSymbol, rc)); NOREF(rc); 68 } 69 else 70 Log(("Symbol #%05u %#018x %s [SKIPPED - INVALID ADDRESS]\n", uSymbol, Value, pszSymbol)); 71 return VINF_SUCCESS; 72 } 73 74 75 /** @callback_method_impl{FNRTLDRENUMSEGS, 76 * Copies the segments over into the container.} */ 77 static DECLCALLBACK(int) rtDbgModExportsAddSegmentsCallback(RTLDRMOD hLdrMod, PCRTLDRSEG pSeg, void *pvUser) 78 { 79 PRTDBGMODEXPORTARGS pArgs = (PRTDBGMODEXPORTARGS)pvUser; 80 Log(("Segment %.*s: LinkAddress=%#llx RVA=%#llx cb=%#llx\n", 81 pSeg->cchName, pSeg->pchName, (uint64_t)pSeg->LinkAddress, (uint64_t)pSeg->RVA, pSeg->cb)); 82 NOREF(hLdrMod); 83 84 /* Find the best base address for the module. */ 85 if ( pSeg->LinkAddress != NIL_RTLDRADDR 86 && ( !pArgs->uImageBase 87 || pArgs->uImageBase > pSeg->LinkAddress)) 88 pArgs->uImageBase = pSeg->LinkAddress; 89 90 /* Make sure the name is terminated before we add it. */ 91 char *pszName = (char *)pSeg->pchName; 92 if (pszName[pSeg->cchName]) 93 { 94 pszName = (char *)alloca(pSeg->cchName + 1); 95 memcpy(pszName, pSeg->pchName, pSeg->cchName); 96 pszName[pSeg->cchName] = '\0'; 97 } 98 99 RTLDRADDR cb = RT_MAX(pSeg->cb, pSeg->cbMapped); 100 return RTDbgModSegmentAdd(pArgs->pDbgMod, pSeg->RVA, cb, pszName, 0 /*fFlags*/, NULL); 101 } 42 102 43 103 … … 62 122 * We simply use a container type for this work. 63 123 */ 64 /// @todo later int rc = rtDbgModContainerCreate(pDbgMod, 0); 65 int rc = rtDbgModContainerCreate(pDbgMod, cbImage); 124 int rc = rtDbgModContainerCreate(pDbgMod, 0); 66 125 if (RT_FAILURE(rc)) 67 126 return rc; 127 pDbgMod->fExports = true; 68 128 69 129 /* 70 * Copy the segments .130 * Copy the segments and symbols. 71 131 */ 132 RTDBGMODEXPORTARGS Args; 133 Args.pDbgMod = pDbgMod; 134 Args.uImageBase = 0; 135 rc = pDbgMod->pImgVt->pfnEnumSegments(pDbgMod, rtDbgModExportsAddSegmentsCallback, &Args); 136 if (RT_SUCCESS(rc)) 137 { 138 rc = pDbgMod->pImgVt->pfnEnumSymbols(pDbgMod, RTLDR_ENUM_SYMBOL_FLAGS_ALL | RTLDR_ENUM_SYMBOL_FLAGS_NO_FWD, 139 Args.uImageBase ? Args.uImageBase : 0x10000, 140 rtDbgModExportsAddSymbolCallback, &Args); 141 if (RT_FAILURE(rc)) 142 Log(("rtDbgModCreateForExports: Error during symbol enum: %Rrc\n", rc)); 143 } 144 else 145 Log(("rtDbgModCreateForExports: Error during segment enum: %Rrc\n", rc)); 72 146 73 /* 74 * Copy the symbols.75 */76 77 78 return VINF_SUCCESS;147 /* This won't fail. */ 148 if (RT_SUCCESS(rc)) 149 rc = VINF_SUCCESS; 150 else 151 rc = -rc; /* Change it into a warning. */ 152 return rc; 79 153 } 80 154 -
trunk/src/VBox/Runtime/common/dbg/dbgmodldr.cpp
r46083 r46113 109 109 110 110 /** @interface_method_impl{RTDBGMODVTIMG,pfnEnumSegments} */ 111 static DECLCALLBACK(int) rtDbgModLdr_EnumSymbols(PRTDBGMODINT pMod, uint32_t fFlags, RTLDRADDR BaseAddress, 112 PFNRTLDRENUMSYMS pfnCallback, void *pvUser) 113 { 114 PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv; 115 return RTLdrEnumSymbols(pThis->hLdrMod, fFlags, NULL /*pvBits*/, BaseAddress, pfnCallback, pvUser); 116 } 117 118 119 /** @interface_method_impl{RTDBGMODVTIMG,pfnEnumSegments} */ 111 120 static DECLCALLBACK(int) rtDbgModLdr_EnumSegments(PRTDBGMODINT pMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser) 112 121 { … … 164 173 /*.pfnEnumDbgInfo = */ rtDbgModLdr_EnumDbgInfo, 165 174 /*.pfnEnumSegments = */ rtDbgModLdr_EnumSegments, 175 /*.pfnEnumSymbols = */ rtDbgModLdr_EnumSymbols, 166 176 /*.pfnGetLoadedSize = */ rtDbgModLdr_GetLoadedSize, 167 177 /*.pfnLinkAddressToSegOffset = */ rtDbgModLdr_LinkAddressToSegOffset, -
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r46108 r46113 971 971 uintptr_t uRVAExport = paAddress[uOrdinal]; 972 972 RTUINTPTR Value; 973 if ( uRVAExport - (uintptr_t)pModPe->ExportDir.VirtualAddress 974 < pModPe->ExportDir.Size) 975 { 976 /* Resolve forwarder. */ 977 AssertMsgFailed(("Forwarders are not supported!\n")); 973 if ( uRVAExport - (uintptr_t)pModPe->ExportDir.VirtualAddress 974 < pModPe->ExportDir.Size) 975 { 976 if (!(fFlags & RTLDR_ENUM_SYMBOL_FLAGS_NO_FWD)) 977 { 978 /* Resolve forwarder. */ 979 AssertMsgFailed(("Forwarders are not supported!\n")); 980 } 978 981 continue; 979 982 } -
trunk/src/VBox/Runtime/include/internal/dbgmod.h
r46101 r46113 115 115 */ 116 116 DECLCALLBACKMEMBER(int, pfnEnumSegments)(PRTDBGMODINT pMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser); 117 118 /** 119 * Enumerates the symbols exported by the module. 120 * 121 * @returns iprt status code, which might have been returned by pfnCallback. 122 * @param pMod Pointer to the module structure. 123 * @param fFlags Flags indicating what to return and such. 124 * @param BaseAddress The image base addressto use when calculating the 125 * symbol values. 126 * @param pfnCallback The callback function which each symbol is to be fed 127 * to. 128 * @param pvUser User argument to pass to the enumerator. 129 */ 130 DECLCALLBACKMEMBER(int, pfnEnumSymbols)(PRTDBGMODINT pMod, uint32_t fFlags, RTLDRADDR BaseAddress, 131 PFNRTLDRENUMSYMS pfnCallback, void *pvUser); 117 132 118 133 /**
Note:
See TracChangeset
for help on using the changeset viewer.