DBGCCmdHlp.cpp revision 6ffa2eb79bdf1b3299aacf589ece7b124ec34dc7
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* $Id$ */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/** @file
248c89033c87fed7229aa29bbbc4f4698fb13687vboxsync * DBGC - Debugger Console, Command Helpers.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/*
248c89033c87fed7229aa29bbbc4f4698fb13687vboxsync * Copyright (C) 2006-2011 Oracle Corporation
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * available from http://www.virtualbox.org. This file is free software;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * General Public License (GPL) as published by the Free Software
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/*******************************************************************************
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync* Header Files *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync*******************************************************************************/
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#define LOG_GROUP LOG_GROUP_DBGC
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <VBox/dbg.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <VBox/vmm/dbgf.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <VBox/vmm/pgm.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <VBox/param.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <VBox/err.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <VBox/log.h>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <iprt/assert.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <iprt/ctype.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <iprt/mem.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <iprt/string.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include "DBGCInternal.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync/**
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync * Command helper for writing text to the debug console.
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync *
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync * @returns VBox status.
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync * @param pCmdHlp Pointer to the command callback structure.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pvBuf What to write.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param cbBuf Number of bytes to write.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param pcbWritten Where to store the number of bytes actually written.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * If NULL the entire buffer must be successfully written.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsyncstatic DECLCALLBACK(int) dbgcHlpWrite(PDBGCCMDHLP pCmdHlp, const void *pvBuf, size_t cbBuf, size_t *pcbWritten)
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return pDbgc->pBack->pfnWrite(pDbgc->pBack, pvBuf, cbBuf, pcbWritten);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync}
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync/**
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * Command helper for writing formatted text to the debug console.
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync *
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * @returns VBox status.
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * @param pCmdHlp Pointer to the command callback structure.
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * @param pcb Where to store the number of bytes written.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param pszFormat The format string.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This is using the log formatter, so it's format extensions can be used.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param ... Arguments specified in the format string.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DECLCALLBACK(int) dbgcHlpPrintf(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, ...)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Do the formatting and output.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_list args;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_start(args, pszFormat);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int rc = pCmdHlp->pfnPrintfV(pCmdHlp, pcbWritten, pszFormat, args);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_end(args);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync return rc;
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync}
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync/**
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * Callback to format non-standard format specifiers.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync *
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @returns The number of bytes formatted.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param pvArg Formatter argument.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param pfnOutput Pointer to output function.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param pvArgOutput Argument for the output function.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param ppszFormat Pointer to the format string pointer. Advance this till the char
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * after the format specifier.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param pArgs Pointer to the argument list. Use this to fetch the arguments.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param cchWidth Format Width. -1 if not specified.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param cchPrecision Format Precision. -1 if not specified.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param fFlags Flags (RTSTR_NTFS_*).
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * @param chArgSize The argument size specifier, 'l' or 'L'.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsyncstatic DECLCALLBACK(size_t) dbgcStringFormatter(void *pvArg, PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync const char **ppszFormat, va_list *pArgs, int cchWidth,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int cchPrecision, unsigned fFlags, char chArgSize)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NOREF(cchWidth); NOREF(cchPrecision); NOREF(fFlags); NOREF(chArgSize); NOREF(pvArg);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (**ppszFormat != 'D')
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync (*ppszFormat)++;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync (*ppszFormat)++;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (**ppszFormat)
ffb50166c9adb4ae583b914d405197035cf890advboxsync {
ffb50166c9adb4ae583b914d405197035cf890advboxsync /*
ffb50166c9adb4ae583b914d405197035cf890advboxsync * Print variable without range.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * The argument is a const pointer to the variable.
ffb50166c9adb4ae583b914d405197035cf890advboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 'V':
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync (*ppszFormat)++;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PCDBGCVAR pVar = va_arg(*pArgs, PCDBGCVAR);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (pVar->enmType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%%%RGv", pVar->u.GCFlat);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FAR:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%04x:%08x", pVar->u.GCFar.sel, pVar->u.GCFar.off);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%%%%%RGp", pVar->u.GCPhys);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%%#%RHv", (uintptr_t)pVar->u.pvHCFlat);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "#%%%%%RHp", pVar->u.HCPhys);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_STRING:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return pfnOutput(pvArgOutput, pVar->u.pszString, (size_t)pVar->u64Range);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_NUMBER:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%llx", pVar->u.u64Number);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_UNKNOWN:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync default:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return pfnOutput(pvArgOutput, "??", 2);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Print variable with range.
248c89033c87fed7229aa29bbbc4f4698fb13687vboxsync * The argument is a const pointer to the variable.
248c89033c87fed7229aa29bbbc4f4698fb13687vboxsync */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync case 'v':
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync (*ppszFormat)++;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PCDBGCVAR pVar = va_arg(*pArgs, PCDBGCVAR);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync char szRange[32];
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (pVar->enmRangeType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_RANGE_NONE:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync szRange[0] = '\0';
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_RANGE_ELEMENTS:
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync RTStrPrintf(szRange, sizeof(szRange), " L %llx", pVar->u64Range);
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync break;
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync case DBGCVAR_RANGE_BYTES:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTStrPrintf(szRange, sizeof(szRange), " LB %llx", pVar->u64Range);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (pVar->enmType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync case DBGCVAR_TYPE_GC_FLAT:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%%%RGv%s", pVar->u.GCFlat, szRange);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync case DBGCVAR_TYPE_GC_FAR:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%04x:%08x%s", pVar->u.GCFar.sel, pVar->u.GCFar.off, szRange);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync case DBGCVAR_TYPE_GC_PHYS:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%%%%%RGp%s", pVar->u.GCPhys, szRange);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync case DBGCVAR_TYPE_HC_FLAT:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%%#%RHv%s", (uintptr_t)pVar->u.pvHCFlat, szRange);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync case DBGCVAR_TYPE_HC_PHYS:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "#%%%%%RHp%s", pVar->u.HCPhys, szRange);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync case DBGCVAR_TYPE_STRING:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return pfnOutput(pvArgOutput, pVar->u.pszString, (size_t)pVar->u64Range);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync case DBGCVAR_TYPE_NUMBER:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%llx%s", pVar->u.u64Number, szRange);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync case DBGCVAR_TYPE_UNKNOWN:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync default:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return pfnOutput(pvArgOutput, "??", 2);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync }
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync }
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync default:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync AssertMsgFailed(("Invalid format type '%s'!\n", **ppszFormat));
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return 0;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync }
9bff17fe6983cfda2ddd98f1979841bcb48e78e7vboxsync}
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync/**
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * Output callback.
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync *
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * @returns number of bytes written.
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * @param pvArg User argument.
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * @param pachChars Pointer to an array of utf-8 characters.
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * @param cbChars Number of bytes in the character array pointed to by pachChars.
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsyncstatic DECLCALLBACK(size_t) dbgcFormatOutput(void *pvArg, const char *pachChars, size_t cbChars)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync{
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync PDBGC pDbgc = (PDBGC)pvArg;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync if (cbChars)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync {
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync int rc = pDbgc->pBack->pfnWrite(pDbgc->pBack, pachChars, cbChars, NULL);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync if (RT_FAILURE(rc))
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync {
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync pDbgc->rcOutput = rc;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync cbChars = 0;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync }
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync }
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return cbChars;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync}
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync/**
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * Command helper for writing formatted text to the debug console.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @returns VBox status.
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync * @param pCmdHlp Pointer to the command callback structure.
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync * @param pcbWritten Where to store the number of bytes written.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pszFormat The format string.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This is using the log formatter, so it's format extensions can be used.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param args Arguments specified in the format string.
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DECLCALLBACK(int) dbgcHlpPrintfV(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, va_list args)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Do the formatting and output.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDbgc->rcOutput = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync size_t cb = RTStrFormatV(dbgcFormatOutput, pDbgc, dbgcStringFormatter, pDbgc, pszFormat, args);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pcbWritten)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pcbWritten = cb;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return pDbgc->rcOutput;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/**
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Reports an error from a DBGF call.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @returns VBox status code appropriate to return from a command.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pCmdHlp Pointer to command helpers.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param rc The VBox status code returned by a DBGF call.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pszFormat Format string for additional messages. Can be NULL.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param ... Format arguments, optional.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DECLCALLBACK(int) dbgcHlpVBoxErrorV(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, va_list args)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (rc)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case VINF_SUCCESS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync default:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: %Rrc: %s", rc, pszFormat ? " " : "\n");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(rc) && pszFormat)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = pCmdHlp->pfnPrintfV(pCmdHlp, NULL, pszFormat, args);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VERR_DBGC_COMMAND_FAILED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/**
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Reports an error from a DBGF call.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @returns VBox status code appropriate to return from a command.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pCmdHlp Pointer to command helpers.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param rc The VBox status code returned by a DBGF call.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pszFormat Format string for additional messages. Can be NULL.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param ... Format arguments, optional.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DECLCALLBACK(int) dbgcHlpVBoxError(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, ...)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_list args;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_start(args, pszFormat);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int rcRet = pCmdHlp->pfnVBoxErrorV(pCmdHlp, rc, pszFormat, args);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_end(args);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rcRet;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/**
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Command helper for reading memory specified by a DBGC variable.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @returns VBox status code appropriate to return from a command.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pCmdHlp Pointer to the command callback structure.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pVM VM handle if GC or physical HC address.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pvBuffer Where to store the read data.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param cbRead Number of bytes to read.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pVarPointer DBGC variable specifying where to start reading.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pcbRead Where to store the number of bytes actually read.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This optional, but it's useful when read GC virtual memory where a
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * page in the requested range might not be present.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * If not specified not-present failure or end of a HC physical page
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * will cause failure.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DECLCALLBACK(int) dbgcHlpMemRead(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBuffer, size_t cbRead, PCDBGCVAR pVarPointer, size_t *pcbRead)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DBGFADDRESS Address;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Dummy check.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (cbRead == 0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (*pcbRead)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync *pcbRead = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Convert Far addresses getting size and the correct base address.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * Getting and checking the size is what makes this messy and slow.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync */
b8bb9c9f6b8ebfd0a7d6df0c0289f9fe80241750vboxsync DBGCVAR Var = *pVarPointer;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync switch (pVarPointer->enmType)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_GC_FAR:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /* Use DBGFR3AddrFromSelOff for the conversion. */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Assert(pDbgc->pVM);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, Var.u.GCFar.sel, Var.u.GCFar.off);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_FAILURE(rc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return rc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /* don't bother with flat selectors (for now). */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!DBGFADDRESS_IS_FLAT(&Address))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync DBGFSELINFO SelInfo;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3SelQueryInfo(pDbgc->pVM, pDbgc->idCpu, Address.Sel,
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync DBGFSELQI_FLAGS_DT_GUEST | DBGFSELQI_FLAGS_DT_ADJ_64BIT_MODE, &SelInfo);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTGCUINTPTR cb; /* -1 byte */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (DBGFSelInfoIsExpandDown(&SelInfo))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if ( !SelInfo.u.Raw.Gen.u1Granularity
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync && Address.off > UINT16_C(0xffff))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_OUT_OF_SELECTOR_BOUNDS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (Address.off <= SelInfo.cbLimit)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VERR_OUT_OF_SELECTOR_BOUNDS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync cb = (SelInfo.u.Raw.Gen.u1Granularity ? UINT32_C(0xffffffff) : UINT32_C(0xffff)) - Address.off;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (Address.off > SelInfo.cbLimit)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_OUT_OF_SELECTOR_BOUNDS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync cb = SelInfo.cbLimit - Address.off;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (cbRead - 1 > cb)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (!pcbRead)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_OUT_OF_SELECTOR_BOUNDS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync cbRead = cb + 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Var.enmType = DBGCVAR_TYPE_GC_FLAT;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Var.u.GCFlat = Address.FlatPtr;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync default:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_NOT_IMPLEMENTED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Copy page by page.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync size_t cbLeft = cbRead;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync for (;;)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Calc read size.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync size_t cb = RT_MIN(PAGE_SIZE, cbLeft);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (pVarPointer->enmType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FLAT: cb = RT_MIN(cb, PAGE_SIZE - (Var.u.GCFlat & PAGE_OFFSET_MASK)); break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_PHYS: cb = RT_MIN(cb, PAGE_SIZE - (Var.u.GCPhys & PAGE_OFFSET_MASK)); break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_FLAT: cb = RT_MIN(cb, PAGE_SIZE - ((uintptr_t)Var.u.pvHCFlat & PAGE_OFFSET_MASK)); break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_PHYS: cb = RT_MIN(cb, PAGE_SIZE - ((size_t)Var.u.HCPhys & PAGE_OFFSET_MASK)); break; /* size_t: MSC has braindead loss of data warnings! */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync default: break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /*
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * Perform read.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (Var.enmType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_GC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3MemRead(pDbgc->pVM, pDbgc->idCpu,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DBGFR3AddrFromFlat(pVM, &Address, Var.u.GCFlat),
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pvBuffer, cb);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3MemRead(pDbgc->pVM, pDbgc->idCpu,
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync DBGFR3AddrFromPhys(pVM, &Address, Var.u.GCPhys),
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pvBuffer, cb);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_HC_PHYS:
b8bb9c9f6b8ebfd0a7d6df0c0289f9fe80241750vboxsync case DBGCVAR_TYPE_HC_FLAT:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync DBGCVAR Var2;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync rc = dbgcOpAddrFlat(pDbgc, &Var, &Var2);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(rc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /** @todo protect this!!! */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync memcpy(pvBuffer, Var2.u.pvHCFlat, cb);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync rc = 0;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync else
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync rc = VERR_INVALID_POINTER;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync default:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VERR_PARSE_INCORRECT_ARG_TYPE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Check for failure.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_FAILURE(rc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (pcbRead && (*pcbRead = cbRead - cbLeft) > 0)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Next.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync cbLeft -= cb;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!cbLeft)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pvBuffer = (char *)pvBuffer + cb;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGCCmdHlpEval(pCmdHlp, &Var, "%DV + %d", &Var, cb);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_FAILURE(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pcbRead && (*pcbRead = cbRead - cbLeft) > 0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Done
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pcbRead)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pcbRead = cbRead;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/**
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Command helper for writing memory specified by a DBGC variable.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @returns VBox status code appropriate to return from a command.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * @param pCmdHlp Pointer to the command callback structure.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * @param pVM VM handle if GC or physical HC address.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * @param pvBuffer What to write.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * @param cbWrite Number of bytes to write.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pVarPointer DBGC variable specifying where to start reading.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pcbWritten Where to store the number of bytes written.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This is optional. If NULL be aware that some of the buffer
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * might have been written to the specified address.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsyncstatic DECLCALLBACK(int) dbgcHlpMemWrite(PDBGCCMDHLP pCmdHlp, PVM pVM, const void *pvBuffer, size_t cbWrite, PCDBGCVAR pVarPointer, size_t *pcbWritten)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync{
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DBGFADDRESS Address;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * Dummy check.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (cbWrite == 0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (*pcbWritten)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync *pcbWritten = 0;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VINF_SUCCESS;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /*
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * Convert Far addresses getting size and the correct base address.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * Getting and checking the size is what makes this messy and slow.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync DBGCVAR Var = *pVarPointer;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync switch (pVarPointer->enmType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FAR:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Use DBGFR3AddrFromSelOff for the conversion. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Assert(pDbgc->pVM);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, Var.u.GCFar.sel, Var.u.GCFar.off);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_FAILURE(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* don't bother with flat selectors (for now). */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!DBGFADDRESS_IS_FLAT(&Address))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync DBGFSELINFO SelInfo;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync rc = DBGFR3SelQueryInfo(pDbgc->pVM, pDbgc->idCpu, Address.Sel,
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync DBGFSELQI_FLAGS_DT_GUEST | DBGFSELQI_FLAGS_DT_ADJ_64BIT_MODE, &SelInfo);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTGCUINTPTR cb; /* -1 byte */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (DBGFSelInfoIsExpandDown(&SelInfo))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if ( !SelInfo.u.Raw.Gen.u1Granularity
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync && Address.off > UINT16_C(0xffff))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_OUT_OF_SELECTOR_BOUNDS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (Address.off <= SelInfo.cbLimit)
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync return VERR_OUT_OF_SELECTOR_BOUNDS;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync cb = (SelInfo.u.Raw.Gen.u1Granularity ? UINT32_C(0xffffffff) : UINT32_C(0xffff)) - Address.off;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (Address.off > SelInfo.cbLimit)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_OUT_OF_SELECTOR_BOUNDS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync cb = SelInfo.cbLimit - Address.off;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (cbWrite - 1 > cb)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!pcbWritten)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_OUT_OF_SELECTOR_BOUNDS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync cbWrite = cb + 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Var.enmType = DBGCVAR_TYPE_GC_FLAT;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Var.u.GCFlat = Address.FlatPtr;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* fall thru */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3MemWrite(pVM, pDbgc->idCpu,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DBGFR3AddrFromFlat(pVM, &Address, Var.u.GCFlat),
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pvBuffer, cbWrite);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pcbWritten && RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pcbWritten = cbWrite;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3MemWrite(pVM, pDbgc->idCpu,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DBGFR3AddrFromPhys(pVM, &Address, Var.u.GCPhys),
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pvBuffer, cbWrite);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pcbWritten && RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pcbWritten = cbWrite;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Copy HC memory page by page.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pcbWritten)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pcbWritten = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync while (cbWrite > 0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* convert to flat address */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DBGCVAR Var2;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = dbgcOpAddrFlat(pDbgc, &Var, &Var2);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_FAILURE(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pcbWritten && *pcbWritten)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return -VERR_INVALID_POINTER;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_INVALID_POINTER;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* calc size. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync size_t cbChunk = PAGE_SIZE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync cbChunk -= (uintptr_t)Var.u.pvHCFlat & PAGE_OFFSET_MASK;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (cbChunk > cbWrite)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync cbChunk = cbWrite;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /** @todo protect this!!! */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(Var2.u.pvHCFlat, pvBuffer, cbChunk);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /* advance */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (Var.enmType == DBGCVAR_TYPE_HC_FLAT)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Var.u.pvHCFlat = (uint8_t *)Var.u.pvHCFlat + cbChunk;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Var.u.HCPhys += cbChunk;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pvBuffer = (uint8_t const *)pvBuffer + cbChunk;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pcbWritten)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pcbWritten += cbChunk;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync cbWrite -= cbChunk;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
c99b597540585068d22dde4c9f74730305f24097vboxsync
c99b597540585068d22dde4c9f74730305f24097vboxsync return VINF_SUCCESS;
c99b597540585068d22dde4c9f74730305f24097vboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync default:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_NOT_IMPLEMENTED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/**
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Executes one command expression.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * (Hopefully the parser and functions are fully reentrant.)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @returns VBox status code appropriate to return from a command.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pCmdHlp Pointer to the command callback structure.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pszExpr The expression. Format string with the format DBGC extensions.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param ... Format arguments.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DECLCALLBACK(int) dbgcHlpExec(PDBGCCMDHLP pCmdHlp, const char *pszExpr, ...)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Save the scratch state. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync char *pszScratch = pDbgc->pszScratch;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync unsigned iArg = pDbgc->iArg;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Format the expression.
c99b597540585068d22dde4c9f74730305f24097vboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_list args;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_start(args, pszExpr);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync size_t cbScratch = sizeof(pDbgc->achScratch) - (pDbgc->pszScratch - &pDbgc->achScratch[0]);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync size_t cb = RTStrPrintfExV(dbgcStringFormatter, pDbgc, pDbgc->pszScratch, cbScratch, pszExpr, args);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_end(args);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (cb >= cbScratch)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VERR_BUFFER_OVERFLOW;
b8bb9c9f6b8ebfd0a7d6df0c0289f9fe80241750vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /*
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * Execute the command.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * We save and restore the arg index and scratch buffer pointer.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pDbgc->pszScratch = pDbgc->pszScratch + cb + 1;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int rc = dbgcEvalCommand(pDbgc, pszScratch, cb, false /* fNoExecute */);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /* Restore the scratch state. */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pDbgc->iArg = iArg;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pDbgc->pszScratch = pszScratch;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/**
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @copydoc DBGCCMDHLP::pfnEvalV
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DECLCALLBACK(int) dbgcHlpEvalV(PDBGCCMDHLP pCmdHlp, PDBGCVAR pResult, const char *pszExpr, va_list va)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * Format the expression.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync char szExprFormatted[2048];
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync size_t cb = RTStrPrintfExV(dbgcStringFormatter, pDbgc, szExprFormatted, sizeof(szExprFormatted), pszExpr, va);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /* ignore overflows. */
b8bb9c9f6b8ebfd0a7d6df0c0289f9fe80241750vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return dbgcEvalSub(pDbgc, &szExprFormatted[0], cb, pResult);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync}
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync/**
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * @copydoc DBGCCMDHLP::pfnFailV
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsyncstatic DECLCALLBACK(int) dbgcHlpFailV(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, const char *pszFormat, va_list va)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync{
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /*
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * Do the formatting and output.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pDbgc->rcOutput = VINF_SUCCESS;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync RTStrFormat(dbgcFormatOutput, pDbgc, dbgcStringFormatter, pDbgc, "%s: error: ", pCmd->pszCmd);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_FAILURE(pDbgc->rcOutput))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return pDbgc->rcOutput;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTStrFormatV(dbgcFormatOutput, pDbgc, dbgcStringFormatter, pDbgc, pszFormat, va);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_FAILURE(pDbgc->rcOutput))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return pDbgc->rcOutput;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_DBGC_COMMAND_FAILED;
bd331bd19103fa6f1c3d34bd69217d09b6fcd25dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync/**
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Converts a DBGC variable to a DBGF address structure.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * @returns VBox status code.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * @param pCmdHlp Pointer to the command callback structure.
b8bb9c9f6b8ebfd0a7d6df0c0289f9fe80241750vboxsync * @param pVar The variable to convert.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * @param pAddress The target address.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsyncstatic DECLCALLBACK(int) dbgcHlpVarToDbgfAddr(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, PDBGFADDRESS pAddress)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync{
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return dbgcVarToDbgfAddr(pDbgc, pVar, pAddress);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync}
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync/**
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * Converts a DBGC variable to a number.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @returns VBox status code.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pCmdHlp Pointer to the command callback structure.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pVar The variable to convert.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pu64Number Where to store the number value.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DECLCALLBACK(int) dbgcHlpVarToNumber(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, uint64_t *pu64Number)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NOREF(pDbgc);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync uint64_t u64Number;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (pVar->enmType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync u64Number = pVar->u.GCFlat;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync u64Number = pVar->u.GCPhys;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync u64Number = (uintptr_t)pVar->u.pvHCFlat;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync u64Number = (uintptr_t)pVar->u.HCPhys;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_NUMBER:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync u64Number = (uintptr_t)pVar->u.u64Number;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FAR:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync u64Number = (uintptr_t)pVar->u.GCFar.off;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_SYMBOL:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_STRING:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE; /** @todo better error code! */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync default:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pu64Number = u64Number;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VINF_SUCCESS;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/**
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Converts a DBGC variable to a boolean.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @returns VBox status code.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pCmdHlp Pointer to the command callback structure.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pVar The variable to convert.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pf Where to store the boolean.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DECLCALLBACK(int) dbgcHlpVarToBool(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, bool *pf)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NOREF(pDbgc);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (pVar->enmType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_STRING:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /** @todo add strcasecmp / stricmp wrappers to iprt/string.h. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if ( !strcmp(pVar->u.pszString, "true")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "True")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "TRUE")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "on")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "On")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "oN")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "ON")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "enabled")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "Enabled")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "DISABLED"))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pf = true;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if ( !strcmp(pVar->u.pszString, "false")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "False")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "FALSE")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "off")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "Off")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "OFF")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "disabled")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "Disabled")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync || !strcmp(pVar->u.pszString, "DISABLED"))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pf = false;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync return VERR_PARSE_INCORRECT_ARG_TYPE; /** @todo better error code! */
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_NUMBER:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pf = pVar->u.u64Number != 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FAR:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_SYMBOL:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync default:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/**
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @interface_method_impl{DBGCCMDHLP,pfnVarGetRange}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DECLCALLBACK(int) dbgcHlpVarGetRange(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, uint64_t cbElement, uint64_t cbDefault,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync uint64_t *pcbRange)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/** @todo implement this properly, strings/symbols are not resolved now. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (pVar->enmRangeType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync default:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_RANGE_NONE:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pcbRange = cbDefault;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_RANGE_BYTES:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pcbRange = pVar->u64Range;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_RANGE_ELEMENTS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pcbRange = pVar->u64Range * cbElement;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/**
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @interface_method_impl{DBGCCMDHLP,pfnVarConvert}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DECLCALLBACK(int) dbgcHlpVarConvert(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pInVar, DBGCVARTYPE enmToType, bool fConvSyms,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PDBGCVAR pResult)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DBGCVAR const InVar = *pInVar; /* if pInVar == pResult */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PCDBGCVAR pArg = &InVar; /* lazy bird, clean up later */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DBGFADDRESS Address;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Assert(pDbgc->pVM);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pResult = InVar;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (InVar.enmType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (enmToType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FAR:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pResult->enmType = DBGCVAR_TYPE_GC_PHYS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3AddrToPhys(pDbgc->pVM, pDbgc->idCpu,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DBGFR3AddrFromFlat(pDbgc->pVM, &Address, pArg->u.GCFlat),
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync &pResult->u.GCPhys);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_CONVERSION_FAILED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync case DBGCVAR_TYPE_HC_FLAT:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync pResult->enmType = DBGCVAR_TYPE_HC_FLAT;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3AddrToVolatileR3Ptr(pDbgc->pVM, pDbgc->idCpu,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DBGFR3AddrFromFlat(pDbgc->pVM, &Address, pArg->u.GCFlat),
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync false /*fReadOnly */,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync &pResult->u.pvHCFlat);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_CONVERSION_FAILED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pResult->enmType = DBGCVAR_TYPE_HC_PHYS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3AddrToHostPhys(pDbgc->pVM, pDbgc->idCpu,
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync DBGFR3AddrFromFlat(pDbgc->pVM, &Address, pArg->u.GCFlat),
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync &pResult->u.GCPhys);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_CONVERSION_FAILED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_NUMBER:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pResult->enmType = enmToType;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pResult->u.u64Number = InVar.u.GCFlat;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_STRING:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_SYMBOL:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_UNKNOWN:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_ANY:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FAR:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (enmToType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FLAT:
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync if (RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pResult->enmType = DBGCVAR_TYPE_GC_FLAT;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pResult->u.GCFlat = Address.FlatPtr;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_CONVERSION_FAILED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync case DBGCVAR_TYPE_GC_FAR:
ffb50166c9adb4ae583b914d405197035cf890advboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(rc))
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync pResult->enmType = DBGCVAR_TYPE_GC_PHYS;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync rc = DBGFR3AddrToPhys(pDbgc->pVM, pDbgc->idCpu, &Address, &pResult->u.GCPhys);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync if (RT_SUCCESS(rc))
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync return VINF_SUCCESS;
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VERR_PARSE_CONVERSION_FAILED;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_HC_FLAT:
b8bb9c9f6b8ebfd0a7d6df0c0289f9fe80241750vboxsync rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(rc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pResult->enmType = DBGCVAR_TYPE_HC_FLAT;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync rc = DBGFR3AddrToVolatileR3Ptr(pDbgc->pVM, pDbgc->idCpu, &Address,
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync false /*fReadOnly*/, &pResult->u.pvHCFlat);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(rc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VINF_SUCCESS;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VERR_PARSE_CONVERSION_FAILED;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_HC_PHYS:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3AddrFromSelOff(pDbgc->pVM, pDbgc->idCpu, &Address, pArg->u.GCFar.sel, pArg->u.GCFar.off);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pResult->enmType = DBGCVAR_TYPE_HC_PHYS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3AddrToHostPhys(pDbgc->pVM, pDbgc->idCpu, &Address, &pResult->u.GCPhys);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_CONVERSION_FAILED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_NUMBER:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pResult->enmType = enmToType;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pResult->u.u64Number = InVar.u.GCFar.off;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_STRING:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_SYMBOL:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_UNKNOWN:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_ANY:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_GC_PHYS:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync switch (enmToType)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FLAT:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync //rc = MMR3PhysGCPhys2GCVirtEx(pDbgc->pVM, pResult->u.GCPhys, ..., &pResult->u.GCFlat); - yea, sure.
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FAR:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_GC_PHYS:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VINF_SUCCESS;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_HC_FLAT:
b8bb9c9f6b8ebfd0a7d6df0c0289f9fe80241750vboxsync pResult->enmType = DBGCVAR_TYPE_HC_FLAT;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DBGFR3AddrToVolatileR3Ptr(pDbgc->pVM, pDbgc->idCpu,
d3b1b01528fe21777281edf167f8deca06f86e39vboxsync DBGFR3AddrFromPhys(pDbgc->pVM, &Address, pArg->u.GCPhys),
d3b1b01528fe21777281edf167f8deca06f86e39vboxsync false /*fReadOnly */,
d3b1b01528fe21777281edf167f8deca06f86e39vboxsync &pResult->u.pvHCFlat);
d3b1b01528fe21777281edf167f8deca06f86e39vboxsync if (RT_SUCCESS(rc))
d3b1b01528fe21777281edf167f8deca06f86e39vboxsync return VINF_SUCCESS;
d3b1b01528fe21777281edf167f8deca06f86e39vboxsync return VERR_PARSE_CONVERSION_FAILED;
d3b1b01528fe21777281edf167f8deca06f86e39vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case DBGCVAR_TYPE_HC_PHYS:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pResult->enmType = DBGCVAR_TYPE_HC_PHYS;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync rc = DBGFR3AddrToHostPhys(pDbgc->pVM, pDbgc->idCpu,
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync DBGFR3AddrFromPhys(pDbgc->pVM, &Address, pArg->u.GCPhys),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync &pResult->u.HCPhys);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(rc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_CONVERSION_FAILED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_NUMBER:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pResult->enmType = enmToType;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pResult->u.u64Number = InVar.u.GCPhys;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_STRING:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_SYMBOL:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_UNKNOWN:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_ANY:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (enmToType)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FLAT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_FAR:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_GC_PHYS:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pResult->enmType = DBGCVAR_TYPE_GC_PHYS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = PGMR3DbgR3Ptr2GCPhys(pDbgc->pVM, pArg->u.pvHCFlat, &pResult->u.GCPhys);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (RT_SUCCESS(rc))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VINF_SUCCESS;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /** @todo more memory types! */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VERR_PARSE_CONVERSION_FAILED;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_HC_FLAT:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VINF_SUCCESS;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_HC_PHYS:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pResult->enmType = DBGCVAR_TYPE_HC_PHYS;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync rc = PGMR3DbgR3Ptr2HCPhys(pDbgc->pVM, pArg->u.pvHCFlat, &pResult->u.HCPhys);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (RT_SUCCESS(rc))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /** @todo more memory types! */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VERR_PARSE_CONVERSION_FAILED;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_NUMBER:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pResult->enmType = enmToType;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pResult->u.u64Number = (uintptr_t)InVar.u.pvHCFlat;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync return VINF_SUCCESS;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync
0dd3967035b8a02985920baa57f948dc542b9388vboxsync case DBGCVAR_TYPE_STRING:
0dd3967035b8a02985920baa57f948dc542b9388vboxsync case DBGCVAR_TYPE_SYMBOL:
0dd3967035b8a02985920baa57f948dc542b9388vboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync case DBGCVAR_TYPE_UNKNOWN:
0dd3967035b8a02985920baa57f948dc542b9388vboxsync case DBGCVAR_TYPE_ANY:
0dd3967035b8a02985920baa57f948dc542b9388vboxsync break;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync }
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync break;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync case DBGCVAR_TYPE_HC_PHYS:
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync switch (enmToType)
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync {
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync case DBGCVAR_TYPE_GC_FLAT:
0dd3967035b8a02985920baa57f948dc542b9388vboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync
0dd3967035b8a02985920baa57f948dc542b9388vboxsync case DBGCVAR_TYPE_GC_FAR:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync case DBGCVAR_TYPE_GC_PHYS:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pResult->enmType = DBGCVAR_TYPE_GC_PHYS;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync rc = PGMR3DbgHCPhys2GCPhys(pDbgc->pVM, pArg->u.HCPhys, &pResult->u.GCPhys);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (RT_SUCCESS(rc))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VINF_SUCCESS;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VERR_PARSE_CONVERSION_FAILED;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_HC_FLAT:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_HC_PHYS:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VINF_SUCCESS;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_NUMBER:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pResult->enmType = enmToType;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync pResult->u.u64Number = InVar.u.HCPhys;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VINF_SUCCESS;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync
02651f98b4320e70a300ba1ebe95270096ebfd4dvboxsync case DBGCVAR_TYPE_STRING:
0dd3967035b8a02985920baa57f948dc542b9388vboxsync case DBGCVAR_TYPE_SYMBOL:
0dd3967035b8a02985920baa57f948dc542b9388vboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_UNKNOWN:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_ANY:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync break;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync break;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_NUMBER:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync switch (enmToType)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync case DBGCVAR_TYPE_GC_FLAT:
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync pResult->enmType = DBGCVAR_TYPE_GC_FLAT;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync pResult->u.GCFlat = (RTGCPTR)InVar.u.u64Number;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync case DBGCVAR_TYPE_GC_FAR:
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync case DBGCVAR_TYPE_GC_PHYS:
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync pResult->enmType = DBGCVAR_TYPE_GC_PHYS;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync pResult->u.GCPhys = (RTGCPHYS)InVar.u.u64Number;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync case DBGCVAR_TYPE_HC_FLAT:
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync pResult->enmType = DBGCVAR_TYPE_HC_FLAT;
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync pResult->u.pvHCFlat = (void *)(uintptr_t)InVar.u.u64Number;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync case DBGCVAR_TYPE_HC_PHYS:
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync pResult->enmType = DBGCVAR_TYPE_HC_PHYS;
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync pResult->u.HCPhys = (RTHCPHYS)InVar.u.u64Number;
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync return VINF_SUCCESS;
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync case DBGCVAR_TYPE_NUMBER:
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync return VINF_SUCCESS;
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync case DBGCVAR_TYPE_STRING:
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync case DBGCVAR_TYPE_SYMBOL:
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync case DBGCVAR_TYPE_UNKNOWN:
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync case DBGCVAR_TYPE_ANY:
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync break;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync }
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync break;
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync case DBGCVAR_TYPE_SYMBOL:
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync case DBGCVAR_TYPE_STRING:
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync switch (enmToType)
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync {
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync case DBGCVAR_TYPE_GC_FLAT:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_GC_FAR:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_GC_PHYS:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_HC_FLAT:
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync case DBGCVAR_TYPE_HC_PHYS:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DBGCVAR_TYPE_NUMBER:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (fConvSyms)
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync {
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync rc = dbgcSymbolGet(pDbgc, InVar.u.pszString, enmToType, pResult);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync if (RT_SUCCESS(rc))
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync {
805a319b88bdf29b369da48402c58897a5e8b65dvboxsync if (InVar.enmRangeType != DBGCVAR_RANGE_NONE)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pResult->enmRangeType = InVar.enmRangeType;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pResult->u64Range = InVar.u64Range;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VINF_SUCCESS;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VERR_PARSE_INCORRECT_ARG_TYPE;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_STRING:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_SYMBOL:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pResult->enmType = enmToType;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VINF_SUCCESS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync case DBGCVAR_TYPE_UNKNOWN:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_ANY:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_UNKNOWN:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case DBGCVAR_TYPE_ANY:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync AssertMsgFailed(("f=%d t=%d\n", InVar.enmType, enmToType));
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return VERR_INVALID_PARAMETER;
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync}
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync/**
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Info helper callback wrapper - print formatted string.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pHlp Pointer to this structure.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * @param pszFormat The format string.
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * @param ... Arguments.
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsyncstatic DECLCALLBACK(void) dbgcHlpGetDbgfOutputHlp_Printf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync{
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync PDBGC pDbgc = RT_FROM_MEMBER(pHlp, DBGC, DbgfOutputHlp);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync va_list va;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync va_start(va, pszFormat);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pDbgc->CmdHlp.pfnPrintfV(&pDbgc->CmdHlp, NULL, pszFormat, va);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync va_end(va);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync}
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync/**
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * Info helper callback wrapper - print formatted string.
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync *
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * @param pHlp Pointer to this structure.
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * @param pszFormat The format string.
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * @param args Argument list.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsyncstatic DECLCALLBACK(void) dbgcHlpGetDbgfOutputHlp_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync{
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync PDBGC pDbgc = RT_FROM_MEMBER(pHlp, DBGC, DbgfOutputHlp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDbgc->CmdHlp.pfnPrintfV(&pDbgc->CmdHlp, NULL, pszFormat, args);
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync}
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync/**
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * @interface_method_impl{DBGCCMDHLP,pfnGetDbgfOutputHlp}
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsyncstatic DECLCALLBACK(PCDBGFINFOHLP) dbgcHlpGetDbgfOutputHlp(PDBGCCMDHLP pCmdHlp)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Lazy init */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (!pDbgc->DbgfOutputHlp.pfnPrintf)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pDbgc->DbgfOutputHlp.pfnPrintf = dbgcHlpGetDbgfOutputHlp_Printf;
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync pDbgc->DbgfOutputHlp.pfnPrintfV = dbgcHlpGetDbgfOutputHlp_PrintfV;
ffb50166c9adb4ae583b914d405197035cf890advboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return &pDbgc->DbgfOutputHlp;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync}
ffb50166c9adb4ae583b914d405197035cf890advboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync/**
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * Initializes the Command Helpers for a DBGC instance.
b8bb9c9f6b8ebfd0a7d6df0c0289f9fe80241750vboxsync *
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * @param pDbgc Pointer to the DBGC instance.
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsyncvoid dbgcInitCmdHlp(PDBGC pDbgc)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync{
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pDbgc->CmdHlp.pfnWrite = dbgcHlpWrite;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync pDbgc->CmdHlp.pfnPrintfV = dbgcHlpPrintfV;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync pDbgc->CmdHlp.pfnPrintf = dbgcHlpPrintf;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync pDbgc->CmdHlp.pfnVBoxErrorV = dbgcHlpVBoxErrorV;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pDbgc->CmdHlp.pfnVBoxError = dbgcHlpVBoxError;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pDbgc->CmdHlp.pfnMemRead = dbgcHlpMemRead;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync pDbgc->CmdHlp.pfnMemWrite = dbgcHlpMemWrite;
ffb50166c9adb4ae583b914d405197035cf890advboxsync pDbgc->CmdHlp.pfnEvalV = dbgcHlpEvalV;
ffb50166c9adb4ae583b914d405197035cf890advboxsync pDbgc->CmdHlp.pfnExec = dbgcHlpExec;
ffb50166c9adb4ae583b914d405197035cf890advboxsync pDbgc->CmdHlp.pfnFailV = dbgcHlpFailV;
ffb50166c9adb4ae583b914d405197035cf890advboxsync pDbgc->CmdHlp.pfnVarToDbgfAddr = dbgcHlpVarToDbgfAddr;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDbgc->CmdHlp.pfnVarToNumber = dbgcHlpVarToNumber;
ffb50166c9adb4ae583b914d405197035cf890advboxsync pDbgc->CmdHlp.pfnVarToBool = dbgcHlpVarToBool;
ffb50166c9adb4ae583b914d405197035cf890advboxsync pDbgc->CmdHlp.pfnVarGetRange = dbgcHlpVarGetRange;
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync pDbgc->CmdHlp.pfnVarConvert = dbgcHlpVarConvert;
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync pDbgc->CmdHlp.pfnGetDbgfOutputHlp = dbgcHlpGetDbgfOutputHlp;
ffb50166c9adb4ae583b914d405197035cf890advboxsync}
ffb50166c9adb4ae583b914d405197035cf890advboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync