diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-03-26 19:21:20 +0000 |
---|---|---|
committer | <> | 2014-05-08 15:03:54 +0000 |
commit | fb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch) | |
tree | c2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Debugger | |
parent | 58ed4748338f9466599adfc8a9171280ed99e23f (diff) | |
download | VirtualBox-master.tar.gz |
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Debugger')
28 files changed, 1983 insertions, 1646 deletions
diff --git a/src/VBox/Debugger/DBGCCmdHlp.cpp b/src/VBox/Debugger/DBGCCmdHlp.cpp index 5251093c..fbe94f95 100644 --- a/src/VBox/Debugger/DBGCCmdHlp.cpp +++ b/src/VBox/Debugger/DBGCCmdHlp.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2012 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -315,7 +315,7 @@ static DECLCALLBACK(int) dbgcHlpVBoxError(PDBGCCMDHLP pCmdHlp, int rc, const cha /** * @interface_method_impl{DBGCCMDHLP,pfnMemRead} */ -static DECLCALLBACK(int) dbgcHlpMemRead(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBuffer, size_t cbRead, PCDBGCVAR pVarPointer, size_t *pcbRead) +static DECLCALLBACK(int) dbgcHlpMemRead(PDBGCCMDHLP pCmdHlp, void *pvBuffer, size_t cbRead, PCDBGCVAR pVarPointer, size_t *pcbRead) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); DBGFADDRESS Address; @@ -340,8 +340,8 @@ static DECLCALLBACK(int) dbgcHlpMemRead(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBu { case DBGCVAR_TYPE_GC_FAR: /* Use DBGFR3AddrFromSelOff for the conversion. */ - Assert(pDbgc->pVM); - rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, Var.u.GCFar.sel, Var.u.GCFar.off); + Assert(pDbgc->pUVM); + rc = DBGFR3AddrFromSelOff(pDbgc->pUVM, pDbgc->idCpu, &Address, Var.u.GCFar.sel, Var.u.GCFar.off); if (RT_FAILURE(rc)) return rc; @@ -349,7 +349,7 @@ static DECLCALLBACK(int) dbgcHlpMemRead(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBu if (!DBGFADDRESS_IS_FLAT(&Address)) { DBGFSELINFO SelInfo; - rc = DBGFR3SelQueryInfo(pDbgc->pVM, pDbgc->idCpu, Address.Sel, + rc = DBGFR3SelQueryInfo(pDbgc->pUVM, pDbgc->idCpu, Address.Sel, DBGFSELQI_FLAGS_DT_GUEST | DBGFSELQI_FLAGS_DT_ADJ_64BIT_MODE, &SelInfo); if (RT_SUCCESS(rc)) { @@ -418,14 +418,14 @@ static DECLCALLBACK(int) dbgcHlpMemRead(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBu switch (Var.enmType) { case DBGCVAR_TYPE_GC_FLAT: - rc = DBGFR3MemRead(pDbgc->pVM, pDbgc->idCpu, - DBGFR3AddrFromFlat(pVM, &Address, Var.u.GCFlat), + rc = DBGFR3MemRead(pDbgc->pUVM, pDbgc->idCpu, + DBGFR3AddrFromFlat(pDbgc->pUVM, &Address, Var.u.GCFlat), pvBuffer, cb); break; case DBGCVAR_TYPE_GC_PHYS: - rc = DBGFR3MemRead(pDbgc->pVM, pDbgc->idCpu, - DBGFR3AddrFromPhys(pVM, &Address, Var.u.GCPhys), + rc = DBGFR3MemRead(pDbgc->pUVM, pDbgc->idCpu, + DBGFR3AddrFromPhys(pDbgc->pUVM, &Address, Var.u.GCPhys), pvBuffer, cb); break; @@ -466,7 +466,7 @@ static DECLCALLBACK(int) dbgcHlpMemRead(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBu if (!cbLeft) break; pvBuffer = (char *)pvBuffer + cb; - rc = DBGCCmdHlpEval(pCmdHlp, &Var, "%DV + %d", &Var, cb); + rc = DBGCCmdHlpEval(pCmdHlp, &Var, "%DV + %#zx", &Var, cb); if (RT_FAILURE(rc)) { if (pcbRead && (*pcbRead = cbRead - cbLeft) > 0) @@ -487,7 +487,7 @@ static DECLCALLBACK(int) dbgcHlpMemRead(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBu /** * @interface_method_impl{DBGCCMDHLP,pfnMemWrite} */ -static DECLCALLBACK(int) dbgcHlpMemWrite(PDBGCCMDHLP pCmdHlp, PVM pVM, const void *pvBuffer, size_t cbWrite, PCDBGCVAR pVarPointer, size_t *pcbWritten) +static DECLCALLBACK(int) dbgcHlpMemWrite(PDBGCCMDHLP pCmdHlp, const void *pvBuffer, size_t cbWrite, PCDBGCVAR pVarPointer, size_t *pcbWritten) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); DBGFADDRESS Address; @@ -513,8 +513,8 @@ static DECLCALLBACK(int) dbgcHlpMemWrite(PDBGCCMDHLP pCmdHlp, PVM pVM, const voi case DBGCVAR_TYPE_GC_FAR: { /* Use DBGFR3AddrFromSelOff for the conversion. */ - Assert(pDbgc->pVM); - rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, Var.u.GCFar.sel, Var.u.GCFar.off); + Assert(pDbgc->pUVM); + rc = DBGFR3AddrFromSelOff(pDbgc->pUVM, pDbgc->idCpu, &Address, Var.u.GCFar.sel, Var.u.GCFar.off); if (RT_FAILURE(rc)) return rc; @@ -522,7 +522,7 @@ static DECLCALLBACK(int) dbgcHlpMemWrite(PDBGCCMDHLP pCmdHlp, PVM pVM, const voi if (!DBGFADDRESS_IS_FLAT(&Address)) { DBGFSELINFO SelInfo; - rc = DBGFR3SelQueryInfo(pDbgc->pVM, pDbgc->idCpu, Address.Sel, + rc = DBGFR3SelQueryInfo(pDbgc->pUVM, pDbgc->idCpu, Address.Sel, DBGFSELQI_FLAGS_DT_GUEST | DBGFSELQI_FLAGS_DT_ADJ_64BIT_MODE, &SelInfo); if (RT_SUCCESS(rc)) { @@ -555,16 +555,16 @@ static DECLCALLBACK(int) dbgcHlpMemWrite(PDBGCCMDHLP pCmdHlp, PVM pVM, const voi } /* fall thru */ case DBGCVAR_TYPE_GC_FLAT: - rc = DBGFR3MemWrite(pVM, pDbgc->idCpu, - DBGFR3AddrFromFlat(pVM, &Address, Var.u.GCFlat), + rc = DBGFR3MemWrite(pDbgc->pUVM, pDbgc->idCpu, + DBGFR3AddrFromFlat(pDbgc->pUVM, &Address, Var.u.GCFlat), pvBuffer, cbWrite); if (pcbWritten && RT_SUCCESS(rc)) *pcbWritten = cbWrite; return rc; case DBGCVAR_TYPE_GC_PHYS: - rc = DBGFR3MemWrite(pVM, pDbgc->idCpu, - DBGFR3AddrFromPhys(pVM, &Address, Var.u.GCPhys), + rc = DBGFR3MemWrite(pDbgc->pUVM, pDbgc->idCpu, + DBGFR3AddrFromPhys(pDbgc->pUVM, &Address, Var.u.GCPhys), pvBuffer, cbWrite); if (pcbWritten && RT_SUCCESS(rc)) *pcbWritten = cbWrite; @@ -722,6 +722,25 @@ static DECLCALLBACK(int) dbgcHlpFailRcV(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, int /** + * @copydoc DBGCCMDHLP::pfnParserError + */ +static DECLCALLBACK(int) dbgcHlpParserError(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, int iArg, const char *pszExpr, unsigned iLine) +{ + PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); + + /* + * Do the formatting and output. + */ + pDbgc->rcOutput = VINF_SUCCESS; + RTStrFormat(dbgcFormatOutput, pDbgc, dbgcStringFormatter, pDbgc, "%s: parser error: iArg=%d iLine=%u pszExpr=%s\n", + pCmd->pszCmd, iArg, iLine, pszExpr); + if (RT_FAILURE(pDbgc->rcOutput)) + return pDbgc->rcOutput; + return VERR_DBGC_COMMAND_FAILED; +} + + +/** * @interface_method_impl{DBGCCMDHLP,pfnVarToDbgfAddr} */ static DECLCALLBACK(int) dbgcHlpVarToDbgfAddr(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, PDBGFADDRESS pAddress) @@ -733,18 +752,18 @@ static DECLCALLBACK(int) dbgcHlpVarToDbgfAddr(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVa switch (pVar->enmType) { case DBGCVAR_TYPE_GC_FLAT: - DBGFR3AddrFromFlat(pDbgc->pVM, pAddress, pVar->u.GCFlat); + DBGFR3AddrFromFlat(pDbgc->pUVM, pAddress, pVar->u.GCFlat); return VINF_SUCCESS; case DBGCVAR_TYPE_NUMBER: - DBGFR3AddrFromFlat(pDbgc->pVM, pAddress, (RTGCUINTPTR)pVar->u.u64Number); + DBGFR3AddrFromFlat(pDbgc->pUVM, pAddress, (RTGCUINTPTR)pVar->u.u64Number); return VINF_SUCCESS; case DBGCVAR_TYPE_GC_FAR: - return DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, pAddress, pVar->u.GCFar.sel, pVar->u.GCFar.off); + return DBGFR3AddrFromSelOff(pDbgc->pUVM, pDbgc->idCpu, pAddress, pVar->u.GCFar.sel, pVar->u.GCFar.off); case DBGCVAR_TYPE_GC_PHYS: - DBGFR3AddrFromPhys(pDbgc->pVM, pAddress, pVar->u.GCPhys); + DBGFR3AddrFromPhys(pDbgc->pUVM, pAddress, pVar->u.GCPhys); return VINF_SUCCESS; case DBGCVAR_TYPE_SYMBOL: @@ -922,7 +941,7 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar DBGFADDRESS Address; int rc; - Assert(pDbgc->pVM); + Assert(pDbgc->pUVM); *pResult = InVar; switch (InVar.enmType) @@ -938,8 +957,8 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar case DBGCVAR_TYPE_GC_PHYS: pResult->enmType = DBGCVAR_TYPE_GC_PHYS; - rc = DBGFR3AddrToPhys(pDbgc->pVM, pDbgc->idCpu, - DBGFR3AddrFromFlat(pDbgc->pVM, &Address, pArg->u.GCFlat), + rc = DBGFR3AddrToPhys(pDbgc->pUVM, pDbgc->idCpu, + DBGFR3AddrFromFlat(pDbgc->pUVM, &Address, pArg->u.GCFlat), &pResult->u.GCPhys); if (RT_SUCCESS(rc)) return VINF_SUCCESS; @@ -947,8 +966,8 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar case DBGCVAR_TYPE_HC_FLAT: pResult->enmType = DBGCVAR_TYPE_HC_FLAT; - rc = DBGFR3AddrToVolatileR3Ptr(pDbgc->pVM, pDbgc->idCpu, - DBGFR3AddrFromFlat(pDbgc->pVM, &Address, pArg->u.GCFlat), + rc = DBGFR3AddrToVolatileR3Ptr(pDbgc->pUVM, pDbgc->idCpu, + DBGFR3AddrFromFlat(pDbgc->pUVM, &Address, pArg->u.GCFlat), false /*fReadOnly */, &pResult->u.pvHCFlat); if (RT_SUCCESS(rc)) @@ -957,8 +976,8 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar case DBGCVAR_TYPE_HC_PHYS: pResult->enmType = DBGCVAR_TYPE_HC_PHYS; - rc = DBGFR3AddrToHostPhys(pDbgc->pVM, pDbgc->idCpu, - DBGFR3AddrFromFlat(pDbgc->pVM, &Address, pArg->u.GCFlat), + rc = DBGFR3AddrToHostPhys(pDbgc->pUVM, pDbgc->idCpu, + DBGFR3AddrFromFlat(pDbgc->pUVM, &Address, pArg->u.GCFlat), &pResult->u.GCPhys); if (RT_SUCCESS(rc)) return VINF_SUCCESS; @@ -983,7 +1002,7 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar switch (enmToType) { case DBGCVAR_TYPE_GC_FLAT: - rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off); + rc = DBGFR3AddrFromSelOff(pDbgc->pUVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off); if (RT_SUCCESS(rc)) { pResult->enmType = DBGCVAR_TYPE_GC_FLAT; @@ -996,22 +1015,22 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar return VINF_SUCCESS; case DBGCVAR_TYPE_GC_PHYS: - rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off); + rc = DBGFR3AddrFromSelOff(pDbgc->pUVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off); if (RT_SUCCESS(rc)) { pResult->enmType = DBGCVAR_TYPE_GC_PHYS; - rc = DBGFR3AddrToPhys(pDbgc->pVM, pDbgc->idCpu, &Address, &pResult->u.GCPhys); + rc = DBGFR3AddrToPhys(pDbgc->pUVM, pDbgc->idCpu, &Address, &pResult->u.GCPhys); if (RT_SUCCESS(rc)) return VINF_SUCCESS; } return VERR_DBGC_PARSE_CONVERSION_FAILED; case DBGCVAR_TYPE_HC_FLAT: - rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off); + rc = DBGFR3AddrFromSelOff(pDbgc->pUVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off); if (RT_SUCCESS(rc)) { pResult->enmType = DBGCVAR_TYPE_HC_FLAT; - rc = DBGFR3AddrToVolatileR3Ptr(pDbgc->pVM, pDbgc->idCpu, &Address, + rc = DBGFR3AddrToVolatileR3Ptr(pDbgc->pUVM, pDbgc->idCpu, &Address, false /*fReadOnly*/, &pResult->u.pvHCFlat); if (RT_SUCCESS(rc)) return VINF_SUCCESS; @@ -1019,11 +1038,11 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar return VERR_DBGC_PARSE_CONVERSION_FAILED; case DBGCVAR_TYPE_HC_PHYS: - rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off); + rc = DBGFR3AddrFromSelOff(pDbgc->pUVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off); if (RT_SUCCESS(rc)) { pResult->enmType = DBGCVAR_TYPE_HC_PHYS; - rc = DBGFR3AddrToHostPhys(pDbgc->pVM, pDbgc->idCpu, &Address, &pResult->u.GCPhys); + rc = DBGFR3AddrToHostPhys(pDbgc->pUVM, pDbgc->idCpu, &Address, &pResult->u.GCPhys); if (RT_SUCCESS(rc)) return VINF_SUCCESS; } @@ -1059,8 +1078,8 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar case DBGCVAR_TYPE_HC_FLAT: pResult->enmType = DBGCVAR_TYPE_HC_FLAT; - rc = DBGFR3AddrToVolatileR3Ptr(pDbgc->pVM, pDbgc->idCpu, - DBGFR3AddrFromPhys(pDbgc->pVM, &Address, pArg->u.GCPhys), + rc = DBGFR3AddrToVolatileR3Ptr(pDbgc->pUVM, pDbgc->idCpu, + DBGFR3AddrFromPhys(pDbgc->pUVM, &Address, pArg->u.GCPhys), false /*fReadOnly */, &pResult->u.pvHCFlat); if (RT_SUCCESS(rc)) @@ -1069,8 +1088,8 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar case DBGCVAR_TYPE_HC_PHYS: pResult->enmType = DBGCVAR_TYPE_HC_PHYS; - rc = DBGFR3AddrToHostPhys(pDbgc->pVM, pDbgc->idCpu, - DBGFR3AddrFromPhys(pDbgc->pVM, &Address, pArg->u.GCPhys), + rc = DBGFR3AddrToHostPhys(pDbgc->pUVM, pDbgc->idCpu, + DBGFR3AddrFromPhys(pDbgc->pUVM, &Address, pArg->u.GCPhys), &pResult->u.HCPhys); if (RT_SUCCESS(rc)) return VINF_SUCCESS; @@ -1102,7 +1121,7 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar case DBGCVAR_TYPE_GC_PHYS: pResult->enmType = DBGCVAR_TYPE_GC_PHYS; - rc = PGMR3DbgR3Ptr2GCPhys(pDbgc->pVM, pArg->u.pvHCFlat, &pResult->u.GCPhys); + rc = PGMR3DbgR3Ptr2GCPhys(pDbgc->pUVM, pArg->u.pvHCFlat, &pResult->u.GCPhys); if (RT_SUCCESS(rc)) return VINF_SUCCESS; /** @todo more memory types! */ @@ -1113,7 +1132,7 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar case DBGCVAR_TYPE_HC_PHYS: pResult->enmType = DBGCVAR_TYPE_HC_PHYS; - rc = PGMR3DbgR3Ptr2HCPhys(pDbgc->pVM, pArg->u.pvHCFlat, &pResult->u.HCPhys); + rc = PGMR3DbgR3Ptr2HCPhys(pDbgc->pUVM, pArg->u.pvHCFlat, &pResult->u.HCPhys); if (RT_SUCCESS(rc)) return VINF_SUCCESS; /** @todo more memory types! */ @@ -1145,7 +1164,7 @@ static DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar case DBGCVAR_TYPE_GC_PHYS: pResult->enmType = DBGCVAR_TYPE_GC_PHYS; - rc = PGMR3DbgHCPhys2GCPhys(pDbgc->pVM, pArg->u.HCPhys, &pResult->u.GCPhys); + rc = PGMR3DbgHCPhys2GCPhys(pDbgc->pUVM, pArg->u.HCPhys, &pResult->u.GCPhys); if (RT_SUCCESS(rc)) return VINF_SUCCESS; return VERR_DBGC_PARSE_CONVERSION_FAILED; @@ -1309,8 +1328,8 @@ static DECLCALLBACK(CPUMMODE) dbgcHlpGetCpuMode(PDBGCCMDHLP pCmdHlp) CPUMMODE enmMode = CPUMMODE_INVALID; if (pDbgc->fRegCtxGuest) { - if (pDbgc->pVM) - enmMode = DBGFR3CpuGetMode(pDbgc->pVM, DBGCCmdHlpGetCurrentCpu(pCmdHlp)); + if (pDbgc->pUVM) + enmMode = DBGFR3CpuGetMode(pDbgc->pUVM, DBGCCmdHlpGetCurrentCpu(pCmdHlp)); if (enmMode == CPUMMODE_INVALID) #if HC_ARCH_BITS == 64 enmMode = CPUMMODE_LONG; @@ -1344,6 +1363,7 @@ void dbgcInitCmdHlp(PDBGC pDbgc) pDbgc->CmdHlp.pfnExec = dbgcHlpExec; pDbgc->CmdHlp.pfnFailV = dbgcHlpFailV; pDbgc->CmdHlp.pfnFailRcV = dbgcHlpFailRcV; + pDbgc->CmdHlp.pfnParserError = dbgcHlpParserError; pDbgc->CmdHlp.pfnVarToDbgfAddr = dbgcHlpVarToDbgfAddr; pDbgc->CmdHlp.pfnVarFromDbgfAddr = dbgcHlpVarFromDbgfAddr; pDbgc->CmdHlp.pfnVarToNumber = dbgcHlpVarToNumber; diff --git a/src/VBox/Debugger/DBGCCommands.cpp b/src/VBox/Debugger/DBGCCommands.cpp index a47b4114..6992c548 100644 --- a/src/VBox/Debugger/DBGCCommands.cpp +++ b/src/VBox/Debugger/DBGCCommands.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2012 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -47,31 +47,32 @@ /******************************************************************************* * Internal Functions * *******************************************************************************/ -static DECLCALLBACK(int) dbgcCmdHelp(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdQuit(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdStop(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdDetect(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdCpu(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdLog(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdLogDest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdLogFlags(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdFormat(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdLoadImage(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdLoadMap(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdLoadSeg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdLoadSyms(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdUnset(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdLoadVars(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdShowVars(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdLoadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdUnloadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdShowPlugIns(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdHarakiri(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdEcho(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdRunScript(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdWriteCore(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); +static FNDBGCCMD dbgcCmdHelp; +static FNDBGCCMD dbgcCmdQuit; +static FNDBGCCMD dbgcCmdStop; +static FNDBGCCMD dbgcCmdDetect; +static FNDBGCCMD dbgcCmdCpu; +static FNDBGCCMD dbgcCmdInfo; +static FNDBGCCMD dbgcCmdLog; +static FNDBGCCMD dbgcCmdLogDest; +static FNDBGCCMD dbgcCmdLogFlags; +static FNDBGCCMD dbgcCmdLogFlush; +static FNDBGCCMD dbgcCmdFormat; +static FNDBGCCMD dbgcCmdLoadImage; +static FNDBGCCMD dbgcCmdLoadMap; +static FNDBGCCMD dbgcCmdLoadSeg; +static FNDBGCCMD dbgcCmdUnload; +static FNDBGCCMD dbgcCmdSet; +static FNDBGCCMD dbgcCmdUnset; +static FNDBGCCMD dbgcCmdLoadVars; +static FNDBGCCMD dbgcCmdShowVars; +static FNDBGCCMD dbgcCmdLoadPlugIn; +static FNDBGCCMD dbgcCmdUnloadPlugIn; +static FNDBGCCMD dbgcCmdShowPlugIns; +static FNDBGCCMD dbgcCmdHarakiri; +static FNDBGCCMD dbgcCmdEcho; +static FNDBGCCMD dbgcCmdRunScript; +static FNDBGCCMD dbgcCmdWriteCore; /******************************************************************************* @@ -157,23 +158,11 @@ static const DBGCVARDESC g_aArgLoadSeg[] = }; -/** loadsyms arguments. */ -static const DBGCVARDESC g_aArgLoadSyms[] = -{ - /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ - { 1, 1, DBGCVAR_CAT_STRING, 0, "path", "Filename string." }, - { 0, 1, DBGCVAR_CAT_NUMBER, 0, "delta", "Delta to add to the loaded symbols. (optional)" }, - { 0, 1, DBGCVAR_CAT_STRING, 0, "module name", "Module name. (optional)" }, - { 0, 1, DBGCVAR_CAT_POINTER, DBGCVD_FLAGS_DEP_PREV, "module address", "Module address. (optional)" }, - { 0, 1, DBGCVAR_CAT_NUMBER, 0, "module size", "The module size. (optional)" }, -}; - - /** log arguments. */ static const DBGCVARDESC g_aArgLog[] = { /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ - { 1, 1, DBGCVAR_CAT_STRING, 0, "groups", "Group modifier string (quote it!)." } + { 0, 1, DBGCVAR_CAT_STRING, 0, "groups", "Group modifier string (quote it!)." } }; @@ -181,7 +170,7 @@ static const DBGCVARDESC g_aArgLog[] = static const DBGCVARDESC g_aArgLogDest[] = { /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ - { 1, 1, DBGCVAR_CAT_STRING, 0, "dests", "Destination modifier string (quote it!)." } + { 0, 1, DBGCVAR_CAT_STRING, 0, "dests", "Destination modifier string (quote it!)." } }; @@ -189,7 +178,7 @@ static const DBGCVARDESC g_aArgLogDest[] = static const DBGCVARDESC g_aArgLogFlags[] = { /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ - { 1, 1, DBGCVAR_CAT_STRING, 0, "flags", "Flag modifier string (quote it!)." } + { 0, 1, DBGCVAR_CAT_STRING, 0, "flags", "Flag modifier string (quote it!)." } }; @@ -209,6 +198,13 @@ static const DBGCVARDESC g_aArgSet[] = { 1, 1, DBGCVAR_CAT_ANY, 0, "value", "Value to assign to the variable." }, }; +/** loadplugin, unloadplugin. */ +static const DBGCVARDESC g_aArgUnload[] = +{ + /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ + { 1, ~0U, DBGCVAR_CAT_STRING, 0, "modname", "Unloads all mappings of the given modules in the active address space." }, +}; + /** 'unset' arguments */ static const DBGCVARDESC g_aArgUnset[] = { @@ -241,6 +237,8 @@ const DBGCCMD g_aDbgcCmds[] = { "loadimage", 2, 3, &g_aArgLoadImage[0], RT_ELEMENTS(g_aArgLoadImage), 0, dbgcCmdLoadImage, "<filename> <address> [name]", "Loads the symbols of an executable image at the specified address. " /*"Optionally giving the module a name other than the file name stem."*/ }, /** @todo implement line breaks */ + { "loadimage32",2, 3, &g_aArgLoadImage[0], RT_ELEMENTS(g_aArgLoadImage), 0, dbgcCmdLoadImage, "<filename> <address> [name]", "loadimage variant for selecting 32-bit images (mach-o)." }, + { "loadimage64",2, 3, &g_aArgLoadImage[0], RT_ELEMENTS(g_aArgLoadImage), 0, dbgcCmdLoadImage, "<filename> <address> [name]", "loadimage variant for selecting 64-bit images (mach-o)." }, { "loadmap", 2, 5, &g_aArgLoadMap[0], RT_ELEMENTS(g_aArgLoadMap), 0, dbgcCmdLoadMap, "<filename> <address> [name] [subtrahend] [seg]", "Loads the symbols from a map file, usually at a specified address. " /*"Optionally giving the module a name other than the file name stem " @@ -249,11 +247,11 @@ const DBGCCMD g_aDbgcCmds[] = { "loadseg", 3, 4, &g_aArgLoadSeg[0], RT_ELEMENTS(g_aArgLoadSeg), 0, dbgcCmdLoadSeg, "<filename> <address> <seg> [name]", "Loads the symbols of a segment in the executable image at the specified address. " /*"Optionally giving the module a name other than the file name stem."*/ }, - { "loadsyms", 1, 5, &g_aArgLoadSyms[0], RT_ELEMENTS(g_aArgLoadSyms), 0, dbgcCmdLoadSyms, "<filename> [delta] [module] [module address]", "Loads symbols from a text file. Optionally giving a delta and a module." }, { "loadvars", 1, 1, &g_aArgFilename[0], RT_ELEMENTS(g_aArgFilename), 0, dbgcCmdLoadVars, "<filename>", "Load variables from file. One per line, same as the args to the set command." }, - { "log", 1, 1, &g_aArgLog[0], RT_ELEMENTS(g_aArgLog), 0, dbgcCmdLog, "<group string>", "Modifies the logging group settings (VBOX_LOG)" }, - { "logdest", 1, 1, &g_aArgLogDest[0], RT_ELEMENTS(g_aArgLogDest), 0, dbgcCmdLogDest, "<dest string>", "Modifies the logging destination (VBOX_LOG_DEST)." }, - { "logflags", 1, 1, &g_aArgLogFlags[0], RT_ELEMENTS(g_aArgLogFlags), 0, dbgcCmdLogFlags, "<flags string>", "Modifies the logging flags (VBOX_LOG_FLAGS)." }, + { "log", 0, 1, &g_aArgLog[0], RT_ELEMENTS(g_aArgLog), 0, dbgcCmdLog, "[group string]", "Displays or modifies the logging group settings (VBOX_LOG)" }, + { "logdest", 0, 1, &g_aArgLogDest[0], RT_ELEMENTS(g_aArgLogDest), 0, dbgcCmdLogDest, "[dest string]", "Displays or modifies the logging destination (VBOX_LOG_DEST)." }, + { "logflags", 0, 1, &g_aArgLogFlags[0], RT_ELEMENTS(g_aArgLogFlags), 0, dbgcCmdLogFlags, "[flags string]", "Displays or modifies the logging flags (VBOX_LOG_FLAGS)." }, + { "logflush", 0, 0, NULL, 0, 0, dbgcCmdLogFlush, "", "Flushes the log buffers." }, { "quit", 0, 0, NULL, 0, 0, dbgcCmdQuit, "", "Exits the debugger." }, { "runscript", 1, 1, &g_aArgFilename[0], RT_ELEMENTS(g_aArgFilename), 0, dbgcCmdRunScript, "<filename>", "Runs the command listed in the script. Lines starting with '#' " "(after removing blanks) are comment. blank lines are ignored. Stops on failure." }, @@ -261,6 +259,7 @@ const DBGCCMD g_aDbgcCmds[] = { "showplugins",0, 0, NULL, 0, 0, dbgcCmdShowPlugIns,"", "List loaded plugins." }, { "showvars", 0, 0, NULL, 0, 0, dbgcCmdShowVars, "", "List all the defined variables." }, { "stop", 0, 0, NULL, 0, 0, dbgcCmdStop, "", "Stop execution." }, + { "unload", 1, ~0U, &g_aArgUnload[0], RT_ELEMENTS(g_aArgUnload), 0, dbgcCmdUnload, "<modname1> [modname2..N]", "Unloads one or more modules in the current address space." }, { "unloadplugin", 1, ~0U, &g_aArgPlugIn[0], RT_ELEMENTS(g_aArgPlugIn), 0, dbgcCmdUnloadPlugIn, "<plugin1> [plugin2..N]", "Unloads one or more plugins." }, { "unset", 1, ~0U, &g_aArgUnset[0], RT_ELEMENTS(g_aArgUnset), 0, dbgcCmdUnset, "<var1> [var1..[varN]]", "Unsets (delete) one or more global variables." }, { "writecore", 1, 1, &g_aArgWriteCore[0], RT_ELEMENTS(g_aArgWriteCore), 0, dbgcCmdWriteCore, "<filename>", "Write core to file." }, @@ -717,16 +716,9 @@ static void dbgcCmdHelpSummary(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp, uint32_t *pcHit /** - * The 'help' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'help' command.} */ -static DECLCALLBACK(int) dbgcCmdHelp(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdHelp(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); int rc = VINF_SUCCESS; @@ -832,26 +824,19 @@ static DECLCALLBACK(int) dbgcCmdHelp(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pV } NOREF(pCmd); - NOREF(pVM); + NOREF(pUVM); return rc; } /** - * The 'quit', 'exit' and 'bye' commands. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'quit', 'exit' and 'bye' commands. } */ -static DECLCALLBACK(int) dbgcCmdQuit(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdQuit(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Quitting console...\n"); + DBGCCmdHlpPrintf(pCmdHlp, "Quitting console...\n"); NOREF(pCmd); - NOREF(pVM); + NOREF(pUVM); NOREF(paArgs); NOREF(cArgs); return VERR_DBGC_QUIT; @@ -859,30 +844,23 @@ static DECLCALLBACK(int) dbgcCmdQuit(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pV /** - * The 'stop' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'stop' command.} */ -static DECLCALLBACK(int) dbgcCmdStop(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdStop(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Check if the VM is halted or not before trying to halt it. */ int rc; - if (DBGFR3IsHalted(pVM)) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "warning: The VM is already halted...\n"); + if (DBGFR3IsHalted(pUVM)) + rc = DBGCCmdHlpPrintf(pCmdHlp, "warning: The VM is already halted...\n"); else { - rc = DBGFR3Halt(pVM); + rc = DBGFR3Halt(pUVM); if (RT_SUCCESS(rc)) rc = VWRN_DBGC_CMD_PENDING; else - rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Executing DBGFR3Halt()."); + rc = DBGCCmdHlpVBoxError(pCmdHlp, rc, "Executing DBGFR3Halt()."); } NOREF(pCmd); NOREF(paArgs); NOREF(cArgs); @@ -891,16 +869,9 @@ static DECLCALLBACK(int) dbgcCmdStop(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pV /** - * The 'echo' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'echo' command.} */ -static DECLCALLBACK(int) dbgcCmdEcho(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdEcho(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Loop thru the arguments and print them with one space between. @@ -909,31 +880,24 @@ static DECLCALLBACK(int) dbgcCmdEcho(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pV for (unsigned i = 0; i < cArgs; i++) { AssertReturn(paArgs[i].enmType == DBGCVAR_TYPE_STRING, VERR_DBGC_PARSE_BUG); - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, i ? " %s" : "%s", paArgs[i].u.pszString); + rc = DBGCCmdHlpPrintf(pCmdHlp, i ? " %s" : "%s", paArgs[i].u.pszString); if (RT_FAILURE(rc)) return rc; } - NOREF(pCmd); NOREF(pVM); - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "\n"); + NOREF(pCmd); NOREF(pUVM); + return DBGCCmdHlpPrintf(pCmdHlp, "\n"); } /** - * The 'runscript' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'runscript' command.} */ -static DECLCALLBACK(int) dbgcCmdRunScript(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdRunScript(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* check that the parser did what it's supposed to do. */ if ( cArgs != 1 || paArgs[0].enmType != DBGCVAR_TYPE_STRING) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "parser error\n"); + return DBGCCmdHlpPrintf(pCmdHlp, "parser error\n"); /** @todo Load the script here, but someone else should do the actual * evaluation and execution of it. */ @@ -944,7 +908,7 @@ static DECLCALLBACK(int) dbgcCmdRunScript(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P const char *pszFilename = paArgs[0].u.pszString; FILE *pFile = fopen(pszFilename, "r"); if (!pFile) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Failed to open '%s'.\n", pszFilename); + return DBGCCmdHlpPrintf(pCmdHlp, "Failed to open '%s'.\n", pszFilename); /* * Execute it line by line. @@ -958,7 +922,7 @@ static DECLCALLBACK(int) dbgcCmdRunScript(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P char *pszEnd = strchr(szLine, '\0'); if (pszEnd == &szLine[sizeof(szLine) - 1]) { - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "runscript error: Line #%u is too long\n", iLine); + rc = DBGCCmdHlpPrintf(pCmdHlp, "runscript error: Line #%u is too long\n", iLine); break; } iLine++; @@ -989,72 +953,58 @@ static DECLCALLBACK(int) dbgcCmdRunScript(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P if (RT_FAILURE(rc)) { if (rc == VERR_BUFFER_OVERFLOW) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "runscript error: Line #%u is too long (exec overflowed)\n", iLine); + rc = DBGCCmdHlpPrintf(pCmdHlp, "runscript error: Line #%u is too long (exec overflowed)\n", iLine); break; } if (rc == VWRN_DBGC_CMD_PENDING) { - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "runscript error: VWRN_DBGC_CMD_PENDING on line #%u, script terminated\n", iLine); + rc = DBGCCmdHlpPrintf(pCmdHlp, "runscript error: VWRN_DBGC_CMD_PENDING on line #%u, script terminated\n", iLine); break; } } fclose(pFile); - NOREF(pCmd); NOREF(pVM); + NOREF(pCmd); NOREF(pUVM); return rc; } /** - * The 'detect' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'detect' command.} */ -static DECLCALLBACK(int) dbgcCmdDetect(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdDetect(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* check that the parser did what it's supposed to do. */ if (cArgs != 0) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "parser error\n"); + return DBGCCmdHlpPrintf(pCmdHlp, "parser error\n"); /* * Perform the detection. */ char szName[64]; - int rc = DBGFR3OSDetect(pVM, szName, sizeof(szName)); + int rc = DBGFR3OSDetect(pUVM, szName, sizeof(szName)); if (RT_FAILURE(rc)) - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Executing DBGFR3OSDetect()."); + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Executing DBGFR3OSDetect().\n"); if (rc == VINF_SUCCESS) { - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Guest OS: %s\n", szName); + rc = DBGCCmdHlpPrintf(pCmdHlp, "Guest OS: %s\n", szName); char szVersion[512]; - int rc2 = DBGFR3OSQueryNameAndVersion(pVM, NULL, 0, szVersion, sizeof(szVersion)); + int rc2 = DBGFR3OSQueryNameAndVersion(pUVM, NULL, 0, szVersion, sizeof(szVersion)); if (RT_SUCCESS(rc2)) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Version : %s\n", szVersion); + rc = DBGCCmdHlpPrintf(pCmdHlp, "Version : %s\n", szVersion); } else - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Unable to figure out which guest OS it is, sorry.\n"); + rc = DBGCCmdHlpPrintf(pCmdHlp, "Unable to figure out which guest OS it is, sorry.\n"); NOREF(pCmd); NOREF(paArgs); return rc; } /** - * The 'cpu' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'cpu' command.} */ -static DECLCALLBACK(int) dbgcCmdCpu(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdCpu(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); @@ -1062,22 +1012,21 @@ static DECLCALLBACK(int) dbgcCmdCpu(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM if ( cArgs != 0 && ( cArgs != 1 || paArgs[0].enmType != DBGCVAR_TYPE_NUMBER)) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "parser error\n"); - if (!pVM) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: No VM.\n"); + return DBGCCmdHlpPrintf(pCmdHlp, "parser error\n"); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); int rc; if (!cArgs) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Current CPU ID: %u\n", pDbgc->idCpu); + rc = DBGCCmdHlpPrintf(pCmdHlp, "Current CPU ID: %u\n", pDbgc->idCpu); else { -/** @todo add a DBGF getter for this. */ - if (paArgs[0].u.u64Number >= pVM->cCpus) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: idCpu %u is out of range! Highest ID is %u.\n", - paArgs[0].u.u64Number, pVM->cCpus); + VMCPUID cCpus = DBGFR3CpuGetCount(pUVM); + if (paArgs[0].u.u64Number >= cCpus) + rc = DBGCCmdHlpPrintf(pCmdHlp, "error: idCpu %u is out of range! Highest ID is %u.\n", + paArgs[0].u.u64Number, cCpus); else { - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Changed CPU from %u to %u.\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "Changed CPU from %u to %u.\n", pDbgc->idCpu, (VMCPUID)paArgs[0].u.u64Number); pDbgc->idCpu = (VMCPUID)paArgs[0].u.u64Number; } @@ -1087,16 +1036,9 @@ static DECLCALLBACK(int) dbgcCmdCpu(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM /** - * The 'info' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'info' command.} */ -static DECLCALLBACK(int) dbgcCmdInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); @@ -1107,19 +1049,18 @@ static DECLCALLBACK(int) dbgcCmdInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pV || cArgs > 2 || paArgs[0].enmType != DBGCVAR_TYPE_STRING || paArgs[cArgs - 1].enmType != DBGCVAR_TYPE_STRING) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "internal error: The parser doesn't do its job properly yet.. quote the string.\n"); - if (!pVM) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: No VM.\n"); + return DBGCCmdHlpPrintf(pCmdHlp, "internal error: The parser doesn't do its job properly yet.. quote the string.\n"); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Dump it. */ - int rc = DBGFR3InfoEx(pVM, pDbgc->idCpu, + int rc = DBGFR3InfoEx(pUVM, pDbgc->idCpu, paArgs[0].u.pszString, cArgs == 2 ? paArgs[1].u.pszString : NULL, DBGCCmdHlpGetDbgfOutputHlp(pCmdHlp)); if (RT_FAILURE(rc)) - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3InfoEx()\n"); + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3InfoEx()\n"); NOREF(pCmd); return 0; @@ -1127,76 +1068,100 @@ static DECLCALLBACK(int) dbgcCmdInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pV /** - * The 'log' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'log' command.} */ -static DECLCALLBACK(int) dbgcCmdLog(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdLog(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - int rc = DBGFR3LogModifyGroups(pVM, paArgs[0].u.pszString); - if (RT_SUCCESS(rc)) - return VINF_SUCCESS; - NOREF(pCmd); NOREF(cArgs); - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3LogModifyGroups(%p,'%s')\n", pVM, paArgs[0].u.pszString); + int rc; + if (cArgs == 0) + { + char szBuf[_64K]; + rc = RTLogGetGroupSettings(NULL, szBuf, sizeof(szBuf)); + if (RT_FAILURE(rc)) + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "RTLogGetDestinations(NULL,,%#zx)\n", sizeof(szBuf)); + DBGCCmdHlpPrintf(pCmdHlp, "VBOX_LOG=%s\n", szBuf); + } + else + { + rc = DBGFR3LogModifyGroups(pUVM, paArgs[0].u.pszString); + if (RT_FAILURE(rc)) + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3LogModifyGroups(%p,'%s')\n", pUVM, paArgs[0].u.pszString); + } + NOREF(pCmd); + return VINF_SUCCESS; } /** - * The 'logdest' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'logdest' command.} */ -static DECLCALLBACK(int) dbgcCmdLogDest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdLogDest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - int rc = DBGFR3LogModifyDestinations(pVM, paArgs[0].u.pszString); - if (RT_SUCCESS(rc)) - return VINF_SUCCESS; - NOREF(pCmd); NOREF(cArgs); - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3LogModifyDestinations(%p,'%s')\n", pVM, paArgs[0].u.pszString); + int rc; + if (cArgs == 0) + { + char szBuf[_16K]; + rc = RTLogGetDestinations(NULL, szBuf, sizeof(szBuf)); + if (RT_FAILURE(rc)) + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "RTLogGetDestinations(NULL,,%#zx)\n", sizeof(szBuf)); + DBGCCmdHlpPrintf(pCmdHlp, "VBOX_LOG_DEST=%s\n", szBuf); + } + else + { + rc = DBGFR3LogModifyDestinations(pUVM, paArgs[0].u.pszString); + if (RT_FAILURE(rc)) + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3LogModifyDestinations(%p,'%s')\n", pUVM, paArgs[0].u.pszString); + } + NOREF(pCmd); + return VINF_SUCCESS; } /** - * The 'logflags' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'logflags' command.} */ -static DECLCALLBACK(int) dbgcCmdLogFlags(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdLogFlags(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - int rc = DBGFR3LogModifyFlags(pVM, paArgs[0].u.pszString); - if (RT_SUCCESS(rc)) - return VINF_SUCCESS; + int rc; + if (cArgs == 0) + { + char szBuf[_16K]; + rc = RTLogGetFlags(NULL, szBuf, sizeof(szBuf)); + if (RT_FAILURE(rc)) + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "RTLogGetFlags(NULL,,%#zx)\n", sizeof(szBuf)); + DBGCCmdHlpPrintf(pCmdHlp, "VBOX_LOG_FLAGS=%s\n", szBuf); + } + else + { + rc = DBGFR3LogModifyFlags(pUVM, paArgs[0].u.pszString); + if (RT_FAILURE(rc)) + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3LogModifyFlags(%p,'%s')\n", pUVM, paArgs[0].u.pszString); + } + + NOREF(pCmd); + return rc; +} + + +/** + * @interface_method_impl{FNDBCCMD, The 'logflush' command.} + */ +static DECLCALLBACK(int) dbgcCmdLogFlush(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) +{ + RTLogFlush(NULL); + PRTLOGGER pLogRel = RTLogRelDefaultInstance(); + if (pLogRel) + RTLogFlush(pLogRel); + NOREF(pCmd); NOREF(cArgs); - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3LogModifyFlags(%p,'%s')\n", pVM, paArgs[0].u.pszString); + return VINF_SUCCESS; } /** - * The 'format' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'format' command.} */ -static DECLCALLBACK(int) dbgcCmdFormat(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdFormat(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { LogFlow(("dbgcCmdFormat\n")); static const char *apszRangeDesc[] = @@ -1210,81 +1175,81 @@ static DECLCALLBACK(int) dbgcCmdFormat(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM switch (paArgs[iArg].enmType) { case DBGCVAR_TYPE_UNKNOWN: - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Unknown variable type!\n"); break; case DBGCVAR_TYPE_GC_FLAT: if (paArgs[iArg].enmRangeType != DBGCVAR_RANGE_NONE) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Guest flat address: %%%08x range %lld %s\n", paArgs[iArg].u.GCFlat, paArgs[iArg].u64Range, apszRangeDesc[paArgs[iArg].enmRangeType]); else - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Guest flat address: %%%08x\n", paArgs[iArg].u.GCFlat); break; case DBGCVAR_TYPE_GC_FAR: if (paArgs[iArg].enmRangeType != DBGCVAR_RANGE_NONE) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Guest far address: %04x:%08x range %lld %s\n", paArgs[iArg].u.GCFar.sel, paArgs[iArg].u.GCFar.off, paArgs[iArg].u64Range, apszRangeDesc[paArgs[iArg].enmRangeType]); else - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Guest far address: %04x:%08x\n", paArgs[iArg].u.GCFar.sel, paArgs[iArg].u.GCFar.off); break; case DBGCVAR_TYPE_GC_PHYS: if (paArgs[iArg].enmRangeType != DBGCVAR_RANGE_NONE) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Guest physical address: %%%%%08x range %lld %s\n", paArgs[iArg].u.GCPhys, paArgs[iArg].u64Range, apszRangeDesc[paArgs[iArg].enmRangeType]); else - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Guest physical address: %%%%%08x\n", paArgs[iArg].u.GCPhys); break; case DBGCVAR_TYPE_HC_FLAT: if (paArgs[iArg].enmRangeType != DBGCVAR_RANGE_NONE) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Host flat address: %%%08x range %lld %s\n", paArgs[iArg].u.pvHCFlat, paArgs[iArg].u64Range, apszRangeDesc[paArgs[iArg].enmRangeType]); else - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Host flat address: %%%08x\n", paArgs[iArg].u.pvHCFlat); break; case DBGCVAR_TYPE_HC_PHYS: if (paArgs[iArg].enmRangeType != DBGCVAR_RANGE_NONE) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Host physical address: %RHp range %lld %s\n", paArgs[iArg].u.HCPhys, paArgs[iArg].u64Range, apszRangeDesc[paArgs[iArg].enmRangeType]); else - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Host physical address: %RHp\n", paArgs[iArg].u.HCPhys); break; case DBGCVAR_TYPE_STRING: - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "String, %lld bytes long: %s\n", paArgs[iArg].u64Range, paArgs[iArg].u.pszString); break; case DBGCVAR_TYPE_SYMBOL: - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Symbol, %lld bytes long: %s\n", paArgs[iArg].u64Range, paArgs[iArg].u.pszString); @@ -1292,7 +1257,7 @@ static DECLCALLBACK(int) dbgcCmdFormat(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM case DBGCVAR_TYPE_NUMBER: if (paArgs[iArg].enmRangeType != DBGCVAR_RANGE_NONE) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Number: hex %llx dec 0i%lld oct 0t%llo range %lld %s\n", paArgs[iArg].u.u64Number, paArgs[iArg].u.u64Number, @@ -1300,7 +1265,7 @@ static DECLCALLBACK(int) dbgcCmdFormat(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM paArgs[iArg].u64Range, apszRangeDesc[paArgs[iArg].enmRangeType]); else - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Number: hex %llx dec 0i%lld oct 0t%llo\n", paArgs[iArg].u.u64Number, paArgs[iArg].u.u64Number, @@ -1308,29 +1273,22 @@ static DECLCALLBACK(int) dbgcCmdFormat(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM break; default: - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, + rc = DBGCCmdHlpPrintf(pCmdHlp, "Invalid argument type %d\n", paArgs[iArg].enmType); break; } } /* arg loop */ - NOREF(pCmd); NOREF(pVM); + NOREF(pCmd); NOREF(pUVM); return 0; } /** - * The 'loadimage' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'loadimage' command.} */ -static DECLCALLBACK(int) dbgcCmdLoadImage(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdLoadImage(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Validate the parsing and make sense of the input. @@ -1347,7 +1305,7 @@ static DECLCALLBACK(int) dbgcCmdLoadImage(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P DBGFADDRESS ModAddress; int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[1], &ModAddress); if (RT_FAILURE(rc)) - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "pfnVarToDbgfAddr: %Dv\n", &paArgs[1]); + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "pfnVarToDbgfAddr: %Dv\n", &paArgs[1]); const char *pszModName = NULL; if (cArgs >= 3) @@ -1357,30 +1315,31 @@ static DECLCALLBACK(int) dbgcCmdLoadImage(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P } /* + * Determine the desired image arch from the load command used. + */ + RTLDRARCH enmArch = RTLDRARCH_WHATEVER; + if (pCmd->pszCmd[sizeof("loadimage") - 1] == '3') + enmArch = RTLDRARCH_X86_32; + else if (pCmd->pszCmd[sizeof("loadimage") - 1] == '6') + enmArch = RTLDRARCH_AMD64; + + /* * Try create a module for it. */ PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); - rc = DBGFR3AsLoadImage(pVM, pDbgc->hDbgAs, pszFilename, pszModName, &ModAddress, NIL_RTDBGSEGIDX, 0 /*fFlags*/); + rc = DBGFR3AsLoadImage(pUVM, pDbgc->hDbgAs, pszFilename, pszModName, enmArch, &ModAddress, NIL_RTDBGSEGIDX, 0 /*fFlags*/); if (RT_FAILURE(rc)) - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3ModuleLoadImage(,,'%s','%s',%Dv,)\n", - pszFilename, pszModName, &paArgs[1]); + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3ModuleLoadImage(,,'%s','%s',%Dv,)\n", + pszFilename, pszModName, &paArgs[1]); - NOREF(pCmd); return VINF_SUCCESS; } /** - * The 'loadmap' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'loadmap' command.} */ -static DECLCALLBACK(int) dbgcCmdLoadMap(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdLoadMap(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Validate the parsing and make sense of the input. @@ -1397,7 +1356,7 @@ static DECLCALLBACK(int) dbgcCmdLoadMap(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM DBGFADDRESS ModAddress; int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[1], &ModAddress); if (RT_FAILURE(rc)) - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "pfnVarToDbgfAddr: %Dv\n", &paArgs[1]); + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "pfnVarToDbgfAddr: %Dv\n", &paArgs[1]); const char *pszModName = NULL; if (cArgs >= 3) @@ -1420,17 +1379,17 @@ static DECLCALLBACK(int) dbgcCmdLoadMap(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM iModSeg = (RTDBGSEGIDX)paArgs[4].u.u64Number; if ( iModSeg != paArgs[4].u.u64Number || iModSeg > RTDBGSEGIDX_LAST) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Segment index out of range: %Dv; range={0..%#x}\n", &paArgs[1], RTDBGSEGIDX_LAST); + return DBGCCmdHlpPrintf(pCmdHlp, "Segment index out of range: %Dv; range={0..%#x}\n", &paArgs[1], RTDBGSEGIDX_LAST); } /* * Try create a module for it. */ PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); - rc = DBGFR3AsLoadMap(pVM, pDbgc->hDbgAs, pszFilename, pszModName, &ModAddress, NIL_RTDBGSEGIDX, uSubtrahend, 0 /*fFlags*/); + rc = DBGFR3AsLoadMap(pUVM, pDbgc->hDbgAs, pszFilename, pszModName, &ModAddress, NIL_RTDBGSEGIDX, uSubtrahend, 0 /*fFlags*/); if (RT_FAILURE(rc)) - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3AsLoadMap(,,'%s','%s',%Dv,)\n", - pszFilename, pszModName, &paArgs[1]); + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3AsLoadMap(,,'%s','%s',%Dv,)\n", + pszFilename, pszModName, &paArgs[1]); NOREF(pCmd); return VINF_SUCCESS; @@ -1438,16 +1397,9 @@ static DECLCALLBACK(int) dbgcCmdLoadMap(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM /** - * The 'loadseg' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'loadseg' command.} */ -static DECLCALLBACK(int) dbgcCmdLoadSeg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdLoadSeg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Validate the parsing and make sense of the input. @@ -1465,12 +1417,12 @@ static DECLCALLBACK(int) dbgcCmdLoadSeg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM DBGFADDRESS ModAddress; int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[1], &ModAddress); if (RT_FAILURE(rc)) - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "pfnVarToDbgfAddr: %Dv\n", &paArgs[1]); + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "pfnVarToDbgfAddr: %Dv\n", &paArgs[1]); RTDBGSEGIDX iModSeg = (RTDBGSEGIDX)paArgs[1].u.u64Number; if ( iModSeg != paArgs[2].u.u64Number || iModSeg > RTDBGSEGIDX_LAST) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Segment index out of range: %Dv; range={0..%#x}\n", &paArgs[1], RTDBGSEGIDX_LAST); + return DBGCCmdHlpPrintf(pCmdHlp, "Segment index out of range: %Dv; range={0..%#x}\n", &paArgs[1], RTDBGSEGIDX_LAST); const char *pszModName = NULL; if (cArgs >= 4) @@ -1483,10 +1435,10 @@ static DECLCALLBACK(int) dbgcCmdLoadSeg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM * Call the debug info manager about this loading. */ PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); - rc = DBGFR3AsLoadImage(pVM, pDbgc->hDbgAs, pszFilename, pszModName, &ModAddress, iModSeg, 0 /*fFlags*/); + rc = DBGFR3AsLoadImage(pUVM, pDbgc->hDbgAs, pszFilename, pszModName, RTLDRARCH_WHATEVER, &ModAddress, iModSeg, 0 /*fFlags*/); if (RT_FAILURE(rc)) - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3ModuleLoadImage(,,'%s','%s',%Dv,)\n", - pszFilename, pszModName, &paArgs[1]); + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3ModuleLoadImage(,,'%s','%s',%Dv,)\n", + pszFilename, pszModName, &paArgs[1]); NOREF(pCmd); return VINF_SUCCESS; @@ -1494,87 +1446,27 @@ static DECLCALLBACK(int) dbgcCmdLoadSeg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM /** - * The 'loadsyms' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'unload' command.} */ -static DECLCALLBACK(int) dbgcCmdLoadSyms(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdUnload(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { + PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); + /* * Validate the parsing and make sense of the input. * This is a mess as usual because we don't trust the parser yet. */ - if ( cArgs < 1 - || paArgs[0].enmType != DBGCVAR_TYPE_STRING) - { - AssertMsgFailed(("Parse error, first argument required to be string!\n")); - return VERR_DBGC_PARSE_INCORRECT_ARG_TYPE; - } - DBGCVAR AddrVar; - RTGCUINTPTR Delta = 0; - const char *pszModule = NULL; - RTGCUINTPTR ModuleAddress = 0; - unsigned cbModule = 0; - if (cArgs > 1) + AssertReturn( cArgs >= 1 + && paArgs[0].enmType == DBGCVAR_TYPE_STRING, + VERR_DBGC_PARSE_INCORRECT_ARG_TYPE); + for (unsigned i = 0; i < cArgs; i++) { - unsigned iArg = 1; - if (paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER) - { - Delta = (RTGCUINTPTR)paArgs[iArg].u.u64Number; - iArg++; - } - if (iArg < cArgs) - { - if (paArgs[iArg].enmType != DBGCVAR_TYPE_STRING) - { - AssertMsgFailed(("Parse error, module argument required to be string!\n")); - return VERR_DBGC_PARSE_INCORRECT_ARG_TYPE; - } - pszModule = paArgs[iArg].u.pszString; - iArg++; - if (iArg < cArgs) - { - if (!DBGCVAR_ISPOINTER(paArgs[iArg].enmType)) - { - AssertMsgFailed(("Parse error, module argument required to be GC pointer!\n")); - return VERR_DBGC_PARSE_INCORRECT_ARG_TYPE; - } - int rc = DBGCCmdHlpEval(pCmdHlp, &AddrVar, "%%(%Dv)", &paArgs[iArg]); - if (RT_FAILURE(rc)) - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Module address cast %%(%Dv) failed.", &paArgs[iArg]); - ModuleAddress = paArgs[iArg].u.GCFlat; - iArg++; - if (iArg < cArgs) - { - if (paArgs[iArg].enmType != DBGCVAR_TYPE_NUMBER) - { - AssertMsgFailed(("Parse error, module argument required to be an integer!\n")); - return VERR_DBGC_PARSE_INCORRECT_ARG_TYPE; - } - cbModule = (unsigned)paArgs[iArg].u.u64Number; - iArg++; - if (iArg < cArgs) - { - AssertMsgFailed(("Parse error, too many arguments!\n")); - return VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS; - } - } - } - } - } + AssertReturn(paArgs[i].enmType == DBGCVAR_TYPE_STRING, VERR_DBGC_PARSE_INCORRECT_ARG_TYPE); - /* - * Call the debug info manager about this loading... - */ - int rc = DBGFR3ModuleLoad(pVM, paArgs[0].u.pszString, Delta, pszModule, ModuleAddress, cbModule); - if (RT_FAILURE(rc)) - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGInfoSymbolLoad(, '%s', %RGv, '%s', %RGv, 0)\n", - paArgs[0].u.pszString, Delta, pszModule, ModuleAddress); + int rc = DBGFR3AsUnlinkModuleByName(pUVM, pDbgc->hDbgAs, paArgs[i].u.pszString); + if (RT_FAILURE(rc)) + return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3AsUnlinkModuleByName(,,'%s')\n", paArgs[i].u.pszString); + } NOREF(pCmd); return VINF_SUCCESS; @@ -1582,16 +1474,9 @@ static DECLCALLBACK(int) dbgcCmdLoadSyms(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV /** - * The 'set' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'set' command.} */ -static DECLCALLBACK(int) dbgcCmdSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); @@ -1606,14 +1491,16 @@ static DECLCALLBACK(int) dbgcCmdSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM */ const char *pszVar = paArgs[0].u.pszString; if (!RT_C_IS_ALPHA(*pszVar) || *pszVar == '_') - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, - "syntax error: Invalid variable name '%s'. Variable names must match regex '[_a-zA-Z][_a-zA-Z0-9*'!", paArgs[0].u.pszString); + return DBGCCmdHlpPrintf(pCmdHlp, + "syntax error: Invalid variable name '%s'. Variable names must match regex '[_a-zA-Z][_a-zA-Z0-9*'!", + paArgs[0].u.pszString); while (RT_C_IS_ALNUM(*pszVar) || *pszVar == '_') *pszVar++; if (*pszVar) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, - "syntax error: Invalid variable name '%s'. Variable names must match regex '[_a-zA-Z][_a-zA-Z0-9*]'!", paArgs[0].u.pszString); + return DBGCCmdHlpPrintf(pCmdHlp, + "syntax error: Invalid variable name '%s'. Variable names must match regex '[_a-zA-Z][_a-zA-Z0-9*]'!", + paArgs[0].u.pszString); /* @@ -1670,22 +1557,15 @@ static DECLCALLBACK(int) dbgcCmdSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM } pDbgc->papVars[pDbgc->cVars++] = pVar; - NOREF(pCmd); NOREF(pVM); NOREF(cArgs); + NOREF(pCmd); NOREF(pUVM); NOREF(cArgs); return 0; } /** - * The 'unset' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'unset' command.} */ -static DECLCALLBACK(int) dbgcCmdUnset(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdUnset(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); for (unsigned i = 0; i < cArgs; i++) @@ -1720,22 +1600,15 @@ static DECLCALLBACK(int) dbgcCmdUnset(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM p } /* lookup */ } /* arg loop */ - NOREF(pCmd); NOREF(pVM); + NOREF(pCmd); NOREF(pUVM); return 0; } /** - * The 'loadvars' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'loadvars' command.} */ -static DECLCALLBACK(int) dbgcCmdLoadVars(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdLoadVars(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Don't trust the parser. @@ -1768,39 +1641,32 @@ static DECLCALLBACK(int) dbgcCmdLoadVars(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV && *psz != '#' && *psz != ';') { - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "dbg: set %s", psz); + DBGCCmdHlpPrintf(pCmdHlp, "dbg: set %s", psz); pCmdHlp->pfnExec(pCmdHlp, "set %s", psz); } } fclose(pFile); } else - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Failed to open file '%s'.\n", paArgs[0].u.pszString); + return DBGCCmdHlpPrintf(pCmdHlp, "Failed to open file '%s'.\n", paArgs[0].u.pszString); - NOREF(pCmd); NOREF(pVM); + NOREF(pCmd); NOREF(pUVM); return 0; } /** - * The 'showvars' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'showvars' command.} */ -static DECLCALLBACK(int) dbgcCmdShowVars(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdShowVars(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); for (unsigned iVar = 0; iVar < pDbgc->cVars; iVar++) { - int rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%-20s ", &pDbgc->papVars[iVar]->szName); + int rc = DBGCCmdHlpPrintf(pCmdHlp, "%-20s ", &pDbgc->papVars[iVar]->szName); if (!rc) - rc = dbgcCmdFormat(pCmd, pCmdHlp, pVM, &pDbgc->papVars[iVar]->Var, 1); + rc = dbgcCmdFormat(pCmd, pCmdHlp, pUVM, &pDbgc->papVars[iVar]->Var, 1); if (rc) return rc; } @@ -2033,7 +1899,7 @@ static int dbgcPlugInLoad(PDBGC pDbgc, const char *pszName, const char *pszPlugI /* * Try initialize it. */ - rc = pPlugIn->pfnEntry(DBGCPLUGINOP_INIT, pDbgc->pVM, VBOX_VERSION); + rc = pPlugIn->pfnEntry(DBGCPLUGINOP_INIT, pDbgc->pUVM, VBOX_VERSION); if (RT_FAILURE(rc)) { RTLdrClose(pPlugIn->hLdrMod); @@ -2108,16 +1974,9 @@ void dbgcPlugInAutoLoad(PDBGC pDbgc) /** - * The 'loadplugin' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'loadplugin' command.} */ -static DECLCALLBACK(int) dbgcCmdLoadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdLoadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); @@ -2164,7 +2023,7 @@ void dbgcPlugInUnloadAll(PDBGC pDbgc) if ( pDbgc->pVM /* prevents trouble during destruction. */ && pDbgc->pVM->enmVMState < VMSTATE_DESTROYING) { - pPlugIn->pfnEntry(DBGCPLUGINOP_TERM, pDbgc->pVM, 0); + pPlugIn->pfnEntry(DBGCPLUGINOP_TERM, pDbgc->pUVM, 0); RTLdrClose(pPlugIn->hLdrMod); } pPlugIn->hLdrMod = NIL_RTLDRMOD; @@ -2175,16 +2034,9 @@ void dbgcPlugInUnloadAll(PDBGC pDbgc) /** - * The 'unload' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'unload' command.} */ -static DECLCALLBACK(int) dbgcCmdUnloadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdUnloadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); @@ -2210,7 +2062,7 @@ static DECLCALLBACK(int) dbgcCmdUnloadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp /* * Terminate and unload it. */ - pPlugIn->pfnEntry(DBGCPLUGINOP_TERM, pDbgc->pVM, 0); + pPlugIn->pfnEntry(DBGCPLUGINOP_TERM, pDbgc->pUVM, 0); RTLdrClose(pPlugIn->hLdrMod); pPlugIn->hLdrMod = NIL_RTLDRMOD; @@ -2227,16 +2079,9 @@ static DECLCALLBACK(int) dbgcCmdUnloadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp /** - * The 'showplugins' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'showplugins' command.} */ -static DECLCALLBACK(int) dbgcCmdShowPlugIns(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdShowPlugIns(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); PDBGCPLUGIN pPlugIn = pDbgc->pPlugInHead; @@ -2257,35 +2102,21 @@ static DECLCALLBACK(int) dbgcCmdShowPlugIns(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, /** - * The 'harakiri' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'harakiri' command.} */ -static DECLCALLBACK(int) dbgcCmdHarakiri(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdHarakiri(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { Log(("dbgcCmdHarakiri\n")); for (;;) exit(126); - NOREF(pCmd); NOREF(pCmdHlp); NOREF(pVM); NOREF(paArgs); NOREF(cArgs); + NOREF(pCmd); NOREF(pCmdHlp); NOREF(pUVM); NOREF(paArgs); NOREF(cArgs); } /** - * The 'writecore' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'writecore' command.} */ -static DECLCALLBACK(int) dbgcCmdWriteCore(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdWriteCore(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { Log(("dbgcCmdWriteCore\n")); @@ -2303,7 +2134,7 @@ static DECLCALLBACK(int) dbgcCmdWriteCore(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P if (!pszDumpPath) return DBGCCmdHlpFail(pCmdHlp, pCmd, "Missing file path.\n"); - int rc = DBGFR3CoreWrite(pVM, pszDumpPath, true /*fReplaceFile*/); + int rc = DBGFR3CoreWrite(pUVM, pszDumpPath, true /*fReplaceFile*/); if (RT_FAILURE(rc)) return DBGCCmdHlpFail(pCmdHlp, pCmd, "DBGFR3WriteCore failed. rc=%Rrc\n", rc); @@ -2315,13 +2146,13 @@ static DECLCALLBACK(int) dbgcCmdWriteCore(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P /** * @callback_method_impl{The randu32() function implementation.} */ -static DECLCALLBACK(int) dbgcFuncRandU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs, +static DECLCALLBACK(int) dbgcFuncRandU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs, PDBGCVAR pResult) { AssertReturn(cArgs == 0, VERR_DBGC_PARSE_BUG); uint32_t u32 = RTRandU32(); DBGCVAR_INIT_NUMBER(pResult, u32); - NOREF(pFunc); NOREF(pCmdHlp); NOREF(pVM); NOREF(paArgs); + NOREF(pFunc); NOREF(pCmdHlp); NOREF(pUVM); NOREF(paArgs); return VINF_SUCCESS; } diff --git a/src/VBox/Debugger/DBGCEmulateCodeView.cpp b/src/VBox/Debugger/DBGCEmulateCodeView.cpp index d970d7ce..d8c6e9a5 100644 --- a/src/VBox/Debugger/DBGCEmulateCodeView.cpp +++ b/src/VBox/Debugger/DBGCEmulateCodeView.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2011 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -43,37 +43,37 @@ /******************************************************************************* * Internal Functions * *******************************************************************************/ -static DECLCALLBACK(int) dbgcCmdBrkAccess(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdBrkClear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdBrkDisable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdBrkEnable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdBrkList(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdDumpDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdDumpPageDir(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdDumpPageDirBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdDumpPageHierarchy(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdDumpPageTableBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdDumpTSS(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdEditMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdGo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdListModules(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdListNear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdMemoryInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdReg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdRegGuest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdRegHyper(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdRegTerse(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdSearchMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdSearchMemType(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdTrace(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); -static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs); +static FNDBGCCMD dbgcCmdBrkAccess; +static FNDBGCCMD dbgcCmdBrkClear; +static FNDBGCCMD dbgcCmdBrkDisable; +static FNDBGCCMD dbgcCmdBrkEnable; +static FNDBGCCMD dbgcCmdBrkList; +static FNDBGCCMD dbgcCmdBrkSet; +static FNDBGCCMD dbgcCmdBrkREM; +static FNDBGCCMD dbgcCmdDumpMem; +static FNDBGCCMD dbgcCmdDumpDT; +static FNDBGCCMD dbgcCmdDumpIDT; +static FNDBGCCMD dbgcCmdDumpPageDir; +static FNDBGCCMD dbgcCmdDumpPageDirBoth; +static FNDBGCCMD dbgcCmdDumpPageHierarchy; +static FNDBGCCMD dbgcCmdDumpPageTable; +static FNDBGCCMD dbgcCmdDumpPageTableBoth; +static FNDBGCCMD dbgcCmdDumpTSS; +static FNDBGCCMD dbgcCmdEditMem; +static FNDBGCCMD dbgcCmdGo; +static FNDBGCCMD dbgcCmdListModules; +static FNDBGCCMD dbgcCmdListNear; +static FNDBGCCMD dbgcCmdListSource; +static FNDBGCCMD dbgcCmdMemoryInfo; +static FNDBGCCMD dbgcCmdReg; +static FNDBGCCMD dbgcCmdRegGuest; +static FNDBGCCMD dbgcCmdRegHyper; +static FNDBGCCMD dbgcCmdRegTerse; +static FNDBGCCMD dbgcCmdSearchMem; +static FNDBGCCMD dbgcCmdSearchMemType; +static FNDBGCCMD dbgcCmdStack; +static FNDBGCCMD dbgcCmdTrace; +static FNDBGCCMD dbgcCmdUnassemble; /******************************************************************************* @@ -247,7 +247,8 @@ static const DBGCVARDESC g_aArgReg[] = { /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ { 0, 1, DBGCVAR_CAT_SYMBOL, 0, "register", "Register to show or set." }, - { 0, 1, DBGCVAR_CAT_NUMBER_NO_RANGE, DBGCVD_FLAGS_DEP_PREV, "value", "New register value." }, + { 0, 1, DBGCVAR_CAT_STRING, DBGCVD_FLAGS_DEP_PREV, "=", "Equal sign." }, + { 0, 1, DBGCVAR_CAT_NUMBER, DBGCVD_FLAGS_DEP_PREV, "value", "New register value." }, }; @@ -341,15 +342,17 @@ const DBGCCMD g_aCmdsCodeView[] = { "kg", 0, 0, NULL, 0, 0, dbgcCmdStack, "", "Callstack - guest." }, { "kh", 0, 0, NULL, 0, 0, dbgcCmdStack, "", "Callstack - hypervisor." }, { "lm", 0, ~0U, &g_aArgListMods[0], RT_ELEMENTS(g_aArgListMods), 0, dbgcCmdListModules, "[module [..]]", "List modules." }, + { "lmv", 0, ~0U, &g_aArgListMods[0], RT_ELEMENTS(g_aArgListMods), 0, dbgcCmdListModules, "[module [..]]", "List modules, verbose." }, { "lmo", 0, ~0U, &g_aArgListMods[0], RT_ELEMENTS(g_aArgListMods), 0, dbgcCmdListModules, "[module [..]]", "List modules and their segments." }, + { "lmov", 0, ~0U, &g_aArgListMods[0], RT_ELEMENTS(g_aArgListMods), 0, dbgcCmdListModules, "[module [..]]", "List modules and their segments, verbose." }, { "ln", 0, ~0U, &g_aArgListNear[0], RT_ELEMENTS(g_aArgListNear), 0, dbgcCmdListNear, "[addr/sym [..]]", "List symbols near to the address. Default address is CS:EIP." }, { "ls", 0, 1, &g_aArgListSource[0],RT_ELEMENTS(g_aArgListSource), 0, dbgcCmdListSource, "[addr]", "Source." }, { "m", 1, 1, &g_aArgMemoryInfo[0],RT_ELEMENTS(g_aArgMemoryInfo), 0, dbgcCmdMemoryInfo, "<addr>", "Display information about that piece of memory." }, - { "r", 0, 2, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), 0, dbgcCmdReg, "[reg [newval]]", "Show or set register(s) - active reg set." }, - { "rg", 0, 2, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), 0, dbgcCmdRegGuest, "[reg [newval]]", "Show or set register(s) - guest reg set." }, + { "r", 0, 3, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), 0, dbgcCmdReg, "[reg [[=] newval]]", "Show or set register(s) - active reg set." }, + { "rg", 0, 3, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), 0, dbgcCmdRegGuest, "[reg [[=] newval]]", "Show or set register(s) - guest reg set." }, { "rg32", 0, 0, NULL, 0, 0, dbgcCmdRegGuest, "", "Show 32-bit guest registers." }, { "rg64", 0, 0, NULL, 0, 0, dbgcCmdRegGuest, "", "Show 64-bit guest registers." }, - { "rh", 0, 2, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), 0, dbgcCmdRegHyper, "[reg [newval]]", "Show or set register(s) - hypervisor reg set." }, + { "rh", 0, 3, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), 0, dbgcCmdRegHyper, "[reg [[=] newval]]", "Show or set register(s) - hypervisor reg set." }, { "rt", 0, 0, NULL, 0, 0, dbgcCmdRegTerse, "", "Toggles terse / verbose register info." }, { "s", 0, ~0U, &g_aArgSearchMem[0], RT_ELEMENTS(g_aArgSearchMem), 0, dbgcCmdSearchMem, "[options] <range> <pattern>", "Continue last search." }, { "sa", 2, ~0U, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType),0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for an ascii string." }, @@ -373,26 +376,19 @@ const uint32_t g_cCmdsCodeView = RT_ELEMENTS(g_aCmdsCodeView); /** - * The 'go' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'go' command.} */ -static DECLCALLBACK(int) dbgcCmdGo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdGo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Check if the VM is halted or not before trying to resume it. */ - if (!DBGFR3IsHalted(pVM)) + if (!DBGFR3IsHalted(pUVM)) return DBGCCmdHlpFail(pCmdHlp, pCmd, "The VM is already running"); - int rc = DBGFR3Resume(pVM); + int rc = DBGFR3Resume(pUVM); if (RT_FAILURE(rc)) return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3Resume"); @@ -402,18 +398,11 @@ static DECLCALLBACK(int) dbgcCmdGo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, /** - * The 'ba' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'ba' command.} */ -static DECLCALLBACK(int) dbgcCmdBrkAccess(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdBrkAccess(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Interpret access type. @@ -485,7 +474,7 @@ static DECLCALLBACK(int) dbgcCmdBrkAccess(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P * Try set the breakpoint. */ uint32_t iBp; - rc = DBGFR3BpSetReg(pVM, &Address, iHitTrigger, iHitDisable, fType, cb, &iBp); + rc = DBGFR3BpSetReg(pUVM, &Address, iHitTrigger, iHitDisable, fType, cb, &iBp); if (RT_SUCCESS(rc)) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); @@ -498,7 +487,7 @@ static DECLCALLBACK(int) dbgcCmdBrkAccess(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P if (RT_SUCCESS(rc)) return DBGCCmdHlpPrintf(pCmdHlp, "Updated access breakpoint %u at %RGv\n", iBp, Address.FlatPtr); } - int rc2 = DBGFR3BpClear(pDbgc->pVM, iBp); + int rc2 = DBGFR3BpClear(pDbgc->pUVM, iBp); AssertRC(rc2); } return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set access breakpoint at %RGv", Address.FlatPtr); @@ -506,18 +495,11 @@ static DECLCALLBACK(int) dbgcCmdBrkAccess(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P /** - * The 'bc' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'bc' command.} */ -static DECLCALLBACK(int) dbgcCmdBrkClear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdBrkClear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Enumerate the arguments. @@ -532,7 +514,7 @@ static DECLCALLBACK(int) dbgcCmdBrkClear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number; if (iBp == paArgs[iArg].u.u64Number) { - int rc2 = DBGFR3BpClear(pVM, iBp); + int rc2 = DBGFR3BpClear(pUVM, iBp); if (RT_FAILURE(rc2)) rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpClear(,%#x)", iBp); if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND) @@ -550,7 +532,7 @@ static DECLCALLBACK(int) dbgcCmdBrkClear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV uint32_t iBp = pBp->iBp; pBp = pBp->pNext; - int rc2 = DBGFR3BpClear(pVM, iBp); + int rc2 = DBGFR3BpClear(pUVM, iBp); if (RT_FAILURE(rc2)) rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpClear(,%#x)", iBp); if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND) @@ -565,16 +547,9 @@ static DECLCALLBACK(int) dbgcCmdBrkClear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV /** - * The 'bd' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'bd' command.} */ -static DECLCALLBACK(int) dbgcCmdBrkDisable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdBrkDisable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Enumerate the arguments. @@ -588,7 +563,7 @@ static DECLCALLBACK(int) dbgcCmdBrkDisable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number; if (iBp == paArgs[iArg].u.u64Number) { - rc = DBGFR3BpDisable(pVM, iBp); + rc = DBGFR3BpDisable(pUVM, iBp); if (RT_FAILURE(rc)) rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpDisable failed for breakpoint %#x", iBp); } @@ -601,7 +576,7 @@ static DECLCALLBACK(int) dbgcCmdBrkDisable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); for (PDBGCBP pBp = pDbgc->pFirstBp; pBp; pBp = pBp->pNext) { - int rc2 = DBGFR3BpDisable(pVM, pBp->iBp); + int rc2 = DBGFR3BpDisable(pUVM, pBp->iBp); if (RT_FAILURE(rc2)) rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpDisable failed for breakpoint %#x", pBp->iBp); } @@ -614,18 +589,11 @@ static DECLCALLBACK(int) dbgcCmdBrkDisable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, /** - * The 'be' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'be' command.} */ -static DECLCALLBACK(int) dbgcCmdBrkEnable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdBrkEnable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Enumerate the arguments. @@ -639,7 +607,7 @@ static DECLCALLBACK(int) dbgcCmdBrkEnable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number; if (iBp == paArgs[iArg].u.u64Number) { - rc = DBGFR3BpEnable(pVM, iBp); + rc = DBGFR3BpEnable(pUVM, iBp); if (RT_FAILURE(rc)) rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpEnable failed for breakpoint %#x", iBp); } @@ -652,7 +620,7 @@ static DECLCALLBACK(int) dbgcCmdBrkEnable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); for (PDBGCBP pBp = pDbgc->pFirstBp; pBp; pBp = pBp->pNext) { - int rc2 = DBGFR3BpEnable(pVM, pBp->iBp); + int rc2 = DBGFR3BpEnable(pUVM, pBp->iBp); if (RT_FAILURE(rc2)) rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpEnable failed for breakpoint %#x", pBp->iBp); } @@ -668,11 +636,11 @@ static DECLCALLBACK(int) dbgcCmdBrkEnable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P * Breakpoint enumeration callback function. * * @returns VBox status code. Any failure will stop the enumeration. - * @param pVM The VM handle. + * @param pUVM The user mode VM handle. * @param pvUser The user argument. * @param pBp Pointer to the breakpoint information. (readonly) */ -static DECLCALLBACK(int) dbgcEnumBreakpointsCallback(PVM pVM, void *pvUser, PCDBGFBP pBp) +static DECLCALLBACK(int) dbgcEnumBreakpointsCallback(PUVM pUVM, void *pvUser, PCDBGFBP pBp) { PDBGC pDbgc = (PDBGC)pvUser; PDBGCBP pDbgcBp = dbgcBpGet(pDbgc, pBp->iBp); @@ -721,7 +689,8 @@ static DECLCALLBACK(int) dbgcEnumBreakpointsCallback(PVM pVM, void *pvUser, PCDB RTDBGSYMBOL Sym; RTINTPTR off; DBGFADDRESS Addr; - int rc = DBGFR3AsSymbolByAddr(pVM, pDbgc->hDbgAs, DBGFR3AddrFromFlat(pVM, &Addr, pBp->GCPtr), &off, &Sym, NULL); + int rc = DBGFR3AsSymbolByAddr(pUVM, pDbgc->hDbgAs, DBGFR3AddrFromFlat(pDbgc->pUVM, &Addr, pBp->GCPtr), + RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, &off, &Sym, NULL); if (RT_SUCCESS(rc)) { if (!off) @@ -729,7 +698,7 @@ static DECLCALLBACK(int) dbgcEnumBreakpointsCallback(PVM pVM, void *pvUser, PCDB else if (off > 0) DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s+%RGv", Sym.szName, off); else - DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s+%RGv", Sym.szName, -off); + DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s-%RGv", Sym.szName, -off); } /* @@ -750,25 +719,19 @@ static DECLCALLBACK(int) dbgcEnumBreakpointsCallback(PVM pVM, void *pvUser, PCDB /** - * The 'bl' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'bl' command.} */ -static DECLCALLBACK(int) dbgcCmdBrkList(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR /*paArgs*/, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdBrkList(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, -1, cArgs == 0); + NOREF(paArgs); /* * Enumerate the breakpoints. */ PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); - int rc = DBGFR3BpEnum(pVM, dbgcEnumBreakpointsCallback, pDbgc); + int rc = DBGFR3BpEnum(pUVM, dbgcEnumBreakpointsCallback, pDbgc); if (RT_FAILURE(rc)) return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpEnum"); return rc; @@ -776,16 +739,9 @@ static DECLCALLBACK(int) dbgcCmdBrkList(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM /** - * The 'bp' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'bp' command.} */ -static DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Convert the pointer to a DBGF address. @@ -822,7 +778,7 @@ static DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM * Try set the breakpoint. */ uint32_t iBp; - rc = DBGFR3BpSet(pVM, &Address, iHitTrigger, iHitDisable, &iBp); + rc = DBGFR3BpSet(pUVM, &Address, iHitTrigger, iHitDisable, &iBp); if (RT_SUCCESS(rc)) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); @@ -835,7 +791,7 @@ static DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM if (RT_SUCCESS(rc)) return DBGCCmdHlpPrintf(pCmdHlp, "Updated breakpoint %u at %RGv\n", iBp, Address.FlatPtr); } - int rc2 = DBGFR3BpClear(pDbgc->pVM, iBp); + int rc2 = DBGFR3BpClear(pDbgc->pUVM, iBp); AssertRC(rc2); } return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set breakpoint at %RGv", Address.FlatPtr); @@ -843,16 +799,9 @@ static DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM /** - * The 'br' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'br' command.} */ -static DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Convert the pointer to a DBGF address. @@ -889,7 +838,7 @@ static DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM * Try set the breakpoint. */ uint32_t iBp; - rc = DBGFR3BpSetREM(pVM, &Address, iHitTrigger, iHitDisable, &iBp); + rc = DBGFR3BpSetREM(pUVM, &Address, iHitTrigger, iHitDisable, &iBp); if (RT_SUCCESS(rc)) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); @@ -902,7 +851,7 @@ static DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM if (RT_SUCCESS(rc)) return DBGCCmdHlpPrintf(pCmdHlp, "Updated REM breakpoint %u at %RGv\n", iBp, Address.FlatPtr); } - int rc2 = DBGFR3BpClear(pDbgc->pVM, iBp); + int rc2 = DBGFR3BpClear(pDbgc->pUVM, iBp); AssertRC(rc2); } return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set REM breakpoint at %RGv", Address.FlatPtr); @@ -910,23 +859,57 @@ static DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM /** - * The 'u' command. + * Helps the unassmble ('u') command display symbols it starts at and passes. * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @param pUVM The user mode VM handle. + * @param pCmdHlp The command helpers for printing via. + * @param hDbgAs The address space to look up addresses in. + * @param pAddress The current address. + * @param pcbCallAgain Where to return the distance to the next check (in + * instruction bytes). + */ +static void dbgcCmdUnassambleHelpListNear(PUVM pUVM, PDBGCCMDHLP pCmdHlp, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, + PRTUINTPTR pcbCallAgain) +{ + RTDBGSYMBOL Symbol; + RTGCINTPTR offDispSym; + int rc = DBGFR3AsSymbolByAddr(pUVM, hDbgAs, pAddress, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, &offDispSym, &Symbol, NULL); + if (RT_FAILURE(rc) || offDispSym > _1G) + rc = DBGFR3AsSymbolByAddr(pUVM, hDbgAs, pAddress, RTDBGSYMADDR_FLAGS_GREATER_OR_EQUAL, &offDispSym, &Symbol, NULL); + if (RT_SUCCESS(rc) && offDispSym < _1G) + { + if (!offDispSym) + { + DBGCCmdHlpPrintf(pCmdHlp, "%s:\n", Symbol.szName); + *pcbCallAgain = Symbol.cb; + } + else if (offDispSym > 0) + { + DBGCCmdHlpPrintf(pCmdHlp, "%s+%#llx:\n", Symbol.szName, (uint64_t)offDispSym); + *pcbCallAgain = Symbol.cb > (RTGCUINTPTR)offDispSym ? Symbol.cb - (RTGCUINTPTR)offDispSym : 1; + } + else + { + DBGCCmdHlpPrintf(pCmdHlp, "%s-%#llx:\n", Symbol.szName, (uint64_t)-offDispSym); + *pcbCallAgain = (RTGCUINTPTR)-offDispSym + Symbol.cb; + } + } + else + *pcbCallAgain = UINT32_MAX; +} + + +/** + * @interface_method_impl{FNDBCCMD, The 'u' command.} */ -static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); /* * Validate input. */ - DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, -1, cArgs <= 1); DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs == 0 || DBGCVAR_ISPOINTER(paArgs[0].enmType)); @@ -936,7 +919,7 @@ static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, /* * Check the desired mode. */ - unsigned fFlags = DBGF_DISAS_FLAGS_NO_ADDRESS; + unsigned fFlags = DBGF_DISAS_FLAGS_NO_ADDRESS | DBGF_DISAS_FLAGS_UNPATCHED_BYTES | DBGF_DISAS_FLAGS_ANNOTATE_PATCHED; switch (pCmd->pszCmd[1]) { default: AssertFailed(); @@ -947,6 +930,8 @@ static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, case 'v': fFlags |= DBGF_DISAS_FLAGS_16BIT_REAL_MODE; break; } + /** @todo should use DBGFADDRESS for everything */ + /* * Find address. */ @@ -954,8 +939,8 @@ static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, { if (!DBGCVAR_ISPOINTER(pDbgc->DisasmPos.enmType)) { - /** @todo Batch query CS, RIP & CPU mode. */ - PVMCPU pVCpu = VMMGetCpuById(pVM, pDbgc->idCpu); + /** @todo Batch query CS, RIP, CPU mode and flags. */ + PVMCPU pVCpu = VMMR3GetCpuByIdU(pUVM, pDbgc->idCpu); if ( pDbgc->fRegCtxGuest && CPUMIsGuestIn64BitCode(pVCpu)) { @@ -967,12 +952,24 @@ static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, pDbgc->DisasmPos.enmType = DBGCVAR_TYPE_GC_FAR; pDbgc->SourcePos.u.GCFar.off = pDbgc->fRegCtxGuest ? CPUMGetGuestEIP(pVCpu) : CPUMGetHyperEIP(pVCpu); pDbgc->SourcePos.u.GCFar.sel = pDbgc->fRegCtxGuest ? CPUMGetGuestCS(pVCpu) : CPUMGetHyperCS(pVCpu); + if ( (fFlags & DBGF_DISAS_FLAGS_MODE_MASK) == DBGF_DISAS_FLAGS_DEFAULT_MODE + && pDbgc->fRegCtxGuest + && (CPUMGetGuestEFlags(pVCpu) & X86_EFL_VM)) + { + fFlags &= ~DBGF_DISAS_FLAGS_MODE_MASK; + fFlags |= DBGF_DISAS_FLAGS_16BIT_REAL_MODE; + } } if (pDbgc->fRegCtxGuest) fFlags |= DBGF_DISAS_FLAGS_CURRENT_GUEST; else - fFlags |= DBGF_DISAS_FLAGS_CURRENT_HYPER; + fFlags |= DBGF_DISAS_FLAGS_CURRENT_HYPER | DBGF_DISAS_FLAGS_HYPER; + } + else if ((fFlags & DBGF_DISAS_FLAGS_MODE_MASK) == DBGF_DISAS_FLAGS_DEFAULT_MODE && pDbgc->fDisasm) + { + fFlags &= ~DBGF_DISAS_FLAGS_MODE_MASK; + fFlags |= pDbgc->fDisasm & (DBGF_DISAS_FLAGS_MODE_MASK | DBGF_DISAS_FLAGS_HYPER); } pDbgc->DisasmPos.enmRangeType = DBGCVAR_RANGE_NONE; } @@ -1007,6 +1004,7 @@ static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, /* * Convert physical and host addresses to guest addresses. */ + RTDBGAS hDbgAs = pDbgc->hDbgAs; int rc; switch (pDbgc->DisasmPos.enmType) { @@ -1014,6 +1012,7 @@ static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, case DBGCVAR_TYPE_GC_FAR: break; case DBGCVAR_TYPE_GC_PHYS: + hDbgAs = DBGF_AS_PHYS; case DBGCVAR_TYPE_HC_FLAT: case DBGCVAR_TYPE_HC_PHYS: { @@ -1027,15 +1026,27 @@ static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, default: AssertFailed(); break; } + DBGFADDRESS CurAddr; + if ( (fFlags & DBGF_DISAS_FLAGS_MODE_MASK) == DBGF_DISAS_FLAGS_16BIT_REAL_MODE + && pDbgc->DisasmPos.enmType == DBGCVAR_TYPE_GC_FAR) + DBGFR3AddrFromFlat(pUVM, &CurAddr, ((uint32_t)pDbgc->DisasmPos.u.GCFar.sel << 4) + pDbgc->DisasmPos.u.GCFar.off); + else + { + rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &pDbgc->DisasmPos, &CurAddr); + if (RT_FAILURE(rc)) + return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr failed on '%Dv'", &pDbgc->DisasmPos); + } + + if (CurAddr.fFlags & DBGFADDRESS_FLAGS_HMA) + fFlags |= DBGF_DISAS_FLAGS_HYPER; /* This crap is due to not using DBGFADDRESS as DBGFR3Disas* input. */ + pDbgc->fDisasm = fFlags; + /* - * Print address. - * todo: Change to list near. + * Figure out where we are and display it. Also calculate when we need to + * check for a new symbol if possible. */ -#if 0 - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%DV:\n", &pDbgc->DisasmPos); - if (RT_FAILURE(rc)) - return rc; -#endif + RTGCUINTPTR cbCheckSymbol; + dbgcCmdUnassambleHelpListNear(pUVM, pCmdHlp, hDbgAs, &CurAddr, &cbCheckSymbol); /* * Do the disassembling. @@ -1052,10 +1063,10 @@ static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, char szDis[256]; uint32_t cbInstr = 1; if (pDbgc->DisasmPos.enmType == DBGCVAR_TYPE_GC_FLAT) - rc = DBGFR3DisasInstrEx(pVM, pDbgc->idCpu, DBGF_SEL_FLAT, pDbgc->DisasmPos.u.GCFlat, fFlags, + rc = DBGFR3DisasInstrEx(pUVM, pDbgc->idCpu, DBGF_SEL_FLAT, pDbgc->DisasmPos.u.GCFlat, fFlags, &szDis[0], sizeof(szDis), &cbInstr); else - rc = DBGFR3DisasInstrEx(pVM, pDbgc->idCpu, pDbgc->DisasmPos.u.GCFar.sel, pDbgc->DisasmPos.u.GCFar.off, fFlags, + rc = DBGFR3DisasInstrEx(pUVM, pDbgc->idCpu, pDbgc->DisasmPos.u.GCFar.sel, pDbgc->DisasmPos.u.GCFar.off, fFlags, &szDis[0], sizeof(szDis), &cbInstr); if (RT_SUCCESS(rc)) { @@ -1067,9 +1078,9 @@ static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, else { /* bitch. */ - rc = DBGCCmdHlpPrintf(pCmdHlp, "Failed to disassemble instruction, skipping one byte.\n"); - if (RT_FAILURE(rc)) - return rc; + int rc2 = DBGCCmdHlpPrintf(pCmdHlp, "Failed to disassemble instruction, skipping one byte.\n"); + if (RT_FAILURE(rc2)) + return rc2; if (cTries-- > 0) return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Too many disassembly failures. Giving up"); cbInstr = 1; @@ -1088,6 +1099,22 @@ static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, if (iRangeLeft <= 0) break; fFlags &= ~(DBGF_DISAS_FLAGS_CURRENT_GUEST | DBGF_DISAS_FLAGS_CURRENT_HYPER); + + /* Print next symbol? */ + if (cbCheckSymbol <= cbInstr) + { + if ( (fFlags & DBGF_DISAS_FLAGS_MODE_MASK) == DBGF_DISAS_FLAGS_16BIT_REAL_MODE + && pDbgc->DisasmPos.enmType == DBGCVAR_TYPE_GC_FAR) + DBGFR3AddrFromFlat(pUVM, &CurAddr, ((uint32_t)pDbgc->DisasmPos.u.GCFar.sel << 4) + pDbgc->DisasmPos.u.GCFar.off); + else + rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &pDbgc->DisasmPos, &CurAddr); + if (RT_SUCCESS(rc)) + dbgcCmdUnassambleHelpListNear(pUVM, pCmdHlp, hDbgAs, &CurAddr, &cbCheckSymbol); + else + cbCheckSymbol = UINT32_MAX; + } + else + cbCheckSymbol -= cbInstr; } NOREF(pCmd); @@ -1096,29 +1123,22 @@ static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, /** - * The 'ls' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'ls' command.} */ -static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); /* * Validate input. */ - if ( cArgs > 1 - || (cArgs == 1 && !DBGCVAR_ISPOINTER(paArgs[0].enmType))) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "internal error: The parser doesn't do its job properly yet.. It might help to use the '%%' operator.\n"); - if (!pVM && !cArgs && !DBGCVAR_ISPOINTER(pDbgc->SourcePos.enmType)) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Don't know where to start disassembling...\n"); - if (!pVM && cArgs && DBGCVAR_ISGCPOINTER(paArgs[0].enmType)) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: GC address but no VM.\n"); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs <= 1); + if (cArgs == 1) + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, DBGCVAR_ISPOINTER(paArgs[0].enmType)); + if (!pUVM && !cArgs && !DBGCVAR_ISPOINTER(pDbgc->SourcePos.enmType)) + return DBGCCmdHlpFail(pCmdHlp, pCmd, "Don't know where to start listing..."); + if (!pUVM && cArgs && DBGCVAR_ISGCPOINTER(paArgs[0].enmType)) + return DBGCCmdHlpFail(pCmdHlp, pCmd, "GC address but no VM"); /* * Find address. @@ -1127,7 +1147,7 @@ static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, { if (!DBGCVAR_ISPOINTER(pDbgc->SourcePos.enmType)) { - PVMCPU pVCpu = VMMGetCpuById(pVM, pDbgc->idCpu); + PVMCPU pVCpu = VMMR3GetCpuByIdU(pUVM, pDbgc->idCpu); pDbgc->SourcePos.enmType = DBGCVAR_TYPE_GC_FAR; pDbgc->SourcePos.u.GCFar.off = pDbgc->fRegCtxGuest ? CPUMGetGuestEIP(pVCpu) : CPUMGetHyperEIP(pVCpu); pDbgc->SourcePos.u.GCFar.sel = pDbgc->fRegCtxGuest ? CPUMGetGuestCS(pVCpu) : CPUMGetHyperCS(pVCpu); @@ -1152,7 +1172,7 @@ static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, { int rc = DBGCCmdHlpEval(pCmdHlp, &pDbgc->SourcePos, "%%(%Dv)", &pDbgc->SourcePos); if (RT_FAILURE(rc)) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid address or address type. (rc=%d)\n", rc); + return DBGCCmdHlpPrintf(pCmdHlp, "error: Invalid address or address type. (rc=%d)\n", rc); break; } default: AssertFailed(); break; @@ -1170,23 +1190,23 @@ static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, case DBGCVAR_RANGE_ELEMENTS: if (pDbgc->SourcePos.u64Range > 2048) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Too many lines requested. Max is 2048 lines.\n"); + return DBGCCmdHlpPrintf(pCmdHlp, "error: Too many lines requested. Max is 2048 lines.\n"); break; case DBGCVAR_RANGE_BYTES: if (pDbgc->SourcePos.u64Range > 65536) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: The requested range is too big. Max is 64KB.\n"); + return DBGCCmdHlpPrintf(pCmdHlp, "error: The requested range is too big. Max is 64KB.\n"); break; default: - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "internal error: Unknown range type %d.\n", pDbgc->SourcePos.enmRangeType); + return DBGCCmdHlpPrintf(pCmdHlp, "internal error: Unknown range type %d.\n", pDbgc->SourcePos.enmRangeType); } /* * Do the disassembling. */ bool fFirst = 1; - DBGFLINE LinePrev = { 0, 0, "" }; + RTDBGLINE LinePrev = { 0, 0, 0, 0, 0, "" }; int iRangeLeft = (int)pDbgc->SourcePos.u64Range; if (iRangeLeft == 0) /* kludge for 'r'. */ iRangeLeft = -1; @@ -1195,9 +1215,13 @@ static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, /* * Get line info. */ - DBGFLINE Line; + RTDBGLINE Line; RTGCINTPTR off; - int rc = DBGFR3LineByAddr(pVM, pDbgc->SourcePos.u.GCFlat, &off, &Line); + DBGFADDRESS SourcePosAddr; + int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &pDbgc->SourcePos, &SourcePosAddr); + if (RT_FAILURE(rc)) + return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,%Dv)", &pDbgc->SourcePos); + rc = DBGFR3AsLineByAddr(pUVM, pDbgc->hDbgAs, &SourcePosAddr, &off, &Line, NULL); if (RT_FAILURE(rc)) return VINF_SUCCESS; @@ -1211,7 +1235,7 @@ static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, fFirst = true; if (fFirst) { - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "[%s @ %d]\n", Line.szFilename, Line.uLineNo); + rc = DBGCCmdHlpPrintf(pCmdHlp, "[%s @ %d]\n", Line.szFilename, Line.uLineNo); if (RT_FAILURE(rc)) return rc; } @@ -1246,13 +1270,13 @@ static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, if (cBefore-- <= 0) break; - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " %4d: %s\n", Line.uLineNo - cBefore - 1, szLine); + rc = DBGCCmdHlpPrintf(pCmdHlp, " %4d: %s\n", Line.uLineNo - cBefore - 1, szLine); szLine[0] = '\0'; fgets(szLine, sizeof(szLine), phFile); cLines++; } /* print the actual line */ - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%08llx %4d: %s\n", Line.Address, Line.uLineNo, szLine); + rc = DBGCCmdHlpPrintf(pCmdHlp, "%08llx %4d: %s\n", Line.Address, Line.uLineNo, szLine); } fclose(phFile); if (RT_FAILURE(rc)) @@ -1260,7 +1284,7 @@ static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, fFirst = false; } else - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Warning: couldn't open source file '%s'\n", Line.szFilename); + return DBGCCmdHlpPrintf(pCmdHlp, "Warning: couldn't open source file '%s'\n", Line.szFilename); LinePrev = Line; } @@ -1288,43 +1312,28 @@ static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, /** - * The 'r' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'r' command.} */ -static DECLCALLBACK(int) dbgcCmdReg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdReg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); if (!pDbgc->fRegCtxGuest) - return dbgcCmdRegHyper(pCmd, pCmdHlp, pVM, paArgs, cArgs); - return dbgcCmdRegGuest(pCmd, pCmdHlp, pVM, paArgs, cArgs); + return dbgcCmdRegHyper(pCmd, pCmdHlp, pUVM, paArgs, cArgs); + return dbgcCmdRegGuest(pCmd, pCmdHlp, pUVM, paArgs, cArgs); } /** - * Common worker for the dbgcCmdReg*() commands. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. - * @param pszPrefix The symbol prefix. + * @interface_method_impl{FNDBCCMD, Common worker for the dbgcCmdReg*() + * commands.} */ -static DECLCALLBACK(int) dbgcCmdRegCommon(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, +static DECLCALLBACK(int) dbgcCmdRegCommon(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs, const char *pszPrefix) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); - Assert(cArgs == 1 || cArgs == 2); /* cArgs == 0 is handled by the caller */ - if ( paArgs[0].enmType != DBGCVAR_TYPE_STRING - && paArgs[0].enmType != DBGCVAR_TYPE_SYMBOL) - return DBGCCmdHlpPrintf(pCmdHlp, "internal error: The parser doesn't do its job properly yet.. Try drop the '@' or/and quote the register name\n"); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs == 1 || cArgs == 2 || cArgs == 3); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[0].enmType == DBGCVAR_TYPE_STRING + || paArgs[0].enmType == DBGCVAR_TYPE_SYMBOL); /* * Parse the register name and kind. @@ -1347,7 +1356,7 @@ static DECLCALLBACK(int) dbgcCmdRegCommon(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P */ DBGFREGVALTYPE enmType; DBGFREGVAL Value; - int rc = DBGFR3RegNmQuery(pVM, idCpu, pszReg, &Value, &enmType); + int rc = DBGFR3RegNmQuery(pUVM, idCpu, pszReg, &Value, &enmType); if (RT_FAILURE(rc)) { if (rc == VERR_DBGF_REGISTER_NOT_FOUND) @@ -1368,56 +1377,65 @@ static DECLCALLBACK(int) dbgcCmdRegCommon(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P else rc = DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3RegFormatValue failed: %Rrc.\n", rc); } - else if (cArgs == 2) + else { + DBGCVAR NewValueTmp; + PCDBGCVAR pNewValue; + if (cArgs == 3) + { + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 1, paArgs[1].enmType == DBGCVAR_TYPE_STRING); + if (strcmp(paArgs[1].u.pszString, "=")) + return DBGCCmdHlpFail(pCmdHlp, pCmd, "Second argument must be '='."); + pNewValue = &paArgs[2]; + } + else + { + /* Not possible to convince the parser to support both codeview and + windbg syntax and make the equal sign optional. Try help it. */ + /** @todo make DBGCCmdHlpConvert do more with strings. */ + rc = DBGCCmdHlpConvert(pCmdHlp, &paArgs[1], DBGCVAR_TYPE_NUMBER, true /*fConvSyms*/, &NewValueTmp); + if (RT_FAILURE(rc)) + return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "The last argument must be a value or valid symbol."); + pNewValue = &NewValueTmp; + } + /* * Modify the register. */ - if ( paArgs[1].enmType == DBGCVAR_TYPE_STRING - || paArgs[1].enmType == DBGCVAR_TYPE_SYMBOL) - return DBGCCmdHlpPrintf(pCmdHlp, "internal error: The parser doesn't do its job properly on the 2nd argument yet...\n"); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 1, pNewValue->enmType == DBGCVAR_TYPE_NUMBER); if (enmType != DBGFREGVALTYPE_DTR) { enmType = DBGFREGVALTYPE_U64; - rc = DBGCCmdHlpVarToNumber(pCmdHlp, &paArgs[1], &Value.u64); + rc = DBGCCmdHlpVarToNumber(pCmdHlp, pNewValue, &Value.u64); } else { enmType = DBGFREGVALTYPE_DTR; - rc = DBGCCmdHlpVarToNumber(pCmdHlp, &paArgs[1], &Value.dtr.u64Base); - if (RT_SUCCESS(rc) && paArgs[1].enmRangeType != DBGCVAR_RANGE_NONE) - Value.dtr.u32Limit = (uint32_t)paArgs[1].u64Range; + rc = DBGCCmdHlpVarToNumber(pCmdHlp, pNewValue, &Value.dtr.u64Base); + if (RT_SUCCESS(rc) && pNewValue->enmRangeType != DBGCVAR_RANGE_NONE) + Value.dtr.u32Limit = (uint32_t)pNewValue->u64Range; } if (RT_SUCCESS(rc)) { - rc = DBGFR3RegNmSet(pVM, idCpu, pszReg, &Value, enmType); + rc = DBGFR3RegNmSet(pUVM, idCpu, pszReg, &Value, enmType); if (RT_FAILURE(rc)) rc = DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3RegNmSet failed settings '%s%s': %Rrc\n", pszActualPrefix, pszReg, rc); + if (rc != VINF_SUCCESS) + DBGCCmdHlpPrintf(pCmdHlp, "%s: warning: %Rrc\n", pCmd->pszCmd, rc); } else rc = DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3RegFormatValue failed: %Rrc.\n", rc); } - else - { - NOREF(pCmd); NOREF(paArgs); - rc = DBGCCmdHlpPrintf(pCmdHlp, "Huh? cArgs=%d Expected 0, 1 or 2!\n", cArgs); - } return rc; } /** - * The 'rg', 'rg64' and 'rg32' commands. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, + * The 'rg', 'rg64' and 'rg32' commands, worker for 'r'.} */ -static DECLCALLBACK(int) dbgcCmdRegGuest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdRegGuest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Show all registers our selves. @@ -1426,15 +1444,15 @@ static DECLCALLBACK(int) dbgcCmdRegGuest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); bool const f64BitMode = !strcmp(pCmd->pszCmd, "rg64") - || ( !strcmp(pCmd->pszCmd, "rg32") - && CPUMIsGuestIn64BitCode(VMMGetCpuById(pVM, pDbgc->idCpu))); + || ( strcmp(pCmd->pszCmd, "rg32") != 0 + && DBGFR3CpuIsIn64BitCode(pUVM, pDbgc->idCpu)); char szDisAndRegs[8192]; int rc; if (pDbgc->fRegTerse) { if (f64BitMode) - rc = DBGFR3RegPrintf(pVM, pDbgc->idCpu, &szDisAndRegs[0], sizeof(szDisAndRegs), + rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu, &szDisAndRegs[0], sizeof(szDisAndRegs), "u %016VR{rip} L 0\n" "rax=%016VR{rax} rbx=%016VR{rbx} rcx=%016VR{rcx} rdx=%016VR{rdx}\n" "rsi=%016VR{rsi} rdi=%016VR{rdi} r8 =%016VR{r8} r9 =%016VR{r9}\n" @@ -1443,7 +1461,7 @@ static DECLCALLBACK(int) dbgcCmdRegGuest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV "rip=%016VR{rip} rsp=%016VR{rsp} rbp=%016VR{rbp}\n" "cs=%04VR{cs} ds=%04VR{ds} es=%04VR{es} fs=%04VR{fs} gs=%04VR{gs} ss=%04VR{ss} rflags=%08VR{rflags}\n"); else - rc = DBGFR3RegPrintf(pVM, pDbgc->idCpu, szDisAndRegs, sizeof(szDisAndRegs), + rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu, szDisAndRegs, sizeof(szDisAndRegs), "u %04VR{cs}:%08VR{eip} L 0\n" "eax=%08VR{eax} ebx=%08VR{ebx} ecx=%08VR{ecx} edx=%08VR{edx} esi=%08VR{esi} edi=%08VR{edi}\n" "eip=%08VR{eip} esp=%08VR{esp} ebp=%08VR{ebp} %VRF{eflags}\n" @@ -1452,7 +1470,7 @@ static DECLCALLBACK(int) dbgcCmdRegGuest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV else { if (f64BitMode) - rc = DBGFR3RegPrintf(pVM, pDbgc->idCpu, &szDisAndRegs[0], sizeof(szDisAndRegs), + rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu, &szDisAndRegs[0], sizeof(szDisAndRegs), "u %016VR{rip} L 0\n" "rax=%016VR{rax} rbx=%016VR{rbx} rcx=%016VR{rcx} rdx=%016VR{rdx}\n" "rsi=%016VR{rsi} rdi=%016VR{rdi} r8 =%016VR{r8} r9 =%016VR{r9}\n" @@ -1480,7 +1498,7 @@ static DECLCALLBACK(int) dbgcCmdRegGuest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV "fcw=%04VR{fcw} fsw=%04VR{fsw} ftw=%04VR{ftw} mxcsr=%04VR{mxcsr} mxcsr_mask=%04VR{mxcsr_mask}\n" ); else - rc = DBGFR3RegPrintf(pVM, pDbgc->idCpu, szDisAndRegs, sizeof(szDisAndRegs), + rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu, szDisAndRegs, sizeof(szDisAndRegs), "u %04VR{cs}:%08VR{eip} L 0\n" "eax=%08VR{eax} ebx=%08VR{ebx} ecx=%08VR{ecx} edx=%08VR{edx} esi=%08VR{esi} edi=%08VR{edi}\n" "eip=%08VR{eip} esp=%08VR{esp} ebp=%08VR{ebp} %VRF{eflags}\n" @@ -1506,23 +1524,18 @@ static DECLCALLBACK(int) dbgcCmdRegGuest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV /* * Disassemble one instruction at cs:[r|e]ip. */ + if (!f64BitMode && strstr(pszRegs, " vm ")) /* a big ugly... */ + return pCmdHlp->pfnExec(pCmdHlp, "uv86 %s", szDisAndRegs + 2); return pCmdHlp->pfnExec(pCmdHlp, "%s", szDisAndRegs); } - return dbgcCmdRegCommon(pCmd, pCmdHlp, pVM, paArgs, cArgs, ""); + return dbgcCmdRegCommon(pCmd, pCmdHlp, pUVM, paArgs, cArgs, ""); } /** - * The 'rh' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'rh' command.} */ -static DECLCALLBACK(int) dbgcCmdRegHyper(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdRegHyper(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Show all registers our selves. @@ -1534,13 +1547,13 @@ static DECLCALLBACK(int) dbgcCmdRegHyper(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV int rc; if (pDbgc->fRegTerse) - rc = DBGFR3RegPrintf(pVM, pDbgc->idCpu | DBGFREG_HYPER_VMCPUID, szDisAndRegs, sizeof(szDisAndRegs), + rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu | DBGFREG_HYPER_VMCPUID, szDisAndRegs, sizeof(szDisAndRegs), "u %VR{cs}:%VR{eip} L 0\n" ".eax=%08VR{eax} .ebx=%08VR{ebx} .ecx=%08VR{ecx} .edx=%08VR{edx} .esi=%08VR{esi} .edi=%08VR{edi}\n" ".eip=%08VR{eip} .esp=%08VR{esp} .ebp=%08VR{ebp} .%VRF{eflags}\n" ".cs=%04VR{cs} .ds=%04VR{ds} .es=%04VR{es} .fs=%04VR{fs} .gs=%04VR{gs} .ss=%04VR{ss} .eflags=%08VR{eflags}\n"); else - rc = DBGFR3RegPrintf(pVM, pDbgc->idCpu | DBGFREG_HYPER_VMCPUID, szDisAndRegs, sizeof(szDisAndRegs), + rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu | DBGFREG_HYPER_VMCPUID, szDisAndRegs, sizeof(szDisAndRegs), "u %04VR{cs}:%08VR{eip} L 0\n" ".eax=%08VR{eax} .ebx=%08VR{ebx} .ecx=%08VR{ecx} .edx=%08VR{edx} .esi=%08VR{esi} .edi=%08VR{edi}\n" ".eip=%08VR{eip} .esp=%08VR{esp} .ebp=%08VR{ebp} .%VRF{eflags}\n" @@ -1565,45 +1578,31 @@ static DECLCALLBACK(int) dbgcCmdRegHyper(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV */ return pCmdHlp->pfnExec(pCmdHlp, "%s", szDisAndRegs); } - return dbgcCmdRegCommon(pCmd, pCmdHlp, pVM, paArgs, cArgs, "."); + return dbgcCmdRegCommon(pCmd, pCmdHlp, pUVM, paArgs, cArgs, "."); } /** - * The 'rt' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'rt' command.} */ -static DECLCALLBACK(int) dbgcCmdRegTerse(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdRegTerse(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - NOREF(pCmd); NOREF(pVM); NOREF(paArgs); NOREF(cArgs); + NOREF(pCmd); NOREF(pUVM); NOREF(paArgs); NOREF(cArgs); PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); pDbgc->fRegTerse = !pDbgc->fRegTerse; - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, pDbgc->fRegTerse ? "info: Terse register info.\n" : "info: Verbose register info.\n"); + return DBGCCmdHlpPrintf(pCmdHlp, pDbgc->fRegTerse ? "info: Terse register info.\n" : "info: Verbose register info.\n"); } /** - * The 't' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 't' command.} */ -static DECLCALLBACK(int) dbgcCmdTrace(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdTrace(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); - int rc = DBGFR3Step(pVM, pDbgc->idCpu); + int rc = DBGFR3Step(pUVM, pDbgc->idCpu); if (RT_SUCCESS(rc)) pDbgc->fReady = false; else @@ -1615,16 +1614,9 @@ static DECLCALLBACK(int) dbgcCmdTrace(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM p /** - * The 'k', 'kg' and 'kh' commands. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'k', 'kg' and 'kh' commands.} */ -static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); @@ -1635,9 +1627,9 @@ static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM p PCDBGFSTACKFRAME pFirstFrame; bool const fGuest = pCmd->pszCmd[1] == 'g' || (!pCmd->pszCmd[1] && pDbgc->fRegCtxGuest); - rc = DBGFR3StackWalkBegin(pVM, pDbgc->idCpu, fGuest ? DBGFCODETYPE_GUEST : DBGFCODETYPE_HYPER, &pFirstFrame); + rc = DBGFR3StackWalkBegin(pUVM, pDbgc->idCpu, fGuest ? DBGFCODETYPE_GUEST : DBGFCODETYPE_HYPER, &pFirstFrame); if (RT_FAILURE(rc)) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Failed to begin stack walk, rc=%Rrc\n", rc); + return DBGCCmdHlpPrintf(pCmdHlp, "Failed to begin stack walk, rc=%Rrc\n", rc); /* * Print header. @@ -1653,7 +1645,7 @@ static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM p { if (fCurBitFlags != fBitFlags) pCmdHlp->pfnPrintf(pCmdHlp, NULL, "SS:BP Ret SS:BP Ret CS:EIP Arg0 Arg1 Arg2 Arg3 CS:EIP / Symbol [line]\n"); - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04RX16:%04RX16 %04RX16:%04RX16 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04RX16:%04RX16 %04RX16:%04RX16 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32", pFrame->AddrFrame.Sel, (uint16_t)pFrame->AddrFrame.off, pFrame->AddrReturnFrame.Sel, @@ -1669,7 +1661,7 @@ static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM p { if (fCurBitFlags != fBitFlags) pCmdHlp->pfnPrintf(pCmdHlp, NULL, "EBP Ret EBP Ret CS:EIP Arg0 Arg1 Arg2 Arg3 CS:EIP / Symbol [line]\n"); - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%08RX32 %08RX32 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%08RX32 %08RX32 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32", (uint32_t)pFrame->AddrFrame.off, (uint32_t)pFrame->AddrReturnFrame.off, (uint32_t)pFrame->AddrReturnPC.Sel, @@ -1683,7 +1675,7 @@ static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM p { if (fCurBitFlags != fBitFlags) pCmdHlp->pfnPrintf(pCmdHlp, NULL, "RBP Ret SS:RBP Ret RIP CS:RIP / Symbol [line]\n"); - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%016RX64 %04RX16:%016RX64 %016RX64", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%016RX64 %04RX16:%016RX64 %016RX64", (uint64_t)pFrame->AddrFrame.off, pFrame->AddrReturnFrame.Sel, (uint64_t)pFrame->AddrReturnFrame.off, @@ -1695,7 +1687,7 @@ static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM p rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, fCurBitFlags & DBGFSTACKFRAME_FLAGS_64BIT ? " %RTsel:%016RGv" - : fCurBitFlags & DBGFSTACKFRAME_FLAGS_64BIT + : fCurBitFlags & DBGFSTACKFRAME_FLAGS_32BIT ? " %RTsel:%08RGv" : " %RTsel:%04RGv" , pFrame->AddrPC.Sel, pFrame->AddrPC.off); @@ -1703,16 +1695,16 @@ static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM p { RTGCINTPTR offDisp = pFrame->AddrPC.FlatPtr - pFrame->pSymPC->Value; /** @todo this isn't 100% correct for segmented stuff. */ if (offDisp > 0) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " %s+%llx", pFrame->pSymPC->szName, (int64_t)offDisp); + rc = DBGCCmdHlpPrintf(pCmdHlp, " %s+%llx", pFrame->pSymPC->szName, (int64_t)offDisp); else if (offDisp < 0) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " %s-%llx", pFrame->pSymPC->szName, -(int64_t)offDisp); + rc = DBGCCmdHlpPrintf(pCmdHlp, " %s-%llx", pFrame->pSymPC->szName, -(int64_t)offDisp); else - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " %s", pFrame->pSymPC->szName); + rc = DBGCCmdHlpPrintf(pCmdHlp, " %s", pFrame->pSymPC->szName); } if (RT_SUCCESS(rc) && pFrame->pLinePC) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " [%s @ 0i%d]", pFrame->pLinePC->szFilename, pFrame->pLinePC->uLineNo); + rc = DBGCCmdHlpPrintf(pCmdHlp, " [%s @ 0i%d]", pFrame->pLinePC->szFilename, pFrame->pLinePC->uLineNo); if (RT_SUCCESS(rc)) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "\n"); + rc = DBGCCmdHlpPrintf(pCmdHlp, "\n"); if (RT_FAILURE(rc)) break; @@ -1760,7 +1752,7 @@ static int dbgcCmdDumpDTWorker64(PDBGCCMDHLP pCmdHlp, PCX86DESC64 pDesc, unsigne uint32_t u32Base = X86DESC_BASE(pDesc); uint32_t cbLimit = X86DESC_LIMIT_G(pDesc); - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d L=%d%s\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d L=%d%s\n", iEntry, s_apszTypes[pDesc->Gen.u4Type], u32Base, cbLimit, pDesc->Gen.u2Dpl, pszPresent, pszAccessed, pszGranularity, pszBig, pDesc->Gen.u1Available, pDesc->Gen.u1Long, pszHyper); @@ -1799,7 +1791,7 @@ static int dbgcCmdDumpDTWorker64(PDBGCCMDHLP pCmdHlp, PCX86DESC64 pDesc, unsigne case X86_SEL_TYPE_SYS_286_INT_GATE: case X86_SEL_TYPE_SYS_286_TRAP_GATE: case X86_SEL_TYPE_SYS_TASK_GATE: - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s %.8Rhxs DPL=%d %s%s\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s %.8Rhxs DPL=%d %s%s\n", iEntry, s_apszTypes[pDesc->Gen.u4Type], pDesc, pDesc->Gen.u2Dpl, pszPresent, pszHyper); break; @@ -1812,11 +1804,11 @@ static int dbgcCmdDumpDTWorker64(PDBGCCMDHLP pCmdHlp, PCX86DESC64 pDesc, unsigne const char *pszBig = pDesc->Gen.u1DefBig ? "BIG" : " "; const char *pszLong = pDesc->Gen.u1Long ? "LONG" : " "; - uint64_t u32Base = X86DESC64_BASE(pDesc); + uint64_t u64Base = X86DESC64_BASE(pDesc); uint32_t cbLimit = X86DESC_LIMIT_G(pDesc); - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Bas=%016RX64 Lim=%08x DPL=%d %s %s %s %sAVL=%d R=%d%s\n", - iEntry, s_apszTypes[pDesc->Gen.u4Type], u32Base, cbLimit, + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Bas=%016RX64 Lim=%08x DPL=%d %s %s %s %sAVL=%d R=%d%s\n", + iEntry, s_apszTypes[pDesc->Gen.u4Type], u64Base, cbLimit, pDesc->Gen.u2Dpl, pszPresent, pszBusy, pszLong, pszBig, pDesc->Gen.u1Available, pDesc->Gen.u1Long | (pDesc->Gen.u1DefBig << 1), pszHyper); @@ -1833,7 +1825,7 @@ static int dbgcCmdDumpDTWorker64(PDBGCCMDHLP pCmdHlp, PCX86DESC64 pDesc, unsigne uint64_t off = pDesc->au16[0] | ((uint64_t)pDesc->au16[3] << 16) | ((uint64_t)pDesc->Gen.u32BaseHigh3 << 32); - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Sel:Off=%04x:%016RX64 DPL=%d %s %s=%d%s\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Sel:Off=%04x:%016RX64 DPL=%d %s %s=%d%s\n", iEntry, s_apszTypes[pDesc->Gen.u4Type], sel, off, pDesc->Gen.u2Dpl, pszPresent, pszCountOf, cParams, pszHyper); if (pfDblEntry) @@ -1848,7 +1840,7 @@ static int dbgcCmdDumpDTWorker64(PDBGCCMDHLP pCmdHlp, PCX86DESC64 pDesc, unsigne uint64_t off = pDesc->au16[0] | ((uint64_t)pDesc->au16[3] << 16) | ((uint64_t)pDesc->Gen.u32BaseHigh3 << 32); - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Sel:Off=%04x:%016RX64 DPL=%d %s%s\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Sel:Off=%04x:%016RX64 DPL=%d %s%s\n", iEntry, s_apszTypes[pDesc->Gen.u4Type], sel, off, pDesc->Gen.u2Dpl, pszPresent, pszHyper); if (pfDblEntry) @@ -1911,7 +1903,7 @@ static int dbgcCmdDumpDTWorker32(PDBGCCMDHLP pCmdHlp, PCX86DESC pDesc, unsigned if (pDesc->Gen.u1Granularity) cbLimit <<= PAGE_SHIFT; - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d L=%d%s\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d L=%d%s\n", iEntry, s_apszTypes[pDesc->Gen.u4Type], u32Base, cbLimit, pDesc->Gen.u2Dpl, pszPresent, pszAccessed, pszGranularity, pszBig, pDesc->Gen.u1Available, pDesc->Gen.u1Long, pszHyper); @@ -1944,7 +1936,7 @@ static int dbgcCmdDumpDTWorker32(PDBGCCMDHLP pCmdHlp, PCX86DESC pDesc, unsigned case X86_SEL_TYPE_SYS_UNDEFINED2: case X86_SEL_TYPE_SYS_UNDEFINED4: case X86_SEL_TYPE_SYS_UNDEFINED3: - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s %.8Rhxs DPL=%d %s%s\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s %.8Rhxs DPL=%d %s%s\n", iEntry, s_apszTypes[pDesc->Gen.u4Type], pDesc, pDesc->Gen.u2Dpl, pszPresent, pszHyper); break; @@ -1965,7 +1957,7 @@ static int dbgcCmdDumpDTWorker32(PDBGCCMDHLP pCmdHlp, PCX86DESC pDesc, unsigned if (pDesc->Gen.u1Granularity) cbLimit <<= PAGE_SHIFT; - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d R=%d%s\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d R=%d%s\n", iEntry, s_apszTypes[pDesc->Gen.u4Type], u32Base, cbLimit, pDesc->Gen.u2Dpl, pszPresent, pszBusy, pszGranularity, pszBig, pDesc->Gen.u1Available, pDesc->Gen.u1Long | (pDesc->Gen.u1DefBig << 1), @@ -1975,7 +1967,7 @@ static int dbgcCmdDumpDTWorker32(PDBGCCMDHLP pCmdHlp, PCX86DESC pDesc, unsigned case X86_SEL_TYPE_SYS_TASK_GATE: { - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s TSS=%04x DPL=%d %s%s\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s TSS=%04x DPL=%d %s%s\n", iEntry, s_apszTypes[pDesc->Gen.u4Type], pDesc->au16[1], pDesc->Gen.u2Dpl, pszPresent, pszHyper); break; @@ -1988,7 +1980,7 @@ static int dbgcCmdDumpDTWorker32(PDBGCCMDHLP pCmdHlp, PCX86DESC pDesc, unsigned const char *pszCountOf = pDesc->Gen.u4Type & RT_BIT(3) ? "DC" : "WC"; RTSEL sel = pDesc->au16[1]; uint32_t off = pDesc->au16[0] | ((uint32_t)pDesc->au16[3] << 16); - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Sel:Off=%04x:%08x DPL=%d %s %s=%d%s\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Sel:Off=%04x:%08x DPL=%d %s %s=%d%s\n", iEntry, s_apszTypes[pDesc->Gen.u4Type], sel, off, pDesc->Gen.u2Dpl, pszPresent, pszCountOf, cParams, pszHyper); break; @@ -2001,7 +1993,7 @@ static int dbgcCmdDumpDTWorker32(PDBGCCMDHLP pCmdHlp, PCX86DESC pDesc, unsigned { RTSEL sel = pDesc->au16[1]; uint32_t off = pDesc->au16[0] | ((uint32_t)pDesc->au16[3] << 16); - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Sel:Off=%04x:%08x DPL=%d %s%s\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Sel:Off=%04x:%08x DPL=%d %s%s\n", iEntry, s_apszTypes[pDesc->Gen.u4Type], sel, off, pDesc->Gen.u2Dpl, pszPresent, pszHyper); break; @@ -2017,29 +2009,21 @@ static int dbgcCmdDumpDTWorker32(PDBGCCMDHLP pCmdHlp, PCX86DESC pDesc, unsigned /** - * The 'dg', 'dga', 'dl' and 'dla' commands. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'dg', 'dga', 'dl' and 'dla' commands.} */ -static DECLCALLBACK(int) dbgcCmdDumpDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdDumpDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Validate input. */ - if (!pVM) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: No VM.\n"); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Get the CPU mode, check which command variation this is * and fix a default parameter if needed. */ PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); - PVMCPU pVCpu = VMMGetCpuById(pVM, pDbgc->idCpu); + PVMCPU pVCpu = VMMR3GetCpuByIdU(pUVM, pDbgc->idCpu); CPUMMODE enmMode = CPUMGetGuestMode(pVCpu); bool fGdt = pCmd->pszCmd[1] == 'g'; bool fAll = pCmd->pszCmd[2] == 'a'; @@ -2066,10 +2050,7 @@ static DECLCALLBACK(int) dbgcCmdDumpDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM * The parser may confuse pointers and numbers if more than one * argument is given, that that into account. */ - /* check that what we got makes sense as we don't trust the parser yet. */ - if ( paArgs[i].enmType != DBGCVAR_TYPE_NUMBER - && !DBGCVAR_ISPOINTER(paArgs[i].enmType)) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: arg #%u isn't of number or pointer type but %d.\n", i, paArgs[i].enmType); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, i, paArgs[i].enmType == DBGCVAR_TYPE_NUMBER || DBGCVAR_ISPOINTER(paArgs[i].enmType)); uint64_t u64; unsigned cSels = 1; switch (paArgs[i].enmType) @@ -2098,11 +2079,11 @@ static DECLCALLBACK(int) dbgcCmdDumpDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM && Sel < _64K) { DBGFSELINFO SelInfo; - int rc = DBGFR3SelQueryInfo(pVM, pDbgc->idCpu, Sel | SelTable, DBGFSELQI_FLAGS_DT_GUEST, &SelInfo); + int rc = DBGFR3SelQueryInfo(pUVM, pDbgc->idCpu, Sel | SelTable, DBGFSELQI_FLAGS_DT_GUEST, &SelInfo); if (RT_SUCCESS(rc)) { if (SelInfo.fFlags & DBGFSELINFO_FLAGS_REAL_MODE) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x RealM Bas=%04x Lim=%04x\n", + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x RealM Bas=%04x Lim=%04x\n", Sel, (unsigned)SelInfo.GCPtrBase, (unsigned)SelInfo.cbLimit); else if ( fAll || fSingle @@ -2121,7 +2102,7 @@ static DECLCALLBACK(int) dbgcCmdDumpDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM } else { - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %Rrc\n", Sel, rc); + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %Rrc\n", Sel, rc); if (!fAll) return rc; } @@ -2133,7 +2114,7 @@ static DECLCALLBACK(int) dbgcCmdDumpDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM } } else - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: %llx is out of bounds\n", u64); + DBGCCmdHlpPrintf(pCmdHlp, "error: %llx is out of bounds\n", u64); } return VINF_SUCCESS; @@ -2141,29 +2122,21 @@ static DECLCALLBACK(int) dbgcCmdDumpDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM /** - * The 'di' and 'dia' commands. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'di' and 'dia' commands.} */ -static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* * Validate input. */ - if (!pVM) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: No VM.\n"); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Establish some stuff like the current IDTR and CPU mode, * and fix a default parameter. */ PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); - PVMCPU pVCpu = VMMGetCpuById(pVM, pDbgc->idCpu); + PVMCPU pVCpu = VMMR3GetCpuByIdU(pUVM, pDbgc->idCpu); uint16_t cbLimit; RTGCUINTPTR GCPtrBase = CPUMGetGuestIDTR(pVCpu, &cbLimit); CPUMMODE enmMode = CPUMGetGuestMode(pVCpu); @@ -2174,7 +2147,7 @@ static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM case CPUMMODE_PROTECTED: cbEntry = sizeof(X86DESC); break; case CPUMMODE_LONG: cbEntry = sizeof(X86DESC64); break; default: - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid CPU mode %d.\n", enmMode); + return DBGCCmdHlpPrintf(pCmdHlp, "error: Invalid CPU mode %d.\n", enmMode); } bool fAll = pCmd->pszCmd[2] == 'a'; @@ -2194,9 +2167,7 @@ static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM */ for (unsigned i = 0; i < cArgs; i++) { - /* check that what we got makes sense as we don't trust the parser yet. */ - if (paArgs[i].enmType != DBGCVAR_TYPE_NUMBER) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: arg #%u isn't of number type but %d.\n", i, paArgs[i].enmType); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, i, paArgs[i].enmType == DBGCVAR_TYPE_NUMBER); if (paArgs[i].u.u64Number < 256) { RTGCUINTPTR iInt = (RTGCUINTPTR)paArgs[i].u.u64Number; @@ -2218,7 +2189,7 @@ static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM } u; if (iInt * cbEntry + (cbEntry - 1) > cbLimit) { - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x not within the IDT\n", (unsigned)iInt); + DBGCCmdHlpPrintf(pCmdHlp, "%04x not within the IDT\n", (unsigned)iInt); if (!fAll && !fSingle) return VINF_SUCCESS; } @@ -2226,7 +2197,7 @@ static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM AddrVar.enmType = DBGCVAR_TYPE_GC_FLAT; AddrVar.u.GCFlat = GCPtrBase + iInt * cbEntry; AddrVar.enmRangeType = DBGCVAR_RANGE_NONE; - int rc = pCmdHlp->pfnMemRead(pCmdHlp, pVM, &u, cbEntry, &AddrVar, NULL); + int rc = pCmdHlp->pfnMemRead(pCmdHlp, &u, cbEntry, &AddrVar, NULL); if (RT_FAILURE(rc)) return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Reading IDT entry %#04x.\n", (unsigned)iInt); @@ -2236,7 +2207,7 @@ static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM switch (enmMode) { case CPUMMODE_REAL: - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %RTfp16\n", (unsigned)iInt, u.Real); + rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %RTfp16\n", (unsigned)iInt, u.Real); /** @todo resolve 16:16 IDTE to a symbol */ break; case CPUMMODE_PROTECTED: @@ -2257,7 +2228,7 @@ static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM } } else - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: %llx is out of bounds (max 256)\n", paArgs[i].u.u64Number); + DBGCCmdHlpPrintf(pCmdHlp, "error: %llx is out of bounds (max 256)\n", paArgs[i].u.u64Number); } return VINF_SUCCESS; @@ -2265,27 +2236,20 @@ static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM /** - * The 'da', 'dq', 'dd', 'dw' and 'db' commands. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'da', 'dq', 'dd', 'dw' and 'db' + * commands.} */ -static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); /* * Validate input. */ - if ( cArgs > 1 - || (cArgs == 1 && !DBGCVAR_ISPOINTER(paArgs[0].enmType))) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "internal error: The parser doesn't do its job properly yet.. It might help to use the '%%' operator.\n"); - if (!pVM) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: No VM.\n"); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs <= 1); + if (cArgs == 1) + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, DBGCVAR_ISPOINTER(paArgs[0].enmType)); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Figure out the element size. @@ -2331,18 +2295,18 @@ static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM case DBGCVAR_RANGE_ELEMENTS: if (pDbgc->DumpPos.u64Range > 2048) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Too many elements requested. Max is 2048 elements.\n"); + return DBGCCmdHlpPrintf(pCmdHlp, "error: Too many elements requested. Max is 2048 elements.\n"); pDbgc->DumpPos.enmRangeType = DBGCVAR_RANGE_BYTES; pDbgc->DumpPos.u64Range = (cbElement ? cbElement : 1) * pDbgc->DumpPos.u64Range; break; case DBGCVAR_RANGE_BYTES: if (pDbgc->DumpPos.u64Range > 65536) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: The requested range is too big. Max is 64KB.\n"); + return DBGCCmdHlpPrintf(pCmdHlp, "error: The requested range is too big. Max is 64KB.\n"); break; default: - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "internal error: Unknown range type %d.\n", pDbgc->DumpPos.enmRangeType); + return DBGCCmdHlpPrintf(pCmdHlp, "internal error: Unknown range type %d.\n", pDbgc->DumpPos.enmRangeType); } pDbgc->pLastPos = &pDbgc->DumpPos; @@ -2361,11 +2325,11 @@ static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM char achBuffer[16]; size_t cbReq = RT_MIN((int)sizeof(achBuffer), cbLeft); size_t cb = RT_MIN((int)sizeof(achBuffer), cbLeft); - int rc = pCmdHlp->pfnMemRead(pCmdHlp, pVM, &achBuffer, cbReq, &pDbgc->DumpPos, &cb); + int rc = pCmdHlp->pfnMemRead(pCmdHlp, &achBuffer, cbReq, &pDbgc->DumpPos, &cb); if (RT_FAILURE(rc)) { if (u8Prev && u8Prev != '\n') - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "\n"); + DBGCCmdHlpPrintf(pCmdHlp, "\n"); return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Reading memory at %DV.\n", &pDbgc->DumpPos); } @@ -2375,7 +2339,7 @@ static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM memset(&achBuffer[cb], 0, sizeof(achBuffer) - cb); if (!fAscii) { - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%DV:", &pDbgc->DumpPos); + DBGCCmdHlpPrintf(pCmdHlp, "%DV:", &pDbgc->DumpPos); unsigned i; for (i = 0; i < cb; i += cbElement) { @@ -2384,10 +2348,10 @@ static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pszSpace = "-"; switch (cbElement) { - case 1: pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%s%02x", pszSpace, *(uint8_t *)&achBuffer[i]); break; - case 2: pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%s%04x", pszSpace, *(uint16_t *)&achBuffer[i]); break; - case 4: pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%s%08x", pszSpace, *(uint32_t *)&achBuffer[i]); break; - case 8: pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%s%016llx", pszSpace, *(uint64_t *)&achBuffer[i]); break; + case 1: DBGCCmdHlpPrintf(pCmdHlp, "%s%02x", pszSpace, *(uint8_t *)&achBuffer[i]); break; + case 2: DBGCCmdHlpPrintf(pCmdHlp, "%s%04x", pszSpace, *(uint16_t *)&achBuffer[i]); break; + case 4: DBGCCmdHlpPrintf(pCmdHlp, "%s%08x", pszSpace, *(uint32_t *)&achBuffer[i]); break; + case 8: DBGCCmdHlpPrintf(pCmdHlp, "%s%016llx", pszSpace, *(uint64_t *)&achBuffer[i]); break; } } @@ -2395,18 +2359,18 @@ static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM if (pDbgc->cbDumpElement == 1) { while (i++ < sizeof(achBuffer)) - pCmdHlp->pfnPrintf(pCmdHlp, NULL, " "); - pCmdHlp->pfnPrintf(pCmdHlp, NULL, " "); + DBGCCmdHlpPrintf(pCmdHlp, " "); + DBGCCmdHlpPrintf(pCmdHlp, " "); for (i = 0; i < cb; i += cbElement) { uint8_t u8 = *(uint8_t *)&achBuffer[i]; if (RT_C_IS_PRINT(u8) && u8 < 127 && u8 >= 32) - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%c", u8); + DBGCCmdHlpPrintf(pCmdHlp, "%c", u8); else - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "."); + DBGCCmdHlpPrintf(pCmdHlp, "."); } } - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "\n"); + rc = DBGCCmdHlpPrintf(pCmdHlp, "\n"); } else { @@ -2415,7 +2379,7 @@ static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM * Only printables + '\t' and '\n' are printed. */ if (!u8Prev) - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%DV:\n", &pDbgc->DumpPos); + DBGCCmdHlpPrintf(pCmdHlp, "%DV:\n", &pDbgc->DumpPos); uint8_t u8 = '\0'; unsigned i; for (i = 0; i < cb; i++) @@ -2426,16 +2390,16 @@ static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM && ( (RT_C_IS_PRINT(u8) && u8 >= 32) || u8 == '\t' || u8 == '\n')) - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%c", u8); + DBGCCmdHlpPrintf(pCmdHlp, "%c", u8); else if (!u8) break; else - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "\\x%x", u8); + DBGCCmdHlpPrintf(pCmdHlp, "\\x%x", u8); } if (u8 == '\0') cb = cbLeft = i + 1; if (cbLeft - cb <= 0 && u8Prev != '\n') - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "\n"); + DBGCCmdHlpPrintf(pCmdHlp, "\n"); } /* @@ -2471,7 +2435,7 @@ static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM */ static RTGCPHYS dbgcGetGuestPageMode(PDBGC pDbgc, bool *pfPAE, bool *pfLME, bool *pfPSE, bool *pfPGE, bool *pfNXE) { - PVMCPU pVCpu = VMMGetCpuById(pDbgc->pVM, pDbgc->idCpu); + PVMCPU pVCpu = VMMR3GetCpuByIdU(pDbgc->pUVM, pDbgc->idCpu); RTGCUINTREG cr4 = CPUMGetGuestCR4(pVCpu); *pfPSE = !!(cr4 & X86_CR4_PSE); *pfPGE = !!(cr4 & X86_CR4_PGE); @@ -2502,7 +2466,7 @@ static RTGCPHYS dbgcGetGuestPageMode(PDBGC pDbgc, bool *pfPAE, bool *pfLME, bool */ static RTHCPHYS dbgcGetShadowPageMode(PDBGC pDbgc, bool *pfPAE, bool *pfLME, bool *pfPSE, bool *pfPGE, bool *pfNXE) { - PVMCPU pVCpu = VMMGetCpuById(pDbgc->pVM, pDbgc->idCpu); + PVMCPU pVCpu = VMMR3GetCpuByIdU(pDbgc->pUVM, pDbgc->idCpu); *pfPSE = true; *pfPGE = false; @@ -2533,29 +2497,23 @@ static RTHCPHYS dbgcGetShadowPageMode(PDBGC pDbgc, bool *pfPAE, bool *pfLME, boo /** - * The 'dpd', 'dpda', 'dpdb', 'dpdg' and 'dpdh' commands. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'dpd', 'dpda', 'dpdb', 'dpdg' and 'dpdh' + * commands.} */ -static DECLCALLBACK(int) dbgcCmdDumpPageDir(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdDumpPageDir(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); /* * Validate input. */ - if ( cArgs > 1 - || (cArgs == 1 && pCmd->pszCmd[3] == 'a' && !DBGCVAR_ISPOINTER(paArgs[0].enmType)) - || (cArgs == 1 && pCmd->pszCmd[3] != 'a' && !(paArgs[0].enmType == DBGCVAR_TYPE_NUMBER || DBGCVAR_ISPOINTER(paArgs[0].enmType))) - ) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "internal error: The parser doesn't do its job properly yet.. It might help to use the '%%' operator.\n"); - if (!pVM) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: No VM.\n"); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs <= 1); + if (cArgs == 1 && pCmd->pszCmd[3] == 'a') + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, DBGCVAR_ISPOINTER(paArgs[0].enmType)); + if (cArgs == 1 && pCmd->pszCmd[3] != 'a') + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[0].enmType == DBGCVAR_TYPE_NUMBER + || DBGCVAR_ISPOINTER(paArgs[0].enmType)); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Guest or shadow page directories? Get the paging parameters. @@ -2675,7 +2633,7 @@ static DECLCALLBACK(int) dbgcCmdDumpPageDir(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, VarCur.u.u64Number &= X86_PTE_PAE_PG_MASK; VarCur.u.u64Number += (((uint64_t)VarGCPtr.u.GCFlat >> X86_PML4_SHIFT) & X86_PML4_MASK) * sizeof(X86PML4E); X86PML4E Pml4e; - rc = pCmdHlp->pfnMemRead(pCmdHlp, pVM, &Pml4e, sizeof(Pml4e), &VarCur, NULL); + rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pml4e, sizeof(Pml4e), &VarCur, NULL); if (RT_FAILURE(rc)) return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PML4E memory at %DV.\n", &VarCur); if (!Pml4e.n.u1Present) @@ -2689,7 +2647,7 @@ static DECLCALLBACK(int) dbgcCmdDumpPageDir(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, /* Page directory pointer table. */ X86PDPE Pdpe; VarCur.u.u64Number += ((VarGCPtr.u.GCFlat >> X86_PDPT_SHIFT) & X86_PDPT_MASK_PAE) * sizeof(Pdpe); - rc = pCmdHlp->pfnMemRead(pCmdHlp, pVM, &Pdpe, sizeof(Pdpe), &VarCur, NULL); + rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pdpe, sizeof(Pdpe), &VarCur, NULL); if (RT_FAILURE(rc)) return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PDPE memory at %DV.\n", &VarCur); if (!Pdpe.n.u1Present) @@ -2726,7 +2684,7 @@ static DECLCALLBACK(int) dbgcCmdDumpPageDir(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, */ X86PDEPAE Pde; Pde.u = 0; - rc = pCmdHlp->pfnMemRead(pCmdHlp, pVM, &Pde, cbEntry, &VarPDEAddr, NULL); + rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pde, cbEntry, &VarPDEAddr, NULL); if (RT_FAILURE(rc)) return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Reading PDE memory at %DV.\n", &VarPDEAddr); @@ -2793,19 +2751,11 @@ static DECLCALLBACK(int) dbgcCmdDumpPageDir(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, /** - * The 'dpdb' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'dpdb' command.} */ -static DECLCALLBACK(int) dbgcCmdDumpPageDirBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdDumpPageDirBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - if (!pVM) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: No VM.\n"); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); int rc1 = pCmdHlp->pfnExec(pCmdHlp, "dpdg %DV", &paArgs[0]); int rc2 = pCmdHlp->pfnExec(pCmdHlp, "dpdh %DV", &paArgs[0]); if (RT_FAILURE(rc1)) @@ -2816,20 +2766,12 @@ static DECLCALLBACK(int) dbgcCmdDumpPageDirBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmd /** - * The 'dph*' commands and main part of 'm'. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'dph*' commands and main part of 'm'.} */ -static DECLCALLBACK(int) dbgcCmdDumpPageHierarchy(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdDumpPageHierarchy(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); - if (!pVM) - return DBGCCmdHlpFail(pCmdHlp, pCmd, "No VM.\n"); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Figure the context and base flags. @@ -2930,7 +2872,7 @@ static DECLCALLBACK(int) dbgcCmdDumpPageHierarchy(PCDBGCCMD pCmd, PDBGCCMDHLP pC /* * Call the worker. */ - rc = DBGFR3PagingDumpEx(pVM, pDbgc->idCpu, fFlags, cr3, GCPtrFirst, GCPtrLast, 99 /*cMaxDepth*/, + rc = DBGFR3PagingDumpEx(pUVM, pDbgc->idCpu, fFlags, cr3, GCPtrFirst, GCPtrLast, 99 /*cMaxDepth*/, DBGCCmdHlpGetDbgfOutputHlp(pCmdHlp)); if (RT_FAILURE(rc)) return DBGCCmdHlpFail(pCmdHlp, pCmd, "DBGFR3PagingDumpEx: %Rrc\n", rc); @@ -2940,29 +2882,22 @@ static DECLCALLBACK(int) dbgcCmdDumpPageHierarchy(PCDBGCCMD pCmd, PDBGCCMDHLP pC /** - * The 'dpg*' commands. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'dpg*' commands.} */ -static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); /* * Validate input. */ - if ( cArgs != 1 - || (pCmd->pszCmd[3] == 'a' && !DBGCVAR_ISPOINTER(paArgs[0].enmType)) - || (pCmd->pszCmd[3] != 'a' && !(paArgs[0].enmType == DBGCVAR_TYPE_NUMBER || DBGCVAR_ISPOINTER(paArgs[0].enmType))) - ) - return DBGCCmdHlpPrintf(pCmdHlp, "internal error: The parser doesn't do its job properly yet.. It might help to use the '%%' operator.\n"); - if (!pVM) - return DBGCCmdHlpPrintf(pCmdHlp, "error: No VM.\n"); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs == 1); + if (pCmd->pszCmd[3] == 'a') + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, DBGCVAR_ISPOINTER(paArgs[0].enmType)); + else + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[0].enmType == DBGCVAR_TYPE_NUMBER + || DBGCVAR_ISPOINTER(paArgs[0].enmType)); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Guest or shadow page tables? Get the paging parameters. @@ -3044,7 +2979,7 @@ static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHl VarCur.u.u64Number &= X86_PTE_PAE_PG_MASK; VarCur.u.u64Number += (((uint64_t)VarGCPtr.u.GCFlat >> X86_PML4_SHIFT) & X86_PML4_MASK) * sizeof(X86PML4E); X86PML4E Pml4e; - rc = pCmdHlp->pfnMemRead(pCmdHlp, pVM, &Pml4e, sizeof(Pml4e), &VarCur, NULL); + rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pml4e, sizeof(Pml4e), &VarCur, NULL); if (RT_FAILURE(rc)) return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PML4E memory at %DV.\n", &VarCur); if (!Pml4e.n.u1Present) @@ -3058,7 +2993,7 @@ static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHl /* Page directory pointer table. */ X86PDPE Pdpe; VarCur.u.u64Number += ((VarGCPtr.u.GCFlat >> X86_PDPT_SHIFT) & X86_PDPT_MASK_PAE) * sizeof(Pdpe); - rc = pCmdHlp->pfnMemRead(pCmdHlp, pVM, &Pdpe, sizeof(Pdpe), &VarCur, NULL); + rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pdpe, sizeof(Pdpe), &VarCur, NULL); if (RT_FAILURE(rc)) return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PDPE memory at %DV.\n", &VarCur); if (!Pdpe.n.u1Present) @@ -3069,7 +3004,7 @@ static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHl /* Page directory (PAE). */ X86PDEPAE Pde; VarCur.u.u64Number += ((VarGCPtr.u.GCFlat >> X86_PD_PAE_SHIFT) & X86_PD_PAE_MASK) * sizeof(Pde); - rc = pCmdHlp->pfnMemRead(pCmdHlp, pVM, &Pde, sizeof(Pde), &VarCur, NULL); + rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pde, sizeof(Pde), &VarCur, NULL); if (RT_FAILURE(rc)) return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PDE memory at %DV.\n", &VarCur); if (!Pde.n.u1Present) @@ -3087,7 +3022,7 @@ static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHl /* Page directory (legacy). */ X86PDE Pde; VarCur.u.u64Number += ((VarGCPtr.u.GCFlat >> X86_PD_SHIFT) & X86_PD_MASK) * sizeof(Pde); - rc = pCmdHlp->pfnMemRead(pCmdHlp, pVM, &Pde, sizeof(Pde), &VarCur, NULL); + rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pde, sizeof(Pde), &VarCur, NULL); if (RT_FAILURE(rc)) return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PDE memory at %DV.\n", &VarCur); if (!Pde.n.u1Present) @@ -3119,7 +3054,7 @@ static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHl */ X86PTEPAE Pte; Pte.u = 0; - rc = pCmdHlp->pfnMemRead(pCmdHlp, pVM, &Pte, cbEntry, &VarPTEAddr, NULL); + rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pte, cbEntry, &VarPTEAddr, NULL); if (RT_FAILURE(rc)) return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PTE memory at %DV.\n", &VarPTEAddr); @@ -3168,19 +3103,11 @@ static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHl /** - * The 'dptb' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'dptb' command.} */ -static DECLCALLBACK(int) dbgcCmdDumpPageTableBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdDumpPageTableBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { - if (!pVM) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: No VM.\n"); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); int rc1 = pCmdHlp->pfnExec(pCmdHlp, "dptg %DV", &paArgs[0]); int rc2 = pCmdHlp->pfnExec(pCmdHlp, "dpth %DV", &paArgs[0]); if (RT_FAILURE(rc1)) @@ -3191,26 +3118,18 @@ static DECLCALLBACK(int) dbgcCmdDumpPageTableBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pC /** - * The 'dt' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'dt' command.} */ -static DECLCALLBACK(int) dbgcCmdDumpTSS(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdDumpTSS(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); int rc; - if (!pVM) - return DBGCCmdHlpFail(pCmdHlp, pCmd, "No VM.\n"); - if ( cArgs > 1 - || (cArgs == 1 && paArgs[0].enmType == DBGCVAR_TYPE_STRING) - || (cArgs == 1 && paArgs[0].enmType == DBGCVAR_TYPE_SYMBOL)) - return DBGCCmdHlpFail(pCmdHlp, pCmd, "internal error: The parser doesn't do its job properly yet...\n"); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs <= 1); + if (cArgs == 1) + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[0].enmType != DBGCVAR_TYPE_STRING + && paArgs[0].enmType != DBGCVAR_TYPE_SYMBOL); /* * Check if the command indicates the type. @@ -3232,7 +3151,7 @@ static DECLCALLBACK(int) dbgcCmdDumpTSS(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM { /** @todo consider querying the hidden bits instead (missing API). */ uint16_t SelTR; - rc = DBGFR3RegCpuQueryU16(pVM, pDbgc->idCpu, DBGFREG_TR, &SelTR); + rc = DBGFR3RegCpuQueryU16(pUVM, pDbgc->idCpu, DBGFREG_TR, &SelTR); if (RT_FAILURE(rc)) return DBGCCmdHlpFail(pCmdHlp, pCmd, "Failed to query TR, rc=%Rrc\n", rc); DBGCVAR_INIT_GC_FAR(&VarTssAddr, SelTR, 0); @@ -3264,7 +3183,7 @@ static DECLCALLBACK(int) dbgcCmdDumpTSS(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM { SelTss = VarTssAddr.u.GCFar.sel; DBGFSELINFO SelInfo; - rc = DBGFR3SelQueryInfo(pVM, pDbgc->idCpu, VarTssAddr.u.GCFar.sel, DBGFSELQI_FLAGS_DT_GUEST, &SelInfo); + rc = DBGFR3SelQueryInfo(pUVM, pDbgc->idCpu, VarTssAddr.u.GCFar.sel, DBGFSELQI_FLAGS_DT_GUEST, &SelInfo); if (RT_FAILURE(rc)) return DBGCCmdHlpFail(pCmdHlp, pCmd, "DBGFR3SelQueryInfo(,%u,%d,,) -> %Rrc.\n", pDbgc->idCpu, VarTssAddr.u.GCFar.sel, rc); @@ -3306,7 +3225,7 @@ static DECLCALLBACK(int) dbgcCmdDumpTSS(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM else { uint64_t uEfer; - rc = DBGFR3RegCpuQueryU64(pVM, pDbgc->idCpu, DBGFREG_MSR_K6_EFER, &uEfer); + rc = DBGFR3RegCpuQueryU64(pUVM, pDbgc->idCpu, DBGFREG_MSR_K6_EFER, &uEfer); if ( RT_FAILURE(rc) || !(uEfer & MSR_K6_EFER_LMA) ) enmTssType = kTss32; @@ -3352,7 +3271,7 @@ static DECLCALLBACK(int) dbgcCmdDumpTSS(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM */ uint8_t abBuf[_64K]; size_t cbTssRead; - rc = DBGCCmdHlpMemRead(pCmdHlp, pVM, abBuf, cbTss, &VarTssAddr, &cbTssRead); + rc = DBGCCmdHlpMemRead(pCmdHlp, abBuf, cbTss, &VarTssAddr, &cbTssRead); if (RT_FAILURE(rc)) return DBGCCmdHlpFail(pCmdHlp, pCmd, "Failed to read TSS at %Dv: %Rrc\n", &VarTssAddr, rc); if (cbTssRead < cbTssMin) @@ -3525,21 +3444,13 @@ static DECLCALLBACK(int) dbgcCmdDumpTSS(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM /** - * The 'm' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'm' command.} */ -static DECLCALLBACK(int) dbgcCmdMemoryInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdMemoryInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { DBGCCmdHlpPrintf(pCmdHlp, "Address: %DV\n", &paArgs[0]); - if (!pVM) - return DBGCCmdHlpFail(pCmdHlp, pCmd, "No VM.\n"); - return dbgcCmdDumpPageHierarchy(pCmd, pCmdHlp, pVM, paArgs, cArgs); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); + return dbgcCmdDumpPageHierarchy(pCmd, pCmdHlp, pUVM, paArgs, cArgs); } @@ -3681,16 +3592,9 @@ int dbgcVarsToBytes(PDBGCCMDHLP pCmdHlp, void *pvBuf, uint32_t *pcbBuf, size_t c /** - * The 'eb', 'ew', 'ed' and 'eq' commands. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'eb', 'ew', 'ed' and 'eq' commands.} */ -static DECLCALLBACK(int) dbgcCmdEditMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdEditMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); unsigned iArg; @@ -3698,14 +3602,11 @@ static DECLCALLBACK(int) dbgcCmdEditMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM /* * Validate input. */ - if ( cArgs < 2 - || !DBGCVAR_ISPOINTER(paArgs[0].enmType)) - return DBGCCmdHlpFail(pCmdHlp, pCmd, "internal error: The parser doesn't do its job properly yet... It might help to use the '%%' operator.\n"); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs >= 2); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, DBGCVAR_ISPOINTER(paArgs[0].enmType)); for (iArg = 1; iArg < cArgs; iArg++) - if (paArgs[iArg].enmType != DBGCVAR_TYPE_NUMBER) - return DBGCCmdHlpFail(pCmdHlp, pCmd, "internal error: The parser doesn't do its job properly yet: Arg #%u is not a number.\n", iArg); - if (!pVM) - return DBGCCmdHlpFail(pCmdHlp, pCmd, "error: No VM.\n"); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER); + DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); /* * Figure out the element size. @@ -3727,7 +3628,7 @@ static DECLCALLBACK(int) dbgcCmdEditMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM for (iArg = 1;;) { size_t cbWritten; - int rc = pCmdHlp->pfnMemWrite(pCmdHlp, pVM, &paArgs[iArg].u, cbElement, &Addr, &cbWritten); + int rc = pCmdHlp->pfnMemWrite(pCmdHlp, &paArgs[iArg].u, cbElement, &Addr, &cbWritten); if (RT_FAILURE(rc)) return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Writing memory at %DV.\n", &Addr); if (cbWritten != cbElement) @@ -3751,7 +3652,7 @@ static DECLCALLBACK(int) dbgcCmdEditMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM * * @returns VBox status code. * @param pCmdHlp The command helpers. - * @param pVM The VM handle. + * @param pUVM The user mode VM handle. * @param pAddress The address to start searching from. (undefined on output) * @param cbRange The address range to search. Must not wrap. * @param pabBytes The byte pattern to search for. @@ -3760,7 +3661,7 @@ static DECLCALLBACK(int) dbgcCmdEditMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM * @param cMaxHits The max number of hits. * @param pResult Where to store the result if it's a function invocation. */ -static int dbgcCmdWorkerSearchMemDoIt(PDBGCCMDHLP pCmdHlp, PVM pVM, PDBGFADDRESS pAddress, RTGCUINTPTR cbRange, +static int dbgcCmdWorkerSearchMemDoIt(PDBGCCMDHLP pCmdHlp, PUVM pUVM, PDBGFADDRESS pAddress, RTGCUINTPTR cbRange, const uint8_t *pabBytes, uint32_t cbBytes, uint32_t cbUnit, uint64_t cMaxHits, PDBGCVAR pResult) { @@ -3774,7 +3675,7 @@ static int dbgcCmdWorkerSearchMemDoIt(PDBGCCMDHLP pCmdHlp, PVM pVM, PDBGFADDRESS { /* search */ DBGFADDRESS HitAddress; - int rc = DBGFR3MemScan(pVM, pDbgc->idCpu, pAddress, cbRange, 1, pabBytes, cbBytes, &HitAddress); + int rc = DBGFR3MemScan(pUVM, pDbgc->idCpu, pAddress, cbRange, 1, pabBytes, cbBytes, &HitAddress); if (RT_FAILURE(rc)) { if (rc != VERR_DBGF_MEM_NOT_FOUND) @@ -3838,10 +3739,10 @@ static int dbgcCmdWorkerSearchMemDoIt(PDBGCCMDHLP pCmdHlp, PVM pVM, PDBGFADDRESS * * @returns VBox status code. * @param pCmdHlp Pointer to the command helper functions. - * @param pVM Pointer to the current VM (if any). + * @param pUVM The user mode VM handle. * @param pResult Where to store the result of a function invocation. */ -static int dbgcCmdWorkerSearchMemResume(PDBGCCMDHLP pCmdHlp, PVM pVM, PDBGCVAR pResult) +static int dbgcCmdWorkerSearchMemResume(PDBGCCMDHLP pCmdHlp, PUVM pUVM, PDBGCVAR pResult) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); @@ -3850,7 +3751,7 @@ static int dbgcCmdWorkerSearchMemResume(PDBGCCMDHLP pCmdHlp, PVM pVM, PDBGCVAR p */ if (!pDbgc->cbSearch) { - pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Error: No previous search\n"); + DBGCCmdHlpPrintf(pCmdHlp, "Error: No previous search\n"); return VERR_DBGC_COMMAND_FAILED; } @@ -3870,7 +3771,7 @@ static int dbgcCmdWorkerSearchMemResume(PDBGCCMDHLP pCmdHlp, PVM pVM, PDBGCVAR p if (Address.FlatPtr + cbRange < pDbgc->SearchAddr.FlatPtr) cbRange = ~(RTGCUINTPTR)0 - pDbgc->SearchAddr.FlatPtr + !!pDbgc->SearchAddr.FlatPtr; - return dbgcCmdWorkerSearchMemDoIt(pCmdHlp, pVM, &Address, cbRange, pDbgc->abSearch, pDbgc->cbSearch, + return dbgcCmdWorkerSearchMemDoIt(pCmdHlp, pUVM, &Address, cbRange, pDbgc->abSearch, pDbgc->cbSearch, pDbgc->cbSearchUnit, pDbgc->cMaxSearchHits, pResult); } @@ -3880,7 +3781,7 @@ static int dbgcCmdWorkerSearchMemResume(PDBGCCMDHLP pCmdHlp, PVM pVM, PDBGCVAR p * * @returns VBox status. * @param pCmdHlp Pointer to the command helper functions. - * @param pVM Pointer to the current VM (if any). + * @param pUVM The user mode VM handle. * @param pAddress Where to start searching. If no range, search till end of address space. * @param cMaxHits The maximum number of hits. * @param chType The search type. @@ -3888,7 +3789,7 @@ static int dbgcCmdWorkerSearchMemResume(PDBGCCMDHLP pCmdHlp, PVM pVM, PDBGCVAR p * @param cPatArgs Number of pattern variables. * @param pResult Where to store the result of a function invocation. */ -static int dbgcCmdWorkerSearchMem(PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR pAddress, uint64_t cMaxHits, char chType, +static int dbgcCmdWorkerSearchMem(PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR pAddress, uint64_t cMaxHits, char chType, PCDBGCVAR paPatArgs, unsigned cPatArgs, PDBGCVAR pResult) { if (pResult) @@ -3949,32 +3850,25 @@ static int dbgcCmdWorkerSearchMem(PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR pAddre /* * Ok, do it. */ - return dbgcCmdWorkerSearchMemDoIt(pCmdHlp, pVM, &Address, cbRange, abBytes, cbBytes, cbUnit, cMaxHits, pResult); + return dbgcCmdWorkerSearchMemDoIt(pCmdHlp, pUVM, &Address, cbRange, abBytes, cbBytes, cbUnit, cMaxHits, pResult); } /** - * The 's' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 's' command.} */ -static DECLCALLBACK(int) dbgcCmdSearchMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdSearchMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* check that the parser did what it's supposed to do. */ //if ( cArgs <= 2 // && paArgs[0].enmType != DBGCVAR_TYPE_STRING) - // return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "parser error\n"); + // return DBGCCmdHlpPrintf(pCmdHlp, "parser error\n"); /* * Repeat previous search? */ if (cArgs == 0) - return dbgcCmdWorkerSearchMemResume(pCmdHlp, pVM, NULL); + return dbgcCmdWorkerSearchMemResume(pCmdHlp, pUVM, NULL); /* * Parse arguments. @@ -3985,22 +3879,13 @@ static DECLCALLBACK(int) dbgcCmdSearchMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, P /** - * The 's?' command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 's?' command.} */ -static DECLCALLBACK(int) dbgcCmdSearchMemType(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdSearchMemType(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { /* check that the parser did what it's supposed to do. */ - if ( cArgs < 2 - || !DBGCVAR_ISGCPOINTER(paArgs[0].enmType)) - return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "parser error\n"); - return dbgcCmdWorkerSearchMem(pCmdHlp, pVM, &paArgs[0], 25, pCmd->pszCmd[1], paArgs + 1, cArgs - 1, NULL); + DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs >= 2 && DBGCVAR_ISGCPOINTER(paArgs[0].enmType)); + return dbgcCmdWorkerSearchMem(pCmdHlp, pUVM, &paArgs[0], 25, pCmd->pszCmd[1], paArgs + 1, cArgs - 1, NULL); } @@ -4009,10 +3894,10 @@ static DECLCALLBACK(int) dbgcCmdSearchMemType(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHl * * @returns VBox status code. * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). + * @param pUVM The user mode VM handle. * @param pArg Pointer to the address or symbol to lookup. */ -static int dbgcDoListNear(PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR pArg) +static int dbgcDoListNear(PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR pArg) { PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); @@ -4023,11 +3908,11 @@ static int dbgcDoListNear(PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR pArg) /* * Lookup the symbol address. */ - rc = DBGFR3AsSymbolByName(pVM, pDbgc->hDbgAs, pArg->u.pszString, &Symbol, NULL); + rc = DBGFR3AsSymbolByName(pUVM, pDbgc->hDbgAs, pArg->u.pszString, &Symbol, NULL); if (RT_FAILURE(rc)) return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3AsSymbolByName(,,%s,)\n", pArg->u.pszString); - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%Rptr %s\n", Symbol.Value, Symbol.szName); + rc = DBGCCmdHlpPrintf(pCmdHlp, "%RTptr %s\n", Symbol.Value, Symbol.szName); } else { @@ -4041,20 +3926,21 @@ static int dbgcDoListNear(PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR pArg) RTINTPTR offDisp; DBGFADDRESS Addr; - rc = DBGFR3AsSymbolByAddr(pVM, pDbgc->hDbgAs, DBGFR3AddrFromFlat(pVM, &Addr, AddrVar.u.GCFlat), &offDisp, &Symbol, NULL); + rc = DBGFR3AsSymbolByAddr(pUVM, pDbgc->hDbgAs, DBGFR3AddrFromFlat(pDbgc->pUVM, &Addr, AddrVar.u.GCFlat), + RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, &offDisp, &Symbol, NULL); if (RT_FAILURE(rc)) return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3ASymbolByAddr(,,%RGv,,)\n", AddrVar.u.GCFlat); if (!offDisp) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%DV %s", &AddrVar, Symbol.szName); + rc = DBGCCmdHlpPrintf(pCmdHlp, "%DV %s", &AddrVar, Symbol.szName); else if (offDisp > 0) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%DV %s + %RGv", &AddrVar, Symbol.szName, offDisp); + rc = DBGCCmdHlpPrintf(pCmdHlp, "%DV %s + %RGv", &AddrVar, Symbol.szName, offDisp); else - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%DV %s - %RGv", &AddrVar, Symbol.szName, -offDisp); - if ((RTGCINTPTR)Symbol.cb > -offDisp) - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " LB %RGv\n", Symbol.cb + offDisp); + rc = DBGCCmdHlpPrintf(pCmdHlp, "%DV %s - %RGv", &AddrVar, Symbol.szName, -offDisp); + if (Symbol.cb > 0) + rc = DBGCCmdHlpPrintf(pCmdHlp, " (LB %RGv)\n", Symbol.cb); else - rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "\n"); + rc = DBGCCmdHlpPrintf(pCmdHlp, "\n"); } return rc; @@ -4062,27 +3948,22 @@ static int dbgcDoListNear(PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR pArg) /** - * The 'ln' (listnear) command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'ln' (listnear) command.} */ -static DECLCALLBACK(int) dbgcCmdListNear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdListNear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { + PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); if (!cArgs) { /* * Current cs:eip symbol. */ DBGCVAR AddrVar; - int rc = DBGCCmdHlpEval(pCmdHlp, &AddrVar, "%%(cs:eip)"); + const char *pszFmtExpr = pDbgc->fRegCtxGuest ? "%%(cs:eip)" : "%%(.cs:.eip)"; + int rc = DBGCCmdHlpEval(pCmdHlp, &AddrVar, pszFmtExpr); if (RT_FAILURE(rc)) - return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "%%(cs:eip)\n"); - return dbgcDoListNear(pCmdHlp, pVM, &AddrVar); + return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "%s\n", pszFmtExpr + 1); + return dbgcDoListNear(pCmdHlp, pUVM, &AddrVar); } /** @todo Fix the darn parser, it's resolving symbols specified as arguments before we get in here. */ @@ -4091,7 +3972,7 @@ static DECLCALLBACK(int) dbgcCmdListNear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PV */ for (unsigned iArg = 0; iArg < cArgs; iArg++) { - int rc = dbgcDoListNear(pCmdHlp, pVM, &paArgs[iArg]); + int rc = dbgcDoListNear(pCmdHlp, pUVM, &paArgs[iArg]); if (RT_FAILURE(rc)) return rc; } @@ -4119,33 +4000,32 @@ static bool dbgcCmdListModuleMatch(const char *pszName, PCDBGCVAR paArgs, unsign /** - * The 'ln' (listnear) command. - * - * @returns VBox status. - * @param pCmd Pointer to the command descriptor (as registered). - * @param pCmdHlp Pointer to command helper functions. - * @param pVM Pointer to the current VM (if any). - * @param paArgs Pointer to (readonly) array of arguments. - * @param cArgs Number of arguments in the array. + * @interface_method_impl{FNDBCCMD, The 'ln' (list near) command.} */ -static DECLCALLBACK(int) dbgcCmdListModules(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs) +static DECLCALLBACK(int) dbgcCmdListModules(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) { bool const fMappings = pCmd->pszCmd[2] == 'o'; + bool const fVerbose = pCmd->pszCmd[strlen(pCmd->pszCmd) - 1] == 'v'; PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); /* * Iterate the modules in the current address space and print info about * those matching the input. */ - RTDBGAS hAs = DBGFR3AsResolveAndRetain(pVM, pDbgc->hDbgAs); + RTDBGAS hAs = DBGFR3AsResolveAndRetain(pUVM, pDbgc->hDbgAs); uint32_t cMods = RTDbgAsModuleCount(hAs); for (uint32_t iMod = 0; iMod < cMods; iMod++) { RTDBGMOD hMod = RTDbgAsModuleByIndex(hAs, iMod); if (hMod != NIL_RTDBGMOD) { - uint32_t const cSegs = RTDbgModSegmentCount(hMod); - const char * const pszName = RTDbgModName(hMod); + bool const fDeferred = RTDbgModIsDeferred(hMod); + bool const fExports = RTDbgModIsExports(hMod); + uint32_t const cSegs = fDeferred ? 1 : RTDbgModSegmentCount(hMod); + const char * const pszName = RTDbgModName(hMod); + const char * const pszImgFile = RTDbgModImageFile(hMod); + const char * const pszImgFileUsed = RTDbgModImageFileUsed(hMod); + const char * const pszDbgFile = RTDbgModDebugFile(hMod); if ( cArgs == 0 || dbgcCmdListModuleMatch(pszName, paArgs, cArgs)) { @@ -4165,7 +4045,16 @@ static DECLCALLBACK(int) dbgcCmdListModules(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, && ( !fFull || aMappings[iMap].iSeg == NIL_RTDBGSEGIDX)) uMin = aMappings[iMap].Address; - DBGCCmdHlpPrintf(pCmdHlp, "%RGv %04x %s\n", (RTGCUINTPTR)uMin, cSegs, pszName); + if (!fVerbose || !pszImgFile) + DBGCCmdHlpPrintf(pCmdHlp, "%RGv %04x %s%s\n", (RTGCUINTPTR)uMin, cSegs, pszName, + fExports ? " (exports)" : fDeferred ? " (deferred)" : ""); + else + DBGCCmdHlpPrintf(pCmdHlp, "%RGv %04x %-12s %s%s\n", (RTGCUINTPTR)uMin, cSegs, pszName, pszImgFile, + fExports ? " (exports)" : fDeferred ? " (deferred)" : ""); + if (fVerbose && pszImgFileUsed) + DBGCCmdHlpPrintf(pCmdHlp, " Local image: %s\n", pszImgFileUsed); + if (fVerbose && pszDbgFile) + DBGCCmdHlpPrintf(pCmdHlp, " Debug file: %s\n", pszDbgFile); if (fMappings) { @@ -4180,17 +4069,54 @@ static DECLCALLBACK(int) dbgcCmdListModules(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, } /* print */ - for (uint32_t iMap = 0; iMap < cMappings; iMap++) - if (aMappings[iMap].iSeg != NIL_RTDBGSEGIDX) - DBGCCmdHlpPrintf(pCmdHlp, " %RGv %RGv #%02x %s\n", - (RTGCUINTPTR)aMappings[iMap].Address, - (RTGCUINTPTR)RTDbgModSegmentSize(hMod, aMappings[iMap].iSeg), - aMappings[iMap].iSeg, - /** @todo RTDbgModSegmentName(hMod, aMappings[iMap].iSeg)*/ "noname"); - else - DBGCCmdHlpPrintf(pCmdHlp, " %RGv %RGv <everything>\n", - (RTGCUINTPTR)aMappings[iMap].Address, - (RTGCUINTPTR)RTDbgModImageSize(hMod)); + if ( cMappings == 1 + && aMappings[0].iSeg == NIL_RTDBGSEGIDX + && !fDeferred) + { + for (uint32_t iSeg = 0; iSeg < cSegs; iSeg++) + { + RTDBGSEGMENT SegInfo; + rc = RTDbgModSegmentByIndex(hMod, iSeg, &SegInfo); + if (RT_SUCCESS(rc)) + { + if (SegInfo.uRva != RTUINTPTR_MAX) + DBGCCmdHlpPrintf(pCmdHlp, " %RGv %RGv #%02x %s\n", + (RTGCUINTPTR)(aMappings[0].Address + SegInfo.uRva), + (RTGCUINTPTR)SegInfo.cb, iSeg, SegInfo.szName); + else + DBGCCmdHlpPrintf(pCmdHlp, " %*s %RGv #%02x %s\n", + sizeof(RTGCUINTPTR)*2, "noload", + (RTGCUINTPTR)SegInfo.cb, iSeg, SegInfo.szName); + } + else + DBGCCmdHlpPrintf(pCmdHlp, " Error query segment #%u: %Rrc\n", iSeg, rc); + } + } + else + { + for (uint32_t iMap = 0; iMap < cMappings; iMap++) + if (aMappings[iMap].iSeg == NIL_RTDBGSEGIDX) + DBGCCmdHlpPrintf(pCmdHlp, " %RGv %RGv <everything>\n", + (RTGCUINTPTR)aMappings[iMap].Address, + (RTGCUINTPTR)RTDbgModImageSize(hMod)); + else if (!fDeferred) + { + RTDBGSEGMENT SegInfo; + rc = RTDbgModSegmentByIndex(hMod, aMappings[iMap].iSeg, &SegInfo); + if (RT_FAILURE(rc)) + { + RT_ZERO(SegInfo); + strcpy(SegInfo.szName, "error"); + } + DBGCCmdHlpPrintf(pCmdHlp, " %RGv %RGv #%02x %s\n", + (RTGCUINTPTR)aMappings[iMap].Address, + (RTGCUINTPTR)SegInfo.cb, + aMappings[iMap].iSeg, SegInfo.szName); + } + else + DBGCCmdHlpPrintf(pCmdHlp, " %RGv #%02x\n", + (RTGCUINTPTR)aMappings[iMap].Address, aMappings[iMap].iSeg); + } } } else @@ -4212,7 +4138,7 @@ static DECLCALLBACK(int) dbgcCmdListModules(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, /** * @callback_method_impl{Reads a unsigned 8-bit value.} */ -static DECLCALLBACK(int) dbgcFuncReadU8(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs, +static DECLCALLBACK(int) dbgcFuncReadU8(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs, PDBGCVAR pResult) { AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG); @@ -4220,7 +4146,7 @@ static DECLCALLBACK(int) dbgcFuncReadU8(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, P AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG); uint8_t b; - int rc = DBGCCmdHlpMemRead(pCmdHlp, pVM, &b, sizeof(b), &paArgs[0], NULL); + int rc = DBGCCmdHlpMemRead(pCmdHlp, &b, sizeof(b), &paArgs[0], NULL); if (RT_FAILURE(rc)) return rc; DBGCVAR_INIT_NUMBER(pResult, b); @@ -4233,7 +4159,7 @@ static DECLCALLBACK(int) dbgcFuncReadU8(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, P /** * @callback_method_impl{Reads a unsigned 16-bit value.} */ -static DECLCALLBACK(int) dbgcFuncReadU16(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs, +static DECLCALLBACK(int) dbgcFuncReadU16(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs, PDBGCVAR pResult) { AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG); @@ -4241,7 +4167,7 @@ static DECLCALLBACK(int) dbgcFuncReadU16(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG); uint16_t u16; - int rc = DBGCCmdHlpMemRead(pCmdHlp, pVM, &u16, sizeof(u16), &paArgs[0], NULL); + int rc = DBGCCmdHlpMemRead(pCmdHlp, &u16, sizeof(u16), &paArgs[0], NULL); if (RT_FAILURE(rc)) return rc; DBGCVAR_INIT_NUMBER(pResult, u16); @@ -4254,7 +4180,7 @@ static DECLCALLBACK(int) dbgcFuncReadU16(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, /** * @callback_method_impl{Reads a unsigned 32-bit value.} */ -static DECLCALLBACK(int) dbgcFuncReadU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs, +static DECLCALLBACK(int) dbgcFuncReadU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs, PDBGCVAR pResult) { AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG); @@ -4262,7 +4188,7 @@ static DECLCALLBACK(int) dbgcFuncReadU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG); uint32_t u32; - int rc = DBGCCmdHlpMemRead(pCmdHlp, pVM, &u32, sizeof(u32), &paArgs[0], NULL); + int rc = DBGCCmdHlpMemRead(pCmdHlp, &u32, sizeof(u32), &paArgs[0], NULL); if (RT_FAILURE(rc)) return rc; DBGCVAR_INIT_NUMBER(pResult, u32); @@ -4275,7 +4201,7 @@ static DECLCALLBACK(int) dbgcFuncReadU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, /** * @callback_method_impl{Reads a unsigned 64-bit value.} */ -static DECLCALLBACK(int) dbgcFuncReadU64(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs, +static DECLCALLBACK(int) dbgcFuncReadU64(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs, PDBGCVAR pResult) { AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG); @@ -4283,7 +4209,7 @@ static DECLCALLBACK(int) dbgcFuncReadU64(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG); uint64_t u64; - int rc = DBGCCmdHlpMemRead(pCmdHlp, pVM, &u64, sizeof(u64), &paArgs[0], NULL); + int rc = DBGCCmdHlpMemRead(pCmdHlp, &u64, sizeof(u64), &paArgs[0], NULL); if (RT_FAILURE(rc)) return rc; DBGCVAR_INIT_NUMBER(pResult, u64); @@ -4296,7 +4222,7 @@ static DECLCALLBACK(int) dbgcFuncReadU64(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, /** * @callback_method_impl{Reads a unsigned pointer-sized value.} */ -static DECLCALLBACK(int) dbgcFuncReadPtr(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs, +static DECLCALLBACK(int) dbgcFuncReadPtr(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs, PDBGCVAR pResult) { AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG); @@ -4305,15 +4231,15 @@ static DECLCALLBACK(int) dbgcFuncReadPtr(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, CPUMMODE enmMode = DBGCCmdHlpGetCpuMode(pCmdHlp); if (enmMode == CPUMMODE_LONG) - return dbgcFuncReadU64(pFunc, pCmdHlp, pVM, paArgs, cArgs, pResult); - return dbgcFuncReadU32(pFunc, pCmdHlp, pVM, paArgs, cArgs, pResult); + return dbgcFuncReadU64(pFunc, pCmdHlp, pUVM, paArgs, cArgs, pResult); + return dbgcFuncReadU32(pFunc, pCmdHlp, pUVM, paArgs, cArgs, pResult); } /** * @callback_method_impl{The hi(value) function implementation.} */ -static DECLCALLBACK(int) dbgcFuncHi(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs, +static DECLCALLBACK(int) dbgcFuncHi(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs, PDBGCVAR pResult) { AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG); @@ -4333,7 +4259,7 @@ static DECLCALLBACK(int) dbgcFuncHi(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM p DBGCVAR_INIT_NUMBER(pResult, uHi); DBGCVAR_SET_RANGE(pResult, paArgs[0].enmRangeType, paArgs[0].u64Range); - NOREF(pFunc); NOREF(pCmdHlp); NOREF(pVM); + NOREF(pFunc); NOREF(pCmdHlp); NOREF(pUVM); return VINF_SUCCESS; } @@ -4341,7 +4267,7 @@ static DECLCALLBACK(int) dbgcFuncHi(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM p /** * @callback_method_impl{The low(value) function implementation.} */ -static DECLCALLBACK(int) dbgcFuncLow(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs, +static DECLCALLBACK(int) dbgcFuncLow(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs, PDBGCVAR pResult) { AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG); @@ -4361,7 +4287,7 @@ static DECLCALLBACK(int) dbgcFuncLow(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM DBGCVAR_INIT_NUMBER(pResult, uLow); DBGCVAR_SET_RANGE(pResult, paArgs[0].enmRangeType, paArgs[0].u64Range); - NOREF(pFunc); NOREF(pCmdHlp); NOREF(pVM); + NOREF(pFunc); NOREF(pCmdHlp); NOREF(pUVM); return VINF_SUCCESS; } @@ -4369,11 +4295,11 @@ static DECLCALLBACK(int) dbgcFuncLow(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM /** * @callback_method_impl{The low(value) function implementation.} */ -static DECLCALLBACK(int) dbgcFuncNot(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs, +static DECLCALLBACK(int) dbgcFuncNot(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs, PDBGCVAR pResult) { AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG); - NOREF(pFunc); NOREF(pCmdHlp); NOREF(pVM); + NOREF(pFunc); NOREF(pCmdHlp); NOREF(pUVM); return DBGCCmdHlpEval(pCmdHlp, pResult, "!(%Dv)", &paArgs[0]); } diff --git a/src/VBox/Debugger/DBGCEval.cpp b/src/VBox/Debugger/DBGCEval.cpp index 334c5060..4bd07403 100644 --- a/src/VBox/Debugger/DBGCEval.cpp +++ b/src/VBox/Debugger/DBGCEval.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2012 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -433,7 +433,7 @@ static int dbgcEvalSubCall(PDBGC pDbgc, char *pszFuncNm, size_t cchFuncNm, bool pFunc->cArgsMin, pFunc->cArgsMax, pFunc->paArgDescs, pFunc->cArgDescs, pszArgs, &iArg, &cArgs); if (RT_SUCCESS(rc)) - rc = pFunc->pfnHandler(pFunc, &pDbgc->CmdHlp, pDbgc->pVM, &pDbgc->aArgs[iArg], cArgs, pResult); + rc = pFunc->pfnHandler(pFunc, &pDbgc->CmdHlp, pDbgc->pUVM, &pDbgc->aArgs[iArg], cArgs, pResult); pDbgc->iArg = iArg; return rc; } @@ -1370,7 +1370,7 @@ int dbgcEvalCommand(PDBGC pDbgc, char *pszCmd, size_t cchCmd, bool fNoExecute) * Execute the command. */ if (!fNoExecute) - rc = pCmd->pfnHandler(pCmd, &pDbgc->CmdHlp, pDbgc->pVM, &pDbgc->aArgs[iArg], cArgs); + rc = pCmd->pfnHandler(pCmd, &pDbgc->CmdHlp, pDbgc->pUVM, &pDbgc->aArgs[iArg], cArgs); pDbgc->rcCmd = rc; pDbgc->iArg = iArg; if (rc == VERR_DBGC_COMMAND_FAILED) diff --git a/src/VBox/Debugger/DBGCFunctions.cpp b/src/VBox/Debugger/DBGCFunctions.cpp index dbfa0b2d..62a6fb38 100644 --- a/src/VBox/Debugger/DBGCFunctions.cpp +++ b/src/VBox/Debugger/DBGCFunctions.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2012 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -44,13 +44,13 @@ static PDBGCEXTFUNCS g_pExtFuncsHead; /** * @callback_method_impl{The randu32() function implementation.} */ -static DECLCALLBACK(int) dbgcFuncRandU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs, +static DECLCALLBACK(int) dbgcFuncRandU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs, PDBGCVAR pResult) { AssertReturn(cArgs == 0, VERR_DBGC_PARSE_BUG); uint32_t u32 = RTRandU32(); DBGCVAR_INIT_NUMBER(pResult, u32); - NOREF(pFunc); NOREF(pCmdHlp); NOREF(pVM); NOREF(paArgs); + NOREF(pFunc); NOREF(pCmdHlp); NOREF(pUVM); NOREF(paArgs); return VINF_SUCCESS; } diff --git a/src/VBox/Debugger/DBGCInternal.h b/src/VBox/Debugger/DBGCInternal.h index a7a0f6a9..46f7b713 100644 --- a/src/VBox/Debugger/DBGCInternal.h +++ b/src/VBox/Debugger/DBGCInternal.h @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2011 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -111,6 +111,8 @@ typedef struct DBGC /** Pointer to the current VM. */ PVM pVM; + /** The user mode handle of the current VM. */ + PUVM pUVM; /** The ID of current virtual CPU. */ VMCPUID idCpu; /** The current address space handle. */ @@ -137,6 +139,8 @@ typedef struct DBGC /** Current disassembler position. */ DBGCVAR DisasmPos; + /** The flags that goes with DisasmPos. */ + uint32_t fDisasm; /** Current source position. (flat GC) */ DBGCVAR SourcePos; /** Current memory dump position. */ diff --git a/src/VBox/Debugger/DBGCOps.cpp b/src/VBox/Debugger/DBGCOps.cpp index ea9ce5a7..6abe515e 100644 --- a/src/VBox/Debugger/DBGCOps.cpp +++ b/src/VBox/Debugger/DBGCOps.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2011 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -455,13 +455,22 @@ DECLCALLBACK(int) dbgcOpRegister(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, LogFlow(("dbgcOpRegister: %s\n", pArg->u.pszString)); AssertReturn(pArg->enmType == DBGCVAR_TYPE_SYMBOL, VERR_DBGC_PARSE_BUG); + /* Detect references to hypervisor registers. */ + const char *pszReg = pArg->u.pszString; + VMCPUID idCpu = pDbgc->idCpu; + if (pszReg[0] == '.') + { + pszReg++; + idCpu |= DBGFREG_HYPER_VMCPUID; + } + /* * If the desired result is a symbol, pass the argument along unmodified. * This is a great help for "r @eax" and such, since it will be translated to "r eax". */ if (enmCat == DBGCVAR_CAT_SYMBOL) { - int rc = DBGFR3RegNmValidate(pDbgc->pVM, pDbgc->idCpu, pArg->u.pszString); + int rc = DBGFR3RegNmValidate(pDbgc->pUVM, idCpu, pszReg); if (RT_SUCCESS(rc)) DBGCVAR_INIT_STRING(pResult, pArg->u.pszString); return rc; @@ -472,7 +481,7 @@ DECLCALLBACK(int) dbgcOpRegister(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, */ DBGFREGVALTYPE enmType; DBGFREGVAL Value; - int rc = DBGFR3RegNmQuery(pDbgc->pVM, pDbgc->idCpu, pArg->u.pszString, &Value, &enmType); + int rc = DBGFR3RegNmQuery(pDbgc->pUVM, idCpu, pszReg, &Value, &enmType); if (RT_SUCCESS(rc)) { switch (enmType) diff --git a/src/VBox/Debugger/DBGCTcp.cpp b/src/VBox/Debugger/DBGCTcp.cpp index 58ce10a2..6e18e408 100644 --- a/src/VBox/Debugger/DBGCTcp.cpp +++ b/src/VBox/Debugger/DBGCTcp.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2011 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -184,7 +184,7 @@ static DECLCALLBACK(void) dbgcTcpBackSetReady(PDBGCBACK pBack, bool fBusy) * The call will close this socket. * @param pvUser The VM handle. */ -static int dbgcTcpConnection(RTSOCKET Sock, void *pvUser) +static DECLCALLBACK(int) dbgcTcpConnection(RTSOCKET Sock, void *pvUser) { LogFlow(("dbgcTcpConnection: connection! Sock=%d pvUser=%p\n", Sock, pvUser)); @@ -198,7 +198,7 @@ static int dbgcTcpConnection(RTSOCKET Sock, void *pvUser) DbgcTcp.Back.pfnSetReady = dbgcTcpBackSetReady; DbgcTcp.fAlive = true; DbgcTcp.Sock = Sock; - int rc = DBGCCreate((PVM)pvUser, &DbgcTcp.Back, 0); + int rc = DBGCCreate((PUVM)pvUser, &DbgcTcp.Back, 0); LogFlow(("dbgcTcpConnection: disconnect rc=%Rrc\n", rc)); return rc; } @@ -208,15 +208,15 @@ static int dbgcTcpConnection(RTSOCKET Sock, void *pvUser) * Spawns a new thread with a TCP based debugging console service. * * @returns VBox status. - * @param pVM VM handle. + * @param pUVM The user mode VM handle. * @param ppvData Where to store a pointer to the instance data. */ -DBGDECL(int) DBGCTcpCreate(PVM pVM, void **ppvData) +DBGDECL(int) DBGCTcpCreate(PUVM pUVM, void **ppvData) { /* * Check what the configuration says. */ - PCFGMNODE pKey = CFGMR3GetChild(CFGMR3GetRoot(pVM), "DBGC"); + PCFGMNODE pKey = CFGMR3GetChild(CFGMR3GetRootU(pUVM), "DBGC"); bool fEnabled; int rc = CFGMR3QueryBoolDef(pKey, "Enabled", &fEnabled, #if defined(VBOX_WITH_DEBUGGER) && defined(VBOX_WITH_DEBUGGER_TCP_BY_DEFAULT) && !defined(__L4ENV__) && !defined(DEBUG_dmik) @@ -226,7 +226,7 @@ DBGDECL(int) DBGCTcpCreate(PVM pVM, void **ppvData) #endif ); if (RT_FAILURE(rc)) - return VM_SET_ERROR(pVM, rc, "Configuration error: Failed querying \"DBGC/Enabled\""); + return VM_SET_ERROR_U(pUVM, rc, "Configuration error: Failed querying \"DBGC/Enabled\""); if (!fEnabled) { @@ -240,7 +240,7 @@ DBGDECL(int) DBGCTcpCreate(PVM pVM, void **ppvData) uint32_t u32Port; rc = CFGMR3QueryU32Def(pKey, "Port", &u32Port, 5000); if (RT_FAILURE(rc)) - return VM_SET_ERROR(pVM, rc, "Configuration error: Failed querying \"DBGC/Port\""); + return VM_SET_ERROR_U(pUVM, rc, "Configuration error: Failed querying \"DBGC/Port\""); /* * Get the address configuration. @@ -248,13 +248,13 @@ DBGDECL(int) DBGCTcpCreate(PVM pVM, void **ppvData) char szAddress[512]; rc = CFGMR3QueryStringDef(pKey, "Address", szAddress, sizeof(szAddress), ""); if (RT_FAILURE(rc)) - return VM_SET_ERROR(pVM, rc, "Configuration error: Failed querying \"DBGC/Address\""); + return VM_SET_ERROR_U(pUVM, rc, "Configuration error: Failed querying \"DBGC/Address\""); /* * Create the server (separate thread). */ PRTTCPSERVER pServer; - rc = RTTcpServerCreate(szAddress, u32Port, RTTHREADTYPE_DEBUGGER, "DBGC", dbgcTcpConnection, pVM, &pServer); + rc = RTTcpServerCreate(szAddress, u32Port, RTTHREADTYPE_DEBUGGER, "DBGC", dbgcTcpConnection, pUVM, &pServer); if (RT_SUCCESS(rc)) { LogFlow(("DBGCTcpCreate: Created server on port %d %s\n", u32Port, szAddress)); @@ -263,7 +263,7 @@ DBGDECL(int) DBGCTcpCreate(PVM pVM, void **ppvData) } LogFlow(("DBGCTcpCreate: returns %Rrc\n", rc)); - return VM_SET_ERROR(pVM, rc, "Cannot start TCP-based debugging console service"); + return VM_SET_ERROR_U(pUVM, rc, "Cannot start TCP-based debugging console service"); } @@ -271,9 +271,10 @@ DBGDECL(int) DBGCTcpCreate(PVM pVM, void **ppvData) * Terminates any running TCP base debugger console service. * * @returns VBox status. - * @param pVM VM handle. + * @param pUVM The user mode VM handle. + * @param pvData The data returned by DBGCTcpCreate. */ -DBGDECL(int) DBGCTcpTerminate(PVM pVM, void *pvData) +DBGDECL(int) DBGCTcpTerminate(PUVM pUVM, void *pvData) { /* * Destroy the server instance if any. diff --git a/src/VBox/Debugger/DBGConsole.cpp b/src/VBox/Debugger/DBGConsole.cpp index 0787dcf1..07848550 100644 --- a/src/VBox/Debugger/DBGConsole.cpp +++ b/src/VBox/Debugger/DBGConsole.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2011 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -161,6 +161,8 @@ #define LOG_GROUP LOG_GROUP_DBGC #include <VBox/dbg.h> #include <VBox/vmm/dbgf.h> +#include <VBox/vmm/vmapi.h> /* VMR3GetVM() */ +#include <VBox/vmm/hm.h> /* HMR3IsEnabled */ #include <VBox/err.h> #include <VBox/log.h> @@ -234,10 +236,11 @@ int dbgcSymbolGet(PDBGC pDbgc, const char *pszSymbol, DBGCVARTYPE enmType, PDBGC "sp;" "ss;" "ip;" ; - size_t const cchSymbol = strlen(pszSymbol); - if ( (cchSymbol == 2 && strstr(s_szTwoLetterRegisters, pszSymbol)) - || (cchSymbol == 3 && strstr(s_szThreeLetterRegisters, pszSymbol)) - || (cchSymbol == 6 && strstr(s_szSixLetterRegisters, pszSymbol))) + const char *pszRegSym = *pszSymbol == '.' ? pszSymbol + 1 : pszSymbol; + size_t const cchRegSym = strlen(pszRegSym); + if ( (cchRegSym == 2 && strstr(s_szTwoLetterRegisters, pszRegSym)) + || (cchRegSym == 3 && strstr(s_szThreeLetterRegisters, pszRegSym)) + || (cchRegSym == 6 && strstr(s_szSixLetterRegisters, pszRegSym))) { if (!strchr(pszSymbol, ';')) { @@ -258,7 +261,7 @@ int dbgcSymbolGet(PDBGC pDbgc, const char *pszSymbol, DBGCVARTYPE enmType, PDBGC * Ask the debug info manager. */ RTDBGSYMBOL Symbol; - rc = DBGFR3AsSymbolByName(pDbgc->pVM, pDbgc->hDbgAs, pszSymbol, &Symbol, NULL); + rc = DBGFR3AsSymbolByName(pDbgc->pUVM, pDbgc->hDbgAs, pszSymbol, &Symbol, NULL); if (RT_SUCCESS(rc)) { /* @@ -579,7 +582,7 @@ static const char *dbgcGetEventCtx(DBGFEVENTCTX enmCtx) { case DBGFEVENTCTX_RAW: return "raw"; case DBGFEVENTCTX_REM: return "rem"; - case DBGFEVENTCTX_HWACCL: return "hwaccl"; + case DBGFEVENTCTX_HM: return "hwaccl"; case DBGFEVENTCTX_HYPER: return "hyper"; case DBGFEVENTCTX_OTHER: return "other"; @@ -673,7 +676,7 @@ static int dbgcProcessEvent(PDBGC pDbgc, PCDBGFEVENT pEvent) default: break; } - if (RT_SUCCESS(rc) && DBGFR3IsHalted(pDbgc->pVM)) + if (RT_SUCCESS(rc) && DBGFR3IsHalted(pDbgc->pUVM)) rc = pDbgc->CmdHlp.pfnExec(&pDbgc->CmdHlp, "r"); else pDbgc->fRegCtxGuest = fRegCtxGuest; @@ -736,11 +739,11 @@ static int dbgcProcessEvent(PDBGC pDbgc, PCDBGFEVENT pEvent) break; } - case DBGFEVENT_TERMINATING: + case DBGFEVENT_POWERING_OFF: { pDbgc->fReady = false; pDbgc->pBack->pfnSetReady(pDbgc->pBack, false); - pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\nVM is terminating!\n"); + pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\nVM is powering off!\n"); fPrintPrompt = false; rc = VERR_GENERAL_FAILURE; break; @@ -784,6 +787,15 @@ static int dbgcProcessLog(PDBGC pDbgc) return 0; } +/** @callback_method_impl{FNRTDBGCFGLOG} */ +static DECLCALLBACK(void) dbgcDbgCfgLogCallback(RTDBGCFG hDbgCfg, uint32_t iLevel, const char *pszMsg, void *pvUser) +{ + /** @todo Add symbol noise setting. */ + NOREF(hDbgCfg); NOREF(iLevel); + PDBGC pDbgc = (PDBGC)pvUser; + pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%s", pszMsg); +} + /** * Run the debugger console. @@ -806,17 +818,20 @@ int dbgcRun(PDBGC pDbgc) * debug events. If we're forwarding the log we cannot wait for long * before we must flush the log. */ - int rc = VINF_SUCCESS; + int rc; for (;;) { - if ( pDbgc->pVM - && DBGFR3CanWait(pDbgc->pVM)) + rc = VERR_SEM_OUT_OF_TURN; + if (pDbgc->pUVM) + rc = DBGFR3QueryWaitable(pDbgc->pUVM); + + if (RT_SUCCESS(rc)) { /* * Wait for a debug event. */ PCDBGFEVENT pEvent; - rc = DBGFR3EventWait(pDbgc->pVM, pDbgc->fLog ? 1 : 32, &pEvent); + rc = DBGFR3EventWait(pDbgc->pUVM, pDbgc->fLog ? 1 : 32, &pEvent); if (RT_SUCCESS(rc)) { rc = dbgcProcessEvent(pDbgc, pEvent); @@ -836,7 +851,7 @@ int dbgcRun(PDBGC pDbgc) break; } } - else + else if (rc == VERR_SEM_OUT_OF_TURN) { /* * Wait for input. If Logging is enabled we'll only wait very briefly. @@ -848,6 +863,8 @@ int dbgcRun(PDBGC pDbgc) break; } } + else + break; /* * Forward log output. @@ -890,6 +907,7 @@ int dbgcCreate(PDBGC *ppDbgc, PDBGCBACK pBack, unsigned fFlags) dbgcInitCmdHlp(pDbgc); pDbgc->pBack = pBack; pDbgc->pVM = NULL; + pDbgc->pUVM = NULL; pDbgc->idCpu = 0; pDbgc->hDbgAs = DBGF_AS_GLOBAL; pDbgc->pszEmulation = "CodeView/WinDbg"; @@ -953,8 +971,8 @@ void dbgcDestroy(PDBGC pDbgc) dbgcPlugInUnloadAll(pDbgc); /* Detach from the VM. */ - if (pDbgc->pVM) - DBGFR3Detach(pDbgc->pVM); + if (pDbgc->pUVM) + DBGFR3Detach(pDbgc->pUVM); /* finally, free the instance memory. */ RTMemFree(pDbgc); @@ -970,19 +988,25 @@ void dbgcDestroy(PDBGC pDbgc) * @returns VINF_SUCCESS if console termination caused by the 'exit' command. * @returns The VBox status code causing the console termination. * - * @param pVM VM Handle. + * @param pUVM The user mode VM handle. * @param pBack Pointer to the backend structure. This must contain * a full set of function pointers to service the console. * @param fFlags Reserved, must be zero. * @remark A forced termination of the console is easiest done by forcing the * callbacks to return fatal failures. */ -DBGDECL(int) DBGCCreate(PVM pVM, PDBGCBACK pBack, unsigned fFlags) +DBGDECL(int) DBGCCreate(PUVM pUVM, PDBGCBACK pBack, unsigned fFlags) { /* * Validate input. */ - AssertPtrNullReturn(pVM, VERR_INVALID_POINTER); + AssertPtrNullReturn(pUVM, VERR_INVALID_VM_HANDLE); + PVM pVM = NULL; + if (pUVM) + { + pVM = VMR3GetVM(pUVM); + AssertPtrReturn(pVM, VERR_INVALID_VM_HANDLE); + } /* * Allocate and initialize instance data @@ -991,6 +1015,8 @@ DBGDECL(int) DBGCCreate(PVM pVM, PDBGCBACK pBack, unsigned fFlags) int rc = dbgcCreate(&pDbgc, pBack, fFlags); if (RT_FAILURE(rc)) return rc; + if (!HMR3IsEnabled(pUVM)) + pDbgc->hDbgAs = DBGF_AS_RC_AND_GC_GLOBAL; /* * Print welcome message. @@ -1001,12 +1027,13 @@ DBGDECL(int) DBGCCreate(PVM pVM, PDBGCBACK pBack, unsigned fFlags) /* * Attach to the specified VM. */ - if (RT_SUCCESS(rc) && pVM) + if (RT_SUCCESS(rc) && pUVM) { - rc = DBGFR3Attach(pVM); + rc = DBGFR3Attach(pUVM); if (RT_SUCCESS(rc)) { pDbgc->pVM = pVM; + pDbgc->pUVM = pUVM; pDbgc->idCpu = 0; rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "Current VM is %08x, CPU #%u\n" /** @todo get and print the VM name! */ @@ -1024,15 +1051,45 @@ DBGDECL(int) DBGCCreate(PVM pVM, PDBGCBACK pBack, unsigned fFlags) if (pVM) dbgcPlugInAutoLoad(pDbgc); rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "VBoxDbg> "); + if (RT_SUCCESS(rc)) + { + /* + * Set debug config log callback. + */ + RTDBGCFG hDbgCfg = DBGFR3AsGetConfig(pUVM); + if ( hDbgCfg != NIL_RTDBGCFG + && RTDbgCfgRetain(hDbgCfg) != UINT32_MAX) + { + int rc2 = RTDbgCfgSetLogCallback(hDbgCfg, dbgcDbgCfgLogCallback, pDbgc); + if (RT_FAILURE(rc2)) + { + hDbgCfg = NIL_RTDBGCFG; + RTDbgCfgRelease(hDbgCfg); + } + } + else + hDbgCfg = NIL_RTDBGCFG; + + + /* + * Run the debugger main loop. + */ + rc = dbgcRun(pDbgc); + + + /* + * Remove debug config log callback. + */ + if (hDbgCfg != NIL_RTDBGCFG) + { + RTDbgCfgSetLogCallback(hDbgCfg, NULL, NULL); + RTDbgCfgRelease(hDbgCfg); + } + } } else pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\nDBGCCreate error: %Rrc\n", rc); - /* - * Run the debugger main loop. - */ - if (RT_SUCCESS(rc)) - rc = dbgcRun(pDbgc); /* * Cleanup console debugger session. diff --git a/src/VBox/Debugger/DBGPlugInCommonELF.h b/src/VBox/Debugger/DBGPlugInCommonELF.h index 5590d45a..0ef190ca 100644 --- a/src/VBox/Debugger/DBGPlugInCommonELF.h +++ b/src/VBox/Debugger/DBGPlugInCommonELF.h @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2008-2010 Oracle Corporation + * Copyright (C) 2008-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -34,13 +34,13 @@ #define DBG_DIGGER_ELF_MASK UINT32_C(0x00000003) /* @} */ -int DBGDiggerCommonParseElf32Mod(PVM pVM, const char *pszModName, const char *pszFilename, uint32_t fFlags, +int DBGDiggerCommonParseElf32Mod(PUVM pUVM, const char *pszModName, const char *pszFilename, uint32_t fFlags, Elf32_Ehdr const *pEhdr, Elf32_Shdr const *paShdrs, Elf32_Sym const *paSyms, size_t cMaxSyms, char const *pbStrings, size_t cbMaxStrings, RTGCPTR MinAddr, RTGCPTR MaxAddr, uint64_t uModTag); -int DBGDiggerCommonParseElf64Mod(PVM pVM, const char *pszModName, const char *pszFilename, uint32_t fFlags, +int DBGDiggerCommonParseElf64Mod(PUVM pUVM, const char *pszModName, const char *pszFilename, uint32_t fFlags, Elf64_Ehdr const *pEhdr, Elf64_Shdr const *paShdrs, Elf64_Sym const *paSyms, size_t cMaxSyms, char const *pbStrings, size_t cbMaxStrings, diff --git a/src/VBox/Debugger/DBGPlugInCommonELFTmpl.cpp.h b/src/VBox/Debugger/DBGPlugInCommonELFTmpl.cpp.h index 52419f35..31c8f7ad 100644 --- a/src/VBox/Debugger/DBGPlugInCommonELFTmpl.cpp.h +++ b/src/VBox/Debugger/DBGPlugInCommonELFTmpl.cpp.h @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2008-2010 Oracle Corporation + * Copyright (C) 2008-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -43,7 +43,7 @@ * * @returns VBox status code. * - * @param pVM The VM handle. + * @param pUVM The user mode VM handle. * @param pszModName The module name. * @param pszFilename The filename. optional. * @param fFlags Flags. @@ -68,13 +68,13 @@ * sanity checks.. * @param uModTag Module tag. Pass 0 if tagging is of no interest. */ -int DBGDiggerCommonParseElfMod(PVM pVM, const char *pszModName, const char *pszFilename, uint32_t fFlags, +int DBGDiggerCommonParseElfMod(PUVM pUVM, const char *pszModName, const char *pszFilename, uint32_t fFlags, Elf_Ehdr const *pEhdr, Elf_Shdr const *paShdrs, Elf_Sym const *paSyms, size_t cMaxSyms, char const *pbStrings, size_t cbMaxStrings, RTGCPTR MinAddr, RTGCPTR MaxAddr, uint64_t uModTag) { - AssertPtrReturn(pVM, VERR_INVALID_POINTER); + AssertPtrReturn(pUVM, VERR_INVALID_POINTER); AssertPtrReturn(pszModName, VERR_INVALID_POINTER); AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); AssertReturn(!(fFlags & ~DBG_DIGGER_ELF_MASK), VERR_INVALID_PARAMETER); @@ -239,7 +239,7 @@ int DBGDiggerCommonParseElfMod(PVM pVM, const char *pszModName, const char *pszF if (paSegs[i].uLastAddr != 0) { char szSeg[32]; - RTStrPrintf(szSeg, sizeof(szSeg), "sec%02", i); + RTStrPrintf(szSeg, sizeof(szSeg), "sec%02u", i); RTGCPTR cbSeg = paSegs[i].uLastAddr - paSegs[i].uLoadAddr + 1; rc = RTDbgModSegmentAdd(hMod, uRvaNext, cbSeg, szSeg, 0 /*fFlags*/, &paSegs[i].iSeg); if (RT_FAILURE(rc)) @@ -255,7 +255,7 @@ int DBGDiggerCommonParseElfMod(PVM pVM, const char *pszModName, const char *pszF if (paShdrs[i].sh_flags & SHF_ALLOC) { char szSeg[32]; - RTStrPrintf(szSeg, sizeof(szSeg), "sec%02", i); + RTStrPrintf(szSeg, sizeof(szSeg), "sec%02u", i); rc = RTDbgModSegmentAdd(hMod, paShdrs[i].sh_addr - uLoadAddr, paShdrs[i].sh_size, szSeg, 0 /*fFlags*/, &paSegs[i].iSeg); if (RT_FAILURE(rc)) break; @@ -315,7 +315,7 @@ int DBGDiggerCommonParseElfMod(PVM pVM, const char *pszModName, const char *pszF /* * Link it into the address space. */ - RTDBGAS hAs = DBGFR3AsResolveAndRetain(pVM, DBGF_AS_KERNEL); + RTDBGAS hAs = DBGFR3AsResolveAndRetain(pUVM, DBGF_AS_KERNEL); if (hAs != NIL_RTDBGAS) rc = dbgDiggerCommonLinkElfSegs(hAs, hMod, paSegs, cSegs); else diff --git a/src/VBox/Debugger/DBGPlugInDiggers.cpp b/src/VBox/Debugger/DBGPlugInDiggers.cpp index 83839102..0622431e 100644 --- a/src/VBox/Debugger/DBGPlugInDiggers.cpp +++ b/src/VBox/Debugger/DBGPlugInDiggers.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -27,7 +27,7 @@ #include <VBox/err.h> -DECLEXPORT(int) DBGCPlugInEntry(DBGCPLUGINOP enmOperation, PVM pVM, uintptr_t uArg) +DECLEXPORT(int) DBGCPlugInEntry(DBGCPLUGINOP enmOperation, PUVM pUVM, uintptr_t uArg) { static PCDBGFOSREG s_aPlugIns[] = { @@ -47,12 +47,12 @@ DECLEXPORT(int) DBGCPlugInEntry(DBGCPLUGINOP enmOperation, PVM pVM, uintptr_t uA for (unsigned i = 0; i < RT_ELEMENTS(s_aPlugIns); i++) { - int rc = DBGFR3OSRegister(pVM, s_aPlugIns[i]); + int rc = DBGFR3OSRegister(pUVM, s_aPlugIns[i]); if (RT_FAILURE(rc)) { AssertRC(rc); while (i-- > 0) - DBGFR3OSDeregister(pVM, s_aPlugIns[i]); + DBGFR3OSDeregister(pUVM, s_aPlugIns[i]); return rc; } } @@ -63,7 +63,7 @@ DECLEXPORT(int) DBGCPlugInEntry(DBGCPLUGINOP enmOperation, PVM pVM, uintptr_t uA { for (unsigned i = 0; i < RT_ELEMENTS(s_aPlugIns); i++) { - int rc = DBGFR3OSDeregister(pVM, s_aPlugIns[i]); + int rc = DBGFR3OSDeregister(pUVM, s_aPlugIns[i]); AssertRC(rc); } return VINF_SUCCESS; diff --git a/src/VBox/Debugger/DBGPlugInLinux.cpp b/src/VBox/Debugger/DBGPlugInLinux.cpp index 07fa9648..bbe5df34 100644 --- a/src/VBox/Debugger/DBGPlugInLinux.cpp +++ b/src/VBox/Debugger/DBGPlugInLinux.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2008-2010 Oracle Corporation + * Copyright (C) 2008-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -73,7 +73,7 @@ typedef DBGDIGGERLINUX *PDBGDIGGERLINUX; /******************************************************************************* * Internal Functions * *******************************************************************************/ -static DECLCALLBACK(int) dbgDiggerLinuxInit(PVM pVM, void *pvData); +static DECLCALLBACK(int) dbgDiggerLinuxInit(PUVM pUVM, void *pvData); /******************************************************************************* @@ -91,7 +91,7 @@ static uint64_t g_au64LnxKernelAddresses[] = /** * @copydoc DBGFOSREG::pfnQueryInterface */ -static DECLCALLBACK(void *) dbgDiggerLinuxQueryInterface(PVM pVM, void *pvData, DBGFOSINTERFACE enmIf) +static DECLCALLBACK(void *) dbgDiggerLinuxQueryInterface(PUVM pUVM, void *pvData, DBGFOSINTERFACE enmIf) { return NULL; } @@ -100,7 +100,7 @@ static DECLCALLBACK(void *) dbgDiggerLinuxQueryInterface(PVM pVM, void *pvData, /** * @copydoc DBGFOSREG::pfnQueryVersion */ -static DECLCALLBACK(int) dbgDiggerLinuxQueryVersion(PVM pVM, void *pvData, char *pszVersion, size_t cchVersion) +static DECLCALLBACK(int) dbgDiggerLinuxQueryVersion(PUVM pUVM, void *pvData, char *pszVersion, size_t cchVersion) { PDBGDIGGERLINUX pThis = (PDBGDIGGERLINUX)pvData; Assert(pThis->fValid); @@ -108,7 +108,7 @@ static DECLCALLBACK(int) dbgDiggerLinuxQueryVersion(PVM pVM, void *pvData, char /* * It's all in the linux banner. */ - int rc = DBGFR3MemReadString(pVM, 0, &pThis->AddrLinuxBanner, pszVersion, cchVersion); + int rc = DBGFR3MemReadString(pUVM, 0, &pThis->AddrLinuxBanner, pszVersion, cchVersion); if (RT_SUCCESS(rc)) { char *pszEnd = RTStrEnd(pszVersion, cchVersion); @@ -128,7 +128,7 @@ static DECLCALLBACK(int) dbgDiggerLinuxQueryVersion(PVM pVM, void *pvData, char /** * @copydoc DBGFOSREG::pfnTerm */ -static DECLCALLBACK(void) dbgDiggerLinuxTerm(PVM pVM, void *pvData) +static DECLCALLBACK(void) dbgDiggerLinuxTerm(PUVM pUVM, void *pvData) { PDBGDIGGERLINUX pThis = (PDBGDIGGERLINUX)pvData; Assert(pThis->fValid); @@ -140,7 +140,7 @@ static DECLCALLBACK(void) dbgDiggerLinuxTerm(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnRefresh */ -static DECLCALLBACK(int) dbgDiggerLinuxRefresh(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerLinuxRefresh(PUVM pUVM, void *pvData) { PDBGDIGGERLINUX pThis = (PDBGDIGGERLINUX)pvData; NOREF(pThis); @@ -149,15 +149,15 @@ static DECLCALLBACK(int) dbgDiggerLinuxRefresh(PVM pVM, void *pvData) /* * For now we'll flush and reload everything. */ - dbgDiggerLinuxTerm(pVM, pvData); - return dbgDiggerLinuxInit(pVM, pvData); + dbgDiggerLinuxTerm(pUVM, pvData); + return dbgDiggerLinuxInit(pUVM, pvData); } /** * @copydoc DBGFOSREG::pfnInit */ -static DECLCALLBACK(int) dbgDiggerLinuxInit(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerLinuxInit(PUVM pUVM, void *pvData) { PDBGDIGGERLINUX pThis = (PDBGDIGGERLINUX)pvData; Assert(!pThis->fValid); @@ -182,7 +182,7 @@ static DECLCALLBACK(int) dbgDiggerLinuxInit(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnProbe */ -static DECLCALLBACK(bool) dbgDiggerLinuxProbe(PVM pVM, void *pvData) +static DECLCALLBACK(bool) dbgDiggerLinuxProbe(PUVM pUVM, void *pvData) { PDBGDIGGERLINUX pThis = (PDBGDIGGERLINUX)pvData; @@ -195,16 +195,16 @@ static DECLCALLBACK(bool) dbgDiggerLinuxProbe(PVM pVM, void *pvData) for (unsigned i = 0; i < RT_ELEMENTS(g_au64LnxKernelAddresses); i++) { DBGFADDRESS KernelAddr; - DBGFR3AddrFromFlat(pVM, &KernelAddr, g_au64LnxKernelAddresses[i]); + DBGFR3AddrFromFlat(pUVM, &KernelAddr, g_au64LnxKernelAddresses[i]); DBGFADDRESS HitAddr; - static const uint8_t s_abLinuxVersion[] = "Linux version 2."; - int rc = DBGFR3MemScan(pVM, 0, &KernelAddr, LNX_MAX_KERNEL_SIZE, 1, - s_abLinuxVersion, sizeof(s_abLinuxVersion) - 1, &HitAddr); + static const uint8_t s_abLinuxVersion2x[] = "Linux version 2."; + int rc = DBGFR3MemScan(pUVM, 0, &KernelAddr, LNX_MAX_KERNEL_SIZE, 1, + s_abLinuxVersion2x, sizeof(s_abLinuxVersion2x) - 1, &HitAddr); if (RT_SUCCESS(rc)) { char szTmp[128]; - char const *pszY = &szTmp[sizeof(s_abLinuxVersion) - 1]; - rc = DBGFR3MemReadString(pVM, 0, &HitAddr, szTmp, sizeof(szTmp)); + char const *pszY = &szTmp[sizeof(s_abLinuxVersion2x) - 1]; + rc = DBGFR3MemReadString(pUVM, 0, &HitAddr, szTmp, sizeof(szTmp)); if ( RT_SUCCESS(rc) && *pszY >= '0' && *pszY <= '6') @@ -214,6 +214,23 @@ static DECLCALLBACK(bool) dbgDiggerLinuxProbe(PVM pVM, void *pvData) return true; } } + static const uint8_t s_abLinuxVersion3x[] = "Linux version 3."; + rc = DBGFR3MemScan(pUVM, 0, &KernelAddr, LNX_MAX_KERNEL_SIZE, 1, + s_abLinuxVersion3x, sizeof(s_abLinuxVersion3x) - 1, &HitAddr); + if (RT_SUCCESS(rc)) + { + char szTmp[128]; + char const *pszY = &szTmp[sizeof(s_abLinuxVersion3x) - 1]; + rc = DBGFR3MemReadString(pUVM, 0, &HitAddr, szTmp, sizeof(szTmp)); + if ( RT_SUCCESS(rc) + && *pszY >= '0' + && *pszY <= '9') + { + pThis->AddrKernelBase = KernelAddr; + pThis->AddrLinuxBanner = HitAddr; + return true; + } + } } return false; } @@ -222,7 +239,7 @@ static DECLCALLBACK(bool) dbgDiggerLinuxProbe(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnDestruct */ -static DECLCALLBACK(void) dbgDiggerLinuxDestruct(PVM pVM, void *pvData) +static DECLCALLBACK(void) dbgDiggerLinuxDestruct(PUVM pUVM, void *pvData) { } @@ -231,7 +248,7 @@ static DECLCALLBACK(void) dbgDiggerLinuxDestruct(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnConstruct */ -static DECLCALLBACK(int) dbgDiggerLinuxConstruct(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerLinuxConstruct(PUVM pUVM, void *pvData) { return VINF_SUCCESS; } diff --git a/src/VBox/Debugger/DBGPlugInOS2.cpp b/src/VBox/Debugger/DBGPlugInOS2.cpp index 054b33e5..1fe576ea 100644 --- a/src/VBox/Debugger/DBGPlugInOS2.cpp +++ b/src/VBox/Debugger/DBGPlugInOS2.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2009-2012 Oracle Corporation + * Copyright (C) 2009-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -84,7 +84,7 @@ typedef DBGDIGGEROS2 *PDBGDIGGEROS2; /******************************************************************************* * Internal Functions * *******************************************************************************/ -static DECLCALLBACK(int) dbgDiggerOS2Init(PVM pVM, void *pvData); +static DECLCALLBACK(int) dbgDiggerOS2Init(PUVM pUVM, void *pvData); /******************************************************************************* @@ -95,16 +95,16 @@ static DECLCALLBACK(int) dbgDiggerOS2Init(PVM pVM, void *pvData); /** * Process a PE image found in guest memory. * - * @param pThis The instance data. - * @param pVM The VM handle. - * @param pszName The image name. - * @param pImageAddr The image address. - * @param cbImage The size of the image. - * @param pbBuf Scratch buffer containing the first - * RT_MIN(cbBuf, cbImage) bytes of the image. - * @param cbBuf The scratch buffer size. + * @param pThis The instance data. + * @param pUVM The user mode VM handle. + * @param pszName The image name. + * @param pImageAddr The image address. + * @param cbImage The size of the image. + * @param pbBuf Scratch buffer containing the first + * RT_MIN(cbBuf, cbImage) bytes of the image. + * @param cbBuf The scratch buffer size. */ -static void dbgDiggerOS2ProcessImage(PDBGDIGGEROS2 pThis, PVM pVM, const char *pszName, +static void dbgDiggerOS2ProcessImage(PDBGDIGGEROS2 pThis, PUVM pUVM, const char *pszName, PCDBGFADDRESS pImageAddr, uint32_t cbImage, uint8_t *pbBuf, size_t cbBuf) { @@ -117,7 +117,7 @@ static void dbgDiggerOS2ProcessImage(PDBGDIGGEROS2 pThis, PVM pVM, const char *p /** * @copydoc DBGFOSREG::pfnQueryInterface */ -static DECLCALLBACK(void *) dbgDiggerOS2QueryInterface(PVM pVM, void *pvData, DBGFOSINTERFACE enmIf) +static DECLCALLBACK(void *) dbgDiggerOS2QueryInterface(PUVM pUVM, void *pvData, DBGFOSINTERFACE enmIf) { return NULL; } @@ -126,7 +126,7 @@ static DECLCALLBACK(void *) dbgDiggerOS2QueryInterface(PVM pVM, void *pvData, DB /** * @copydoc DBGFOSREG::pfnQueryVersion */ -static DECLCALLBACK(int) dbgDiggerOS2QueryVersion(PVM pVM, void *pvData, char *pszVersion, size_t cchVersion) +static DECLCALLBACK(int) dbgDiggerOS2QueryVersion(PUVM pUVM, void *pvData, char *pszVersion, size_t cchVersion) { PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData; Assert(pThis->fValid); @@ -145,14 +145,14 @@ static DECLCALLBACK(int) dbgDiggerOS2QueryVersion(PVM pVM, void *pvData, char * RTStrPrintf(pszOS2ProductType, sizeof(achOS2ProductType), "OS/2 2.%02d", pThis->OS2MinorVersion); pThis->enmVer = DBGDIGGEROS2VER_2_x; } - else if (pThis->OS2MinorVersion < 40) + else if (pThis->OS2MinorVersion < 40) { - RTStrPrintf(pszOS2ProductType, sizeof(achOS2ProductType), "OS/2 Warp", pThis->OS2MinorVersion); + RTStrPrintf(pszOS2ProductType, sizeof(achOS2ProductType), "OS/2 Warp"); pThis->enmVer = DBGDIGGEROS2VER_3_0; } - else if (pThis->OS2MinorVersion == 40) + else if (pThis->OS2MinorVersion == 40) { - RTStrPrintf(pszOS2ProductType, sizeof(achOS2ProductType), "OS/2 Warp 4", pThis->OS2MinorVersion); + RTStrPrintf(pszOS2ProductType, sizeof(achOS2ProductType), "OS/2 Warp 4"); pThis->enmVer = DBGDIGGEROS2VER_4_0; } else @@ -170,7 +170,7 @@ static DECLCALLBACK(int) dbgDiggerOS2QueryVersion(PVM pVM, void *pvData, char * /** * @copydoc DBGFOSREG::pfnTerm */ -static DECLCALLBACK(void) dbgDiggerOS2Term(PVM pVM, void *pvData) +static DECLCALLBACK(void) dbgDiggerOS2Term(PUVM pUVM, void *pvData) { PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData; Assert(pThis->fValid); @@ -182,7 +182,7 @@ static DECLCALLBACK(void) dbgDiggerOS2Term(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnRefresh */ -static DECLCALLBACK(int) dbgDiggerOS2Refresh(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerOS2Refresh(PUVM pUVM, void *pvData) { PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData; NOREF(pThis); @@ -191,7 +191,7 @@ static DECLCALLBACK(int) dbgDiggerOS2Refresh(PVM pVM, void *pvData) /* * For now we'll flush and reload everything. */ - RTDBGAS hDbgAs = DBGFR3AsResolveAndRetain(pVM, DBGF_AS_KERNEL); + RTDBGAS hDbgAs = DBGFR3AsResolveAndRetain(pUVM, DBGF_AS_KERNEL); if (hDbgAs != NIL_RTDBGAS) { uint32_t iMod = RTDbgAsModuleCount(hDbgAs); @@ -211,15 +211,15 @@ static DECLCALLBACK(int) dbgDiggerOS2Refresh(PVM pVM, void *pvData) RTDbgAsRelease(hDbgAs); } - dbgDiggerOS2Term(pVM, pvData); - return dbgDiggerOS2Init(pVM, pvData); + dbgDiggerOS2Term(pUVM, pvData); + return dbgDiggerOS2Init(pUVM, pvData); } /** * @copydoc DBGFOSREG::pfnInit */ -static DECLCALLBACK(int) dbgDiggerOS2Init(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerOS2Init(PUVM pUVM, void *pvData) { PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData; Assert(!pThis->fValid); @@ -239,10 +239,10 @@ static DECLCALLBACK(int) dbgDiggerOS2Init(PVM pVM, void *pvData) */ do { /* Version info is at GIS:15h (major/minor/revision). */ - rc = DBGFR3AddrFromSelOff(pVM, 0 /*idCpu*/, &Addr, pThis->selGIS, 0x15); + rc = DBGFR3AddrFromSelOff(pUVM, 0 /*idCpu*/, &Addr, pThis->selGIS, 0x15); if (RT_FAILURE(rc)) break; - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, &Addr, u.au32, sizeof(uint32_t)); + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, &Addr, u.au32, sizeof(uint32_t)); if (RT_FAILURE(rc)) break; @@ -259,7 +259,7 @@ static DECLCALLBACK(int) dbgDiggerOS2Init(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnProbe */ -static DECLCALLBACK(bool) dbgDiggerOS2Probe(PVM pVM, void *pvData) +static DECLCALLBACK(bool) dbgDiggerOS2Probe(PUVM pUVM, void *pvData) { PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData; DBGFADDRESS Addr; @@ -273,24 +273,24 @@ static DECLCALLBACK(bool) dbgDiggerOS2Probe(PVM pVM, void *pvData) RTUTF16 wsz[8192/2]; } u; - /* + /* * If the DWORD at 70:0 contains 'SAS ' it's quite unlikely that this wouldn't be OS/2. * Note: The SAS layout is similar between 16-bit and 32-bit OS/2, but not identical. - * 32-bit OS/2 will have the flat kernel data selector at SAS:06. The selector is 168h - * or similar. For 16-bit OS/2 the field contains a table offset into the SAS which will - * be much smaller. Fun fact: The global infoseg selector in the SAS is bimodal in 16-bit - * OS/2 and will work in real mode as well. + * 32-bit OS/2 will have the flat kernel data selector at SAS:06. The selector is 168h + * or similar. For 16-bit OS/2 the field contains a table offset into the SAS which will + * be much smaller. Fun fact: The global infoseg selector in the SAS is bimodal in 16-bit + * OS/2 and will work in real mode as well. */ do { - rc = DBGFR3AddrFromSelOff(pVM, 0 /*idCpu*/, &Addr, 0x70, 0x00); + rc = DBGFR3AddrFromSelOff(pUVM, 0 /*idCpu*/, &Addr, 0x70, 0x00); if (RT_FAILURE(rc)) break; - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, &Addr, u.au32, 256); + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, &Addr, u.au32, 256); if (RT_FAILURE(rc)) break; if (u.au32[0] != DIG_OS2_SAS_SIG) break; - + /* This sure looks like OS/2, but a bit of paranoia won't hurt. */ if (u.au16[2] >= u.au16[4]) break; @@ -317,7 +317,7 @@ static DECLCALLBACK(bool) dbgDiggerOS2Probe(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnDestruct */ -static DECLCALLBACK(void) dbgDiggerOS2Destruct(PVM pVM, void *pvData) +static DECLCALLBACK(void) dbgDiggerOS2Destruct(PUVM pUVM, void *pvData) { } @@ -326,7 +326,7 @@ static DECLCALLBACK(void) dbgDiggerOS2Destruct(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnConstruct */ -static DECLCALLBACK(int) dbgDiggerOS2Construct(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerOS2Construct(PUVM pUVM, void *pvData) { PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData; pThis->fValid = false; diff --git a/src/VBox/Debugger/DBGPlugInSolaris.cpp b/src/VBox/Debugger/DBGPlugInSolaris.cpp index 6f717252..4c7f017b 100644 --- a/src/VBox/Debugger/DBGPlugInSolaris.cpp +++ b/src/VBox/Debugger/DBGPlugInSolaris.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2008-2010 Oracle Corporation + * Copyright (C) 2008-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -321,7 +321,7 @@ typedef DBGDIGGERSOLARIS *PDBGDIGGERSOLARIS; #define SOL32_MAX_KRNL_ADDR UINT32_C(0xfffff000) /** Min kernel address. */ -#define SOL64_MIN_KRNL_ADDR UINT64_C(0xFFFFFD8000000000) +#define SOL64_MIN_KRNL_ADDR UINT64_C(0xFFFFC00000000000) /** Max kernel address. */ #define SOL64_MAX_KRNL_ADDR UINT64_C(0xFFFFFFFFFFF00000) @@ -349,14 +349,14 @@ typedef DBGDIGGERSOLARIS *PDBGDIGGERSOLARIS; /******************************************************************************* * Internal Functions * *******************************************************************************/ -static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData); +static DECLCALLBACK(int) dbgDiggerSolarisInit(PUVM pUVM, void *pvData); /** * @copydoc DBGFOSREG::pfnQueryInterface */ -static DECLCALLBACK(void *) dbgDiggerSolarisQueryInterface(PVM pVM, void *pvData, DBGFOSINTERFACE enmIf) +static DECLCALLBACK(void *) dbgDiggerSolarisQueryInterface(PUVM pUVM, void *pvData, DBGFOSINTERFACE enmIf) { return NULL; } @@ -365,7 +365,7 @@ static DECLCALLBACK(void *) dbgDiggerSolarisQueryInterface(PVM pVM, void *pvData /** * @copydoc DBGFOSREG::pfnQueryVersion */ -static DECLCALLBACK(int) dbgDiggerSolarisQueryVersion(PVM pVM, void *pvData, char *pszVersion, size_t cchVersion) +static DECLCALLBACK(int) dbgDiggerSolarisQueryVersion(PUVM pUVM, void *pvData, char *pszVersion, size_t cchVersion) { PDBGDIGGERSOLARIS pThis = (PDBGDIGGERSOLARIS)pvData; Assert(pThis->fValid); @@ -376,9 +376,9 @@ static DECLCALLBACK(int) dbgDiggerSolarisQueryVersion(PVM pVM, void *pvData, ch DBGFADDRESS Addr; SOL_utsname_t UtsName; RTDBGSYMBOL SymUtsName; - int rc = DBGFR3AsSymbolByName(pVM, DBGF_AS_KERNEL, "utsname", &SymUtsName, NULL); + int rc = DBGFR3AsSymbolByName(pUVM, DBGF_AS_KERNEL, "utsname", &SymUtsName, NULL); if (RT_SUCCESS(rc)) - rc = DBGFR3MemRead(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, SymUtsName.Value), &UtsName, sizeof(UtsName)); + rc = DBGFR3MemRead(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, SymUtsName.Value), &UtsName, sizeof(UtsName)); if (RT_FAILURE(rc)) { /* @@ -386,10 +386,10 @@ static DECLCALLBACK(int) dbgDiggerSolarisQueryVersion(PVM pVM, void *pvData, ch */ memset(&UtsName, '\0', sizeof(UtsName)); strcpy(&UtsName.sysname[0], "SunOS"); - rc = DBGFR3MemScan(pVM, 0, &pThis->AddrUnixData, SOL_UNIX_MAX_DATA_SEG_SIZE, 1, + rc = DBGFR3MemScan(pUVM, 0, &pThis->AddrUnixData, SOL_UNIX_MAX_DATA_SEG_SIZE, 1, &UtsName.sysname[0], sizeof(UtsName.sysname), &Addr); if (RT_SUCCESS(rc)) - rc = DBGFR3MemRead(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, Addr.FlatPtr - RT_OFFSETOF(SOL_utsname_t, sysname)), + rc = DBGFR3MemRead(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, Addr.FlatPtr - RT_OFFSETOF(SOL_utsname_t, sysname)), &UtsName, sizeof(UtsName)); } @@ -422,11 +422,11 @@ static DECLCALLBACK(int) dbgDiggerSolarisQueryVersion(PVM pVM, void *pvData, ch /** * Processes a modctl_t. * - * @param pVM The VM handle. + * @param pUVM The user mode VM handle. * @param pThis Our instance data. * @param pModCtl Pointer to the modctl structure. */ -static void dbgDiggerSolarisProcessModCtl32(PVM pVM, PDBGDIGGERSOLARIS pThis, SOL_modctl_t const *pModCtl) +static void dbgDiggerSolarisProcessModCtl32(PUVM pUVM, PDBGDIGGERSOLARIS pThis, SOL_modctl_t const *pModCtl) { /* skip it if it's not loaded and installed */ AssertCompile2MemberOffsets(SOL_modctl_t, v11_32.mod_loaded, v9_32.mod_loaded); @@ -443,7 +443,7 @@ static void dbgDiggerSolarisProcessModCtl32(PVM pVM, PDBGDIGGERSOLARIS pThis, SO AssertCompile2MemberOffsets(SOL_modctl_t, v11_32.mod_modname, v9_32.mod_modname); char szModName[64]; DBGFADDRESS Addr; - int rc = DBGFR3MemReadString(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, pModCtl->v9_32.mod_modname), szModName, sizeof(szModName)); + int rc = DBGFR3MemReadString(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, pModCtl->v9_32.mod_modname), szModName, sizeof(szModName)); if (RT_FAILURE(rc)) return; if (!RTStrEnd(szModName, sizeof(szModName))) @@ -451,7 +451,7 @@ static void dbgDiggerSolarisProcessModCtl32(PVM pVM, PDBGDIGGERSOLARIS pThis, SO AssertCompile2MemberOffsets(SOL_modctl_t, v11_32.mod_filename, v9_32.mod_filename); char szFilename[256]; - rc = DBGFR3MemReadString(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, pModCtl->v9_32.mod_filename), szFilename, sizeof(szFilename)); + rc = DBGFR3MemReadString(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, pModCtl->v9_32.mod_filename), szFilename, sizeof(szFilename)); if (RT_FAILURE(rc)) strcpy(szFilename, szModName); else if (!RTStrEnd(szFilename, sizeof(szFilename))) @@ -462,7 +462,7 @@ static void dbgDiggerSolarisProcessModCtl32(PVM pVM, PDBGDIGGERSOLARIS pThis, SO */ AssertCompile2MemberOffsets(SOL_modctl_t, v11_32.mod_mp, v9_32.mod_mp); struct SOL32_module Module; - rc = DBGFR3MemRead(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, pModCtl->v9_32.mod_mp), &Module, sizeof(Module)); + rc = DBGFR3MemRead(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, pModCtl->v9_32.mod_mp), &Module, sizeof(Module)); if (RT_FAILURE(rc)) return; @@ -532,13 +532,13 @@ static void dbgDiggerSolarisProcessModCtl32(PVM pVM, PDBGDIGGERSOLARIS pThis, SO Elf32_Shdr *paShdrs = (Elf32_Shdr *)RTMemTmpAlloc(cb); if (!paShdrs) return; - rc = DBGFR3MemRead(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, Module.shdrs), paShdrs, cb); + rc = DBGFR3MemRead(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, Module.shdrs), paShdrs, cb); if (RT_SUCCESS(rc)) { void *pvSymSpace = RTMemTmpAlloc(Module.symsize + 1); if (pvSymSpace) { - rc = DBGFR3MemRead(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, Module.symspace), pvSymSpace, Module.symsize); + rc = DBGFR3MemRead(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, Module.symspace), pvSymSpace, Module.symsize); if (RT_SUCCESS(rc)) { ((uint8_t *)pvSymSpace)[Module.symsize] = 0; @@ -553,7 +553,7 @@ static void dbgDiggerSolarisProcessModCtl32(PVM pVM, PDBGDIGGERSOLARIS pThis, SO size_t cMaxSyms = (Module.symsize - (Module.symtbl - Module.symspace)) / sizeof(Elf32_Sym); cMaxSyms = RT_MIN(cMaxSyms, Module.nsyms); - DBGDiggerCommonParseElf32Mod(pVM, szModName, szFilename, DBG_DIGGER_ELF_FUNNY_SHDRS, + DBGDiggerCommonParseElf32Mod(pUVM, szModName, szFilename, DBG_DIGGER_ELF_FUNNY_SHDRS, &Module.hdr, paShdrs, paSyms, cMaxSyms, pbStrings, cbMaxStrings, SOL32_MIN_KRNL_ADDR, SOL32_MAX_KRNL_ADDR - 1, DIG_SOL_MOD_TAG); } @@ -569,11 +569,11 @@ static void dbgDiggerSolarisProcessModCtl32(PVM pVM, PDBGDIGGERSOLARIS pThis, SO /** * Processes a modctl_t. * - * @param pVM The VM handle. + * @param pUVM The user mode VM handle. * @param pThis Our instance data. * @param pModCtl Pointer to the modctl structure. */ -static void dbgDiggerSolarisProcessModCtl64(PVM pVM, PDBGDIGGERSOLARIS pThis, SOL_modctl_t const *pModCtl) +static void dbgDiggerSolarisProcessModCtl64(PUVM pUVM, PDBGDIGGERSOLARIS pThis, SOL_modctl_t const *pModCtl) { /* skip it if it's not loaded and installed */ AssertCompile2MemberOffsets(SOL_modctl_t, v11_64.mod_loaded, v9_64.mod_loaded); @@ -590,7 +590,7 @@ static void dbgDiggerSolarisProcessModCtl64(PVM pVM, PDBGDIGGERSOLARIS pThis, SO AssertCompile2MemberOffsets(SOL_modctl_t, v11_64.mod_modname, v9_64.mod_modname); char szModName[64]; DBGFADDRESS Addr; - int rc = DBGFR3MemReadString(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, pModCtl->v9_64.mod_modname), szModName, sizeof(szModName)); + int rc = DBGFR3MemReadString(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, pModCtl->v9_64.mod_modname), szModName, sizeof(szModName)); if (RT_FAILURE(rc)) return; if (!RTStrEnd(szModName, sizeof(szModName))) @@ -598,7 +598,7 @@ static void dbgDiggerSolarisProcessModCtl64(PVM pVM, PDBGDIGGERSOLARIS pThis, SO AssertCompile2MemberOffsets(SOL_modctl_t, v11_64.mod_filename, v9_64.mod_filename); char szFilename[256]; - rc = DBGFR3MemReadString(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, pModCtl->v9_64.mod_filename), szFilename, sizeof(szFilename)); + rc = DBGFR3MemReadString(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, pModCtl->v9_64.mod_filename), szFilename, sizeof(szFilename)); if (RT_FAILURE(rc)) strcpy(szFilename, szModName); else if (!RTStrEnd(szFilename, sizeof(szFilename))) @@ -609,7 +609,7 @@ static void dbgDiggerSolarisProcessModCtl64(PVM pVM, PDBGDIGGERSOLARIS pThis, SO */ AssertCompile2MemberOffsets(SOL_modctl_t, v11_64.mod_mp, v9_64.mod_mp); struct SOL64_module Module; - rc = DBGFR3MemRead(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, pModCtl->v9_64.mod_mp), &Module, sizeof(Module)); + rc = DBGFR3MemRead(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, pModCtl->v9_64.mod_mp), &Module, sizeof(Module)); if (RT_FAILURE(rc)) return; @@ -678,13 +678,13 @@ static void dbgDiggerSolarisProcessModCtl64(PVM pVM, PDBGDIGGERSOLARIS pThis, SO Elf64_Shdr *paShdrs = (Elf64_Shdr *)RTMemTmpAlloc(cb); if (!paShdrs) return; - rc = DBGFR3MemRead(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, Module.shdrs), paShdrs, cb); + rc = DBGFR3MemRead(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, Module.shdrs), paShdrs, cb); if (RT_SUCCESS(rc)) { void *pvSymSpace = RTMemTmpAlloc(Module.symsize + 1); if (pvSymSpace) { - rc = DBGFR3MemRead(pVM, 0, DBGFR3AddrFromFlat(pVM, &Addr, Module.symspace), pvSymSpace, Module.symsize); + rc = DBGFR3MemRead(pUVM, 0, DBGFR3AddrFromFlat(pUVM, &Addr, Module.symspace), pvSymSpace, Module.symsize); if (RT_SUCCESS(rc)) { ((uint8_t *)pvSymSpace)[Module.symsize] = 0; @@ -699,7 +699,7 @@ static void dbgDiggerSolarisProcessModCtl64(PVM pVM, PDBGDIGGERSOLARIS pThis, SO size_t cMaxSyms = (Module.symsize - (Module.symtbl - Module.symspace)) / sizeof(Elf32_Sym); cMaxSyms = RT_MIN(cMaxSyms, Module.nsyms); - DBGDiggerCommonParseElf64Mod(pVM, szModName, szFilename, DBG_DIGGER_ELF_FUNNY_SHDRS, + DBGDiggerCommonParseElf64Mod(pUVM, szModName, szFilename, DBG_DIGGER_ELF_FUNNY_SHDRS, &Module.hdr, paShdrs, paSyms, cMaxSyms, pbStrings, cbMaxStrings, SOL64_MIN_KRNL_ADDR, SOL64_MAX_KRNL_ADDR - 1, DIG_SOL_MOD_TAG); } @@ -715,7 +715,7 @@ static void dbgDiggerSolarisProcessModCtl64(PVM pVM, PDBGDIGGERSOLARIS pThis, SO /** * @copydoc DBGFOSREG::pfnTerm */ -static DECLCALLBACK(void) dbgDiggerSolarisTerm(PVM pVM, void *pvData) +static DECLCALLBACK(void) dbgDiggerSolarisTerm(PUVM pUVM, void *pvData) { PDBGDIGGERSOLARIS pThis = (PDBGDIGGERSOLARIS)pvData; Assert(pThis->fValid); @@ -727,7 +727,7 @@ static DECLCALLBACK(void) dbgDiggerSolarisTerm(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnRefresh */ -static DECLCALLBACK(int) dbgDiggerSolarisRefresh(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerSolarisRefresh(PUVM pUVM, void *pvData) { PDBGDIGGERSOLARIS pThis = (PDBGDIGGERSOLARIS)pvData; NOREF(pThis); @@ -736,7 +736,7 @@ static DECLCALLBACK(int) dbgDiggerSolarisRefresh(PVM pVM, void *pvData) /* * For now we'll flush and reload everything. */ - RTDBGAS hDbgAs = DBGFR3AsResolveAndRetain(pVM, DBGF_AS_KERNEL); + RTDBGAS hDbgAs = DBGFR3AsResolveAndRetain(pUVM, DBGF_AS_KERNEL); if (hDbgAs != NIL_RTDBGAS) { uint32_t iMod = RTDbgAsModuleCount(hDbgAs); @@ -756,15 +756,15 @@ static DECLCALLBACK(int) dbgDiggerSolarisRefresh(PVM pVM, void *pvData) RTDbgAsRelease(hDbgAs); } - dbgDiggerSolarisTerm(pVM, pvData); - return dbgDiggerSolarisInit(pVM, pvData); + dbgDiggerSolarisTerm(pUVM, pvData); + return dbgDiggerSolarisInit(pUVM, pvData); } /** * @copydoc DBGFOSREG::pfnInit */ -static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerSolarisInit(PUVM pUVM, void *pvData) { PDBGDIGGERSOLARIS pThis = (PDBGDIGGERSOLARIS)pvData; Assert(!pThis->fValid); @@ -774,7 +774,7 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) /* * On Solaris the kernel and is the global address space. */ - DBGFR3AsSetAlias(pVM, DBGF_AS_KERNEL, DBGF_AS_GLOBAL); + DBGFR3AsSetAlias(pUVM, DBGF_AS_KERNEL, DBGF_AS_GLOBAL); /** @todo Use debug_info, build 7x / S10U6. */ @@ -782,18 +782,18 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) * Find the 'unix' modctl_t structure (aka modules). * We know it resides in the unix data segment. */ - DBGFR3AddrFromFlat(pVM, &pThis->AddrUnixModCtl, 0); + DBGFR3AddrFromFlat(pUVM, &pThis->AddrUnixModCtl, 0); DBGFADDRESS CurAddr = pThis->AddrUnixData; DBGFADDRESS MaxAddr; - DBGFR3AddrFromFlat(pVM, &MaxAddr, CurAddr.FlatPtr + SOL_UNIX_MAX_DATA_SEG_SIZE); + DBGFR3AddrFromFlat(pUVM, &MaxAddr, CurAddr.FlatPtr + SOL_UNIX_MAX_DATA_SEG_SIZE); const uint8_t *pbExpr = (const uint8_t *)&pThis->AddrUnixText.FlatPtr; const uint32_t cbExpr = pThis->f64Bit ? sizeof(uint64_t) : sizeof(uint32_t); while ( CurAddr.FlatPtr < MaxAddr.FlatPtr && CurAddr.FlatPtr >= pThis->AddrUnixData.FlatPtr) { DBGFADDRESS HitAddr; - rc = DBGFR3MemScan(pVM, 0, &CurAddr, MaxAddr.FlatPtr - CurAddr.FlatPtr, 1, pbExpr, cbExpr, &HitAddr); + rc = DBGFR3MemScan(pUVM, 0, &CurAddr, MaxAddr.FlatPtr - CurAddr.FlatPtr, 1, pbExpr, cbExpr, &HitAddr); if (RT_FAILURE(rc)) break; @@ -805,9 +805,9 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) /* v11 */ if (pThis->f64Bit) { - DBGFR3AddrFromFlat(pVM, &ModCtlAddr, HitAddr.FlatPtr - RT_OFFSETOF(SOL32v11_modctl_t, mod_text)); + DBGFR3AddrFromFlat(pUVM, &ModCtlAddr, HitAddr.FlatPtr - RT_OFFSETOF(SOL32v11_modctl_t, mod_text)); SOL64v11_modctl_t ModCtlv11; - rc = DBGFR3MemRead(pVM, 0, &ModCtlAddr, &ModCtlv11, sizeof(ModCtlv11)); + rc = DBGFR3MemRead(pUVM, 0, &ModCtlAddr, &ModCtlv11, sizeof(ModCtlv11)); if (RT_SUCCESS(rc)) { if ( SOL64_VALID_ADDRESS(ModCtlv11.mod_next) @@ -827,8 +827,8 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) { char szUnix[5]; DBGFADDRESS NameAddr; - DBGFR3AddrFromFlat(pVM, &NameAddr, ModCtlv11.mod_modname); - rc = DBGFR3MemRead(pVM, 0, &NameAddr, &szUnix, sizeof(szUnix)); + DBGFR3AddrFromFlat(pUVM, &NameAddr, ModCtlv11.mod_modname); + rc = DBGFR3MemRead(pUVM, 0, &NameAddr, &szUnix, sizeof(szUnix)); if (RT_SUCCESS(rc)) { if (!strcmp(szUnix, "unix")) @@ -845,9 +845,9 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) } else { - DBGFR3AddrFromFlat(pVM, &ModCtlAddr, HitAddr.FlatPtr - RT_OFFSETOF(SOL32v11_modctl_t, mod_text)); + DBGFR3AddrFromFlat(pUVM, &ModCtlAddr, HitAddr.FlatPtr - RT_OFFSETOF(SOL32v11_modctl_t, mod_text)); SOL32v11_modctl_t ModCtlv11; - rc = DBGFR3MemRead(pVM, 0, &ModCtlAddr, &ModCtlv11, sizeof(ModCtlv11)); + rc = DBGFR3MemRead(pUVM, 0, &ModCtlAddr, &ModCtlv11, sizeof(ModCtlv11)); if (RT_SUCCESS(rc)) { if ( SOL32_VALID_ADDRESS(ModCtlv11.mod_next) @@ -867,8 +867,8 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) { char szUnix[5]; DBGFADDRESS NameAddr; - DBGFR3AddrFromFlat(pVM, &NameAddr, ModCtlv11.mod_modname); - rc = DBGFR3MemRead(pVM, 0, &NameAddr, &szUnix, sizeof(szUnix)); + DBGFR3AddrFromFlat(pUVM, &NameAddr, ModCtlv11.mod_modname); + rc = DBGFR3MemRead(pUVM, 0, &NameAddr, &szUnix, sizeof(szUnix)); if (RT_SUCCESS(rc)) { if (!strcmp(szUnix, "unix")) @@ -887,9 +887,9 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) /* v9 */ if (pThis->f64Bit) { - DBGFR3AddrFromFlat(pVM, &ModCtlAddr, HitAddr.FlatPtr - RT_OFFSETOF(SOL64v9_modctl_t, mod_text)); + DBGFR3AddrFromFlat(pUVM, &ModCtlAddr, HitAddr.FlatPtr - RT_OFFSETOF(SOL64v9_modctl_t, mod_text)); SOL64v9_modctl_t ModCtlv9; - rc = DBGFR3MemRead(pVM, 0, &ModCtlAddr, &ModCtlv9, sizeof(ModCtlv9)); + rc = DBGFR3MemRead(pUVM, 0, &ModCtlAddr, &ModCtlv9, sizeof(ModCtlv9)); if (RT_SUCCESS(rc)) { if ( SOL64_VALID_ADDRESS(ModCtlv9.mod_next) @@ -907,8 +907,8 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) { char szUnix[5]; DBGFADDRESS NameAddr; - DBGFR3AddrFromFlat(pVM, &NameAddr, ModCtlv9.mod_modname); - rc = DBGFR3MemRead(pVM, 0, &NameAddr, &szUnix, sizeof(szUnix)); + DBGFR3AddrFromFlat(pUVM, &NameAddr, ModCtlv9.mod_modname); + rc = DBGFR3MemRead(pUVM, 0, &NameAddr, &szUnix, sizeof(szUnix)); if (RT_SUCCESS(rc)) { if (!strcmp(szUnix, "unix")) @@ -925,9 +925,9 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) } else { - DBGFR3AddrFromFlat(pVM, &ModCtlAddr, HitAddr.FlatPtr - RT_OFFSETOF(SOL32v9_modctl_t, mod_text)); + DBGFR3AddrFromFlat(pUVM, &ModCtlAddr, HitAddr.FlatPtr - RT_OFFSETOF(SOL32v9_modctl_t, mod_text)); SOL32v9_modctl_t ModCtlv9; - rc = DBGFR3MemRead(pVM, 0, &ModCtlAddr, &ModCtlv9, sizeof(ModCtlv9)); + rc = DBGFR3MemRead(pUVM, 0, &ModCtlAddr, &ModCtlv9, sizeof(ModCtlv9)); if (RT_SUCCESS(rc)) { if ( SOL32_VALID_ADDRESS(ModCtlv9.mod_next) @@ -945,8 +945,8 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) { char szUnix[5]; DBGFADDRESS NameAddr; - DBGFR3AddrFromFlat(pVM, &NameAddr, ModCtlv9.mod_modname); - rc = DBGFR3MemRead(pVM, 0, &NameAddr, &szUnix, sizeof(szUnix)); + DBGFR3AddrFromFlat(pUVM, &NameAddr, ModCtlv9.mod_modname); + rc = DBGFR3MemRead(pUVM, 0, &NameAddr, &szUnix, sizeof(szUnix)); if (RT_SUCCESS(rc)) { if (!strcmp(szUnix, "unix")) @@ -963,7 +963,7 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) } /* next */ - DBGFR3AddrFromFlat(pVM, &CurAddr, HitAddr.FlatPtr + cbExpr); + DBGFR3AddrFromFlat(pUVM, &CurAddr, HitAddr.FlatPtr + cbExpr); } /* @@ -977,18 +977,18 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) { /* read it */ SOL_modctl_t ModCtl; - rc = DBGFR3MemRead(pVM, 0, &CurAddr, &ModCtl, cbModCtl); + rc = DBGFR3MemRead(pUVM, 0, &CurAddr, &ModCtl, cbModCtl); if (RT_FAILURE(rc)) { - LogRel(("sol: bad modctl_t chain: %RGv - %Rrc\n", iMod, CurAddr.FlatPtr, rc)); + LogRel(("sol: bad modctl_t chain for module %d: %RGv - %Rrc\n", iMod, CurAddr.FlatPtr, rc)); break; } /* process it. */ if (pThis->f64Bit) - dbgDiggerSolarisProcessModCtl64(pVM, pThis, &ModCtl); + dbgDiggerSolarisProcessModCtl64(pUVM, pThis, &ModCtl); else - dbgDiggerSolarisProcessModCtl32(pVM, pThis, &ModCtl); + dbgDiggerSolarisProcessModCtl32(pUVM, pThis, &ModCtl); /* next */ if (pThis->f64Bit) @@ -996,20 +996,20 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) AssertCompile2MemberOffsets(SOL_modctl_t, v11_64.mod_next, v9_64.mod_next); if (!SOL64_VALID_ADDRESS(ModCtl.v9_64.mod_next)) { - LogRel(("sol64: bad modctl_t chain at %RGv: %RGv\n", iMod, CurAddr.FlatPtr, (RTGCUINTPTR)ModCtl.v9_64.mod_next)); + LogRel(("sol64: bad modctl_t chain for module %d at %RGv: %RGv\n", iMod, CurAddr.FlatPtr, (RTGCUINTPTR)ModCtl.v9_64.mod_next)); break; } - DBGFR3AddrFromFlat(pVM, &CurAddr, ModCtl.v9_64.mod_next); + DBGFR3AddrFromFlat(pUVM, &CurAddr, ModCtl.v9_64.mod_next); } else { AssertCompile2MemberOffsets(SOL_modctl_t, v11_32.mod_next, v9_32.mod_next); if (!SOL32_VALID_ADDRESS(ModCtl.v9_32.mod_next)) { - LogRel(("sol32: bad modctl_t chain at %RGv: %RGv\n", iMod, CurAddr.FlatPtr, (RTGCUINTPTR)ModCtl.v9_32.mod_next)); + LogRel(("sol32: bad modctl_t chain for module %d at %RGv: %RGv\n", iMod, CurAddr.FlatPtr, (RTGCUINTPTR)ModCtl.v9_32.mod_next)); break; } - DBGFR3AddrFromFlat(pVM, &CurAddr, ModCtl.v9_32.mod_next); + DBGFR3AddrFromFlat(pUVM, &CurAddr, ModCtl.v9_32.mod_next); } if (++iMod >= 1024) { @@ -1027,7 +1027,7 @@ static DECLCALLBACK(int) dbgDiggerSolarisInit(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnProbe */ -static DECLCALLBACK(bool) dbgDiggerSolarisProbe(PVM pVM, void *pvData) +static DECLCALLBACK(bool) dbgDiggerSolarisProbe(PUVM pUVM, void *pvData) { PDBGDIGGERSOLARIS pThis = (PDBGDIGGERSOLARIS)pvData; @@ -1038,18 +1038,18 @@ static DECLCALLBACK(bool) dbgDiggerSolarisProbe(PVM pVM, void *pvData) bool f64Bit = false; /* 32-bit search range. */ - DBGFR3AddrFromFlat(pVM, &Addr, 0xfe800000); + DBGFR3AddrFromFlat(pUVM, &Addr, 0xfe800000); RTGCUINTPTR cbRange = 0xfec00000 - 0xfe800000; DBGFADDRESS HitAddr; static const uint8_t s_abSunRelease[] = "SunOS Release "; - int rc = DBGFR3MemScan(pVM, 0, &Addr, cbRange, 1, s_abSunRelease, sizeof(s_abSunRelease) - 1, &HitAddr); + int rc = DBGFR3MemScan(pUVM, 0, &Addr, cbRange, 1, s_abSunRelease, sizeof(s_abSunRelease) - 1, &HitAddr); if (RT_FAILURE(rc)) { /* 64-bit.... */ - DBGFR3AddrFromFlat(pVM, &Addr, UINT64_C(0xfffffffffb800000)); - cbRange = UINT64_C(0xfffffffffbc00000) - UINT64_C(0xfffffffffb800000); - rc = DBGFR3MemScan(pVM, 0, &Addr, cbRange, 1, s_abSunRelease, sizeof(s_abSunRelease) - 1, &HitAddr); + DBGFR3AddrFromFlat(pUVM, &Addr, UINT64_C(0xfffffffffb800000)); + cbRange = UINT64_C(0xfffffffffbd00000) - UINT64_C(0xfffffffffb800000); + rc = DBGFR3MemScan(pUVM, 0, &Addr, cbRange, 1, s_abSunRelease, sizeof(s_abSunRelease) - 1, &HitAddr); if (RT_FAILURE(rc)) return false; f64Bit = true; @@ -1060,11 +1060,11 @@ static DECLCALLBACK(bool) dbgDiggerSolarisProbe(PVM pVM, void *pvData) */ static const uint8_t s_abSMI[] = "Sun Microsystems, Inc."; static const uint8_t s_abORCL[] = "Oracle and/or its affiliates."; - rc = DBGFR3MemScan(pVM, 0, &Addr, cbRange, 1, s_abSMI, sizeof(s_abSMI) - 1, &HitAddr); + rc = DBGFR3MemScan(pUVM, 0, &Addr, cbRange, 1, s_abSMI, sizeof(s_abSMI) - 1, &HitAddr); if (RT_FAILURE(rc)) { /* Try the alternate copyright string. */ - rc = DBGFR3MemScan(pVM, 0, &Addr, cbRange, 1, s_abORCL, sizeof(s_abORCL) - 1, &HitAddr); + rc = DBGFR3MemScan(pUVM, 0, &Addr, cbRange, 1, s_abORCL, sizeof(s_abORCL) - 1, &HitAddr); if (RT_FAILURE(rc)) return false; } @@ -1084,7 +1084,7 @@ static DECLCALLBACK(bool) dbgDiggerSolarisProbe(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnDestruct */ -static DECLCALLBACK(void) dbgDiggerSolarisDestruct(PVM pVM, void *pvData) +static DECLCALLBACK(void) dbgDiggerSolarisDestruct(PUVM pUVM, void *pvData) { } @@ -1093,7 +1093,7 @@ static DECLCALLBACK(void) dbgDiggerSolarisDestruct(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnConstruct */ -static DECLCALLBACK(int) dbgDiggerSolarisConstruct(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerSolarisConstruct(PUVM pUVM, void *pvData) { return VINF_SUCCESS; } diff --git a/src/VBox/Debugger/DBGPlugInWinNt.cpp b/src/VBox/Debugger/DBGPlugInWinNt.cpp index 503bc48a..be61017d 100644 --- a/src/VBox/Debugger/DBGPlugInWinNt.cpp +++ b/src/VBox/Debugger/DBGPlugInWinNt.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2009-2010 Oracle Corporation + * Copyright (C) 2009-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -24,9 +24,10 @@ #include <VBox/vmm/dbgf.h> #include <VBox/err.h> #include <VBox/param.h> -#include <iprt/string.h> +#include <iprt/ldr.h> #include <iprt/mem.h> #include <iprt/stream.h> +#include <iprt/string.h> #include "../Runtime/include/internal/ldrMZ.h" /* ugly */ #include "../Runtime/include/internal/ldrPE.h" /* ugly */ @@ -80,24 +81,24 @@ typedef struct NTMTE64 { uint64_t Flink; uint64_t Blink; - } InLoadOrderLinks, - InMemoryOrderModuleList, - InInitializationOrderModuleList; - uint64_t DllBase; - uint64_t EntryPoint; - uint32_t SizeOfImage; - uint32_t Alignment; + } InLoadOrderLinks, /**< 0x00 */ + InMemoryOrderModuleList, /**< 0x10 */ + InInitializationOrderModuleList; /**< 0x20 */ + uint64_t DllBase; /**< 0x30 */ + uint64_t EntryPoint; /**< 0x38 */ + uint32_t SizeOfImage; /**< 0x40 */ + uint32_t Alignment; /**< 0x44 */ struct { - uint16_t Length; - uint16_t MaximumLength; - uint32_t Alignment; - uint64_t Buffer; - } FullDllName, - BaseDllName; - uint32_t Flags; - uint16_t LoadCount; - uint16_t TlsIndex; + uint16_t Length; /**< 0x48,0x58 */ + uint16_t MaximumLength; /**< 0x4a,0x5a */ + uint32_t Alignment; /**< 0x4c,0x5c */ + uint64_t Buffer; /**< 0x50,0x60 */ + } FullDllName, /**< 0x48 */ + BaseDllName; /**< 0x58 */ + uint32_t Flags; /**< 0x68 */ + uint16_t LoadCount; /**< 0x6c */ + uint16_t TlsIndex; /**< 0x6e */ /* ... there is more ... */ } NTMTE64; typedef NTMTE64 *PNTMTE64; @@ -160,42 +161,22 @@ typedef enum NTPRODUCTTYPE kNtProductType_Server } NTPRODUCTTYPE; -/** - * PDB v2.0 in image debug info. - * The URL is constructed from the timestamp and the %02x age? - */ -typedef struct CV_INFO_PDB20 -{ - uint32_t Signature; /**< CV_SIGNATURE_PDB70. */ - int32_t Offset; /**< Always 0. Used to be the offset to the real debug info. */ - uint32_t TimeDateStamp; - uint32_t Age; - uint8_t PdbFilename[4]; -} CV_INFO_PDB20; -/** The CV_INFO_PDB20 signature. */ -#define CV_SIGNATURE_PDB20 RT_MAKE_U32_FROM_U8('N','B','1','0') -/** - * PDB v7.0 in image debug info. - * The URL is constructed from the signature and the %02x age. - */ -#pragma pack(4) -typedef struct CV_INFO_PDB70 +/** NT image header union. */ +typedef union NTHDRSU { - uint32_t CvSignature; /**< CV_SIGNATURE_PDB70. */ - RTUUID Signature; - uint32_t Age; - uint8_t PdbFilename[4]; -} CV_INFO_PDB70; -#pragma pack() -AssertCompileMemberOffset(CV_INFO_PDB70, Signature, 4); -AssertCompileMemberOffset(CV_INFO_PDB70, Age, 4 + 16); -/** The CV_INFO_PDB70 signature. */ -#define CV_SIGNATURE_PDB70 RT_MAKE_U32_FROM_U8('R','S','D','S') + IMAGE_NT_HEADERS32 vX_32; + IMAGE_NT_HEADERS64 vX_64; +} NTHDRS; +/** Pointer to NT image header union. */ +typedef NTHDRS *PNTHDRS; +/** Pointer to const NT image header union. */ +typedef NTHDRS const *PCNTHDRS; /** @} */ + typedef enum DBGDIGGERWINNTVER { DBGDIGGERWINNTVER_UNKNOWN, @@ -238,13 +219,48 @@ typedef struct DBGDIGGERWINNT typedef DBGDIGGERWINNT *PDBGDIGGERWINNT; +/** + * The WinNT digger's loader reader instance data. + */ +typedef struct DBGDIGGERWINNTRDR +{ + /** The VM handle (referenced). */ + PUVM pUVM; + /** The image base. */ + DBGFADDRESS ImageAddr; + /** The image size. */ + uint32_t cbImage; + /** The file offset of the SizeOfImage field in the optional header if it + * needs patching, otherwise set to UINT32_MAX. */ + uint32_t offSizeOfImage; + /** The correct image size. */ + uint32_t cbCorrectImageSize; + /** Number of entries in the aMappings table. */ + uint32_t cMappings; + /** Mapping hint. */ + uint32_t iHint; + /** Mapping file offset to memory offsets, ordered by file offset. */ + struct + { + /** The file offset. */ + uint32_t offFile; + /** The size of this mapping. */ + uint32_t cbMem; + /** The offset to the memory from the start of the image. */ + uint32_t offMem; + } aMappings[1]; +} DBGDIGGERWINNTRDR; +/** Pointer a WinNT loader reader instance data. */ +typedef DBGDIGGERWINNTRDR *PDBGDIGGERWINNTRDR; + + /******************************************************************************* * Defined Constants And Macros * *******************************************************************************/ /** Validates a 32-bit Windows NT kernel address */ #define WINNT32_VALID_ADDRESS(Addr) ((Addr) > UINT32_C(0x80000000) && (Addr) < UINT32_C(0xfffff000)) /** Validates a 64-bit Windows NT kernel address */ -#define WINNT64_VALID_ADDRESS(Addr) ((Addr) > UINT64_C(0xffffffff80000000) && (Addr) < UINT64_C(0xfffffffffffff000)) + #define WINNT64_VALID_ADDRESS(Addr) ((Addr) > UINT64_C(0xffff800000000000) && (Addr) < UINT64_C(0xfffffffffffff000)) /** Validates a kernel address. */ #define WINNT_VALID_ADDRESS(pThis, Addr) ((pThis)->f32Bit ? WINNT32_VALID_ADDRESS(Addr) : WINNT64_VALID_ADDRESS(Addr)) /** Versioned and bitness wrapper. */ @@ -260,7 +276,7 @@ typedef DBGDIGGERWINNT *PDBGDIGGERWINNT; /******************************************************************************* * Internal Functions * *******************************************************************************/ -static DECLCALLBACK(int) dbgDiggerWinNtInit(PVM pVM, void *pvData); +static DECLCALLBACK(int) dbgDiggerWinNtInit(PUVM pUVM, void *pvData); /******************************************************************************* @@ -273,19 +289,308 @@ static const RTUTF16 g_wszKernelNames[][WINNT_KERNEL_BASE_NAME_LEN + 1] = }; + +/** @callback_method_impl{PFNRTLDRRDRMEMREAD} */ +static DECLCALLBACK(int) dbgDiggerWinNtRdr_Read(void *pvBuf, size_t cb, size_t off, void *pvUser) +{ + PDBGDIGGERWINNTRDR pThis = (PDBGDIGGERWINNTRDR)pvUser; + uint32_t offFile = (uint32_t)off; + AssertReturn(offFile == off, VERR_INVALID_PARAMETER); + + uint32_t i = pThis->iHint; + if (pThis->aMappings[i].offFile > offFile) + { + i = pThis->cMappings; + while (i-- > 0) + if (offFile >= pThis->aMappings[i].offFile) + break; + pThis->iHint = i; + } + + while (cb > 0) + { + uint32_t offNextMap = i + 1 < pThis->cMappings ? pThis->aMappings[i + 1].offFile : pThis->cbImage; + uint32_t offMap = offFile - pThis->aMappings[i].offFile; + + /* Read file bits backed by memory. */ + if (offMap < pThis->aMappings[i].cbMem) + { + uint32_t cbToRead = pThis->aMappings[i].cbMem - offMap; + if (cbToRead > cb) + cbToRead = (uint32_t)cb; + + DBGFADDRESS Addr = pThis->ImageAddr; + DBGFR3AddrAdd(&Addr, pThis->aMappings[i].offMem + offMap); + + int rc = DBGFR3MemRead(pThis->pUVM, 0 /*idCpu*/, &Addr, pvBuf, cbToRead); + if (RT_FAILURE(rc)) + return rc; + + /* Apply SizeOfImage patch? */ + if ( pThis->offSizeOfImage != UINT32_MAX + && offFile < pThis->offSizeOfImage + 4 + && offFile + cbToRead > pThis->offSizeOfImage) + { + uint32_t SizeOfImage = pThis->cbCorrectImageSize; + uint32_t cbPatch = sizeof(SizeOfImage); + int32_t offPatch = pThis->offSizeOfImage - offFile; + uint8_t *pbPatch = (uint8_t *)pvBuf + offPatch; + if (offFile + cbToRead < pThis->offSizeOfImage + cbPatch) + cbPatch = offFile + cbToRead - pThis->offSizeOfImage; + while (cbPatch-- > 0) + { + if (offPatch >= 0) + *pbPatch = (uint8_t)SizeOfImage; + offPatch++; + pbPatch++; + SizeOfImage >>= 8; + } + } + + /* Done? */ + if (cbToRead == cb) + break; + + offFile += cbToRead; + cb -= cbToRead; + pvBuf = (char *)pvBuf + cbToRead; + } + + /* Mind the gap. */ + if (offNextMap > offFile) + { + uint32_t cbZero = offNextMap - offFile; + if (cbZero > cb) + { + RT_BZERO(pvBuf, cb); + break; + } + + RT_BZERO(pvBuf, cbZero); + offFile += cbZero; + cb -= cbZero; + pvBuf = (char *)pvBuf + cbZero; + } + + pThis->iHint = ++i; + } + + return VINF_SUCCESS; +} + + +/** @callback_method_impl{PFNRTLDRRDRMEMDTOR} */ +static DECLCALLBACK(void) dbgDiggerWinNtRdr_Dtor(void *pvUser) +{ + PDBGDIGGERWINNTRDR pThis = (PDBGDIGGERWINNTRDR)pvUser; + + VMR3ReleaseUVM(pThis->pUVM); + pThis->pUVM = NULL; + RTMemFree(pvUser); +} + + +/** + * Checks if the section headers look okay. + * + * @returns true / false. + * @param paShs Pointer to the section headers. + * @param cShs Number of headers. + * @param cbImage The image size reported by NT. + * @param uRvaRsrc The RVA of the resource directory. UINT32_MAX if + * no resource directory. + * @param cbSectAlign The section alignment specified in the header. + * @param pcbImageCorrect The corrected image size. This is derived from + * cbImage and virtual range of the section tables. + * + * The problem is that NT may choose to drop the + * last pages in images it loads early, starting at + * the resource directory. These images will have + * a page aligned cbImage. + */ +static bool dbgDiggerWinNtCheckSectHdrsAndImgSize(PCIMAGE_SECTION_HEADER paShs, uint32_t cShs, uint32_t cbImage, + uint32_t uRvaRsrc, uint32_t cbSectAlign, uint32_t *pcbImageCorrect) +{ + *pcbImageCorrect = cbImage; + + for (uint32_t i = 0; i < cShs; i++) + { + if (!paShs[i].Name[0]) + { + Log(("DigWinNt: Section header #%u has no name\n", i)); + return false; + } + + if (paShs[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD) + continue; + + /* Check that sizes are within the same range and that both sizes and + addresses are within reasonable limits. */ + if ( RT_ALIGN(paShs[i].Misc.VirtualSize, _64K) < RT_ALIGN(paShs[i].SizeOfRawData, _64K) + || paShs[i].Misc.VirtualSize >= _1G + || paShs[i].SizeOfRawData >= _1G) + { + Log(("DigWinNt: Section header #%u has a VirtualSize=%#x and SizeOfRawData=%#x, that's too much data!\n", + i, paShs[i].Misc.VirtualSize, paShs[i].SizeOfRawData)); + return false; + } + uint32_t uRvaEnd = paShs[i].VirtualAddress + paShs[i].Misc.VirtualSize; + if (uRvaEnd >= _1G || uRvaEnd < paShs[i].VirtualAddress) + { + Log(("DigWinNt: Section header #%u has a VirtualSize=%#x and VirtualAddr=%#x, %#x in total, that's too much!\n", + i, paShs[i].Misc.VirtualSize, paShs[i].VirtualAddress, uRvaEnd)); + return false; + } + + /* Check for images chopped off around '.rsrc'. */ + if ( cbImage < uRvaEnd + && uRvaEnd >= uRvaRsrc) + cbImage = RT_ALIGN(uRvaEnd, cbSectAlign); + + /* Check that the section is within the image. */ + if (uRvaEnd > cbImage) + { + Log(("DigWinNt: Section header #%u has a virtual address range beyond the image: %#x TO %#x cbImage=%#x\n", + i, paShs[i].VirtualAddress, uRvaEnd, cbImage)); + return false; + } + } + + Assert(*pcbImageCorrect == cbImage || !(*pcbImageCorrect & 0xfff)); + *pcbImageCorrect = cbImage; + return true; +} + + +/** + * Create a loader module for the in-guest-memory PE module. + */ +static int dbgDiggerWinNtCreateLdrMod(PDBGDIGGERWINNT pThis, PUVM pUVM, const char *pszName, PCDBGFADDRESS pImageAddr, + uint32_t cbImage, uint8_t *pbBuf, size_t cbBuf, + uint32_t offHdrs, PCNTHDRS pHdrs, PRTLDRMOD phLdrMod) +{ + /* + * Allocate and create a reader instance. + */ + uint32_t const cShs = WINNT_UNION(pThis, pHdrs, FileHeader.NumberOfSections); + PDBGDIGGERWINNTRDR pRdr = (PDBGDIGGERWINNTRDR)RTMemAlloc(RT_OFFSETOF(DBGDIGGERWINNTRDR, aMappings[cShs + 2])); + if (!pRdr) + return VERR_NO_MEMORY; + + VMR3RetainUVM(pUVM); + pRdr->pUVM = pUVM; + pRdr->ImageAddr = *pImageAddr; + pRdr->cbImage = cbImage; + pRdr->cbCorrectImageSize = cbImage; + pRdr->offSizeOfImage = UINT32_MAX; + pRdr->iHint = 0; + + /* + * Use the section table to construct a more accurate view of the file/ + * image if it's in the buffer (it should be). + */ + uint32_t uRvaRsrc = UINT32_MAX; + if (WINNT_UNION(pThis, pHdrs, OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE]).Size > 0) + uRvaRsrc = WINNT_UNION(pThis, pHdrs, OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE]).VirtualAddress; + uint32_t offShs = offHdrs + + ( pThis->f32Bit + ? pHdrs->vX_32.FileHeader.SizeOfOptionalHeader + RT_OFFSETOF(IMAGE_NT_HEADERS32, OptionalHeader) + : pHdrs->vX_64.FileHeader.SizeOfOptionalHeader + RT_OFFSETOF(IMAGE_NT_HEADERS64, OptionalHeader)); + uint32_t cbShs = cShs * sizeof(IMAGE_SECTION_HEADER); + PCIMAGE_SECTION_HEADER paShs = (PCIMAGE_SECTION_HEADER)(pbBuf + offShs); + if ( offShs + cbShs <= RT_MIN(cbImage, cbBuf) + && dbgDiggerWinNtCheckSectHdrsAndImgSize(paShs, cShs, cbImage, uRvaRsrc, + WINNT_UNION(pThis, pHdrs, OptionalHeader.SectionAlignment), + &pRdr->cbCorrectImageSize)) + { + pRdr->cMappings = 0; + + for (uint32_t i = 0; i < cShs; i++) + if ( paShs[i].SizeOfRawData > 0 + && paShs[i].PointerToRawData > 0) + { + uint32_t j = 1; + if (!pRdr->cMappings) + pRdr->cMappings++; + else + { + while (j < pRdr->cMappings && pRdr->aMappings[j].offFile < paShs[i].PointerToRawData) + j++; + if (j < pRdr->cMappings) + memmove(&pRdr->aMappings[j + 1], &pRdr->aMappings[j], (pRdr->cMappings - j) * sizeof(pRdr->aMappings)); + } + pRdr->aMappings[j].offFile = paShs[i].PointerToRawData; + pRdr->aMappings[j].offMem = paShs[i].VirtualAddress; + pRdr->aMappings[j].cbMem = i + 1 < cShs + ? paShs[i + 1].VirtualAddress - paShs[i].VirtualAddress + : paShs[i].Misc.VirtualSize; + if (j == pRdr->cMappings) + pRdr->cbImage = paShs[i].PointerToRawData + paShs[i].SizeOfRawData; + pRdr->cMappings++; + } + + /* Insert the mapping of the headers that isn't covered by the section table. */ + pRdr->aMappings[0].offFile = 0; + pRdr->aMappings[0].offMem = 0; + pRdr->aMappings[0].cbMem = pRdr->cMappings ? pRdr->aMappings[1].offFile : pRdr->cbImage; + + int j = pRdr->cMappings - 1; + while (j-- > 0) + { + uint32_t cbFile = pRdr->aMappings[j + 1].offFile - pRdr->aMappings[j].offFile; + if (pRdr->aMappings[j].cbMem > cbFile) + pRdr->aMappings[j].cbMem = cbFile; + } + } + else + { + /* + * Fallback, fake identity mapped file data. + */ + pRdr->cMappings = 1; + pRdr->aMappings[0].offFile = 0; + pRdr->aMappings[0].offMem = 0; + pRdr->aMappings[0].cbMem = pRdr->cbImage; + } + + /* Enable the SizeOfImage patching if necessary. */ + if (pRdr->cbCorrectImageSize != cbImage) + { + Log(("DigWinNT: The image is really %#x bytes long, not %#x as mapped by NT!\n", pRdr->cbCorrectImageSize, cbImage)); + pRdr->offSizeOfImage = pThis->f32Bit + ? offHdrs + RT_OFFSETOF(IMAGE_NT_HEADERS32, OptionalHeader.SizeOfImage) + : offHdrs + RT_OFFSETOF(IMAGE_NT_HEADERS64, OptionalHeader.SizeOfImage); + } + + /* + * Call the loader to open the PE image for debugging. + * Note! It always calls pfnDtor. + */ + RTLDRMOD hLdrMod; + int rc = RTLdrOpenInMemory(pszName, RTLDR_O_FOR_DEBUG, RTLDRARCH_WHATEVER, pRdr->cbImage, + dbgDiggerWinNtRdr_Read, dbgDiggerWinNtRdr_Dtor, pRdr, + &hLdrMod); + if (RT_SUCCESS(rc)) + *phLdrMod = hLdrMod; + else + *phLdrMod = NIL_RTLDRMOD; + return rc; +} + + /** * Process a PE image found in guest memory. * - * @param pThis The instance data. - * @param pVM The VM handle. - * @param pszName The image name. - * @param pImageAddr The image address. - * @param cbImage The size of the image. - * @param pbBuf Scratch buffer containing the first - * RT_MIN(cbBuf, cbImage) bytes of the image. - * @param cbBuf The scratch buffer size. + * @param pThis The instance data. + * @param pUVM The user mode VM handle. + * @param pszName The image name. + * @param pImageAddr The image address. + * @param cbImage The size of the image. + * @param pbBuf Scratch buffer containing the first + * RT_MIN(cbBuf, cbImage) bytes of the image. + * @param cbBuf The scratch buffer size. */ -static void dbgDiggerWinNtProcessImage(PDBGDIGGERWINNT pThis, PVM pVM, const char *pszName, +static void dbgDiggerWinNtProcessImage(PDBGDIGGERWINNT pThis, PUVM pUVM, const char *pszName, PCDBGFADDRESS pImageAddr, uint32_t cbImage, uint8_t *pbBuf, size_t cbBuf) { @@ -305,17 +610,12 @@ static void dbgDiggerWinNtProcessImage(PDBGDIGGERWINNT pThis, PVM pVM, const cha /* Dig out the NT/PE headers. */ IMAGE_DOS_HEADER const *pMzHdr = (IMAGE_DOS_HEADER const *)pbBuf; - typedef union NTHDRSU - { - IMAGE_NT_HEADERS64 vX_32; - IMAGE_NT_HEADERS64 vX_64; - } NTHDRS; - NTHDRS const *pHdrs; + PCNTHDRS pHdrs; uint32_t offHdrs; if (pMzHdr->e_magic != IMAGE_DOS_SIGNATURE) { offHdrs = 0; - pHdrs = (NTHDRS const *)pbBuf; + pHdrs = (PCNTHDRS)pbBuf; } else if ( pMzHdr->e_lfanew >= cbImage || pMzHdr->e_lfanew < sizeof(*pMzHdr) @@ -352,6 +652,12 @@ static void dbgDiggerWinNtProcessImage(PDBGDIGGERWINNT pThis, PVM pVM, const cha Log(("DigWinNt: %s: Invalid FH.SizeOfOptionalHeader: %#x\n", pszName, pHdrs->vX_32.FileHeader.SizeOfOptionalHeader)); return; } + if (WINNT_UNION(pThis, pHdrs, FileHeader.NumberOfSections) > 64) + { + Log(("DigWinNt: %s: Too many sections: %#x\n", pszName, WINNT_UNION(pThis, pHdrs, FileHeader.NumberOfSections))); + return; + } + const uint32_t TimeDateStamp = pHdrs->vX_32.FileHeader.TimeDateStamp; /* The optional header is not... */ @@ -360,76 +666,52 @@ static void dbgDiggerWinNtProcessImage(PDBGDIGGERWINNT pThis, PVM pVM, const cha Log(("DigWinNt: %s: Invalid OH.Magic: %#x\n", pszName, WINNT_UNION(pThis, pHdrs, OptionalHeader.Magic))); return; } - if (WINNT_UNION(pThis, pHdrs, OptionalHeader.SizeOfImage) != cbImage) + uint32_t cbImageFromHdr = WINNT_UNION(pThis, pHdrs, OptionalHeader.SizeOfImage); + if (RT_ALIGN(cbImageFromHdr, _4K) != RT_ALIGN(cbImage, _4K)) { - Log(("DigWinNt: %s: Invalid OH.SizeOfImage: %#x, expected %#x\n", pszName, WINNT_UNION(pThis, pHdrs, OptionalHeader.SizeOfImage), cbImage)); + Log(("DigWinNt: %s: Invalid OH.SizeOfImage: %#x, expected %#x\n", pszName, cbImageFromHdr, cbImage)); return; } if (WINNT_UNION(pThis, pHdrs, OptionalHeader.NumberOfRvaAndSizes) != IMAGE_NUMBEROF_DIRECTORY_ENTRIES) { - Log(("DigWinNt: %s: Invalid OH.SizeOfImage: %#x\n", pszName, WINNT_UNION(pThis, pHdrs, OptionalHeader.NumberOfRvaAndSizes))); + Log(("DigWinNt: %s: Invalid OH.NumberOfRvaAndSizes: %#x\n", pszName, WINNT_UNION(pThis, pHdrs, OptionalHeader.NumberOfRvaAndSizes))); return; } - uint32_t uRvaDebugDir = 0; - uint32_t cbDebugDir = 0; - IMAGE_DATA_DIRECTORY const *pDir = &WINNT_UNION(pThis, pHdrs, OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG]); - if ( pDir->VirtualAddress > offHdrs - && pDir->VirtualAddress < cbImage - && pDir->Size >= sizeof(IMAGE_DEBUG_DIRECTORY) - && pDir->Size < cbImage - && pDir->VirtualAddress + pDir->Size <= cbImage - ) - { - uRvaDebugDir = pDir->VirtualAddress; - cbDebugDir = pDir->Size; - } - - /* dig into the section table... */ - /* - * Create the module. + * Create the module using the in memory image first, falling back + * on cached image. */ - RTDBGMOD hMod; - int rc = RTDbgModCreate(&hMod, pszName, cbImage, 0 /*fFlags*/); + RTLDRMOD hLdrMod; + int rc = dbgDiggerWinNtCreateLdrMod(pThis, pUVM, pszName, pImageAddr, cbImage, pbBuf, cbBuf, offHdrs, pHdrs, + &hLdrMod); if (RT_FAILURE(rc)) - return; - rc = RTDbgModSetTag(hMod, DIG_WINNT_MOD_TAG); AssertRC(rc); - - /* temp hack: */ - rc = RTDbgModSymbolAdd(hMod, "start", 0 /*iSeg*/, 0, cbImage, 0 /*fFlags*/, NULL); AssertRC(rc); + hLdrMod = NIL_RTLDRMOD; - /* add sections? */ - - /* - * Dig out debug info if possible. What we're after is the CODEVIEW part. - */ - if (uRvaDebugDir != 0) + RTDBGMOD hMod; + rc = RTDbgModCreateFromPeImage(&hMod, pszName, NULL, hLdrMod, + cbImageFromHdr, TimeDateStamp, DBGFR3AsGetConfig(pUVM)); + if (RT_FAILURE(rc)) { - DBGFADDRESS Addr = *pImageAddr; - DBGFR3AddrAdd(&Addr, uRvaDebugDir); - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, &Addr, pbBuf, RT_MIN(cbDebugDir, cbBuf)); - if (RT_SUCCESS(rc)) - { - IMAGE_DEBUG_DIRECTORY const *pa = (IMAGE_DEBUG_DIRECTORY const *)pbBuf; - size_t c = RT_MIN(RT_MIN(cbDebugDir, cbBuf) / sizeof(*pa), 10); - for (uint32_t i = 0; i < c; i++) - if ( pa[i].AddressOfRawData > offHdrs - && pa[i].AddressOfRawData < cbImage - && pa[i].SizeOfData < cbImage - && pa[i].AddressOfRawData + pa[i].SizeOfData <= cbImage - && pa[i].TimeDateStamp == TimeDateStamp /* too paranoid? */ - && pa[i].Type == IMAGE_DEBUG_TYPE_CODEVIEW - ) - { - } - } + /* + * Final fallback is a container module. + */ + rc = RTDbgModCreate(&hMod, pszName, cbImage, 0); + if (RT_FAILURE(rc)) + return; + + rc = RTDbgModSymbolAdd(hMod, "Headers", 0 /*iSeg*/, 0, cbImage, 0 /*fFlags*/, NULL); + AssertRC(rc); } + /* Tag the module. */ + rc = RTDbgModSetTag(hMod, DIG_WINNT_MOD_TAG); + AssertRC(rc); + /* * Link the module. */ - RTDBGAS hAs = DBGFR3AsResolveAndRetain(pVM, DBGF_AS_KERNEL); + RTDBGAS hAs = DBGFR3AsResolveAndRetain(pUVM, DBGF_AS_KERNEL); if (hAs != NIL_RTDBGAS) rc = RTDbgAsModuleLink(hAs, hMod, pImageAddr->FlatPtr, RTDBGASLINK_FLAGS_REPLACE /*fFlags*/); else @@ -442,7 +724,7 @@ static void dbgDiggerWinNtProcessImage(PDBGDIGGERWINNT pThis, PVM pVM, const cha /** * @copydoc DBGFOSREG::pfnQueryInterface */ -static DECLCALLBACK(void *) dbgDiggerWinNtQueryInterface(PVM pVM, void *pvData, DBGFOSINTERFACE enmIf) +static DECLCALLBACK(void *) dbgDiggerWinNtQueryInterface(PUVM pUVM, void *pvData, DBGFOSINTERFACE enmIf) { return NULL; } @@ -451,7 +733,7 @@ static DECLCALLBACK(void *) dbgDiggerWinNtQueryInterface(PVM pVM, void *pvData, /** * @copydoc DBGFOSREG::pfnQueryVersion */ -static DECLCALLBACK(int) dbgDiggerWinNtQueryVersion(PVM pVM, void *pvData, char *pszVersion, size_t cchVersion) +static DECLCALLBACK(int) dbgDiggerWinNtQueryVersion(PUVM pUVM, void *pvData, char *pszVersion, size_t cchVersion) { PDBGDIGGERWINNT pThis = (PDBGDIGGERWINNT)pvData; Assert(pThis->fValid); @@ -463,7 +745,8 @@ static DECLCALLBACK(int) dbgDiggerWinNtQueryVersion(PVM pVM, void *pvData, char case kNtProductType_Server: pszNtProductType = "-Server"; break; default: pszNtProductType = ""; break; } - RTStrPrintf(pszVersion, cchVersion, "%u.%u%s", pThis->NtMajorVersion, pThis->NtMinorVersion, pszNtProductType); + RTStrPrintf(pszVersion, cchVersion, "%u.%u-%s%s", pThis->NtMajorVersion, pThis->NtMinorVersion, + pThis->f32Bit ? "x86" : "AMD64", pszNtProductType); return VINF_SUCCESS; } @@ -471,7 +754,7 @@ static DECLCALLBACK(int) dbgDiggerWinNtQueryVersion(PVM pVM, void *pvData, char /** * @copydoc DBGFOSREG::pfnTerm */ -static DECLCALLBACK(void) dbgDiggerWinNtTerm(PVM pVM, void *pvData) +static DECLCALLBACK(void) dbgDiggerWinNtTerm(PUVM pUVM, void *pvData) { PDBGDIGGERWINNT pThis = (PDBGDIGGERWINNT)pvData; Assert(pThis->fValid); @@ -483,7 +766,7 @@ static DECLCALLBACK(void) dbgDiggerWinNtTerm(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnRefresh */ -static DECLCALLBACK(int) dbgDiggerWinNtRefresh(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerWinNtRefresh(PUVM pUVM, void *pvData) { PDBGDIGGERWINNT pThis = (PDBGDIGGERWINNT)pvData; NOREF(pThis); @@ -492,7 +775,7 @@ static DECLCALLBACK(int) dbgDiggerWinNtRefresh(PVM pVM, void *pvData) /* * For now we'll flush and reload everything. */ - RTDBGAS hDbgAs = DBGFR3AsResolveAndRetain(pVM, DBGF_AS_KERNEL); + RTDBGAS hDbgAs = DBGFR3AsResolveAndRetain(pUVM, DBGF_AS_KERNEL); if (hDbgAs != NIL_RTDBGAS) { uint32_t iMod = RTDbgAsModuleCount(hDbgAs); @@ -512,15 +795,15 @@ static DECLCALLBACK(int) dbgDiggerWinNtRefresh(PVM pVM, void *pvData) RTDbgAsRelease(hDbgAs); } - dbgDiggerWinNtTerm(pVM, pvData); - return dbgDiggerWinNtInit(pVM, pvData); + dbgDiggerWinNtTerm(pUVM, pvData); + return dbgDiggerWinNtInit(pUVM, pvData); } /** * @copydoc DBGFOSREG::pfnInit */ -static DECLCALLBACK(int) dbgDiggerWinNtInit(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerWinNtInit(PUVM pUVM, void *pvData) { PDBGDIGGERWINNT pThis = (PDBGDIGGERWINNT)pvData; Assert(!pThis->fValid); @@ -537,8 +820,8 @@ static DECLCALLBACK(int) dbgDiggerWinNtInit(PVM pVM, void *pvData) /* * Figure the NT version. */ - DBGFR3AddrFromFlat(pVM, &Addr, pThis->f32Bit ? NTKUSERSHAREDDATA_WINNT32 : NTKUSERSHAREDDATA_WINNT64); - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, &Addr, &u, PAGE_SIZE); + DBGFR3AddrFromFlat(pUVM, &Addr, pThis->f32Bit ? NTKUSERSHAREDDATA_WINNT32 : NTKUSERSHAREDDATA_WINNT64); + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, &Addr, &u, PAGE_SIZE); if (RT_FAILURE(rc)) return rc; pThis->NtProductType = u.UserSharedData.ProductTypeIsValid && u.UserSharedData.NtProductType <= kNtProductType_Server @@ -556,7 +839,7 @@ static DECLCALLBACK(int) dbgDiggerWinNtInit(PVM pVM, void *pvData) { /* Read the validate the MTE. */ NTMTE Mte; - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, &Addr, &Mte, pThis->f32Bit ? sizeof(Mte.vX_32) : sizeof(Mte.vX_64)); + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, &Addr, &Mte, pThis->f32Bit ? sizeof(Mte.vX_32) : sizeof(Mte.vX_64)); if (RT_FAILURE(rc)) break; if (WINNT_UNION(pThis, &Mte, InLoadOrderLinks.Blink) != AddrPrev.FlatPtr) @@ -590,18 +873,18 @@ static DECLCALLBACK(int) dbgDiggerWinNtInit(PVM pVM, void *pvData) /* Read the full name. */ DBGFADDRESS AddrName; - DBGFR3AddrFromFlat(pVM, &AddrName, WINNT_UNION(pThis, &Mte, FullDllName.Buffer)); + DBGFR3AddrFromFlat(pUVM, &AddrName, WINNT_UNION(pThis, &Mte, FullDllName.Buffer)); uint16_t cbName = WINNT_UNION(pThis, &Mte, FullDllName.Length); if (cbName < sizeof(u)) - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, &AddrName, &u, cbName); + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, &AddrName, &u, cbName); else rc = VERR_OUT_OF_RANGE; if (RT_FAILURE(rc)) { - DBGFR3AddrFromFlat(pVM, &AddrName, WINNT_UNION(pThis, &Mte, BaseDllName.Buffer)); + DBGFR3AddrFromFlat(pUVM, &AddrName, WINNT_UNION(pThis, &Mte, BaseDllName.Buffer)); cbName = WINNT_UNION(pThis, &Mte, BaseDllName.Length); if (cbName < sizeof(u)) - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, &AddrName, &u, cbName); + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, &AddrName, &u, cbName); else rc = VERR_OUT_OF_RANGE; } @@ -614,12 +897,12 @@ static DECLCALLBACK(int) dbgDiggerWinNtInit(PVM pVM, void *pvData) { /* Read the start of the PE image and pass it along to a worker. */ DBGFADDRESS ImageAddr; - DBGFR3AddrFromFlat(pVM, &ImageAddr, WINNT_UNION(pThis, &Mte, DllBase)); + DBGFR3AddrFromFlat(pUVM, &ImageAddr, WINNT_UNION(pThis, &Mte, DllBase)); uint32_t cbImageBuf = RT_MIN(sizeof(u), WINNT_UNION(pThis, &Mte, SizeOfImage)); - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, &ImageAddr, &u, cbImageBuf); + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, &ImageAddr, &u, cbImageBuf); if (RT_SUCCESS(rc)) dbgDiggerWinNtProcessImage(pThis, - pVM, + pUVM, pszName, &ImageAddr, WINNT_UNION(pThis, &Mte, SizeOfImage), @@ -631,7 +914,7 @@ static DECLCALLBACK(int) dbgDiggerWinNtInit(PVM pVM, void *pvData) /* next */ AddrPrev = Addr; - DBGFR3AddrFromFlat(pVM, &Addr, WINNT_UNION(pThis, &Mte, InLoadOrderLinks.Flink)); + DBGFR3AddrFromFlat(pUVM, &Addr, WINNT_UNION(pThis, &Mte, InLoadOrderLinks.Flink)); } while ( Addr.FlatPtr != pThis->KernelMteAddr.FlatPtr && Addr.FlatPtr != pThis->PsLoadedModuleListAddr.FlatPtr); @@ -643,7 +926,7 @@ static DECLCALLBACK(int) dbgDiggerWinNtInit(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnProbe */ -static DECLCALLBACK(bool) dbgDiggerWinNtProbe(PVM pVM, void *pvData) +static DECLCALLBACK(bool) dbgDiggerWinNtProbe(PUVM pUVM, void *pvData) { PDBGDIGGERWINNT pThis = (PDBGDIGGERWINNT)pvData; DBGFADDRESS Addr; @@ -656,37 +939,41 @@ static DECLCALLBACK(bool) dbgDiggerWinNtProbe(PVM pVM, void *pvData) RTUTF16 wsz[8192/2]; } u; + union + { + NTMTE32 v32; + NTMTE64 v64; + } uMte, uMte2, uMte3; + /* - * Look for the MISYSPTE section name that seems to be a part of all kernels. + * Look for the PAGELK section name that seems to be a part of all kernels. * Then try find the module table entry for it. Since it's the first entry * in the PsLoadedModuleList we can easily validate the list head and report * success. */ - CPUMMODE enmMode = DBGFR3CpuGetMode(pVM, 0 /*idCpu*/); - if (enmMode == CPUMMODE_LONG) + CPUMMODE enmMode = DBGFR3CpuGetMode(pUVM, 0 /*idCpu*/); + uint64_t const uStart = enmMode == CPUMMODE_LONG ? UINT64_C(0xfffff80000000000) : UINT32_C(0x80001000); + uint64_t const uEnd = enmMode == CPUMMODE_LONG ? UINT64_C(0xffffffffffff0000) : UINT32_C(0xffff0000); + DBGFADDRESS KernelAddr; + for (DBGFR3AddrFromFlat(pUVM, &KernelAddr, uStart); + KernelAddr.FlatPtr < uEnd; + KernelAddr.FlatPtr += PAGE_SIZE) { - /** @todo when 32-bit is working, add support for 64-bit windows nt. */ - } - else - { - DBGFADDRESS KernelAddr; - for (DBGFR3AddrFromFlat(pVM, &KernelAddr, UINT32_C(0x80001000)); - KernelAddr.FlatPtr < UINT32_C(0xffff0000); - KernelAddr.FlatPtr += PAGE_SIZE) + int rc = DBGFR3MemScan(pUVM, 0 /*idCpu*/, &KernelAddr, uEnd - KernelAddr.FlatPtr, + 1, "PAGELK\0", sizeof("PAGELK\0"), &KernelAddr); + if (RT_FAILURE(rc)) + break; + DBGFR3AddrSub(&KernelAddr, KernelAddr.FlatPtr & PAGE_OFFSET_MASK); + + /* MZ + PE header. */ + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, &KernelAddr, &u, sizeof(u)); + if ( RT_SUCCESS(rc) + && u.MzHdr.e_magic == IMAGE_DOS_SIGNATURE + && !(u.MzHdr.e_lfanew & 0x7) + && u.MzHdr.e_lfanew >= 0x080 + && u.MzHdr.e_lfanew <= 0x400) /* W8 is at 0x288*/ { - int rc = DBGFR3MemScan(pVM, 0 /*idCpu*/, &KernelAddr, UINT32_C(0xffff0000) - KernelAddr.FlatPtr, - 1, "MISYSPTE", sizeof("MISYSPTE") - 1, &KernelAddr); - if (RT_FAILURE(rc)) - break; - DBGFR3AddrSub(&KernelAddr, KernelAddr.FlatPtr & PAGE_OFFSET_MASK); - - /* MZ + PE header. */ - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, &KernelAddr, &u, sizeof(u)); - if ( RT_SUCCESS(rc) - && u.MzHdr.e_magic == IMAGE_DOS_SIGNATURE - && !(u.MzHdr.e_lfanew & 0x7) - && u.MzHdr.e_lfanew >= 0x080 - && u.MzHdr.e_lfanew <= 0x200) + if (enmMode != CPUMMODE_LONG) { IMAGE_NT_HEADERS32 const *pHdrs = (IMAGE_NT_HEADERS32 const *)&u.au8[u.MzHdr.e_lfanew]; if ( pHdrs->Signature == IMAGE_NT_SIGNATURE @@ -696,58 +983,51 @@ static DECLCALLBACK(bool) dbgDiggerWinNtProbe(PVM pVM, void *pvData) && (pHdrs->FileHeader.Characteristics & (IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_DLL)) == IMAGE_FILE_EXECUTABLE_IMAGE && pHdrs->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC && pHdrs->OptionalHeader.NumberOfRvaAndSizes == IMAGE_NUMBEROF_DIRECTORY_ENTRIES - /** @todo need more ntoskrnl signs? */ ) { /* Find the MTE. */ - NTMTE32 Mte; - RT_ZERO(Mte); - Mte.DllBase = KernelAddr.FlatPtr; - Mte.EntryPoint = KernelAddr.FlatPtr + pHdrs->OptionalHeader.AddressOfEntryPoint; - Mte.SizeOfImage = pHdrs->OptionalHeader.SizeOfImage; + RT_ZERO(uMte); + uMte.v32.DllBase = KernelAddr.FlatPtr; + uMte.v32.EntryPoint = KernelAddr.FlatPtr + pHdrs->OptionalHeader.AddressOfEntryPoint; + uMte.v32.SizeOfImage = pHdrs->OptionalHeader.SizeOfImage; DBGFADDRESS HitAddr; - rc = DBGFR3MemScan(pVM, 0 /*idCpu*/, &KernelAddr, UINT32_MAX - KernelAddr.FlatPtr, - 4 /*align*/, &Mte.DllBase, 3 * sizeof(uint32_t), &HitAddr); + rc = DBGFR3MemScan(pUVM, 0 /*idCpu*/, &KernelAddr, uEnd - KernelAddr.FlatPtr, + 4 /*align*/, &uMte.v32.DllBase, 3 * sizeof(uint32_t), &HitAddr); while (RT_SUCCESS(rc)) { /* check the name. */ - NTMTE32 Mte2; DBGFADDRESS MteAddr = HitAddr; - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, DBGFR3AddrSub(&MteAddr, RT_OFFSETOF(NTMTE32, DllBase)), - &Mte2, sizeof(Mte2)); + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, DBGFR3AddrSub(&MteAddr, RT_OFFSETOF(NTMTE32, DllBase)), + &uMte2.v32, sizeof(uMte2.v32)); if ( RT_SUCCESS(rc) - && Mte2.DllBase == Mte.DllBase - && Mte2.EntryPoint == Mte.EntryPoint - && Mte2.SizeOfImage == Mte.SizeOfImage - && WINNT32_VALID_ADDRESS(Mte2.InLoadOrderLinks.Flink) - && Mte2.InLoadOrderLinks.Blink > KernelAddr.FlatPtr /* list head inside ntoskrnl */ - && Mte2.InLoadOrderLinks.Blink < KernelAddr.FlatPtr + Mte.SizeOfImage - && WINNT32_VALID_ADDRESS(Mte2.BaseDllName.Buffer) - && WINNT32_VALID_ADDRESS(Mte2.FullDllName.Buffer) - && Mte2.BaseDllName.Length <= Mte2.BaseDllName.MaximumLength - && Mte2.BaseDllName.Length == WINNT_KERNEL_BASE_NAME_LEN * 2 - && Mte2.FullDllName.Length <= Mte2.FullDllName.MaximumLength - && Mte2.FullDllName.Length <= 256 + && uMte2.v32.DllBase == uMte.v32.DllBase + && uMte2.v32.EntryPoint == uMte.v32.EntryPoint + && uMte2.v32.SizeOfImage == uMte.v32.SizeOfImage + && WINNT32_VALID_ADDRESS(uMte2.v32.InLoadOrderLinks.Flink) + && WINNT32_VALID_ADDRESS(uMte2.v32.BaseDllName.Buffer) + && WINNT32_VALID_ADDRESS(uMte2.v32.FullDllName.Buffer) + && uMte2.v32.BaseDllName.Length <= 128 + && uMte2.v32.FullDllName.Length <= 260 ) { - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, DBGFR3AddrFromFlat(pVM, &Addr, Mte2.BaseDllName.Buffer), - u.wsz, Mte2.BaseDllName.Length); - u.wsz[Mte2.BaseDllName.Length / 2] = '\0'; + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, DBGFR3AddrFromFlat(pUVM, &Addr, uMte2.v32.BaseDllName.Buffer), + u.wsz, uMte2.v32.BaseDllName.Length); + u.wsz[uMte2.v32.BaseDllName.Length / 2] = '\0'; if ( RT_SUCCESS(rc) && ( !RTUtf16ICmp(u.wsz, g_wszKernelNames[0]) /* || !RTUtf16ICmp(u.wsz, g_wszKernelNames[1]) */ ) ) { - NTMTE32 Mte3; - rc = DBGFR3MemRead(pVM, 0 /*idCpu*/, DBGFR3AddrFromFlat(pVM, &Addr, Mte2.InLoadOrderLinks.Blink), - &Mte3, RT_SIZEOFMEMB(NTMTE32, InLoadOrderLinks)); + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, + DBGFR3AddrFromFlat(pUVM, &Addr, uMte2.v32.InLoadOrderLinks.Blink), + &uMte3.v32, RT_SIZEOFMEMB(NTMTE32, InLoadOrderLinks)); if ( RT_SUCCESS(rc) - && Mte3.InLoadOrderLinks.Flink == MteAddr.FlatPtr - && WINNT32_VALID_ADDRESS(Mte3.InLoadOrderLinks.Blink) ) + && uMte3.v32.InLoadOrderLinks.Flink == MteAddr.FlatPtr + && WINNT32_VALID_ADDRESS(uMte3.v32.InLoadOrderLinks.Blink) ) { Log(("DigWinNt: MteAddr=%RGv KernelAddr=%RGv SizeOfImage=%x &PsLoadedModuleList=%RGv (32-bit)\n", - MteAddr.FlatPtr, KernelAddr.FlatPtr, Mte2.SizeOfImage, Addr.FlatPtr)); + MteAddr.FlatPtr, KernelAddr.FlatPtr, uMte2.v32.SizeOfImage, Addr.FlatPtr)); pThis->KernelAddr = KernelAddr; pThis->KernelMteAddr = MteAddr; pThis->PsLoadedModuleListAddr = Addr; @@ -755,13 +1035,100 @@ static DECLCALLBACK(bool) dbgDiggerWinNtProbe(PVM pVM, void *pvData) return true; } } + else if (RT_SUCCESS(rc)) + { + Log2(("DigWinNt: Wrong module: MteAddr=%RGv ImageAddr=%RGv SizeOfImage=%#x '%ls'\n", + MteAddr.FlatPtr, KernelAddr.FlatPtr, uMte2.v32.SizeOfImage, u.wsz)); + break; /* Not NT kernel */ + } } /* next */ DBGFR3AddrAdd(&HitAddr, 4); - if (HitAddr.FlatPtr <= UINT32_C(0xfffff000)) - rc = DBGFR3MemScan(pVM, 0 /*idCpu*/, &HitAddr, UINT32_MAX - HitAddr.FlatPtr, - 4 /*align*/, &Mte.DllBase, 3 * sizeof(uint32_t), &HitAddr); + if (HitAddr.FlatPtr < uEnd) + rc = DBGFR3MemScan(pUVM, 0 /*idCpu*/, &HitAddr, uEnd - HitAddr.FlatPtr, + 4 /*align*/, &uMte.v32.DllBase, 3 * sizeof(uint32_t), &HitAddr); + else + rc = VERR_DBGF_MEM_NOT_FOUND; + } + } + } + else + { + IMAGE_NT_HEADERS64 const *pHdrs = (IMAGE_NT_HEADERS64 const *)&u.au8[u.MzHdr.e_lfanew]; + if ( pHdrs->Signature == IMAGE_NT_SIGNATURE + && pHdrs->FileHeader.Machine == IMAGE_FILE_MACHINE_AMD64 + && pHdrs->FileHeader.SizeOfOptionalHeader == sizeof(pHdrs->OptionalHeader) + && pHdrs->FileHeader.NumberOfSections >= 10 /* the kernel has lots */ + && (pHdrs->FileHeader.Characteristics & (IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_DLL)) == IMAGE_FILE_EXECUTABLE_IMAGE + && pHdrs->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC + && pHdrs->OptionalHeader.NumberOfRvaAndSizes == IMAGE_NUMBEROF_DIRECTORY_ENTRIES + ) + { + /* Find the MTE. */ + RT_ZERO(uMte.v64); + uMte.v64.DllBase = KernelAddr.FlatPtr; + uMte.v64.EntryPoint = KernelAddr.FlatPtr + pHdrs->OptionalHeader.AddressOfEntryPoint; + uMte.v64.SizeOfImage = pHdrs->OptionalHeader.SizeOfImage; + DBGFADDRESS ScanAddr; + DBGFADDRESS HitAddr; + rc = DBGFR3MemScan(pUVM, 0 /*idCpu*/, DBGFR3AddrFromFlat(pUVM, &ScanAddr, uStart), + uEnd - uStart, 8 /*align*/, &uMte.v64.DllBase, 5 * sizeof(uint32_t), &HitAddr); + while (RT_SUCCESS(rc)) + { + /* check the name. */ + DBGFADDRESS MteAddr = HitAddr; + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, DBGFR3AddrSub(&MteAddr, RT_OFFSETOF(NTMTE64, DllBase)), + &uMte2.v64, sizeof(uMte2.v64)); + if ( RT_SUCCESS(rc) + && uMte2.v64.DllBase == uMte.v64.DllBase + && uMte2.v64.EntryPoint == uMte.v64.EntryPoint + && uMte2.v64.SizeOfImage == uMte.v64.SizeOfImage + && WINNT64_VALID_ADDRESS(uMte2.v64.InLoadOrderLinks.Flink) + && WINNT64_VALID_ADDRESS(uMte2.v64.BaseDllName.Buffer) + && WINNT64_VALID_ADDRESS(uMte2.v64.FullDllName.Buffer) + && uMte2.v64.BaseDllName.Length <= 128 + && uMte2.v64.FullDllName.Length <= 260 + ) + { + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, DBGFR3AddrFromFlat(pUVM, &Addr, uMte2.v64.BaseDllName.Buffer), + u.wsz, uMte2.v64.BaseDllName.Length); + u.wsz[uMte2.v64.BaseDllName.Length / 2] = '\0'; + if ( RT_SUCCESS(rc) + && ( !RTUtf16ICmp(u.wsz, g_wszKernelNames[0]) + /* || !RTUtf16ICmp(u.wsz, g_wszKernelNames[1]) */ + ) + ) + { + rc = DBGFR3MemRead(pUVM, 0 /*idCpu*/, + DBGFR3AddrFromFlat(pUVM, &Addr, uMte2.v64.InLoadOrderLinks.Blink), + &uMte3.v64, RT_SIZEOFMEMB(NTMTE64, InLoadOrderLinks)); + if ( RT_SUCCESS(rc) + && uMte3.v64.InLoadOrderLinks.Flink == MteAddr.FlatPtr + && WINNT64_VALID_ADDRESS(uMte3.v64.InLoadOrderLinks.Blink) ) + { + Log(("DigWinNt: MteAddr=%RGv KernelAddr=%RGv SizeOfImage=%x &PsLoadedModuleList=%RGv (32-bit)\n", + MteAddr.FlatPtr, KernelAddr.FlatPtr, uMte2.v64.SizeOfImage, Addr.FlatPtr)); + pThis->KernelAddr = KernelAddr; + pThis->KernelMteAddr = MteAddr; + pThis->PsLoadedModuleListAddr = Addr; + pThis->f32Bit = false; + return true; + } + } + else if (RT_SUCCESS(rc)) + { + Log2(("DigWinNt: Wrong module: MteAddr=%RGv ImageAddr=%RGv SizeOfImage=%#x '%ls'\n", + MteAddr.FlatPtr, KernelAddr.FlatPtr, uMte2.v64.SizeOfImage, u.wsz)); + break; /* Not NT kernel */ + } + } + + /* next */ + DBGFR3AddrAdd(&HitAddr, 8); + if (HitAddr.FlatPtr < uEnd) + rc = DBGFR3MemScan(pUVM, 0 /*idCpu*/, &HitAddr, uEnd - HitAddr.FlatPtr, + 8 /*align*/, &uMte.v64.DllBase, 3 * sizeof(uint32_t), &HitAddr); else rc = VERR_DBGF_MEM_NOT_FOUND; } @@ -776,7 +1143,7 @@ static DECLCALLBACK(bool) dbgDiggerWinNtProbe(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnDestruct */ -static DECLCALLBACK(void) dbgDiggerWinNtDestruct(PVM pVM, void *pvData) +static DECLCALLBACK(void) dbgDiggerWinNtDestruct(PUVM pUVM, void *pvData) { } @@ -785,7 +1152,7 @@ static DECLCALLBACK(void) dbgDiggerWinNtDestruct(PVM pVM, void *pvData) /** * @copydoc DBGFOSREG::pfnConstruct */ -static DECLCALLBACK(int) dbgDiggerWinNtConstruct(PVM pVM, void *pvData) +static DECLCALLBACK(int) dbgDiggerWinNtConstruct(PUVM pUVM, void *pvData) { PDBGDIGGERWINNT pThis = (PDBGDIGGERWINNT)pvData; pThis->fValid = false; diff --git a/src/VBox/Debugger/Makefile.kmk b/src/VBox/Debugger/Makefile.kmk index 43989478..6492b2e4 100644 --- a/src/VBox/Debugger/Makefile.kmk +++ b/src/VBox/Debugger/Makefile.kmk @@ -46,7 +46,7 @@ Debugger_SOURCES = \ DBGCBuiltInSymbols.cpp \ DBGCCmdHlp.cpp \ DBGCCmdWorkers.cpp \ - DBGCCommands.cpp \ + DBGCCommands.cpp \ DBGCFunctions.cpp \ DBGCEmulateCodeView.cpp \ DBGCOps.cpp \ @@ -66,8 +66,8 @@ DBGCPlugInDiggers_SOURCES = \ DBGPlugInOS2.cpp \ DBGPlugInCommonELF.cpp DBGCPlugInDiggers_LIBS = \ - $(LIB_VMM) \ - $(LIB_REM) \ + $(if-expr "$(LIB_VMM)" == "$(VBOX_LIB_VMM_LAZY)",$(LIB_REM),) \ + $(VBOX_LIB_VMM_LAZY) \ $(LIB_RUNTIME) @@ -107,7 +107,7 @@ VBoxDbg_SOURCES = \ VBoxDbgConsole.cpp \ VBoxDbgStatsQt4.cpp VBoxDbg_LIBS = \ - $(LIB_VMM) + $(VBOX_LIB_VMM_LAZY) VBoxDbg_LDFLAGS.darwin = \ -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxDbg.dylib diff --git a/src/VBox/Debugger/VBoxDbg.cpp b/src/VBox/Debugger/VBoxDbg.cpp index 9c41c934..bc3287e9 100644 --- a/src/VBox/Debugger/VBoxDbg.cpp +++ b/src/VBox/Debugger/VBoxDbg.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -71,11 +71,11 @@ static const DBGGUIVT g_dbgGuiVT = * * @returns VBox status code. * @param pSession The ISession interface. (DBGGuiCreate) - * @param pVM The VM handle. (DBGGuiCreateForVM) + * @param pUVM The VM handle. (DBGGuiCreateForVM) * @param ppGui See DBGGuiCreate. * @param ppGuiVT See DBGGuiCreate. */ -static int dbgGuiCreate(ISession *pSession, PVM pVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT) +static int dbgGuiCreate(ISession *pSession, PUVM pUVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT) { /* * Allocate and initialize the Debugger GUI handle. @@ -90,7 +90,7 @@ static int dbgGuiCreate(ISession *pSession, PVM pVM, PDBGGUI *ppGui, PCDBGGUIVT if (pSession) rc = pGui->pVBoxDbgGui->init(pSession); else - rc = pGui->pVBoxDbgGui->init(pVM); + rc = pGui->pVBoxDbgGui->init(pUVM); if (RT_SUCCESS(rc)) { /* @@ -134,15 +134,20 @@ DBGDECL(int) DBGGuiCreate(ISession *pSession, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiV * Creates the debugger GUI given a VM handle. * * @returns VBox status code. - * @param pVM The VM handle. + * @param pUVM The VM handle. * @param ppGui Where to store the pointer to the debugger instance. * @param ppGuiVT Where to store the virtual method table pointer. * Optional. */ -DBGDECL(int) DBGGuiCreateForVM(PVM pVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT) +DBGDECL(int) DBGGuiCreateForVM(PUVM pUVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT) { - AssertPtrReturn(pVM, VERR_INVALID_POINTER); - return dbgGuiCreate(NULL, pVM, ppGui, ppGuiVT); + AssertPtrReturn(pUVM, VERR_INVALID_POINTER); + AssertPtrReturn(VMR3RetainUVM(pUVM) != UINT32_MAX, VERR_INVALID_POINTER); + + int rc = dbgGuiCreate(NULL, pUVM, ppGui, ppGuiVT); + + VMR3ReleaseUVM(pUVM); + return rc; } diff --git a/src/VBox/Debugger/VBoxDbgBase.cpp b/src/VBox/Debugger/VBoxDbgBase.cpp index dd08ef33..b7038c9a 100644 --- a/src/VBox/Debugger/VBoxDbgBase.cpp +++ b/src/VBox/Debugger/VBoxDbgBase.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -32,16 +32,17 @@ VBoxDbgBase::VBoxDbgBase(VBoxDbgGui *a_pDbgGui) - : m_pDbgGui(a_pDbgGui), m_pVM(NULL), m_hGUIThread(RTThreadNativeSelf()) + : m_pDbgGui(a_pDbgGui), m_pUVM(NULL), m_hGUIThread(RTThreadNativeSelf()) { /* * Register */ - PVM pVM = a_pDbgGui->getVMHandle(); - if (pVM) + m_pUVM = a_pDbgGui->getUvmHandle(); + if (m_pUVM) { - m_pVM = pVM; - int rc = VMR3AtStateRegister(pVM, atStateChange, this); + VMR3RetainUVM(m_pUVM); + + int rc = VMR3AtStateRegister(m_pUVM, atStateChange, this); AssertRC(rc); } } @@ -53,11 +54,13 @@ VBoxDbgBase::~VBoxDbgBase() * If the VM is still around. */ /** @todo need to do some locking here? */ - PVM pVM = ASMAtomicXchgPtrT(&m_pVM, NULL, PVM); - if (pVM) + PUVM pUVM = ASMAtomicXchgPtrT(&m_pUVM, NULL, PUVM); + if (pUVM) { - int rc = VMR3AtStateDeregister(pVM, atStateChange, this); + int rc = VMR3AtStateDeregister(pUVM, atStateChange, this); AssertRC(rc); + + VMR3ReleaseUVM(pUVM); } } @@ -67,10 +70,10 @@ VBoxDbgBase::stamReset(const QString &rPat) { QByteArray Utf8Array = rPat.toUtf8(); const char *pszPat = !rPat.isEmpty() ? Utf8Array.constData() : NULL; - PVM pVM = m_pVM; - if ( pVM - && VMR3GetState(pVM) < VMSTATE_DESTROYING) - return STAMR3Reset(pVM, pszPat); + PUVM pUVM = m_pUVM; + if ( pUVM + && VMR3GetStateU(pUVM) < VMSTATE_DESTROYING) + return STAMR3Reset(pUVM, pszPat); return VERR_INVALID_HANDLE; } @@ -80,10 +83,10 @@ VBoxDbgBase::stamEnum(const QString &rPat, PFNSTAMR3ENUM pfnEnum, void *pvUser) { QByteArray Utf8Array = rPat.toUtf8(); const char *pszPat = !rPat.isEmpty() ? Utf8Array.constData() : NULL; - PVM pVM = m_pVM; - if ( pVM - && VMR3GetState(pVM) < VMSTATE_DESTROYING) - return STAMR3Enum(pVM, pszPat, pfnEnum, pvUser); + PUVM pUVM = m_pUVM; + if ( pUVM + && VMR3GetStateU(pUVM) < VMSTATE_DESTROYING) + return STAMR3Enum(pUVM, pszPat, pfnEnum, pvUser); return VERR_INVALID_HANDLE; } @@ -91,25 +94,32 @@ VBoxDbgBase::stamEnum(const QString &rPat, PFNSTAMR3ENUM pfnEnum, void *pvUser) int VBoxDbgBase::dbgcCreate(PDBGCBACK pBack, unsigned fFlags) { - PVM pVM = m_pVM; - if ( pVM - && VMR3GetState(pVM) < VMSTATE_DESTROYING) - return DBGCCreate(pVM, pBack, fFlags); + PUVM pUVM = m_pUVM; + if ( pUVM + && VMR3GetStateU(pUVM) < VMSTATE_DESTROYING) + return DBGCCreate(pUVM, pBack, fFlags); return VERR_INVALID_HANDLE; } /*static*/ DECLCALLBACK(void) -VBoxDbgBase::atStateChange(PVM pVM, VMSTATE enmState, VMSTATE /*enmOldState*/, void *pvUser) +VBoxDbgBase::atStateChange(PUVM pUVM, VMSTATE enmState, VMSTATE /*enmOldState*/, void *pvUser) { - VBoxDbgBase *pThis = (VBoxDbgBase *)pvUser; + VBoxDbgBase *pThis = (VBoxDbgBase *)pvUser; NOREF(pUVM); switch (enmState) { case VMSTATE_TERMINATED: + { /** @todo need to do some locking here? */ - if (ASMAtomicCmpXchgPtr(&pThis->m_pVM, NULL, pVM)) + PUVM pUVM2 = ASMAtomicXchgPtrT(&pThis->m_pUVM, NULL, PUVM); + if (pUVM2) + { + Assert(pUVM2 == pUVM); pThis->sigTerminated(); + VMR3ReleaseUVM(pUVM2); + } break; + } case VMSTATE_DESTROYING: pThis->sigDestroying(); @@ -150,7 +160,7 @@ unsigned VBoxDbgBaseWindow::m_cyBorder = 0; VBoxDbgBaseWindow::VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent) - : QWidget(a_pParent, Qt::Window), VBoxDbgBase(a_pDbgGui), m_fPolished(false), + : QWidget(a_pParent, Qt::Window), VBoxDbgBase(a_pDbgGui), m_fPolished(false), m_x(INT_MAX), m_y(INT_MAX), m_cx(0), m_cy(0) { } diff --git a/src/VBox/Debugger/VBoxDbgBase.h b/src/VBox/Debugger/VBoxDbgBase.h index 660d44e6..1b8e30d7 100644 --- a/src/VBox/Debugger/VBoxDbgBase.h +++ b/src/VBox/Debugger/VBoxDbgBase.h @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -59,7 +59,7 @@ public: */ bool isVMOk() const { - return m_pVM != NULL; + return m_pUVM != NULL; } /** @@ -103,24 +103,14 @@ protected: private: - /** - * VM state callback function. - * - * You are not allowed to call any function which changes the VM state from a - * state callback, except VMR3Destroy(). - * - * @param pVM The VM handle. - * @param enmState The new state. - * @param enmOldState The old state. - * @param pvUser The user argument. - */ - static DECLCALLBACK(void) atStateChange(PVM pVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser); + /** @callback_method_impl{FNVMATSTATE} */ + static DECLCALLBACK(void) atStateChange(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser); private: /** Pointer to the debugger GUI object. */ VBoxDbgGui *m_pDbgGui; - /** The VM handle. */ - PVM volatile m_pVM; + /** The user mode VM handle. */ + PUVM volatile m_pUVM; /** The handle of the GUI thread. */ RTNATIVETHREAD m_hGUIThread; }; diff --git a/src/VBox/Debugger/VBoxDbgConsole.cpp b/src/VBox/Debugger/VBoxDbgConsole.cpp index 61f5ca69..77eb8ccb 100644 --- a/src/VBox/Debugger/VBoxDbgConsole.cpp +++ b/src/VBox/Debugger/VBoxDbgConsole.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -82,6 +82,18 @@ VBoxDbgConsoleOutput::VBoxDbgConsoleOutput(QWidget *pParent/* = NULL*/, const ch Pal.setColor(QPalette::All, QPalette::Base, QColor(Qt::black)); setPalette(Pal); setTextColor(QColor(qRgb(0, 0xe0, 0))); + +#ifdef DEBUG_ramshankar + /* Solaris host (esp. S10) has illegible Courier font (bad aliasing). */ + Font.setFamily("Monospace [Monotype]"); + setFont(Font); + + /* White on black while I'm at it. */ + Pal.setColor(QPalette::All, QPalette::Base, QColor(Qt::white)); + setPalette(Pal); + setTextColor(QColor(qRgb(0, 0, 0))); +#endif + NOREF(pszName); } @@ -101,9 +113,9 @@ VBoxDbgConsoleOutput::appendText(const QString &rStr, bool fClearSelection) return; /* - * Insert all in one go and make sure it's visible. - * - * We need to move the cursor and unselect any selected text before + * Insert all in one go and make sure it's visible. + * + * We need to move the cursor and unselect any selected text before * inserting anything, otherwise, text will disappear. */ QTextCursor Cursor = textCursor(); @@ -145,9 +157,10 @@ VBoxDbgConsoleOutput::appendText(const QString &rStr, bool fClearSelection) VBoxDbgConsoleInput::VBoxDbgConsoleInput(QWidget *pParent/* = NULL*/, const char *pszName/* = NULL*/) - : QComboBox(pParent), m_iBlankItem(0), m_hGUIThread(RTThreadNativeSelf()) + : QComboBox(pParent), m_hGUIThread(RTThreadNativeSelf()) { - insertItem(m_iBlankItem, ""); + addItem(""); /* invariant: empty command line is the last item */ + setEditable(true); setInsertPolicy(NoInsert); setAutoCompletion(false); @@ -180,23 +193,52 @@ void VBoxDbgConsoleInput::returnPressed() { Assert(m_hGUIThread == RTThreadNativeSelf()); + + QString strCommand = currentText(); + /* TODO: trim whitespace? */ + if (strCommand.isEmpty()) + return; + /* deal with the current command. */ - QString Str = currentText(); - emit commandSubmitted(Str); + emit commandSubmitted(strCommand); + - /* update the history and clear the entry field */ - QString PrevStr = m_iBlankItem > 0 ? itemText(m_iBlankItem - 1) : ""; - if (PrevStr != Str) + /* + * Add current command to history. + */ + bool fNeedsAppending = true; + + /* invariant: empty line at the end */ + int iLastItem = count() - 1; + Assert(itemText(iLastItem).isEmpty()); + + /* have previous command? check duplicate. */ + if (iLastItem > 0) { - setItemText(m_iBlankItem, Str); - if ( m_iBlankItem > 0 - && m_iBlankItem >= maxCount() - 1) - removeItem(m_iBlankItem - maxCount() - 1); - insertItem(++m_iBlankItem, ""); + const QString strPrevCommand(itemText(iLastItem - 1)); + if (strCommand == strPrevCommand) + fNeedsAppending = false; } - clearEditText(); - setCurrentIndex(m_iBlankItem); + if (fNeedsAppending) + { + /* history full? drop the oldest command. */ + if (count() == maxCount()) + { + removeItem(0); + --iLastItem; + } + + /* insert before the empty line. */ + insertItem(iLastItem, strCommand); + } + + /* invariant: empty line at the end */ + int iNewLastItem = count() - 1; + Assert(itemText(iNewLastItem).isEmpty()); + + /* select empty line to present "new" command line to the user */ + setCurrentIndex(iNewLastItem); } diff --git a/src/VBox/Debugger/VBoxDbgConsole.h b/src/VBox/Debugger/VBoxDbgConsole.h index 25847172..f7bf2555 100644 --- a/src/VBox/Debugger/VBoxDbgConsole.h +++ b/src/VBox/Debugger/VBoxDbgConsole.h @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -53,8 +53,8 @@ public: * This differs from QTextEdit::append() in that it won't start on a new paragraph * unless the previous char was a newline ('\n'). * - * @param rStr The text string to append. - * @param fClearSelection Whether to clear selected text before appending. + * @param rStr The text string to append. + * @param fClearSelection Whether to clear selected text before appending. * If @c false the selection and window position * are preserved. */ @@ -117,8 +117,6 @@ private slots: void returnPressed(); protected: - /** The current blank entry. */ - int m_iBlankItem; /** The handle to the GUI thread. */ RTNATIVETHREAD m_hGUIThread; }; diff --git a/src/VBox/Debugger/VBoxDbgGui.cpp b/src/VBox/Debugger/VBoxDbgGui.cpp index d2f7f451..9cf91bf2 100644 --- a/src/VBox/Debugger/VBoxDbgGui.cpp +++ b/src/VBox/Debugger/VBoxDbgGui.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -32,7 +32,7 @@ VBoxDbgGui::VBoxDbgGui() : m_pDbgStats(NULL), m_pDbgConsole(NULL), m_pSession(NULL), m_pConsole(NULL), - m_pMachineDebugger(NULL), m_pMachine(NULL), m_pVM(NULL), + m_pMachineDebugger(NULL), m_pMachine(NULL), m_pUVM(NULL), m_pParent(NULL), m_pMenu(NULL), m_x(0), m_y(0), m_cx(0), m_cy(0), m_xDesktop(0), m_yDesktop(0), m_cxDesktop(0), m_cyDesktop(0) { @@ -40,12 +40,12 @@ VBoxDbgGui::VBoxDbgGui() : } -int VBoxDbgGui::init(PVM pVM) +int VBoxDbgGui::init(PUVM pUVM) { /* * Set the VM handle and update the desktop size. */ - m_pVM = pVM; + m_pUVM = pUVM; /* Note! This eats the incoming reference to the handle! */ updateDesktopSize(); return VINF_SUCCESS; @@ -78,9 +78,12 @@ int VBoxDbgGui::init(ISession *pSession) hrc = m_pMachineDebugger->COMGETTER(VM)(&llVM); if (SUCCEEDED(hrc)) { - rc = init((PVM)(intptr_t)llVM); + PUVM pUVM = (PUVM)(intptr_t)llVM; + rc = init(pUVM); if (RT_SUCCESS(rc)) return rc; + + VMR3ReleaseUVM(pUVM); } /* damn, failure! */ @@ -136,7 +139,11 @@ VBoxDbgGui::~VBoxDbgGui() m_pSession = NULL; } - m_pVM = NULL; + if (m_pUVM) + { + VMR3ReleaseUVM(m_pUVM); + m_pUVM = NULL; + } } void diff --git a/src/VBox/Debugger/VBoxDbgGui.h b/src/VBox/Debugger/VBoxDbgGui.h index 01eb8972..c0727e44 100644 --- a/src/VBox/Debugger/VBoxDbgGui.h +++ b/src/VBox/Debugger/VBoxDbgGui.h @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -57,9 +57,10 @@ public: * Initializes a VBoxDbgGui object by VM handle. * * @returns VBox status code. - * @param pVM The VM handle. + * @param pUVM The user mode VM handle. The caller's reference will be + * consumed on success. */ - int init(PVM pVM); + int init(PUVM pUVM); /** * Destroys the VBoxDbgGui object. @@ -128,12 +129,12 @@ public: void adjustRelativePos(int x, int y, unsigned cx, unsigned cy); /** - * Gets the VM handle. - * @returns The VM handle. + * Gets the user mode VM handle. + * @returns The UVM handle. */ - PVM getVMHandle() const + PUVM getUvmHandle() const { - return m_pVM; + return m_pUVM; } @@ -161,6 +162,8 @@ protected: IMachine *m_pMachine; /** The VM instance. */ PVM m_pVM; + /** The user mode VM handle. */ + PUVM m_pUVM; /** The parent widget. */ QWidget *m_pParent; diff --git a/src/VBox/Debugger/VBoxDbgStatsQt4.cpp b/src/VBox/Debugger/VBoxDbgStatsQt4.cpp index 5e42c274..6637c4b1 100644 --- a/src/VBox/Debugger/VBoxDbgStatsQt4.cpp +++ b/src/VBox/Debugger/VBoxDbgStatsQt4.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -354,6 +354,17 @@ protected: static ssize_t getNodePath(PCDBGGUISTATSNODE pNode, char *psz, ssize_t cch); /** + * Calculates the full path of a node, returning the string pointer. + * + * @returns @a psz. On failure, NULL. + * + * @param pNode The node. + * @param psz The output buffer. + * @param cch The size of the buffer. + */ + static char *getNodePath2(PCDBGGUISTATSNODE pNode, char *psz, ssize_t cch); + + /** * Check if the first node is an ancestor to the second one. * * @returns true/false. @@ -1311,6 +1322,16 @@ VBoxDbgStatsModel::getNodePath(PCDBGGUISTATSNODE pNode, char *psz, ssize_t cch) } +/*static*/ char * +VBoxDbgStatsModel::getNodePath2(PCDBGGUISTATSNODE pNode, char *psz, ssize_t cch) +{ + if (VBoxDbgStatsModel::getNodePath(pNode, psz, cch) < 0) + return NULL; + return psz; +} + + + /*static*/ bool VBoxDbgStatsModel::isNodeAncestorOf(PCDBGGUISTATSNODE pAncestor, PCDBGGUISTATSNODE pDescendant) { @@ -1433,6 +1454,10 @@ VBoxDbgStatsModel::createDiffTree(PDBGGUISTATSNODE pTree1, PDBGGUISTATSNODE pTre PDBGGUISTATSNODE VBoxDbgStatsModel::updateCallbackHandleOutOfOrder(const char *pszName) { +#if defined(VBOX_STRICT) || defined(LOG_ENABLED) + char szStrict[1024]; +#endif + /* * We might be inserting a new node between pPrev and pNode * or we might be removing one or more nodes. Either case is @@ -1450,6 +1475,11 @@ VBoxDbgStatsModel::updateCallbackHandleOutOfOrder(const char *pszName) */ PDBGGUISTATSNODE pNode = m_pUpdateParent->papChildren[m_iUpdateChild]; PDBGGUISTATSNODE const pPrev = prevDataNode(pNode); + AssertMsg(strcmp(pszName, getNodePath2(pNode, szStrict, sizeof(szStrict))), ("%s\n", szStrict)); + AssertMsg(strcmp(pszName, getNodePath2(pPrev, szStrict, sizeof(szStrict))), ("%s\n", szStrict)); + Log(("updateCallbackHandleOutOfOrder: pszName='%s' m_szUpdateParent='%s' m_cchUpdateParent=%u pNode='%s'\n", + pszName, m_szUpdateParent, m_cchUpdateParent, getNodePath2(pNode, szStrict, sizeof(szStrict)))); + pNode = pNode->pParent; while (pNode != m_pRoot) { @@ -1458,6 +1488,7 @@ VBoxDbgStatsModel::updateCallbackHandleOutOfOrder(const char *pszName) Assert(m_cchUpdateParent > pNode->cchName); m_cchUpdateParent -= pNode->cchName + 1; m_szUpdateParent[m_cchUpdateParent] = '\0'; + Log2(("updateCallbackHandleOutOfOrder: m_szUpdateParent='%s' m_cchUpdateParent=%u, removed '/%s' (%u)\n", m_szUpdateParent, m_cchUpdateParent, pNode->pszName, __LINE__)); pNode = pNode->pParent; } Assert(m_szUpdateParent[m_cchUpdateParent - 1] == '/'); @@ -1469,7 +1500,7 @@ VBoxDbgStatsModel::updateCallbackHandleOutOfOrder(const char *pszName) while (pszName[m_cchUpdateParent - 1] == '/') { /* Find the end of this component. */ - const char *const pszSubName = &pszName[m_cchUpdateParent]; + const char * const pszSubName = &pszName[m_cchUpdateParent]; const char *pszEnd = strchr(pszSubName, '/'); if (!pszEnd) pszEnd = strchr(pszSubName, '\0'); @@ -1481,6 +1512,7 @@ VBoxDbgStatsModel::updateCallbackHandleOutOfOrder(const char *pszName) m_szUpdateParent[m_cchUpdateParent++] = '/'; m_szUpdateParent[m_cchUpdateParent] = '\0'; Assert(m_cchUpdateParent < sizeof(m_szUpdateParent)); + Log2(("updateCallbackHandleOutOfOrder: m_szUpdateParent='%s' m_cchUpdateParent=%u (%u)\n", m_szUpdateParent, m_cchUpdateParent, __LINE__)); if (!pNode->cChildren) { @@ -1570,6 +1602,7 @@ VBoxDbgStatsModel::updateCallbackHandleOutOfOrder(const char *pszName) m_szUpdateParent[m_cchUpdateParent] = '\0'; m_pUpdateParent = pNode->pParent; m_iUpdateChild = pNode->iSelf; + Log2(("updateCallbackHandleOutOfOrder: m_szUpdateParent='%s' m_cchUpdateParent=%u (%u)\n", m_szUpdateParent, m_cchUpdateParent, __LINE__)); return pNode; } @@ -2818,7 +2851,12 @@ void VBoxDbgStatsView::resizeColumnsToContent() { for (int i = 0; i <= 8; i++) + { resizeColumnToContents(i); + /* Some extra room for distinguishing numbers better in Value, Min, Avg, Max, Total, dInt columns. */ + if (i >= 2 && i <= 7) + setColumnWidth(i, columnWidth(i) + 10); + } } diff --git a/src/VBox/Debugger/testcase/tstDBGCParser.cpp b/src/VBox/Debugger/testcase/tstDBGCParser.cpp index 56785209..5c1b884e 100644 --- a/src/VBox/Debugger/testcase/tstDBGCParser.cpp +++ b/src/VBox/Debugger/testcase/tstDBGCParser.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2011 Oracle Corporation + * Copyright (C) 2006-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; diff --git a/src/VBox/Debugger/testcase/tstDBGCStubs.cpp b/src/VBox/Debugger/testcase/tstDBGCStubs.cpp index b0429d19..395f5d86 100644 --- a/src/VBox/Debugger/testcase/tstDBGCStubs.cpp +++ b/src/VBox/Debugger/testcase/tstDBGCStubs.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2011 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -22,12 +22,12 @@ #include <VBox/vmm/dbgf.h> -VMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromFlat(PVM pVM, PDBGFADDRESS pAddress, RTGCUINTPTR FlatPtr) +VMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromFlat(PUVM pUVM, PDBGFADDRESS pAddress, RTGCUINTPTR FlatPtr) { return NULL; } -VMMR3DECL(int) DBGFR3AddrFromSelOff(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, RTSEL Sel, RTUINTPTR off) +VMMR3DECL(int) DBGFR3AddrFromSelOff(PUVM pUVM, VMCPUID idCpu, PDBGFADDRESS pAddress, RTSEL Sel, RTUINTPTR off) { /* bad:bad -> provke error during parsing. */ if (Sel == 0xbad && off == 0xbad) @@ -41,125 +41,121 @@ VMMR3DECL(int) DBGFR3AddrFromSelOff(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddres return VINF_SUCCESS; } -VMMR3DECL(int) DBGFR3AddrToPhys(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTGCPHYS pGCPhys) +VMMR3DECL(int) DBGFR3AddrToPhys(PUVM pUVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTGCPHYS pGCPhys) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3AddrToHostPhys(PVMCPU pVCpu, PDBGFADDRESS pAddress, PRTHCPHYS pHCPhys) +VMMR3DECL(int) DBGFR3Attach(PUVM pUVM) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3AddrToVolatileR3Ptr(PVMCPU pVCpu, PDBGFADDRESS pAddress, bool fReadOnly, void **ppvR3Ptr) +VMMR3DECL(int) DBGFR3BpClear(PUVM pUVM, RTUINT iBp) { return VERR_INTERNAL_ERROR; } - -VMMR3DECL(int) DBGFR3Attach(PVM pVM) -{ - return VERR_INTERNAL_ERROR; -} - -VMMR3DECL(int) DBGFR3BpClear(PVM pVM, RTUINT iBp) -{ - return VERR_INTERNAL_ERROR; -} -VMMR3DECL(int) DBGFR3BpDisable(PVM pVM, RTUINT iBp) +VMMR3DECL(int) DBGFR3BpDisable(PUVM pUVM, RTUINT iBp) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3BpEnable(PVM pVM, RTUINT iBp) +VMMR3DECL(int) DBGFR3BpEnable(PUVM pUVM, RTUINT iBp) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3BpEnum(PVM pVM, PFNDBGFBPENUM pfnCallback, void *pvUser) +VMMR3DECL(int) DBGFR3BpEnum(PUVM pUVM, PFNDBGFBPENUM pfnCallback, void *pvUser) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3BpSet(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp) +VMMR3DECL(int) DBGFR3BpSet(PUVM pUVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3BpSetReg(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, +VMMR3DECL(int) DBGFR3BpSetReg(PUVM pUVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint8_t fType, uint8_t cb, PRTUINT piBp) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp) +VMMR3DECL(int) DBGFR3BpSetREM(PUVM pUVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(bool) DBGFR3CanWait(PVM pVM) +VMMR3DECL(int) DBGFR3QueryWaitable(PUVM pUVM) { - return true; + return VINF_SUCCESS; } -VMMR3DECL(int) DBGFR3Detach(PVM pVM) +VMMR3DECL(int) DBGFR3Detach(PUVM pUVM) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3DisasInstrEx(PVM pVM, VMCPUID idCpu, RTSEL Sel, RTGCPTR GCPtr, uint32_t fFlags, +VMMR3DECL(int) DBGFR3DisasInstrEx(PUVM pUVM, VMCPUID idCpu, RTSEL Sel, RTGCPTR GCPtr, uint32_t fFlags, char *pszOutput, uint32_t cchOutput, uint32_t *pcbInstr) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3EventWait(PVM pVM, RTMSINTERVAL cMillies, PCDBGFEVENT *ppEvent) +VMMR3DECL(int) DBGFR3EventWait(PUVM pUVM, RTMSINTERVAL cMillies, PCDBGFEVENT *ppEvent) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3Halt(PVM pVM) +VMMR3DECL(int) DBGFR3Halt(PUVM pUVM) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3Info(PVM pVM, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp) +VMMR3DECL(int) DBGFR3Info(PUVM pUVM, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3InfoEx(PVM pVM, VMCPUID idCpu, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp) +VMMR3DECL(int) DBGFR3InfoEx(PUVM pUVM, VMCPUID idCpu, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(bool) DBGFR3IsHalted(PVM pVM) +VMMR3DECL(bool) DBGFR3IsHalted(PUVM pUVM) { return true; } -VMMR3DECL(int) DBGFR3LineByAddr(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFLINE pLine) +VMMR3DECL(int) DBGFR3LogModifyDestinations(PUVM pUVM, const char *pszDestSettings) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3LogModifyDestinations(PVM pVM, const char *pszDestSettings) +VMMR3DECL(int) DBGFR3LogModifyFlags(PUVM pUVM, const char *pszFlagSettings) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3LogModifyFlags(PVM pVM, const char *pszFlagSettings) +VMMR3DECL(int) DBGFR3LogModifyGroups(PUVM pUVM, const char *pszGroupSettings) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3LogModifyGroups(PVM pVM, const char *pszGroupSettings) +VMMR3DECL(RTDBGCFG) DBGFR3AsGetConfig(PUVM pUVM) { - return VERR_INTERNAL_ERROR; + return NIL_RTDBGCFG; } -VMMR3DECL(int) DBGFR3ModuleLoad(PVM pVM, const char *pszFilename, RTGCUINTPTR AddressDelta, const char *pszName, RTGCUINTPTR ModuleAddress, unsigned cbImage) +VMMR3DECL(int) DBGFR3AsLoadImage(PUVM pUVM, RTDBGAS hAS, const char *pszFilename, const char *pszModName, RTLDRARCH enmArch, + PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3AsLoadImage(PVM pVM, RTDBGAS hAS, const char *pszFilename, const char *pszModName, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags) +VMMR3DECL(int) DBGFR3AsLoadMap(PUVM pUVM, RTDBGAS hAS, const char *pszFilename, const char *pszModName, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, RTGCUINTPTR uSubtrahend, uint32_t fFlags) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3AsLoadMap(PVM pVM, RTDBGAS hAS, const char *pszFilename, const char *pszModName, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, RTGCUINTPTR uSubtrahend, uint32_t fFlags) +VMMR3DECL(int) DBGFR3AsUnlinkModuleByName(PUVM pUVM, RTDBGAS hDbgAs, const char *pszModName) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(RTDBGAS) DBGFR3AsResolveAndRetain(PVM pVM, RTDBGAS hAlias) +VMMR3DECL(RTDBGAS) DBGFR3AsResolveAndRetain(PUVM pUVM, RTDBGAS hAlias) { return NIL_RTDBGAS; } -VMMR3DECL(int) DBGFR3Resume(PVM pVM) +VMMR3DECL(int) DBGFR3AsLineByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, + PRTGCINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod) +{ + return VERR_DBG_LINE_NOT_FOUND; +} +VMMR3DECL(int) DBGFR3Resume(PUVM pUVM) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3StackWalkBegin(PVM pVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFSTACKFRAME *ppFirstFrame) +VMMR3DECL(int) DBGFR3StackWalkBegin(PUVM pUVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFSTACKFRAME *ppFirstFrame) { return VERR_INTERNAL_ERROR; } @@ -170,40 +166,40 @@ VMMR3DECL(PCDBGFSTACKFRAME) DBGFR3StackWalkNext(PCDBGFSTACKFRAME pCurrent) VMMR3DECL(void) DBGFR3StackWalkEnd(PCDBGFSTACKFRAME pFirstFrame) { } -VMMR3DECL(int) DBGFR3Step(PVM pVM, VMCPUID idCpu) +VMMR3DECL(int) DBGFR3Step(PUVM pUVM, VMCPUID idCpu) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3AsSymbolByAddr(PVM pVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, PRTGCINTPTR poffDisplacement, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod) +VMMR3DECL(int) DBGFR3AsSymbolByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, uint32_t fFlags, PRTGCINTPTR poffDisplacement, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3AsSymbolByName(PVM pVM, RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod) +VMMR3DECL(int) DBGFR3AsSymbolByName(PUVM pUVM, RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3MemScan(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, RTGCUINTPTR uAlign, const void *pabNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress) +VMMR3DECL(int) DBGFR3MemScan(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, RTGCUINTPTR uAlign, const void *pabNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3MemRead(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void *pvBuf, size_t cbRead) +VMMR3DECL(int) DBGFR3MemRead(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void *pvBuf, size_t cbRead) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3MemReadString(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, char *pszBuf, size_t cchBuf) +VMMR3DECL(int) DBGFR3MemReadString(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, char *pszBuf, size_t cchBuf) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3MemWrite(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, const void *pvBuf, size_t cbRead) +VMMR3DECL(int) DBGFR3MemWrite(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, const void *pvBuf, size_t cbRead) { return VERR_INTERNAL_ERROR; } -VMMDECL(int) DBGFR3PagingDumpEx(PVM pVM, VMCPUID idCpu, uint32_t fFlags, uint64_t cr3, uint64_t u64FirstAddr, +VMMDECL(int) DBGFR3PagingDumpEx(PUVM pUVM, VMCPUID idCpu, uint32_t fFlags, uint64_t cr3, uint64_t u64FirstAddr, uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3RegNmValidate(PVM pVM, VMCPUID idDefCpu, const char *pszReg) +VMMR3DECL(int) DBGFR3RegNmValidate(PUVM pUVM, VMCPUID idDefCpu, const char *pszReg) { if ( !strcmp(pszReg, "ah") || !strcmp(pszReg, "ax") @@ -212,23 +208,23 @@ VMMR3DECL(int) DBGFR3RegNmValidate(PVM pVM, VMCPUID idDefCpu, const char *pszReg return VINF_SUCCESS; return VERR_DBGF_REGISTER_NOT_FOUND; } -VMMR3DECL(int) DBGFR3RegCpuQueryU8( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t *pu8) +VMMR3DECL(int) DBGFR3RegCpuQueryU8( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t *pu8) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3RegCpuQueryU16( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint16_t *pu16) +VMMR3DECL(int) DBGFR3RegCpuQueryU16( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint16_t *pu16) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3RegCpuQueryU32( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint32_t *pu32) +VMMR3DECL(int) DBGFR3RegCpuQueryU32( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint32_t *pu32) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3RegCpuQueryU64( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t *pu64) +VMMR3DECL(int) DBGFR3RegCpuQueryU64( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t *pu64) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3RegNmQuery(PVM pVM, VMCPUID idDefCpu, const char *pszReg, PDBGFREGVAL pValue, PDBGFREGVALTYPE penmType) +VMMR3DECL(int) DBGFR3RegNmQuery(PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, PDBGFREGVAL pValue, PDBGFREGVALTYPE penmType) { if (idDefCpu == 0 || idDefCpu == DBGFREG_HYPER_VMCPUID) { @@ -259,7 +255,7 @@ VMMR3DECL(int) DBGFR3RegNmQuery(PVM pVM, VMCPUID idDefCpu, const char *pszReg, P } return VERR_DBGF_REGISTER_NOT_FOUND; } -VMMR3DECL(int) DBGFR3RegPrintf(PVM pVM, VMCPUID idCpu, char *pszBuf, size_t cbBuf, const char *pszFormat, ...) +VMMR3DECL(int) DBGFR3RegPrintf(PUVM pUVM, VMCPUID idCpu, char *pszBuf, size_t cbBuf, const char *pszFormat, ...) { return VERR_INTERNAL_ERROR; } @@ -267,48 +263,56 @@ VMMDECL(ssize_t) DBGFR3RegFormatValue(char *pszBuf, size_t cbBuf, PCDBGFREGVAL p { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3RegNmSet(PVM pVM, VMCPUID idDefCpu, const char *pszReg, PCDBGFREGVAL pValue, DBGFREGVALTYPE enmType) +VMMR3DECL(int) DBGFR3RegNmSet(PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, PCDBGFREGVAL pValue, DBGFREGVALTYPE enmType) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromPhys(PVM pVM, PDBGFADDRESS pAddress, RTGCPHYS PhysAddr) +VMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromPhys(PUVM pUVM, PDBGFADDRESS pAddress, RTGCPHYS PhysAddr) { return NULL; } -VMMR3DECL(int) DBGFR3AddrToHostPhys(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTHCPHYS pHCPhys) +VMMR3DECL(int) DBGFR3AddrToHostPhys(PUVM pUVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTHCPHYS pHCPhys) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3AddrToVolatileR3Ptr(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, bool fReadOnly, void **ppvR3Ptr) +VMMR3DECL(int) DBGFR3AddrToVolatileR3Ptr(PUVM pUVM, VMCPUID idCpu, PDBGFADDRESS pAddress, bool fReadOnly, void **ppvR3Ptr) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3OSRegister(PVM pVM, PCDBGFOSREG pReg) +VMMR3DECL(int) DBGFR3OSRegister(PUVM pUVM, PCDBGFOSREG pReg) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3OSDetect(PVM pVM, char *pszName, size_t cchName) +VMMR3DECL(int) DBGFR3OSDetect(PUVM pUVM, char *pszName, size_t cchName) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3OSQueryNameAndVersion(PVM pVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion) +VMMR3DECL(int) DBGFR3OSQueryNameAndVersion(PUVM pUVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) DBGFR3SelQueryInfo(PVM pVM, VMCPUID idCpu, RTSEL Sel, uint32_t fFlags, PDBGFSELINFO pSelInfo) +VMMR3DECL(int) DBGFR3SelQueryInfo(PUVM pUVM, VMCPUID idCpu, RTSEL Sel, uint32_t fFlags, PDBGFSELINFO pSelInfo) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(CPUMMODE) DBGFR3CpuGetMode(PVM pVM, VMCPUID idCpu) +VMMR3DECL(CPUMMODE) DBGFR3CpuGetMode(PUVM pUVM, VMCPUID idCpu) { return CPUMMODE_INVALID; } +VMMR3DECL(VMCPUID) DBGFR3CpuGetCount(PUVM pUVM) +{ + return 1; +} +VMMR3DECL(bool) DBGFR3CpuIsIn64BitCode(PUVM pUVM, VMCPUID idCpu) +{ + return false; +} -VMMR3DECL(int) DBGFR3CoreWrite(PVM pVM, const char *pszFilename, bool fReplaceFile) +VMMR3DECL(int) DBGFR3CoreWrite(PUVM pUVM, const char *pszFilename, bool fReplaceFile) { return VERR_INTERNAL_ERROR; } @@ -380,15 +384,16 @@ VMMDECL(bool) CPUMIsGuestIn64BitCode(PVMCPU pVCpu) return false; } - -#include <VBox/vmm/mm.h> - -VMMR3DECL(int) MMR3HCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys, void **ppv) +VMMDECL(uint32_t) CPUMGetGuestEFlags(PVMCPU pVCpu) { - return VERR_INTERNAL_ERROR; + return 2; } - +#include <VBox/vmm/hm.h> +VMMR3DECL(bool) HMR3IsEnabled(PUVM pUVM) +{ + return true; +} #include <VBox/vmm/pgm.h> @@ -403,16 +408,16 @@ VMMDECL(PGMMODE) PGMGetShadowMode(PVMCPU pVCpu) return PGMMODE_INVALID; } -VMMR3DECL(int) PGMR3DbgR3Ptr2GCPhys(PVM pVM, RTR3PTR R3Ptr, PRTGCPHYS pGCPhys) +VMMR3DECL(int) PGMR3DbgR3Ptr2GCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTGCPHYS pGCPhys) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) PGMR3DbgR3Ptr2HCPhys(PVM pVM, RTR3PTR R3Ptr, PRTHCPHYS pHCPhys) +VMMR3DECL(int) PGMR3DbgR3Ptr2HCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTHCPHYS pHCPhys) { return VERR_INTERNAL_ERROR; } -VMMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PVM pVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys) +VMMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PUVM pUVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys) { return VERR_INTERNAL_ERROR; } @@ -420,8 +425,13 @@ VMMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PVM pVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys #include <VBox/vmm/vmm.h> -VMMDECL(PVMCPU) VMMGetCpuById(PVM pVM, RTCPUID idCpu) +VMMR3DECL(PVMCPU) VMMR3GetCpuByIdU(PUVM pUVM, RTCPUID idCpu) { return NULL; } + +VMMR3DECL(PVM) VMR3GetVM(PUVM pUVM) +{ + return NULL; +} diff --git a/src/VBox/Debugger/testcase/tstVBoxDbg.cpp b/src/VBox/Debugger/testcase/tstVBoxDbg.cpp index d39f4b6a..5d72c8db 100644 --- a/src/VBox/Debugger/testcase/tstVBoxDbg.cpp +++ b/src/VBox/Debugger/testcase/tstVBoxDbg.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -45,7 +45,8 @@ int main(int argc, char **argv) * Create empty VM. */ PVM pVM; - int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM); + PUVM pUVM; + int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM, &pUVM); if (RT_SUCCESS(rc)) { /* @@ -54,7 +55,7 @@ int main(int argc, char **argv) QApplication App(argc, argv); PDBGGUI pGui; PCDBGGUIVT pGuiVT; - rc = DBGGuiCreateForVM(pVM, &pGui, &pGuiVT); + rc = DBGGuiCreateForVM(pUVM, &pGui, &pGuiVT); if (RT_SUCCESS(rc)) { if (argc <= 1 || argc == 2) @@ -92,12 +93,13 @@ int main(int argc, char **argv) /* * Cleanup. */ - rc = VMR3Destroy(pVM); + rc = VMR3Destroy(pUVM); if (!RT_SUCCESS(rc)) { RTPrintf(TESTCASE ": error: failed to destroy vm! rc=%Rrc\n", rc); cErrors++; } + VMR3ReleaseUVM(pUVM); } else { |