Changeset 105723 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Aug 19, 2024 12:05:48 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp
r105718 r105723 8963 8963 { 8964 8964 PVMCPU pVCpu; 8965 PCIEMTB pTb; 8965 8966 # ifdef IEMNATIVE_WITH_RECOMPILER_PER_CHUNK_TAIL_CODE 8966 8967 PCIEMNATIVEPERCHUNKCTX pCtx; 8967 8968 # endif 8969 # ifdef IEMNATIVE_WITH_TB_DEBUG_INFO 8970 PCIEMTBDBG pDbgInfo; 8971 # endif 8968 8972 } IEMNATIVDISASMSYMCTX; 8969 8973 typedef IEMNATIVDISASMSYMCTX *PIEMNATIVDISASMSYMCTX; … … 8973 8977 * Resolve address to symbol, if we can. 8974 8978 */ 8975 static const char *iemNativeDisasmGetSymbol(PIEMNATIVDISASMSYMCTX pSymCtx, uintptr_t uAddress) 8976 { 8977 #ifdef IEMNATIVE_WITH_RECOMPILER_PER_CHUNK_TAIL_CODE 8978 PCIEMNATIVEPERCHUNKCTX pChunkCtx = pSymCtx->pCtx; 8979 if (pChunkCtx) 8980 for (uint32_t i = 1; i < RT_ELEMENTS(pChunkCtx->apExitLabels); i++) 8981 if ((PIEMNATIVEINSTR)uAddress == pChunkCtx->apExitLabels[i]) 8982 return iemNativeGetLabelName((IEMNATIVELABELTYPE)i, true /*fCommonCode*/); 8983 #endif 8979 static const char *iemNativeDisasmGetSymbol(PIEMNATIVDISASMSYMCTX pSymCtx, uintptr_t uAddress, char *pszBuf, size_t cbBuf) 8980 { 8981 #if defined(IEMNATIVE_WITH_TB_DEBUG_INFO) || defined(IEMNATIVE_WITH_RECOMPILER_PER_CHUNK_TAIL_CODE) 8982 PCIEMTB const pTb = pSymCtx->pTb; 8983 uintptr_t const offNative = (uAddress - (uintptr_t)pTb->Native.paInstructions) / sizeof(IEMNATIVEINSTR); 8984 if (offNative <= pTb->Native.cInstructions) 8985 { 8986 # ifdef IEMNATIVE_WITH_TB_DEBUG_INFO 8987 /* 8988 * Scan debug info for a matching label. 8989 * Since the debug info should be 100% linear, we can do a binary search here. 8990 */ 8991 PCIEMTBDBG const pDbgInfo = pSymCtx->pDbgInfo; 8992 if (pDbgInfo) 8993 { 8994 uint32_t const cEntries = pDbgInfo->cEntries; 8995 uint32_t idxEnd = cEntries; 8996 uint32_t idxStart = 0; 8997 for (;;) 8998 { 8999 /* Find a NativeOffset record close to the midpoint. */ 9000 uint32_t idx = idxStart + (idxEnd - idxStart) / 2; 9001 while (idx > idxStart && pDbgInfo->aEntries[idx].Gen.uType != kIemTbDbgEntryType_NativeOffset) 9002 idx--; 9003 if (pDbgInfo->aEntries[idx].Gen.uType != kIemTbDbgEntryType_NativeOffset) 9004 { 9005 idx = idxStart + (idxEnd - idxStart) / 2 + 1; 9006 while (idx < idxEnd && pDbgInfo->aEntries[idx].Gen.uType != kIemTbDbgEntryType_NativeOffset) 9007 idx++; 9008 if (idx >= idxEnd) 9009 break; 9010 } 9011 9012 /* Do the binary searching thing. */ 9013 if (offNative < pDbgInfo->aEntries[idx].NativeOffset.offNative) 9014 { 9015 if (idx > idxStart) 9016 idxEnd = idx; 9017 else 9018 break; 9019 } 9020 else if (offNative > pDbgInfo->aEntries[idx].NativeOffset.offNative) 9021 { 9022 idx += 1; 9023 if (idx < idxEnd) 9024 idxStart = idx; 9025 else 9026 break; 9027 } 9028 else 9029 { 9030 /* Got a matching offset, scan forward till we hit a label, but 9031 stop when the native offset changes. */ 9032 while (++idx < cEntries) 9033 switch (pDbgInfo->aEntries[idx].Gen.uType) 9034 { 9035 case kIemTbDbgEntryType_Label: 9036 { 9037 IEMNATIVELABELTYPE const enmLabel = (IEMNATIVELABELTYPE)pDbgInfo->aEntries[idx].Label.enmLabel; 9038 const char * const pszName = iemNativeGetLabelName(enmLabel); 9039 if (enmLabel < kIemNativeLabelType_FirstWithMultipleInstances) 9040 return pszName; 9041 RTStrPrintf(pszBuf, cbBuf, "%s_%u", pszName, pDbgInfo->aEntries[idx].Label.uData); 9042 return pszBuf; 9043 } 9044 9045 case kIemTbDbgEntryType_NativeOffset: 9046 if (pDbgInfo->aEntries[idx].NativeOffset.offNative != offNative) 9047 return NULL; 9048 break; 9049 } 9050 break; 9051 } 9052 } 9053 } 9054 # endif 9055 } 9056 # ifdef IEMNATIVE_WITH_RECOMPILER_PER_CHUNK_TAIL_CODE 9057 else 9058 { 9059 PCIEMNATIVEPERCHUNKCTX const pChunkCtx = pSymCtx->pCtx; 9060 if (pChunkCtx) 9061 for (uint32_t i = 1; i < RT_ELEMENTS(pChunkCtx->apExitLabels); i++) 9062 if ((PIEMNATIVEINSTR)uAddress == pChunkCtx->apExitLabels[i]) 9063 return iemNativeGetLabelName((IEMNATIVELABELTYPE)i, true /*fCommonCode*/); 9064 } 9065 # endif 9066 #endif 9067 RT_NOREF(pSymCtx, uAddress, pszBuf, cbBuf); 8984 9068 return NULL; 8985 9069 } … … 8991 9075 */ 8992 9076 static DECLCALLBACK(int) iemNativeDisasmGetSymbolCb(PCDISSTATE pDis, uint32_t u32Sel, RTUINTPTR uAddress, 8993 char *pszBuf, size_t cchBuf, RTINTPTR *poff, void *pvUser)8994 { 8995 const char * const pszSym = iemNativeDisasmGetSymbol((PIEMNATIVDISASMSYMCTX)pvUser, uAddress );9077 char *pszBuf, size_t cchBuf, RTINTPTR *poff, void *pvUser) 9078 { 9079 const char * const pszSym = iemNativeDisasmGetSymbol((PIEMNATIVDISASMSYMCTX)pvUser, uAddress, pszBuf, cchBuf); 8996 9080 if (pszSym) 8997 9081 { 8998 9082 *poff = 0; 8999 return RTStrCopy(pszBuf, cchBuf, pszSym); 9083 if (pszSym != pszBuf) 9084 return RTStrCopy(pszBuf, cchBuf, pszSym); 9085 return VINF_SUCCESS; 9000 9086 } 9001 9087 RT_NOREF(pDis, u32Sel); … … 9043 9129 uint64_t uAddr = RTStrToUInt64(pszAddr + 1); 9044 9130 if (uAddr != 0) 9045 return iemNativeDisasmGetSymbol(pSymCtx, uAddr );9131 return iemNativeDisasmGetSymbol(pSymCtx, uAddr, pszBuf, cchBuf); 9046 9132 } 9047 9133 } 9048 9134 # endif 9049 RT_NOREF(p szBuf, cchBuf);9135 RT_NOREF(pSymCtx, pInstr, pszBuf, cchBuf); 9050 9136 return NULL; 9051 9137 } … … 9076 9162 : DISCPUMODE_64BIT; 9077 9163 #ifdef IEMNATIVE_WITH_RECOMPILER_PER_CHUNK_TAIL_CODE 9078 IEMNATIVDISASMSYMCTX SymCtx = { pVCpu, iemExecMemGetTbChunkCtx(pVCpu, pTb) }; 9079 #else 9080 IEMNATIVDISASMSYMCTX SymCtx = { pVCpu }; 9164 # ifdef IEMNATIVE_WITH_TB_DEBUG_INFO 9165 IEMNATIVDISASMSYMCTX SymCtx = { pVCpu, pTb, iemExecMemGetTbChunkCtx(pVCpu, pTb), pDbgInfo }; 9166 # else 9167 IEMNATIVDISASMSYMCTX SymCtx = { pVCpu, pTb, iemExecMemGetTbChunkCtx(pVCpu, pTb) }; 9168 # endif 9169 #elif defined(IEMNATIVE_WITH_TB_DEBUG_INFO) 9170 IEMNATIVDISASMSYMCTX SymCtx = { pVCpu, pTb, pDbgInfo }; 9171 #else 9172 IEMNATIVDISASMSYMCTX SymCtx = { pVCpu, pTb }; 9081 9173 #endif 9082 9174 #if defined(RT_ARCH_AMD64) && !defined(VBOX_WITH_IEM_USING_CAPSTONE_DISASSEMBLER) … … 9381 9473 ? pMemOp->x86.uDisp.u32 : pMemOp->x86.uDisp.u8); 9382 9474 9383 # elif defined(RT_ARCH_ARM64)9475 # elif defined(RT_ARCH_ARM64) 9384 9476 DISFormatArmV8Ex(&Dis, szDisBuf, sizeof(szDisBuf), 9385 9477 DIS_FMT_FLAGS_BYTES_LEFT | DIS_FMT_FLAGS_RELATIVE_BRANCH | DIS_FMT_FLAGS_C_HEX, 9386 NULL /*pfnGetSymbol*/, NULL /*pvUser*/);9478 iemNativeDisasmGetSymbolCb, &SymCtx); 9387 9479 # else 9388 9480 # error "Port me"
Note:
See TracChangeset
for help on using the changeset viewer.