Changeset 78017 in vbox for trunk/src/VBox
- Timestamp:
- Apr 4, 2019 1:36:49 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp
r76553 r78017 69 69 static FNDBGCCMD dbgcCmdListNear; 70 70 static FNDBGCCMD dbgcCmdListSource; 71 static FNDBGCCMD dbgcCmdListSymbols; 71 72 static FNDBGCCMD dbgcCmdMemoryInfo; 72 73 static FNDBGCCMD dbgcCmdReg; … … 353 354 /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ 354 355 { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address where to start disassembling." }, 356 }; 357 358 /** 'x' arguments. */ 359 static const DBGCVARDESC g_aArgListSyms[] = 360 { 361 /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ 362 { 1, 1, DBGCVAR_CAT_STRING, 0, "symbols", "The symbols to list, format is Module!Symbol with wildcards being supoprted." } 355 363 }; 356 364 … … 467 475 { "ucfg", 0, 1, &g_aArgUnassembleCfg[0], RT_ELEMENTS(g_aArgUnassembleCfg), 0, dbgcCmdUnassembleCfg, "[addr]", "Unassemble creating a control flow graph." }, 468 476 { "ucfgc", 0, 1, &g_aArgUnassembleCfg[0], RT_ELEMENTS(g_aArgUnassembleCfg), 0, dbgcCmdUnassembleCfg, "[addr]", "Unassemble creating a control flow graph with colors." }, 477 { "x", 1, 1, &g_aArgListSyms[0], RT_ELEMENTS(g_aArgListSyms), 0, dbgcCmdListSymbols, "* | <Module!Symbol>", "Examine symbols." }, 469 478 }; 470 479 … … 6271 6280 6272 6281 /** 6282 * @callback_method_impl{FNDBGCCMD, The 'x' (examine symbols) command.} 6283 */ 6284 static DECLCALLBACK(int) dbgcCmdListSymbols(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) 6285 { 6286 AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG); 6287 AssertReturn(paArgs[0].enmType == DBGCVAR_TYPE_STRING, VERR_DBGC_PARSE_BUG); 6288 6289 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); 6290 6291 /* 6292 * Allowed is either a single * to match everything or the Module!Symbol style 6293 * which requiresa ! to separate module and symbol. 6294 */ 6295 bool fDumpAll = strcmp(paArgs[0].u.pszString, "*") == 0; 6296 const char *pszModule = NULL; 6297 size_t cchModule = 0; 6298 const char *pszSymbol = NULL; 6299 if (!fDumpAll) 6300 { 6301 const char *pszDelimiter = strchr(paArgs[0].u.pszString, '!'); 6302 if (!pszDelimiter) 6303 return DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid search string '%s' for '%s'. Valid are either '*' or the form <Module>!<Symbol> where the <Module> and <Symbol> can contain wildcards", 6304 paArgs[0].u.pszString, pCmd->pszCmd); 6305 6306 pszModule = paArgs[0].u.pszString; 6307 cchModule = pszDelimiter - pszModule; 6308 pszSymbol = pszDelimiter + 1; 6309 } 6310 6311 /* 6312 * Iterate the modules in the current address space and print info about 6313 * those matching the input. 6314 */ 6315 RTDBGAS hAsCurAlias = pDbgc->hDbgAs; 6316 for (uint32_t iAs = 0;; iAs++) 6317 { 6318 RTDBGAS hAs = DBGFR3AsResolveAndRetain(pUVM, hAsCurAlias); 6319 uint32_t cMods = RTDbgAsModuleCount(hAs); 6320 for (uint32_t iMod = 0; iMod < cMods; iMod++) 6321 { 6322 RTDBGMOD hMod = RTDbgAsModuleByIndex(hAs, iMod); 6323 if (hMod != NIL_RTDBGMOD) 6324 { 6325 const char *pszModName = RTDbgModName(hMod); 6326 if ( fDumpAll 6327 || RTStrSimplePatternNMatch(pszModule, cchModule, pszModName, strlen(pszModName))) 6328 { 6329 RTDBGASMAPINFO aMappings[128]; 6330 uint32_t cMappings = RT_ELEMENTS(aMappings); 6331 RTUINTPTR uMapping = 0; 6332 6333 /* Get the minimum mapping address of the module so we can print absolute values for the symbol later on. */ 6334 int rc = RTDbgAsModuleQueryMapByIndex(hAs, iMod, &aMappings[0], &cMappings, 0 /*fFlags*/); 6335 if (RT_SUCCESS(rc)) 6336 { 6337 uMapping = RTUINTPTR_MAX; 6338 for (uint32_t iMap = 0; iMap < cMappings; iMap++) 6339 if (aMappings[iMap].Address < uMapping) 6340 uMapping = aMappings[iMap].Address; 6341 } 6342 6343 /* Go through the symbols and print any matches. */ 6344 uint32_t cSyms = RTDbgModSymbolCount(hMod); 6345 for (uint32_t iSym = 0; iSym < cSyms; iSym++) 6346 { 6347 RTDBGSYMBOL SymInfo; 6348 rc = RTDbgModSymbolByOrdinal(hMod, iSym, &SymInfo); 6349 if ( RT_SUCCESS(rc) 6350 && ( fDumpAll 6351 || RTStrSimplePatternMatch(pszSymbol, &SymInfo.szName[0]))) 6352 DBGCCmdHlpPrintf(pCmdHlp, "%RGv %s!%s\n", uMapping + (RTGCUINTPTR)SymInfo.Value, pszModName, &SymInfo.szName[0]); 6353 } 6354 } 6355 RTDbgModRelease(hMod); 6356 } 6357 } 6358 RTDbgAsRelease(hAs); 6359 6360 /* For DBGF_AS_RC_AND_GC_GLOBAL we're required to do more work. */ 6361 if (hAsCurAlias != DBGF_AS_RC_AND_GC_GLOBAL) 6362 break; 6363 AssertBreak(iAs == 0); 6364 hAsCurAlias = DBGF_AS_GLOBAL; 6365 } 6366 6367 RT_NOREF(pCmd); 6368 return VINF_SUCCESS; 6369 } 6370 6371 6372 6373 /** 6273 6374 * @callback_method_impl{FNDBGCFUNC, Reads a unsigned 8-bit value.} 6274 6375 */
Note:
See TracChangeset
for help on using the changeset viewer.