- Timestamp:
- Oct 22, 2018 7:53:20 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/BiosCommonCode/MakeAlternativeSource.cpp
r69120 r74982 51 51 uint32_t uFlatAddr; 52 52 uint32_t cb; 53 /** RVA into g_hSymMod. */ 54 uint32_t uRva; 53 55 } BIOSSEG; 54 56 /** Pointer to a BIOS segment. */ … … 97 99 *********************************************************************************************************************************/ 98 100 /** The verbosity level.*/ 99 static unsigned g_cVerbose = 1/*0*/;101 static unsigned g_cVerbose = 2 /*0*/; 100 102 /** Pointer to the BIOS image. */ 101 103 static uint8_t const *g_pbImg; … … 111 113 /** List of BIOSOBJFILE. */ 112 114 static RTLISTANCHOR g_ObjList; 115 116 /** Debug module with symbols. */ 117 static RTDBGMOD g_hSymMod = NIL_RTDBGMOD; 113 118 114 119 /** The output stream. */ … … 633 638 static void disGetNextSymbolWorker(uint32_t uFlatAddr, uint32_t cbMax, uint32_t *poff, PRTDBGSYMBOL pSym) 634 639 { 635 RTINTPTR off = 0; 636 int rc = RTDbgModSymbolByAddr(g_hMapMod, RTDBGSEGIDX_RVA, uFlatAddr, RTDBGSYMADDR_FLAGS_GREATER_OR_EQUAL, &off, pSym); 640 RTINTPTR offMap = RTINTPTR_MAX; 641 RTDBGSYMBOL MapSym; 642 int rcMap = RTDbgModSymbolByAddr(g_hMapMod, RTDBGSEGIDX_RVA, uFlatAddr, RTDBGSYMADDR_FLAGS_GREATER_OR_EQUAL, &offMap, &MapSym); 643 644 RTINTPTR off = RTINTPTR_MAX; 645 int rc = RTDbgModSymbolByAddr(g_hSymMod, RTDBGSEGIDX_RVA, uFlatAddr - g_uBiosFlatBase, 646 RTDBGSYMADDR_FLAGS_GREATER_OR_EQUAL, &off, pSym); 647 if ( RT_SUCCESS(rc) 648 && RT_ABS(off) <= RT_ABS(offMap)) 649 pSym->Value += g_uBiosFlatBase; 650 else 651 { 652 *pSym = MapSym; 653 off = offMap; 654 rc = rcMap; 655 } 637 656 if (RT_SUCCESS(rc)) 638 657 { … … 641 660 { 642 661 *poff = (uint32_t)-off; 662 663 /* Mangle symbols the assembler might confuse with instructions. */ 664 size_t cchName = strlen(pSym->szName); 665 if ( cchName <= 4 666 && ( strcmp("wait", pSym->szName) == 0 667 || strcmp("hlt", pSym->szName) == 0)) 668 { 669 memmove(&pSym->szName[1], &pSym->szName[0], cchName); 670 pSym->szName[0] = '_'; 671 pSym->szName[cchName + 1] = '_'; 672 pSym->szName[cchName + 2] = '\0'; 673 } 643 674 return; 644 675 } … … 858 889 RT_NOREF_PV(pszSymbol); 859 890 return true; 891 } 892 893 894 static bool disIsMemoryParameter(PCDISOPPARAM pParam, uint16_t fParam) 895 { 896 return fParam != OP_PARM_NONE 897 && DISUSE_IS_EFFECTIVE_ADDR(pParam->fUse); 898 } 899 900 901 static bool disAccessesMemory(PCDISCPUSTATE pCpuState) 902 { 903 PCDISOPCODE pCurInstr = pCpuState->pCurInstr; 904 return disIsMemoryParameter(&pCpuState->Param1, pCurInstr->fParam1) 905 || disIsMemoryParameter(&pCpuState->Param2, pCurInstr->fParam2) 906 || disIsMemoryParameter(&pCpuState->Param3, pCurInstr->fParam3) 907 || disIsMemoryParameter(&pCpuState->Param4, pCurInstr->fParam4); 860 908 } 861 909 … … 1079 1127 unsigned cbInstr; 1080 1128 DISCPUSTATE CpuState; 1129 CpuState.ModRM.Bits.Mod = 3; 1081 1130 int rc = DISInstrWithReader(uFlatAddr, fIs16Bit ? DISCPUMODE_16BIT : DISCPUMODE_32BIT, 1082 1131 disReadOpcodeBytes, NULL, &CpuState, &cbInstr); … … 1084 1133 && cbInstr <= cb 1085 1134 && CpuState.pCurInstr 1086 && CpuState.pCurInstr->uOpcode != OP_INVALID) 1135 && CpuState.pCurInstr->uOpcode != OP_INVALID 1136 && CpuState.pCurInstr->uOpcode != OP_ILLUD2 1137 && ( !(CpuState.fPrefix & DISPREFIX_ADDRSIZE) 1138 || disAccessesMemory(&CpuState))) 1087 1139 { 1088 1140 char szTmp[4096]; … … 1098 1150 while (cch < 72) 1099 1151 szTmp[cch++] = ' '; 1100 RTStrPrintf(&szTmp[cch], sizeof(szTmp) - cch, "; %#x", uFlatAddr); 1152 1153 RTDBGLINE LineInfo = {0}; 1154 RTINTPTR offLine = -1; 1155 int rcLine = RTDbgModLineByAddr(g_hSymMod, RTDBGSEGIDX_RVA, uFlatAddr - g_uBiosFlatBase, &offLine, &LineInfo); 1156 if (RT_SUCCESS(rcLine) && offLine == 0 && cch < sizeof(szTmp) - 16) 1157 RTStrPrintf(&szTmp[cch], sizeof(szTmp) - cch, "; %#x %Rbn:%u", 1158 uFlatAddr, LineInfo.szFilename, LineInfo.uLineNo); 1159 else 1160 RTStrPrintf(&szTmp[cch], sizeof(szTmp) - cch, "; %#x", uFlatAddr); 1101 1161 } 1102 1162 … … 1237 1297 static RTEXITCODE ParseSymFile(const char *pszBiosSym) 1238 1298 { 1239 #if 1 1240 /** @todo use RTDbg* later. (Just checking for existance currently.) */ 1241 PRTSTREAM hStrm; 1242 int rc = RTStrmOpen(pszBiosSym, "rb", &hStrm); 1299 int rc = RTDbgModCreateFromImage(&g_hSymMod, pszBiosSym, "VBoxBios", RTLDRARCH_WHATEVER, NIL_RTDBGCFG); 1243 1300 if (RT_FAILURE(rc)) 1244 1301 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error opening '%s': %Rrc", pszBiosSym, rc); 1245 RTStrmClose(hStrm); 1246 #else 1247 RTDBGMOD hDbgMod; 1248 int rc = RTDbgModCreateFromImage(&hDbgMod, pszBiosSym, "VBoxBios", 0 /*fFlags*/); 1249 RTMsgInfo("RTDbgModCreateFromImage -> %Rrc\n", rc); 1250 #endif 1302 1303 if (g_cVerbose > 0) 1304 { 1305 /* Show segments */ 1306 RTDBGSEGIDX cSegs = RTDbgModSegmentCount(g_hSymMod); 1307 for (RTDBGSEGIDX iSeg = 0; iSeg < cSegs; iSeg++) 1308 { 1309 RTDBGSEGMENT SegInfo; 1310 rc = RTDbgModSegmentByIndex(g_hSymMod, iSeg, &SegInfo); 1311 if (RT_SUCCESS(rc)) 1312 RTMsgInfo("Seg#%u: %05RX64 LB %04RX64 rva %04RX64 %s\n", iSeg, SegInfo.Address, SegInfo.cb, SegInfo.uRva, SegInfo.szName); 1313 else 1314 RTMsgInfo("Seg#%u: RTDbgModSegmentByIndex -> %Rrc\n", iSeg, rc); 1315 1316 } 1317 } 1251 1318 return RTEXITCODE_SUCCESS; 1252 1319 } … … 1265 1332 va_list va; 1266 1333 va_start(va, pszFormat); 1267 RTMsgError("%s:%d: %N", pMap->pszMapFile, pMap->iLine, pszFormat, va);1334 RTMsgError("%s:%d: %N", pMap->pszMapFile, pMap->iLine, pszFormat, &va); 1268 1335 va_end(va); 1269 1336 return false; … … 1755 1822 g_aSegs[j] = Tmp; 1756 1823 } 1824 g_aSegs[i].uRva = g_aSegs[i].uFlatAddr - g_aSegs[0].uFlatAddr; 1825 1757 1826 if (g_cVerbose > 0) 1758 RTStrmPrintf(g_pStdErr, "segment at %08x / %04x :%04x LB %04x %s / %s / %s\n",1827 RTStrmPrintf(g_pStdErr, "segment at %08x / %04x / %04x:%04x LB %04x %s / %s / %s\n", 1759 1828 g_aSegs[i].uFlatAddr, 1829 g_aSegs[i].uRva, 1760 1830 g_aSegs[i].Address.sel, 1761 1831 g_aSegs[i].Address.off,
Note:
See TracChangeset
for help on using the changeset viewer.