Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

DBGFInternal.h

Go to the documentation of this file.
/* $Id: DBGFInternal.h $ */
/** @file
 * DBGF - Internal header file.
 */

/*
 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) 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.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 * Clara, CA 95054 USA or visit http://www.sun.com if you need
 * additional information or have any questions.
 */

#ifndef ___DBGFInternal_h
#define ___DBGFInternal_h

#include <VBox/cdefs.h>
#include <VBox/types.h>
#include <iprt/semaphore.h>
#include <iprt/critsect.h>
#include <iprt/string.h>
#include <iprt/avl.h>
#include <VBox/dbgf.h>



/** @defgroup grp_dbgf_int   Internals
 * @ingroup grp_dbgf
 * @internal
 * @{
 */


/** VMM Debugger Command. */
00043 typedef enum DBGFCMD
{
    /** No command.
     * This is assigned to the field by the emulation thread after
     * a command has been completed. */
00048     DBGFCMD_NO_COMMAND = 0,
    /** Halt the VM. */
00050     DBGFCMD_HALT,
    /** Resume execution. */
00052     DBGFCMD_GO,
    /** Single step execution - stepping into calls. */
00054     DBGFCMD_SINGLE_STEP,
    /** Set a breakpoint. */
00056     DBGFCMD_BREAKPOINT_SET,
    /** Set a access breakpoint. */
00058     DBGFCMD_BREAKPOINT_SET_ACCESS,
    /** Set a REM breakpoint. */
00060     DBGFCMD_BREAKPOINT_SET_REM,
    /** Clear a breakpoint. */
00062     DBGFCMD_BREAKPOINT_CLEAR,
    /** Enable a breakpoint. */
00064     DBGFCMD_BREAKPOINT_ENABLE,
    /** Disable a breakpoint. */
00066     DBGFCMD_BREAKPOINT_DISABLE,
    /** List breakpoints. */
00068     DBGFCMD_BREAKPOINT_LIST,

    /** Detaches the debugger.
     * Disabling all breakpoints, watch points and the like. */
00072     DBGFCMD_DETACH_DEBUGGER = 0x7ffffffe,
    /** Detached the debugger.
     * The isn't a command as such, it's just that it's necessary for the
     * detaching protocol to be racefree. */
00076     DBGFCMD_DETACHED_DEBUGGER = 0x7fffffff
} DBGFCMD;

/**
 * VMM Debugger Command.
 */
00082 typedef union DBGFCMDDATA
{
    uint32_t    uDummy;
} DBGFCMDDATA;
/** Pointer to DBGF Command Data. */
00087 typedef DBGFCMDDATA *PDBGFCMDDATA;

/**
 * Info type.
 */
00092 typedef enum DBGFINFOTYPE
{
    /** Invalid. */
00095     DBGFINFOTYPE_INVALID = 0,
    /** Device owner. */
00097     DBGFINFOTYPE_DEV,
    /** Driver owner. */
00099     DBGFINFOTYPE_DRV,
    /** Internal owner. */
00101     DBGFINFOTYPE_INT,
    /** External owner. */
00103     DBGFINFOTYPE_EXT
} DBGFINFOTYPE;


/** Pointer to info structure. */
00108 typedef struct DBGFINFO *PDBGFINFO;

/**
 * Info structure.
 */
00113 typedef struct DBGFINFO
{
    /** The flags. */
00116     uint32_t        fFlags;
    /** Owner type. */
00118     DBGFINFOTYPE    enmType;
    /** Per type data. */
    union
    {
        /** DBGFINFOTYPE_DEV */
        struct
        {
            /** Device info handler function. */
00126             PFNDBGFHANDLERDEV   pfnHandler;
            /** The device instance. */
00128             PPDMDEVINS          pDevIns;
        } Dev;

        /** DBGFINFOTYPE_DRV */
        struct
        {
            /** Driver info handler function. */
00135             PFNDBGFHANDLERDRV   pfnHandler;
            /** The driver instance. */
00137             PPDMDRVINS          pDrvIns;
        } Drv;

        /** DBGFINFOTYPE_INT */
        struct
        {
            /** Internal info handler function. */
00144             PFNDBGFHANDLERINT   pfnHandler;
        } Int;

        /** DBGFINFOTYPE_EXT */
        struct
        {
            /** External info handler function. */
00151             PFNDBGFHANDLEREXT   pfnHandler;
            /** The user argument. */
00153             void               *pvUser;
        } Ext;
    } u;

    /** Pointer to the description. */
00158     const char     *pszDesc;
    /** Pointer to the next info structure. */
00160     PDBGFINFO       pNext;
    /** The identifier name length. */
00162     size_t          cchName;
    /** The identifier name. (Extends 'beyond' the struct as usual.) */
00164     char            szName[1];
} DBGFINFO;


/**
 * Guest OS digger instance.
 */
00171 typedef struct DBGFOS
{
    /** Pointer to the registration record. */
00174     PCDBGFOSREG pReg;
    /** Pointer to the next OS we've registered. */
00176     struct DBGFOS *pNext;
    /** The instance data (variable size). */
00178     uint8_t abData[16];
} DBGFOS;
/** Pointer to guest OS digger instance. */
00181 typedef DBGFOS *PDBGFOS;
/** Pointer to const guest OS digger instance. */
00183 typedef DBGFOS const *PCDBGFOS;


/**
 * Converts a DBGF pointer into a VM pointer.
 * @returns Pointer to the VM structure the CPUM is part of.
 * @param   pDBGF   Pointer to DBGF instance data.
 */
00191 #define DBGF2VM(pDBGF)  ( (PVM)((char*)pDBGF - pDBGF->offVM) )


/**
 * DBGF Data (part of VM)
 */
00197 typedef struct DBGF
{
    /** Offset to the VM structure. */
00200     RTINT                   offVM;

    /** Debugger Attached flag.
     * Set if a debugger is attached, elsewise it's clear.
     */
00205     bool volatile           fAttached;

    /** Stopped in the Hypervisor.
     * Set if we're stopped on a trace, breakpoint or assertion inside
     * the hypervisor and have to restrict the available operations.
     */
00211     bool volatile           fStoppedInHyper;

    /**
     * Ping-Pong construct where the Ping side is the VMM and the Pong side
     * the Debugger.
     */
00217     RTPINGPONG              PingPong;

    /** The Event to the debugger.
     * The VMM will ping the debugger when the event is ready. The event is
     * either a response to a command or to a break/watch point issued
     * previously.
     */
00224     DBGFEVENT               DbgEvent;

    /** The Command to the VMM.
     * Operated in an atomic fashion since the VMM will poll on this.
     * This means that a the command data must be written before this member
     * is set. The VMM will reset this member to the no-command state
     * when it have processed it.
     */
00232     DBGFCMD volatile        enmVMMCmd;
    /** The Command data.
     * Not all commands take data. */
00235     DBGFCMDDATA             VMMCmdData;

    /** List of registered info handlers. */
    R3PTRTYPE(PDBGFINFO)    pInfoFirst;
    /** Critical section protecting the above list. */
00240     RTCRITSECT              InfoCritSect;

    /** Range tree containing the loaded symbols of the a VM.
     * This tree will never have blind spots. */
    R3PTRTYPE(AVLRGCPTRTREE) SymbolTree;
    /** Symbol name space. */
    R3PTRTYPE(PRTSTRSPACE)  pSymbolSpace;
    /** Indicates whether DBGFSym.cpp is initialized or not.
     * This part is initialized in a lazy manner for performance reasons. */
00249     bool                    fSymInited;
    /** Alignment padding. */
00251     RTUINT                  uAlignment0;

    /** The number of hardware breakpoints. */
00254     RTUINT                  cHwBreakpoints;
    /** The number of active breakpoints. */
00256     RTUINT                  cBreakpoints;
    /** Array of hardware breakpoints. (0..3)
     * This is shared among all the CPUs because life is much simpler that way. */
00259     DBGFBP                  aHwBreakpoints[4];
    /** Array of int 3 and REM breakpoints. (4..)
     * @remark This is currently a fixed size array for reasons of simplicity. */
00262     DBGFBP                  aBreakpoints[32];

    /** The address space database lock. */
00265     RTSEMRW                 hAsDbLock;
    /** The address space handle database.      (Protected by hAsDbLock.) */
    R3PTRTYPE(AVLPVTREE)    AsHandleTree;
    /** The address space process id database.  (Protected by hAsDbLock.) */
    R3PTRTYPE(AVLU32TREE)   AsPidTree;
    /** The address space name database.        (Protected by hAsDbLock.) */
    R3PTRTYPE(RTSTRSPACE)   AsNameSpace;
    /** Special address space aliases.          (Protected by hAsDbLock.) */
00273     RTDBGAS volatile        ahAsAliases[DBGF_AS_COUNT];

    /** The current Guest OS digger. */
    R3PTRTYPE(PDBGFOS)      pCurOS;
    /** The head of the Guest OS digger instances. */
    R3PTRTYPE(PDBGFOS)      pOSHead;
} DBGF;
/** Pointer to DBGF Data. */
00281 typedef DBGF *PDBGF;


/** Converts a DBGFCPU pointer into a VM pointer. */
00285 #define DBGFCPU_2_VM(pDbgfCpu) ((PVM)((uint8_t *)(pDbgfCpu) + (pDbgfCpu)->offVM))

/**
 * The per CPU data for DBGF.
 */
00290 typedef struct DBGFCPU
{
    /** The offset into the VM structure.
     * @see DBGFCPU_2_VM(). */
00294     uint32_t                offVM;

    /** Current active breakpoint (id).
     * This is ~0U if not active. It is set when a execution engine
     * encounters a breakpoint and returns VINF_EM_DBG_BREAKPOINT. This is
     * currently not used for REM breakpoints because of the lazy coupling
     * between VBox and REM. */
00301     uint32_t                iActiveBp;
    /** Set if we're singlestepping in raw mode.
     * This is checked and cleared in the \#DB handler. */
00304     bool                    fSingleSteppingRaw;

    /** Padding the structure to 16 bytes. */
00307     uint8_t                 abReserved[3];
} DBGFCPU;
/** Pointer to DBGFCPU data. */
00310 typedef DBGFCPU *PDBGFCPU;


int  dbgfR3AsInit(PVM pVM);
void dbgfR3AsTerm(PVM pVM);
void dbgfR3AsRelocate(PVM pVM, RTGCUINTPTR offDelta);
int  dbgfR3InfoInit(PVM pVM);
int  dbgfR3InfoTerm(PVM pVM);
void dbgfR3OSTerm(PVM pVM);
int  dbgfR3SymInit(PVM pVM);
int  dbgfR3SymTerm(PVM pVM);
int  dbgfR3BpInit(PVM pVM);



#ifdef IN_RING3

#endif

/** @} */

#endif

Generated by  Doxygen 1.6.0   Back to index