DBGCEmulateCodeView.cpp revision c4a8ca07604ce89da937bad1cb7cc76b1d831da5
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * DBGC - Debugger Console, CodeView / WinDbg Emulation.
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * available from http://www.virtualbox.org. This file is free software;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * General Public License (GPL) as published by the Free Software
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * additional information or have any questions.
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync/*******************************************************************************
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync* Header Files *
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync*******************************************************************************/
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/*******************************************************************************
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync* Internal Functions *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync*******************************************************************************/
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkAccess(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkClear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkDisable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkEnable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkList(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsyncstatic DECLCALLBACK(int) dbgcCmdDumpDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsyncstatic DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsyncstatic DECLCALLBACK(int) dbgcCmdDumpPageDir(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsyncstatic DECLCALLBACK(int) dbgcCmdDumpPageDirBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsyncstatic DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdDumpPageTableBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdDumpTSS(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdGo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdListNear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdMemoryInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdReg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdRegGuest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdRegHyper(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdRegTerse(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdSearchMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdSearchMemType(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdTrace(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/*******************************************************************************
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync* Global Variables *
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync*******************************************************************************/
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'ba' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 1, 1, DBGCVAR_CAT_STRING, 0, "access", "The access type: x=execute, rw=read/write (alias r), w=write, i=not implemented." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 1, 1, DBGCVAR_CAT_NUMBER, 0, "size", "The access size: 1, 2, 4, or 8. 'x' access requires 1, and 8 requires amd64 long mode." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 1, 1, DBGCVAR_CAT_GC_POINTER, 0, "address", "The address." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_NUMBER, 0, "passes", "The number of passes before we trigger the breakpoint. (0 is default)" },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_NUMBER, DBGCVD_FLAGS_DEP_PREV, "max passes", "The number of passes after which we stop triggering the breakpoint. (~0 is default)" },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_STRING, 0, "cmds", "String of commands to be executed when the breakpoint is hit. Quote it!" },
9b7ab382b3f9667e8847020e1e58f7143c4d2334vboxsync/** 'bc', 'bd', 'be' arguments. */
9b7ab382b3f9667e8847020e1e58f7143c4d2334vboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
9b7ab382b3f9667e8847020e1e58f7143c4d2334vboxsync { 0, ~0, DBGCVAR_CAT_NUMBER, 0, "#bp", "Breakpoint number." },
9b7ab382b3f9667e8847020e1e58f7143c4d2334vboxsync { 0, 1, DBGCVAR_CAT_STRING, 0, "all", "All breakpoints." },
9b7ab382b3f9667e8847020e1e58f7143c4d2334vboxsync/** 'bp' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 1, 1, DBGCVAR_CAT_GC_POINTER, 0, "address", "The address." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_NUMBER, 0, "passes", "The number of passes before we trigger the breakpoint. (0 is default)" },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_NUMBER, DBGCVD_FLAGS_DEP_PREV, "max passes", "The number of passes after which we stop triggering the breakpoint. (~0 is default)" },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_STRING, 0, "cmds", "String of commands to be executed when the breakpoint is hit. Quote it!" },
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync/** 'br' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 1, 1, DBGCVAR_CAT_GC_POINTER, 0, "address", "The address." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_NUMBER, 0, "passes", "The number of passes before we trigger the breakpoint. (0 is default)" },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_NUMBER, DBGCVD_FLAGS_DEP_PREV, "max passes", "The number of passes after which we stop triggering the breakpoint. (~0 is default)" },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_STRING, 0, "cmds", "String of commands to be executed when the breakpoint is hit. Quote it!" },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'd?' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address where to start dumping memory." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'dg', 'dga', 'dl', 'dla' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync { 0, ~0, DBGCVAR_CAT_NUMBER, 0, "sel", "Selector or selector range." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, ~0, DBGCVAR_CAT_POINTER, 0, "address", "Far address which selector should be dumped." },
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync/** 'di', 'dia' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync { 0, ~0, DBGCVAR_CAT_NUMBER, 0, "int", "The interrupt vector or interrupt vector range." },
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync/** 'dpd*' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_NUMBER, 0, "index", "Index into the page directory." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address which page directory entry to start dumping from. Range is applied to the page directory." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'dpda' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address of the page directory entry to start dumping from." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'dpt?' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync { 1, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address which page directory entry to start dumping from." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'dpta' arguments. */
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 1, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address of the page table entry to start dumping from." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'dt' arguments. */
9540eeb13face31ddc1c5f15338556fe46f18a77vboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync { 0, 1, DBGCVAR_CAT_NUMBER, 0, "tss", "TSS selector number." },
9540eeb13face31ddc1c5f15338556fe46f18a77vboxsync { 0, 1, DBGCVAR_CAT_POINTER, 0, "tss:ign|addr", "TSS address. If the selector is a TSS selector, the offset will be ignored." }
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync/** 'ln' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, ~0, DBGCVAR_CAT_POINTER, 0, "address", "Address of the symbol to look up." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, ~0, DBGCVAR_CAT_SYMBOL, 0, "symbol", "Symbol to lookup." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'ln' return. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync 1, 1, DBGCVAR_CAT_POINTER, 0, "address", "The last resolved symbol/address with adjusted range."
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'ls' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address where to start looking for source lines." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'm' argument. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
9540eeb13face31ddc1c5f15338556fe46f18a77vboxsync { 1, 1, DBGCVAR_CAT_POINTER, 0, "address", "Pointer to obtain info about." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'r' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_SYMBOL, 0, "register", "Register to show or set." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_NUMBER_NO_RANGE, DBGCVD_FLAGS_DEP_PREV, "value", "New register value." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 's' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_OPTION, 0, "-b", "Byte string." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_OPTION, 0, "-w", "Word string." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_OPTION, 0, "-d", "DWord string." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_OPTION, 0, "-q", "QWord string." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_OPTION, 0, "-a", "ASCII string." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_OPTION, 0, "-u", "Unicode string." },
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync { 0, 1, DBGCVAR_CAT_OPTION_NUMBER, 0, "-n <Hits>", "Maximum number of hits." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_GC_POINTER, 0, "range", "Register to show or set." },
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync { 0, ~0, DBGCVAR_CAT_ANY, 0, "pattern", "Pattern to search for." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 's?' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 1, 1, DBGCVAR_CAT_GC_POINTER, 0, "range", "Register to show or set." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 1, ~0, DBGCVAR_CAT_ANY, 0, "pattern", "Pattern to search for." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** 'u' arguments. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address where to start disassembling." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** Command descriptors for the CodeView / WinDbg emulation.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The emulation isn't attempting to be identical, only somewhat similar.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* pszCmd, cArgsMin, cArgsMax, paArgDescs, cArgDescs, pResultDesc, fFlags, pfnHandler pszSyntax, ....pszDescription */
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync { "ba", 3, 6, &g_aArgBrkAcc[0], RT_ELEMENTS(g_aArgBrkAcc), NULL, 0, dbgcCmdBrkAccess, "<access> <size> <address> [passes [max passes]] [cmds]",
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync "Sets a data access breakpoint." },
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync { "bc", 1, ~0, &g_aArgBrks[0], RT_ELEMENTS(g_aArgBrks), NULL, 0, dbgcCmdBrkClear, "all | <bp#> [bp# []]", "Enabled a set of breakpoints." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "bd", 1, ~0, &g_aArgBrks[0], RT_ELEMENTS(g_aArgBrks), NULL, 0, dbgcCmdBrkDisable, "all | <bp#> [bp# []]", "Disables a set of breakpoints." },
2e5aced57476316542e80047953840c7b4887337vboxsync { "be", 1, ~0, &g_aArgBrks[0], RT_ELEMENTS(g_aArgBrks), NULL, 0, dbgcCmdBrkEnable, "all | <bp#> [bp# []]", "Enabled a set of breakpoints." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "bl", 0, 0, NULL, 0, NULL, 0, dbgcCmdBrkList, "", "Lists all the breakpoints." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "bp", 1, 4, &g_aArgBrkSet[0], RT_ELEMENTS(g_aArgBrkSet), NULL, 0, dbgcCmdBrkSet, "<address> [passes [max passes]] [cmds]",
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync "Sets a breakpoint (int 3)." },
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync { "br", 1, 4, &g_aArgBrkREM[0], RT_ELEMENTS(g_aArgBrkREM), NULL, 0, dbgcCmdBrkREM, "<address> [passes [max passes]] [cmds]",
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync "Sets a recompiler specific breakpoint." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "d", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), NULL, 0, dbgcCmdDumpMem, "[addr]", "Dump memory using last element size." },
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync { "da", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), NULL, 0, dbgcCmdDumpMem, "[addr]", "Dump memory as ascii string." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "db", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), NULL, 0, dbgcCmdDumpMem, "[addr]", "Dump memory in bytes." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dd", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), NULL, 0, dbgcCmdDumpMem, "[addr]", "Dump memory in double words." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dg", 0, ~0, &g_aArgDumpDT[0], RT_ELEMENTS(g_aArgDumpDT), NULL, 0, dbgcCmdDumpDT, "[sel [..]]", "Dump the global descriptor table (GDT)." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dga", 0, ~0, &g_aArgDumpDT[0], RT_ELEMENTS(g_aArgDumpDT), NULL, 0, dbgcCmdDumpDT, "[sel [..]]", "Dump the global descriptor table (GDT) including not-present entries." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "di", 0, ~0, &g_aArgDumpIDT[0], RT_ELEMENTS(g_aArgDumpIDT), NULL, 0, dbgcCmdDumpIDT, "[int [..]]", "Dump the interrupt descriptor table (IDT)." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dia", 0, ~0, &g_aArgDumpIDT[0], RT_ELEMENTS(g_aArgDumpIDT), NULL, 0, dbgcCmdDumpIDT, "[int [..]]", "Dump the interrupt descriptor table (IDT) including not-present entries." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dl", 0, ~0, &g_aArgDumpDT[0], RT_ELEMENTS(g_aArgDumpDT), NULL, 0, dbgcCmdDumpDT, "[sel [..]]", "Dump the local descriptor table (LDT)." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dla", 0, ~0, &g_aArgDumpDT[0], RT_ELEMENTS(g_aArgDumpDT), NULL, 0, dbgcCmdDumpDT, "[sel [..]]", "Dump the local descriptor table (LDT) including not-present entries." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dpd", 0, 1, &g_aArgDumpPD[0], RT_ELEMENTS(g_aArgDumpPD), NULL, 0, dbgcCmdDumpPageDir, "[addr] [index]", "Dumps page directory entries of the default context." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dpda", 0, 1, &g_aArgDumpPDAddr[0],RT_ELEMENTS(g_aArgDumpPDAddr),NULL, 0, dbgcCmdDumpPageDir, "[addr]", "Dumps specified page directory." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dpdb", 1, 1, &g_aArgDumpPD[0], RT_ELEMENTS(g_aArgDumpPD), NULL, 0, dbgcCmdDumpPageDirBoth, "[addr] [index]", "Dumps page directory entries of the guest and the hypervisor. " },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dpdg", 0, 1, &g_aArgDumpPD[0], RT_ELEMENTS(g_aArgDumpPD), NULL, 0, dbgcCmdDumpPageDir, "[addr] [index]", "Dumps page directory entries of the guest." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dpdh", 0, 1, &g_aArgDumpPD[0], RT_ELEMENTS(g_aArgDumpPD), NULL, 0, dbgcCmdDumpPageDir, "[addr] [index]", "Dumps page directory entries of the hypervisor. " },
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync { "dpt", 1, 1, &g_aArgDumpPT[0], RT_ELEMENTS(g_aArgDumpPT), NULL, 0, dbgcCmdDumpPageTable,"<addr>", "Dumps page table entries of the default context." },
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync { "dpta", 1, 1, &g_aArgDumpPTAddr[0],RT_ELEMENTS(g_aArgDumpPTAddr), NULL, 0, dbgcCmdDumpPageTable,"<addr>", "Dumps specified page table." },
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync { "dptb", 1, 1, &g_aArgDumpPT[0], RT_ELEMENTS(g_aArgDumpPT), NULL, 0, dbgcCmdDumpPageTableBoth,"<addr>", "Dumps page table entries of the guest and the hypervisor." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dptg", 1, 1, &g_aArgDumpPT[0], RT_ELEMENTS(g_aArgDumpPT), NULL, 0, dbgcCmdDumpPageTable,"<addr>", "Dumps page table entries of the guest." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dpth", 1, 1, &g_aArgDumpPT[0], RT_ELEMENTS(g_aArgDumpPT), NULL, 0, dbgcCmdDumpPageTable,"<addr>", "Dumps page table entries of the hypervisor." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dq", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), NULL, 0, dbgcCmdDumpMem, "[addr]", "Dump memory in quad words." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dt", 0, 1, &g_aArgDumpTSS[0], RT_ELEMENTS(g_aArgDumpTSS), NULL, 0, dbgcCmdDumpTSS, "[tss|tss:ign|addr]", "Dump the task state segment (TSS)." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "dw", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), NULL, 0, dbgcCmdDumpMem, "[addr]", "Dump memory in words." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "g", 0, 0, NULL, 0, NULL, 0, dbgcCmdGo, "", "Continue execution." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "k", 0, 0, NULL, 0, NULL, 0, dbgcCmdStack, "", "Callstack." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "kg", 0, 0, NULL, 0, NULL, 0, dbgcCmdStack, "", "Callstack - guest." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "kh", 0, 0, NULL, 0, NULL, 0, dbgcCmdStack, "", "Callstack - hypervisor." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "ln", 0, ~0, &g_aArgListNear[0], RT_ELEMENTS(g_aArgListNear), &g_RetListNear, 0, dbgcCmdListNear, "[addr/sym [..]]", "List symbols near to the address. Default address is CS:EIP." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "ls", 0, 1, &g_aArgListSource[0],RT_ELEMENTS(g_aArgListSource),NULL, 0, dbgcCmdListSource, "[addr]", "Source." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "m", 1, 1, &g_aArgMemoryInfo[0],RT_ELEMENTS(g_aArgMemoryInfo),NULL, 0, dbgcCmdMemoryInfo, "<addr>", "Display information about that piece of memory." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "r", 0, 2, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), NULL, 0, dbgcCmdReg, "[reg [newval]]", "Show or set register(s) - active reg set." },
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync { "rg", 0, 2, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), NULL, 0, dbgcCmdRegGuest, "[reg [newval]]", "Show or set register(s) - guest reg set." },
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync { "rh", 0, 2, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), NULL, 0, dbgcCmdRegHyper, "[reg [newval]]", "Show or set register(s) - hypervisor reg set." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "rt", 0, 0, NULL, 0, NULL, 0, dbgcCmdRegTerse, "", "Toggles terse / verbose register info." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "s", 0, ~0, &g_aArgSearchMem[0], RT_ELEMENTS(g_aArgSearchMem), NULL, 0, dbgcCmdSearchMem, "[options] <range> <pattern>", "Continue last search." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "sa", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for an ascii string." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "sb", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more bytes." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "sd", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more double words." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "sq", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more quad words." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "su", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for an unicode string." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "sw", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more words." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "t", 0, 0, NULL, 0, NULL, 0, dbgcCmdTrace, "", "Instruction trace (step into)." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync { "u", 0, 1, &g_aArgUnassemble[0],RT_ELEMENTS(g_aArgUnassemble),NULL, 0, dbgcCmdUnassemble, "[addr]", "Unassemble." },
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync/** The number of commands in the CodeView/WinDbg emulation. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncconst unsigned g_cCmdsCodeView = RT_ELEMENTS(g_aCmdsCodeView);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The 'go' command.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns VBox status.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmd Pointer to the command descriptor (as registered).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmdHlp Pointer to command helper functions.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pVM Pointer to the current VM (if any).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param paArgs Pointer to (readonly) array of arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param cArgs Number of arguments in the array.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdGo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * Check if the VM is halted or not before trying to resume it.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pCmdHlp->pfnPrintf(pCmdHlp, NULL, "warning: The VM is already running...\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Executing DBGFR3Resume().");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The 'ba' command.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns VBox status.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmd Pointer to the command descriptor (as registered).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmdHlp Pointer to command helper functions.
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * @param pVM Pointer to the current VM (if any).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param paArgs Pointer to (readonly) array of arguments.
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * @param cArgs Number of arguments in the array.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkAccess(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Interpret access type.
af5224eb6b6676bc892a3f5abeb21f602547d31cvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid access type '%s' for '%s'. Valid types are 'e', 'r', 'w' and 'i'.\n",
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync * Validate size.
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync if (fType == X86_DR7_RW_EO && paArgs[1].u.u64Number != 1)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid access size %RX64 for '%s'. 'x' access type requires size 1!\n",
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /*case 8: - later*/
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid access size %RX64 for '%s'. 1, 2 or 4!\n",
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Convert the pointer to a DBGF address.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[2], &Address);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Couldn't convert '%DV' to a DBGF address, rc=%Vrc.\n", &paArgs[2], rc);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Pick out the optional arguments.
36fbf6dcd3e6b2e5891456b730577ff0eb355c9fvboxsync if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
36fbf6dcd3e6b2e5891456b730577ff0eb355c9fvboxsync if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_STRING)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Try set the breakpoint.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = DBGFR3BpSetReg(pVM, &Address, iHitTrigger, iHitDisable, fType, cb, &iBp);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Set access breakpoint %u at %VGv\n", iBp, Address.FlatPtr);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Updated access breakpoint %u at %VGv\n", iBp, Address.FlatPtr);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Failed to set access breakpoint at %VGv, rc=%Vrc.\n", Address.FlatPtr, rc);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The 'bc' command.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @returns VBox status.
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * @param pCmd Pointer to the command descriptor (as registered).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmdHlp Pointer to command helper functions.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pVM Pointer to the current VM (if any).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param paArgs Pointer to (readonly) array of arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param cArgs Number of arguments in the array.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkClear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * Enumerate the arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync for (unsigned iArg = 0; iArg < cArgs && VBOX_SUCCESS(rc); iArg++)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Breakpoint id %RX64 is too large!\n", paArgs[iArg].u.u64Number);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc2, "DBGFR3BpClear failed for breakpoint %u!\n", iBp);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync if (VBOX_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND)
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc2, "DBGFR3BpClear failed for breakpoint %u!\n", iBp);
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync if (VBOX_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND)
ff03d550549cfd2458dcac64202de635eb8d07cdvboxsync /* invalid parameter */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid argument '%s' to '%s'!\n", paArgs[iArg].u.pszString, pCmd->pszCmd);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The 'bd' command.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns VBox status.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmd Pointer to the command descriptor (as registered).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmdHlp Pointer to command helper functions.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pVM Pointer to the current VM (if any).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param paArgs Pointer to (readonly) array of arguments.
36fbf6dcd3e6b2e5891456b730577ff0eb355c9fvboxsync * @param cArgs Number of arguments in the array.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkDisable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Enumerate the arguments.
36fbf6dcd3e6b2e5891456b730577ff0eb355c9fvboxsync for (unsigned iArg = 0; iArg < cArgs && VBOX_SUCCESS(rc); iArg++)
36fbf6dcd3e6b2e5891456b730577ff0eb355c9fvboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Breakpoint id %RX64 is too large!\n", paArgs[iArg].u.u64Number);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpDisable failed for breakpoint %u!\n", iBp);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync for (PDBGCBP pBp = pDbgc->pFirstBp; pBp; pBp = pBp->pNext)
36fbf6dcd3e6b2e5891456b730577ff0eb355c9fvboxsync rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpDisable failed for breakpoint %u!\n", pBp->iBp);
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync /* invalid parameter */
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid argument '%s' to '%s'!\n", paArgs[iArg].u.pszString, pCmd->pszCmd);
36fbf6dcd3e6b2e5891456b730577ff0eb355c9fvboxsync * The 'be' command.
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync * @returns VBox status.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmd Pointer to the command descriptor (as registered).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmdHlp Pointer to command helper functions.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pVM Pointer to the current VM (if any).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param paArgs Pointer to (readonly) array of arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param cArgs Number of arguments in the array.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkEnable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Enumerate the arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync for (unsigned iArg = 0; iArg < cArgs && VBOX_SUCCESS(rc); iArg++)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Breakpoint id %RX64 is too large!\n", paArgs[iArg].u.u64Number);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpEnable failed for breakpoint %u!\n", iBp);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync for (PDBGCBP pBp = pDbgc->pFirstBp; pBp; pBp = pBp->pNext)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpEnable failed for breakpoint %u!\n", pBp->iBp);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* invalid parameter */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid argument '%s' to '%s'!\n", paArgs[iArg].u.pszString, pCmd->pszCmd);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Breakpoint enumeration callback function.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns VBox status code. Any failure will stop the enumeration.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pVM The VM handle.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pvUser The user argument.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pBp Pointer to the breakpoint information. (readonly)
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsyncstatic DECLCALLBACK(int) dbgcEnumBreakpointsCallback(PVM pVM, void *pvUser, PCDBGFBP pBp)
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync * BP type and size.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%2u %c %d %c %VGv %04RX64 (%04RX64 to ",
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "~0) ");
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%04RX64)");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Try resolve the address.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync int rc = DBGFR3SymbolByAddr(pVM, pBp->GCPtr, &off, &Sym);
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%s", Sym.szName);
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync else if (off > 0)
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%s+%VGv", Sym.szName, off);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%s+%VGv", Sym.szName, -off);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The commands.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\n cmds: '%s'\n",
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, " [unknown bp]\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The 'bl' command.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns VBox status.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmd Pointer to the command descriptor (as registered).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmdHlp Pointer to command helper functions.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pVM Pointer to the current VM (if any).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param paArgs Pointer to (readonly) array of arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param cArgs Number of arguments in the array.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkList(PCDBGCCMD /*pCmd*/, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR /*paArgs*/, unsigned /*cArgs*/, PDBGCVAR /*pResult*/)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Enumerate the breakpoints.
9540eeb13face31ddc1c5f15338556fe46f18a77vboxsync int rc = DBGFR3BpEnum(pVM, dbgcEnumBreakpointsCallback, pDbgc);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpEnum failed.\n");
009d969fa3276b108ddb99a9c1a7a26c003438a7vboxsync * The 'bp' command.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns VBox status.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmd Pointer to the command descriptor (as registered).
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync * @param pCmdHlp Pointer to command helper functions.
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync * @param pVM Pointer to the current VM (if any).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param paArgs Pointer to (readonly) array of arguments.
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync * @param cArgs Number of arguments in the array.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD /*pCmd*/, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync * Convert the pointer to a DBGF address.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address);
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Couldn't convert '%DV' to a DBGF address, rc=%Vrc.\n", &paArgs[0], rc);
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * Pick out the optional arguments.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
fc81313f4240cea1b6db5eaf81f6b5aac0ad5840vboxsync if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_STRING)
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync * Try set the breakpoint.
fc81313f4240cea1b6db5eaf81f6b5aac0ad5840vboxsync rc = DBGFR3BpSet(pVM, &Address, iHitTrigger, iHitDisable, &iBp);
fc81313f4240cea1b6db5eaf81f6b5aac0ad5840vboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Set breakpoint %u at %VGv\n", iBp, Address.FlatPtr);
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Updated breakpoint %u at %VGv\n", iBp, Address.FlatPtr);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Failed to set breakpoint at %VGv, rc=%Vrc.\n", Address.FlatPtr, rc);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The 'br' command.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns VBox status.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmd Pointer to the command descriptor (as registered).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmdHlp Pointer to command helper functions.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pVM Pointer to the current VM (if any).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param paArgs Pointer to (readonly) array of arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param cArgs Number of arguments in the array.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD /*pCmd*/, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Convert the pointer to a DBGF address.
07f038fb9d3d3080465ba0ba2065a4208e53e0f6vboxsync int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Couldn't convert '%DV' to a DBGF address, rc=%Vrc.\n", &paArgs[0], rc);
9540eeb13face31ddc1c5f15338556fe46f18a77vboxsync * Pick out the optional arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_STRING)
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync * Try set the breakpoint.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync rc = DBGFR3BpSetREM(pVM, &Address, iHitTrigger, iHitDisable, &iBp);
07f038fb9d3d3080465ba0ba2065a4208e53e0f6vboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Set REM breakpoint %u at %VGv\n", iBp, Address.FlatPtr);
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Updated REM breakpoint %u at %VGv\n", iBp, Address.FlatPtr);
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Failed to set REM breakpoint at %VGv, rc=%Vrc.\n", Address.FlatPtr, rc);
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * The 'u' command.
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync * @returns VBox status.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @param pCmd Pointer to the command descriptor (as registered).
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @param pCmdHlp Pointer to command helper functions.
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync * @param pVM Pointer to the current VM (if any).
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @param paArgs Pointer to (readonly) array of arguments.
ac6445a70a26cb69d08734f1d9dbc171cec86cd8vboxsync * @param cArgs Number of arguments in the array.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Validate input.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync || (cArgs == 1 && !DBGCVAR_ISPOINTER(paArgs[0].enmType)))
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "internal error: The parser doesn't do its job properly yet.. It might help to use the '%%' operator.\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync if (!pVM && !cArgs && !DBGCVAR_ISPOINTER(pDbgc->DisasmPos.enmType))
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Don't know where to start disassembling...\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync if (!pVM && cArgs && DBGCVAR_ISGCPOINTER(paArgs[0].enmType))
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: GC address but no VM.\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Find address.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->SourcePos.u.GCFar.off = pDbgc->fRegCtxGuest ? CPUMGetGuestEIP(pVM) : CPUMGetHyperEIP(pVM);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->SourcePos.u.GCFar.sel = pDbgc->fRegCtxGuest ? CPUMGetGuestCS(pVM) : CPUMGetHyperCS(pVM);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->DisasmPos.enmRangeType = DBGCVAR_RANGE_NONE;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->DisasmPos.enmRangeType = DBGCVAR_RANGE_ELEMENTS;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Too many lines requested. Max is 2048 lines.\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: The requested range is too big. Max is 64KB.\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "internal error: Unknown range type %d.\n", pDbgc->DisasmPos.enmRangeType);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Convert physical and host addresses to guest addresses.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnEval(pCmdHlp, &VarTmp, "%%(%Dv)", &pDbgc->DisasmPos);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: failed to evaluate '%%(%Dv)' -> %Vrc .\n", &pDbgc->DisasmPos, rc);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync default: AssertFailed(); break;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Print address.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * todo: Change to list near.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%DV:\n", &pDbgc->DisasmPos);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Do the disassembling.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Disassemble the instruction.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync if (pDbgc->DisasmPos.enmType == DBGCVAR_TYPE_GC_FLAT)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = DBGFR3DisasInstrEx(pVM, DBGF_SEL_FLAT, pDbgc->DisasmPos.u.GCFlat, fFlags, &szDis[0], sizeof(szDis), &cbInstr);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = DBGFR3DisasInstrEx(pVM, pDbgc->DisasmPos.u.GCFar.sel, pDbgc->DisasmPos.u.GCFar.off, fFlags, &szDis[0], sizeof(szDis), &cbInstr);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* print it */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%-16DV %s\n", &pDbgc->DisasmPos, &szDis[0]);
23603ed361f22874964e3a841add2c58ec2bb1eavboxsync /* bitch. */
23603ed361f22874964e3a841add2c58ec2bb1eavboxsync int rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Failed to disassemble instruction, skipping one byte.\n");
23603ed361f22874964e3a841add2c58ec2bb1eavboxsync return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Too many disassembly failures. Giving up.\n");
23603ed361f22874964e3a841add2c58ec2bb1eavboxsync /* advance */
9b7ab382b3f9667e8847020e1e58f7143c4d2334vboxsync if (pDbgc->DisasmPos.enmRangeType == DBGCVAR_RANGE_ELEMENTS)
9b7ab382b3f9667e8847020e1e58f7143c4d2334vboxsync rc = pCmdHlp->pfnEval(pCmdHlp, &pDbgc->DisasmPos, "(%Dv) + %x", &pDbgc->DisasmPos, cbInstr);
23603ed361f22874964e3a841add2c58ec2bb1eavboxsync return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Expression: (%Dv) + %x\n", &pDbgc->DisasmPos, cbInstr);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync fFlags &= ~(DBGF_DISAS_FLAGS_CURRENT_GUEST | DBGF_DISAS_FLAGS_CURRENT_HYPER);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The 'ls' command.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns VBox status.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmd Pointer to the command descriptor (as registered).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmdHlp Pointer to command helper functions.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pVM Pointer to the current VM (if any).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param paArgs Pointer to (readonly) array of arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param cArgs Number of arguments in the array.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Validate input.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync || (cArgs == 1 && !DBGCVAR_ISPOINTER(paArgs[0].enmType)))
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "internal error: The parser doesn't do its job properly yet.. It might help to use the '%%' operator.\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync if (!pVM && !cArgs && !DBGCVAR_ISPOINTER(pDbgc->SourcePos.enmType))
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Don't know where to start disassembling...\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync if (!pVM && cArgs && DBGCVAR_ISGCPOINTER(paArgs[0].enmType))
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: GC address but no VM.\n");
7697e43970d863558b6c168a55e8948ccb18d8d1vboxsync * Find address.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->SourcePos.u.GCFar.off = pDbgc->fRegCtxGuest ? CPUMGetGuestEIP(pVM) : CPUMGetHyperEIP(pVM);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->SourcePos.u.GCFar.sel = pDbgc->fRegCtxGuest ? CPUMGetGuestCS(pVM) : CPUMGetHyperCS(pVM);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->SourcePos.enmRangeType = DBGCVAR_RANGE_NONE;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Ensure the the source address is flat GC.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync int rc = pCmdHlp->pfnEval(pCmdHlp, &pDbgc->SourcePos, "%%(%Dv)", &pDbgc->SourcePos);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid address or address type. (rc=%d)\n", rc);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync default: AssertFailed(); break;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pDbgc->SourcePos.enmRangeType = DBGCVAR_RANGE_ELEMENTS;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Too many lines requested. Max is 2048 lines.\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: The requested range is too big. Max is 64KB.\n");
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "internal error: Unknown range type %d.\n", pDbgc->SourcePos.enmRangeType);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Do the disassembling.
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * Get line info.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync int rc = DBGFR3LineByAddr(pVM, pDbgc->SourcePos.u.GCFlat, &off, &Line);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync unsigned cLines = 0;
762a68c2bb3ccde807330e3d1cb05f8b244a5f72vboxsync * Print filenamename
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync if (!fFirst && strcmp(Line.szFilename, LinePrev.szFilename))
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "[%s @ %d]\n", Line.szFilename, Line.uLineNo);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Try open the file and read the line.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* Skip ahead to the desired line. */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync unsigned cBefore = fFirst ? RT_MIN(2, Line.uLineNo - 1) : Line.uLineNo - LinePrev.uLineNo - 1;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* print the before lines */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync while (cch > 0 && (szLine[cch - 1] == '\r' || szLine[cch - 1] == '\n' || isspace(szLine[cch - 1])) )
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " %4d: %s\n", Line.uLineNo - cBefore - 1, szLine);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync /* print the actual line */
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%08llx %4d: %s\n", Line.Address, Line.uLineNo, szLine);
23603ed361f22874964e3a841add2c58ec2bb1eavboxsync return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Warning: couldn't open source file '%s'\n", Line.szFilename);
23603ed361f22874964e3a841add2c58ec2bb1eavboxsync if (pDbgc->SourcePos.enmRangeType == DBGCVAR_RANGE_ELEMENTS)
23603ed361f22874964e3a841add2c58ec2bb1eavboxsync rc = pCmdHlp->pfnEval(pCmdHlp, &pDbgc->SourcePos, "(%Dv) + %x", &pDbgc->SourcePos, 1);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Expression: (%Dv) + %x\n", &pDbgc->SourcePos, 1);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * The 'r' command.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns VBox status.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmd Pointer to the command descriptor (as registered).
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * @param pCmdHlp Pointer to command helper functions.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pVM Pointer to the current VM (if any).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param paArgs Pointer to (readonly) array of arguments.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param cArgs Number of arguments in the array.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdReg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return dbgcCmdRegGuest(pCmd, pCmdHlp, pVM, paArgs, cArgs, pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync return dbgcCmdRegHyper(pCmd, pCmdHlp, pVM, paArgs, cArgs, pResult);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Common worker for the dbgcCmdReg*() commands.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @returns VBox status.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmd Pointer to the command descriptor (as registered).
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * @param pCmdHlp Pointer to command helper functions.
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * @param pVM Pointer to the current VM (if any).
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * @param paArgs Pointer to (readonly) array of arguments.
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * @param cArgs Number of arguments in the array.
fe554d9c0e3a6de4ba221610ac95a44c7d288e01vboxsync * @param pszPrefix The symbol prefix.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsyncstatic DECLCALLBACK(int) dbgcCmdRegCommon(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult, const char *pszPrefix)
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * cArgs == 0: Show all
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Get register context.
9540eeb13face31ddc1c5f15338556fe46f18a77vboxsync return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Getting register context\n");
9540eeb13face31ddc1c5f15338556fe46f18a77vboxsync * Format the flags.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync static struct
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync const char *pszSet; const char *pszClear; uint32_t fFlag;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync const char *pszAdd = aFlags[i].fFlag & efl ? aFlags[i].pszSet : aFlags[i].pszClear;
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync * Format the registers.
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%srax=%016RX64 %srbx=%016RX64 %srcx=%016RX64 %srdx=%016RX64\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%srsi=%016RX64 %srdi=%016RX64 %sr8 =%016RX64 %sr9 =%016RX64\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sr10=%016RX64 %sr11=%016RX64 %sr12=%016RX64 %sr13=%016RX64\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sr14=%016RX64 %sr15=%016RX64\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%srip=%016RX64 %srsp=%016RX64 %srbp=%016RX64 %siopl=%d %*s\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%scs=%04x %sds=%04x %ses=%04x %sfs=%04x %sgs=%04x %sss=%04x %seflags=%08x\n",
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtxCore->rax, pszPrefix, pCtxCore->rbx, pszPrefix, pCtxCore->rcx, pszPrefix, pCtxCore->rdx, pszPrefix, pCtxCore->rsi, pszPrefix, pCtxCore->rdi,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtxCore->r8, pszPrefix, pCtxCore->r9, pszPrefix, pCtxCore->r10, pszPrefix, pCtxCore->r11, pszPrefix, pCtxCore->r12, pszPrefix, pCtxCore->r13,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtxCore->r14, pszPrefix, pCtxCore->r15,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtxCore->rip, pszPrefix, pCtxCore->rsp, pszPrefix, pCtxCore->rbp, pszPrefix, X86_EFL_GET_IOPL(efl), *pszPrefix ? 34 : 31, szEFlags,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtxCore->cs, pszPrefix, (RTSEL)pCtxCore->ds, pszPrefix, (RTSEL)pCtxCore->es,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtxCore->fs, pszPrefix, (RTSEL)pCtxCore->gs, pszPrefix, (RTSEL)pCtxCore->ss, pszPrefix, efl);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%seax=%08x %sebx=%08x %secx=%08x %sedx=%08x %sesi=%08x %sedi=%08x\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%seip=%08x %sesp=%08x %sebp=%08x %siopl=%d %*s\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%scs=%04x %sds=%04x %ses=%04x %sfs=%04x %sgs=%04x %sss=%04x %seflags=%08x\n",
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtxCore->eax, pszPrefix, pCtxCore->ebx, pszPrefix, pCtxCore->ecx, pszPrefix, pCtxCore->edx, pszPrefix, pCtxCore->esi, pszPrefix, pCtxCore->edi,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtxCore->eip, pszPrefix, pCtxCore->esp, pszPrefix, pCtxCore->ebp, pszPrefix, X86_EFL_GET_IOPL(efl), *pszPrefix ? 34 : 31, szEFlags,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtxCore->cs, pszPrefix, (RTSEL)pCtxCore->ds, pszPrefix, (RTSEL)pCtxCore->es,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtxCore->fs, pszPrefix, (RTSEL)pCtxCore->gs, pszPrefix, (RTSEL)pCtxCore->ss, pszPrefix, efl);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%srax=%016RX64 %srbx=%016RX64 %srcx=%016RX64 %srdx=%016RX64\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%srsi=%016RX64 %srdi=%016RX64 %sr8 =%016RX64 %sr9 =%016RX64\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sr10=%016RX64 %sr11=%016RX64 %sr12=%016RX64 %sr13=%016RX64\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sr14=%016RX64 %sr15=%016RX64\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%srip=%016RX64 %srsp=%016RX64 %srbp=%016RX64 %siopl=%d %*s\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%scs={%04x base=%016RX64 limit=%08x flags=%08x}\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sds={%04x base=%016RX64 limit=%08x flags=%08x}\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%ses={%04x base=%016RX64 limit=%08x flags=%08x}\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sfs={%04x base=%016RX64 limit=%08x flags=%08x}\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sgs={%04x base=%016RX64 limit=%08x flags=%08x}\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sss={%04x base=%016RX64 limit=%08x flags=%08x}\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%scr0=%016RX64 %scr2=%016RX64 %scr3=%016RX64 %scr4=%016RX64\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sdr0=%016RX64 %sdr1=%016RX64 %sdr2=%016RX64 %sdr3=%016RX64\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sdr4=%016RX64 %sdr5=%016RX64 %sdr6=%016RX64 %sdr7=%016RX64\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sgdtr=%016RX64:%04x %sidtr=%016RX64:%04x %seflags=%08x\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sldtr={%04x base=%016RX64 limit=%08x flags=%08x}\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%str ={%04x base=%016RX64 limit=%08x flags=%08x}\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sSysEnter={cs=%04llx eip=%016RX64 esp=%016RX64}\n"
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtxCore->rax, pszPrefix, pCtxCore->rbx, pszPrefix, pCtxCore->rcx, pszPrefix, pCtxCore->rdx, pszPrefix, pCtxCore->rsi, pszPrefix, pCtxCore->rdi,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtxCore->r8, pszPrefix, pCtxCore->r9, pszPrefix, pCtxCore->r10, pszPrefix, pCtxCore->r11, pszPrefix, pCtxCore->r12, pszPrefix, pCtxCore->r13,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtxCore->r14, pszPrefix, pCtxCore->r15,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtxCore->rip, pszPrefix, pCtxCore->rsp, pszPrefix, pCtxCore->rbp, pszPrefix, X86_EFL_GET_IOPL(efl), *pszPrefix ? 33 : 31, szEFlags,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtxCore->cs, pCtx->csHid.u64Base, pCtx->csHid.u32Limit, pCtx->csHid.Attr.u,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtxCore->ds, pCtx->dsHid.u64Base, pCtx->dsHid.u32Limit, pCtx->dsHid.Attr.u,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtxCore->es, pCtx->esHid.u64Base, pCtx->esHid.u32Limit, pCtx->esHid.Attr.u,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtxCore->fs, pCtx->fsHid.u64Base, pCtx->fsHid.u32Limit, pCtx->fsHid.Attr.u,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtxCore->gs, pCtx->gsHid.u64Base, pCtx->gsHid.u32Limit, pCtx->gsHid.Attr.u,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtxCore->ss, pCtx->ssHid.u64Base, pCtx->ssHid.u32Limit, pCtx->ssHid.Attr.u,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtx->cr0, pszPrefix, pCtx->cr2, pszPrefix, pCtx->cr3, pszPrefix, pCtx->cr4,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtx->dr[0], pszPrefix, pCtx->dr[1], pszPrefix, pCtx->dr[2], pszPrefix, pCtx->dr[3],
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtx->dr[4], pszPrefix, pCtx->dr[5], pszPrefix, pCtx->dr[6], pszPrefix, pCtx->dr[7],
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pszPrefix, pCtx->idtr.pIdt, pCtx->idtr.cbIdt, pszPrefix, efl,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtx->ldtr, pCtx->ldtrHid.u64Base, pCtx->ldtrHid.u32Limit, pCtx->ldtrHid.Attr.u,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, (RTSEL)pCtx->tr, pCtx->trHid.u64Base, pCtx->trHid.u32Limit, pCtx->trHid.Attr.u,
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync pszPrefix, pCtx->SysEnter.cs, pCtx->SysEnter.eip, pCtx->SysEnter.esp);
016096e367cd20c3d3c3fd9a6650b55935c2e31dvboxsync "%sEFER =%016RX64\n"
pszPrefix, pCtxCore->eax, pszPrefix, pCtxCore->ebx, pszPrefix, pCtxCore->ecx, pszPrefix, pCtxCore->edx, pszPrefix, pCtxCore->esi, pszPrefix, pCtxCore->edi,
pszPrefix, pCtxCore->eip, pszPrefix, pCtxCore->esp, pszPrefix, pCtxCore->ebp, pszPrefix, X86_EFL_GET_IOPL(efl), *pszPrefix ? 33 : 31, szEFlags,
pszPrefix, (RTSEL)pCtxCore->cs, pCtx->csHid.u64Base, pCtx->csHid.u32Limit, pCtx->csHid.Attr.u, pszPrefix, pCtx->dr[0], pszPrefix, pCtx->dr[1],
pszPrefix, (RTSEL)pCtxCore->ds, pCtx->dsHid.u64Base, pCtx->dsHid.u32Limit, pCtx->dsHid.Attr.u, pszPrefix, pCtx->dr[2], pszPrefix, pCtx->dr[3],
pszPrefix, (RTSEL)pCtxCore->es, pCtx->esHid.u64Base, pCtx->esHid.u32Limit, pCtx->esHid.Attr.u, pszPrefix, pCtx->dr[4], pszPrefix, pCtx->dr[5],
pszPrefix, (RTSEL)pCtxCore->fs, pCtx->fsHid.u64Base, pCtx->fsHid.u32Limit, pCtx->fsHid.Attr.u, pszPrefix, pCtx->dr[6], pszPrefix, pCtx->dr[7],
pszPrefix, (RTSEL)pCtxCore->gs, pCtx->gsHid.u64Base, pCtx->gsHid.u32Limit, pCtx->gsHid.Attr.u, pszPrefix, pCtx->cr0, pszPrefix, pCtx->cr2,
pszPrefix, (RTSEL)pCtxCore->ss, pCtx->ssHid.u64Base, pCtx->ssHid.u32Limit, pCtx->ssHid.Attr.u, pszPrefix, pCtx->cr3, pszPrefix, pCtx->cr4,
pszPrefix, pCtx->gdtr.pGdt,pCtx->gdtr.cbGdt, pszPrefix, pCtx->idtr.pIdt, pCtx->idtr.cbIdt, pszPrefix, pCtxCore->eflags,
if ( *pszPrefix
if (!pSym)
return pCmdHlp->pfnVBoxError(pCmdHlp, VERR_INVALID_PARAMETER /* VERR_DBGC_INVALID_REGISTER */, "Invalid register name '%s'.\n", pszReg);
return VINF_SUCCESS;
static DECLCALLBACK(int) dbgcCmdRegGuest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
static DECLCALLBACK(int) dbgcCmdRegHyper(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
static DECLCALLBACK(int) dbgcCmdRegTerse(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
return pCmdHlp->pfnPrintf(pCmdHlp, NULL, pDbgc->fRegTerse ? "info: Terse register info.\n" : "info: Verbose register info.\n");
static DECLCALLBACK(int) dbgcCmdTrace(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
rc = pDbgc->CmdHlp.pfnVBoxError(&pDbgc->CmdHlp, rc, "When trying to single step VM %p\n", pDbgc->pVM);
return rc;
static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
int rc;
if (fGuest)
rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "EBP Ret EBP Ret CS:EIP Arg0 Arg1 Arg2 Arg3 CS:EIP / Symbol [line]\n");
return rc;
rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%08RX32 %08RX32 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32",
return rc;
RTGCINTPTR offDisp = Frame.AddrPC.FlatPtr - Frame.pSymPC->Value; /** @todo this isn't 100% correct for segemnted stuff. */
if (offDisp > 0)
else if (offDisp < 0)
rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " [%s @ 0i%d]", Frame.pLinePC->szFilename, Frame.pLinePC->uLineNo);
return rc;
return VINF_SUCCESS;
static int dbgcCmdDumpDTWorker64(PDBGCCMDHLP pCmdHlp, PCX86DESC64 pDesc, unsigned iEntry, bool fHyper, bool *pfDblEntry)
int rc;
static const char * const s_apszTypes[] =
rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d L=%d%s\n",
static const char * const s_apszTypes[] =
case X86_SEL_TYPE_SYS_LDT:
rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Bas=%016RX64 Lim=%08x DPL=%d %s %s %s %sAVL=%d R=%d%s\n",
pszHyper);
if (pfDblEntry)
*pfDblEntry = true;
if (pfDblEntry)
*pfDblEntry = true;
if (pfDblEntry)
*pfDblEntry = true;
return VINF_SUCCESS;
return VINF_SUCCESS;
static int dbgcCmdDumpDTWorker32(PDBGCCMDHLP pCmdHlp, PCX86DESC pDesc, unsigned iEntry, bool fHyper)
int rc;
static const char * const s_apszTypes[] =
rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d L=%d%s\n",
static const char * const s_apszTypes[] =
case X86_SEL_TYPE_SYS_LDT:
rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d R=%d%s\n",
pszHyper);
return VINF_SUCCESS;
return rc;
static DECLCALLBACK(int) dbgcCmdDumpDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
if (!pVM)
if (!cArgs)
for (unsigned i = 0; i < cArgs; i++)
return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: arg #%u isn't of number or pointer type but %d.\n", i, paArgs[i].enmType);
case DBGCVAR_TYPE_NUMBER:
while ( cSels-- > 0
bool fDblSkip = false;
if (fDblSkip)
if (!fAll)
return rc;
return rc;
return VINF_SUCCESS;
static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
if (!pVM)
unsigned cbEntry;
switch (enmMode)
if (!cArgs)
for (unsigned i = 0; i < cArgs; i++)
return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: arg #%u isn't of number type but %d.\n", i, paArgs[i].enmType);
while ( cInts-- > 0
return VINF_SUCCESS;
switch (enmMode)
case CPUMMODE_REAL:
case CPUMMODE_PROTECTED:
case CPUMMODE_LONG:
return rc;
iInt++;
pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: %llx is out of bounds (max 256)\n", paArgs[i].u.u64Number);
return VINF_SUCCESS;
static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
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)
unsigned cbElement;
bool fAscii = false;
fAscii = true;
if (!cbElement)
if (!cArgs)
case DBGCVAR_RANGE_NONE:
case DBGCVAR_RANGE_ELEMENTS:
return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Too many elements requested. Max is 2048 elements.\n");
case DBGCVAR_RANGE_BYTES:
return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "internal error: Unknown range type %d.\n", pDbgc->DumpPos.enmRangeType);
if (!fAscii)
switch (cbElement)
case 8: pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%s%016llx", pszSpace, *(uint64_t *)&achBuffer[i]); break;
while (i++ < sizeof(achBuffer))
if (!u8Prev)
for (i = 0; i < cb; i++)
else if (!u8)
if (cbLeft <= 0)
return VINF_SUCCESS;
static RTGCPHYS dbgcGetGuestPageMode(PDBGC pDbgc, bool *pfPAE, bool *pfLME, bool *pfPSE, bool *pfPGE, bool *pfNXE)
static RTHCPHYS dbgcGetShadowPageMode(PDBGC pDbgc, bool *pfPAE, bool *pfLME, bool *pfPSE, bool *pfPGE, bool *pfNXE)
*pfPSE = true;
*pfPGE = false;
case PGMMODE_32_BIT:
case PGMMODE_PAE:
*pfPAE = true;
case PGMMODE_PAE_NX:
*pfLME = false;
case PGMMODE_AMD64:
*pfNXE = false;
case PGMMODE_AMD64_NX:
static DECLCALLBACK(int) dbgcCmdDumpPageDir(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
|| (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)
if (!cArgs)
return DBGCCmdHlpPrintf(pCmdHlp, "Default argument for 'dpda' hasn't been fully implemented yet. Try with an address or use one of the other commands.\n");
if (fGuest)
if (fPAE)
int rc;
if (fPAE)
if (fGuest)
if (fLME)
VarCur.u.u64Number += (((uint64_t)VarGCPtr.u.GCFlat >> X86_PML4_SHIFT) & X86_PML4_MASK) * sizeof(X86PML4E);
return DBGCCmdHlpPrintf(pCmdHlp, "Page directory pointer table is not present for %Dv.\n", &VarGCPtr);
if (fPAE)
Pde.u = 0;
if (iEntry != ~0U)
iEntry++;
Pde.u,
Pde.u,
return rc;
if (iEntry != ~0U)
} while (cEntries-- > 0);
return VINF_SUCCESS;
static DECLCALLBACK(int) dbgcCmdDumpPageDirBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
if (!pVM)
return rc1;
return rc2;
static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
|| (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)
int rc;
if (fGuest)
if (fLME)
VarCur.u.u64Number += (((uint64_t)VarGCPtr.u.GCFlat >> X86_PML4_SHIFT) & X86_PML4_MASK) * sizeof(X86PML4E);
return DBGCCmdHlpPrintf(pCmdHlp, "Page directory pointer table is not present for %Dv.\n", &VarGCPtr);
if (fPAE)
Pte.u = 0;
if (iEntry != ~0U)
iEntry++;
Pte.u,
return rc;
if (iEntry != ~0U)
} while (cEntries-- > 0);
return VINF_SUCCESS;
static DECLCALLBACK(int) dbgcCmdDumpPageTableBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
if (!pVM)
return rc1;
return rc2;
static DECLCALLBACK(int) dbgcCmdDumpTSS(PCDBGCCMD /*pCmd*/, PDBGCCMDHLP pCmdHlp, PVM /*pVM*/, PCDBGCVAR /*paArgs*/, unsigned /*cArgs*/, PDBGCVAR /*pResult*/)
* We can get a TSS selector (number), a far pointer using a TSS selector, or some kind of TSS pointer.
static DECLCALLBACK(int) dbgcCmdMemoryInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
if (!pVM)
return rc1;
return rc2;
return rc3;
return rc4;
int dbgcVarsToBytes(PDBGCCMDHLP pCmdHlp, void *pvBuf, uint32_t *pcbBuf, size_t cbUnit, PCDBGCVAR paVars, unsigned cVars)
} u, uEnd;
case DBGCVAR_TYPE_GC_FAR:
case DBGCVAR_TYPE_HC_FAR:
case DBGCVAR_TYPE_GC_FLAT:
case DBGCVAR_TYPE_GC_PHYS:
case DBGCVAR_TYPE_HC_FLAT:
case DBGCVAR_TYPE_HC_PHYS:
case DBGCVAR_TYPE_NUMBER:
} while (u64);
} while (u64);
if (u64)
case DBGCVAR_TYPE_STRING:
case DBGCVAR_TYPE_SYMBOL:
return VERR_TOO_MUCH_DATA;
while (*psz)
psz++;
return VERR_TOO_MUCH_DATA;
if (cbReminder)
return VERR_INTERNAL_ERROR;
if (i != cVars)
return VERR_TOO_MUCH_DATA;
return VINF_SUCCESS;
static int dbgcCmdWorkerSearchMemDoIt(PDBGCCMDHLP pCmdHlp, PVM pVM, PDBGFADDRESS pAddress, RTGCUINTPTR cbRange,
cbRange = 0;
if (!pResult)
cbRange = 0;
return VERR_DBGC_COMMAND_FAILED;
if (!cbRange)
return dbgcCmdWorkerSearchMemDoIt(pCmdHlp, pVM, &Address, cbRange, pDbgc->abSearch, pDbgc->cbSearch,
static int dbgcCmdWorkerSearchMem(PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR pAddress, uint64_t cMaxHits, char chType,
switch (chType)
return VERR_DBGC_COMMAND_FAILED;
case DBGCVAR_RANGE_BYTES:
case DBGCVAR_RANGE_ELEMENTS:
return dbgcCmdWorkerSearchMemDoIt(pCmdHlp, pVM, &Address, cbRange, abBytes, cbBytes, cbUnit, cMaxHits, pResult);
static DECLCALLBACK(int) dbgcCmdSearchMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
if (cArgs == 0)
static DECLCALLBACK(int) dbgcCmdSearchMemType(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
return dbgcCmdWorkerSearchMem(pCmdHlp, pVM, &paArgs[0], pResult ? 1 : 25, pCmd->pszCmd[1], paArgs + 1, cArgs - 1, pResult);
int rc;
rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%VGv %s\n", (RTGCUINTPTR)Symbol.Value, Symbol.szName); /** @todo remove the RTUINGCPTR cast once DBGF got correct interfaces! */
if (!offDisp)
else if (offDisp > 0)
return rc;
static DECLCALLBACK(int) dbgcCmdListNear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
if (!cArgs)
return rc;
return VINF_SUCCESS;