DBGCInternal.h revision ea92dd20a6fa0ed8b766160417497a0c14985d1c
/** $Id$ */
/** @file
* DBGC - Debugger Console, Internal Header File.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ___DBGCInternal_h
#define ___DBGCInternal_h
/*******************************************************************************
* Header Files *
*******************************************************************************/
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/* to err.h! */
#define VERR_DBGC_QUIT (-11999)
#define VERR_PARSE_FIRST (-11000)
#define VERR_PARSE_TOO_FEW_ARGUMENTS (VERR_PARSE_FIRST - 0)
#define VWRN_DBGC_CMD_PENDING 12000
#define VWRN_DBGC_ALREADY_REGISTERED 12001
#define VERR_DBGC_COMMANDS_NOT_REGISTERED (-12002)
#define VERR_DBGC_BP_NOT_FOUND (-12003)
#define VERR_DBGC_BP_EXISTS (-12004)
#define VINF_DBGC_BP_NO_COMMAND 12005
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Debugger console per breakpoint data.
*/
typedef struct DBGCBP
{
/** Pointer to the next breakpoint in the list. */
/** The breakpoint identifier. */
/** The size of the command. */
/** The command to execute when the breakpoint is hit. */
char szCmd[1];
} DBGCBP;
/** Pointer to a breakpoint. */
/**
* Named variable.
*
* Always allocated from heap in one signle block.
*/
typedef struct DBGCNAMEDVAR
{
/** The variable. */
/** It's name. */
char szName[1];
} DBGCNAMEDVAR;
/** Pointer to named variable. */
typedef DBGCNAMEDVAR *PDBGCNAMEDVAR;
/**
* Debugger console status
*/
typedef enum DBGCSTATUS
{
/** Normal status, .*/
} DBGCSTATUS;
/**
* Debugger console instance data.
*/
typedef struct DBGC
{
/** Command helpers. */
/** Pointer to backend callback structure. */
/** Pointer to the current VM. */
/** The current debugger emulation. */
const char *pszEmulation;
/** Pointer to the command and functions for the current debugger emulation. */
/** The number of commands paEmulationCmds points to. */
unsigned cEmulationCmds;
/** Log indicator. (If set we're writing the log to the console.) */
bool fLog;
/** Indicates whether we're in guest (true) or hypervisor (false) register context. */
bool fRegCtxGuest;
/** Indicates whether the register are terse or sparse. */
bool fRegTerse;
/** Current dissassembler position. */
/** Current source position. (flat GC) */
/** Current memory dump position. */
/** Size of the previous dump element. */
unsigned cbDumpElement;
/** Number of variables in papVars. */
unsigned cVars;
/** Array of global variables.
* Global variables can be referenced using the $ operator and set
* and unset using command with those names. */
/** The list of breakpoints. (singly linked) */
/** @name Parsing and Execution
* @{ */
/** Input buffer. */
char achInput[2048];
/** To ease debugging. */
unsigned uInputZero;
/** Write index in the input buffer. */
unsigned iWrite;
/** Read index in the input buffer. */
unsigned iRead;
/** The number of lines in the buffer. */
unsigned cInputLines;
/** Indicates that we have a buffer overflow condition.
* This means that input is ignored up to the next newline. */
bool fInputOverflow;
/** Indicates whether or we're ready for input. */
bool fReady;
/** Scratch buffer position. */
char *pszScratch;
/** Scratch buffer. */
char achScratch[16384];
/** Argument array position. */
unsigned iArg;
/** Array of argument variables. */
/** rc from last dbgcHlpPrintfV(). */
int rcOutput;
/** @} */
} DBGC;
/** Pointer to debugger console instance data. */
/** Converts a Command Helper pointer to a pointer to DBGC instance data. */
/**
* Chunk of external commands.
*/
typedef struct DBGCEXTCMDS
{
/** Number of commands descriptors. */
unsigned cCmds;
/** Pointer to array of command descriptors. */
/** Pointer to the next chunk. */
struct DBGCEXTCMDS *pNext;
} DBGCEXTCMDS;
/** Pointer to chunk of external commands. */
typedef DBGCEXTCMDS *PDBGCEXTCMDS;
/**
* Unary operator handler function.
*
* @returns 0 on success.
* @returns VBox evaluation / parsing error code on failure.
* The caller does the bitching.
* @param pDbgc Debugger console instance data.
* @param pArg The argument.
* @param pResult Where to store the result.
*/
/** Pointer to a unary operator handler function. */
typedef FNDBGCOPUNARY *PFNDBGCOPUNARY;
/**
* Binary operator handler function.
*
* @returns 0 on success.
* @returns VBox evaluation / parsing error code on failure.
* The caller does the bitching.
* @param pDbgc Debugger console instance data.
* @param pArg1 The first argument.
* @param pArg2 The 2nd argument.
* @param pResult Where to store the result.
*/
typedef DECLCALLBACK(int) FNDBGCOPBINARY(PDBGC pDbgc, PCDBGCVAR pArg1, PCDBGCVAR pArg2, PDBGCVAR pResult);
/** Pointer to a binary operator handler function. */
typedef FNDBGCOPBINARY *PFNDBGCOPBINARY;
/**
* Operator descriptor.
*/
typedef struct DBGCOP
{
/** Operator mnemonic. */
char szName[4];
/** Length of name. */
const unsigned cchName;
/** Whether or not this is a binary operator.
* Unary operators are evaluated right-to-left while binary are left-to-right. */
bool fBinary;
/** Precedence level. */
unsigned iPrecedence;
/** Unary operator handler. */
/** Binary operator handler. */
/** Operator description. */
const char *pszDescription;
} DBGCOP;
/** Pointer to an operator descriptor. */
/** Pointer to a const operator descriptor. */
/** Pointer to symbol descriptor. */
/** Pointer to const symbol descriptor. */
/**
* Get builtin symbol.
*
* @returns 0 on success.
* @returns VBox evaluation / parsing error code on failure.
* The caller does the bitching.
* @param pSymDesc Pointer to the symbol descriptor.
* @param pCmdHlp Pointer to the command callback structure.
* @param enmType The result type.
* @param pResult Where to store the result.
*/
typedef DECLCALLBACK(int) FNDBGCSYMGET(PCDBGCSYM pSymDesc, PDBGCCMDHLP pCmdHlp, DBGCVARTYPE enmType, PDBGCVAR pResult);
/** Pointer to get function for a builtin symbol. */
typedef FNDBGCSYMGET *PFNDBGCSYMGET;
/**
* Set builtin symbol.
*
* @returns 0 on success.
* @returns VBox evaluation / parsing error code on failure.
* The caller does the bitching.
* @param pSymDesc Pointer to the symbol descriptor.
* @param pCmdHlp Pointer to the command callback structure.
* @param pValue The value to assign the symbol.
*/
/** Pointer to set function for a builtin symbol. */
typedef FNDBGCSYMSET *PFNDBGCSYMSET;
/**
* Symbol description (for builtin symbols).
*/
typedef struct DBGCSYM
{
/** Symbol name. */
const char *pszName;
/** Get function. */
/** Set function. (NULL if readonly) */
/** User data. */
unsigned uUser;
} DBGCSYM;
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
/*******************************************************************************
* Global Variables *
*******************************************************************************/
extern const DBGCCMD g_aCmdsCodeView[];
extern const unsigned g_cCmdsCodeView;
#endif