VBoxDbgBase.h revision 489ff469f658c1a9e95ec8c62fec535c9ca6c6a7
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync/* $Id$ */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync/** @file
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * VBox Debugger GUI - Base class.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync/*
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync *
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * available from http://www.virtualbox.org. This file is free software;
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * you can redistribute it and/or modify it under the terms of the GNU
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * General Public License (GPL) as published by the Free Software
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync *
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * additional information or have any questions.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync#ifndef __VBoxDbgBase_h__
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync#define __VBoxDbgBase_h__
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync#include <VBox/stam.h>
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync#include <VBox/vmapi.h>
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync#include <VBox/dbg.h>
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync#include <iprt/thread.h>
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync/**
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * VBox Debugger GUI Base Class.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync *
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * The purpose of this class is to hide the VM handle, abstract VM
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * operations, and finally to make sure the GUI won't crash when
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * the VM dies.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsyncclass VBoxDbgBase
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync{
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsyncpublic:
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync /**
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Construct the object.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync *
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * @param pVM The VM handle.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync */
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync VBoxDbgBase(PVM pVM);
8a7af14e45ca3f1aadcad537ddf79f68a830748cvboxsync
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync /**
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Destructor.
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync */
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync virtual ~VBoxDbgBase();
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsyncprotected:
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync /**
1d94ccd0c6d838a45dea3a79ba295adc4caabcf9vboxsync * Checks if the VM is OK for normal operations.
1d94ccd0c6d838a45dea3a79ba295adc4caabcf9vboxsync * @returns true if ok, false if not.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync bool isVMOk() const
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync {
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync return m_pVM != NULL;
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync }
218c5abcfe14c89d04353015e755a02447960018vboxsync
218c5abcfe14c89d04353015e755a02447960018vboxsync /**
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Checks if the current thread is the GUI thread or not.
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync * @return true/false accordingly.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync bool isGUIThread() const
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync {
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync return m_hGUIThread == RTThreadNativeSelf();
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync }
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync
e7e589ca404045e288030a4151e57b63976cb39dvboxsync /** @name Operations
e7e589ca404045e288030a4151e57b63976cb39dvboxsync * @{ */
e7e589ca404045e288030a4151e57b63976cb39dvboxsync /**
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync * Wrapper for STAMR3Reset().
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync */
1d94ccd0c6d838a45dea3a79ba295adc4caabcf9vboxsync int stamReset(const char *pszPat);
df277f214bcaae98f80456ec998330eaa7460ecavboxsync /**
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync * Wrapper for STAMR3Enum().
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync int stamEnum(const char *pszPat, PFNSTAMR3ENUM pfnEnum, void *pvUser);
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync /**
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync * Wrapper for DBGCCreate().
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync */
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync int dbgcCreate(PDBGCBACK pBack, unsigned fFlags);
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync /** @} */
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsyncprotected:
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync /** @name Signals
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync * @{ */
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync /**
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync * Called when the VM has been terminated.
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync */
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync virtual void sigTerminated();
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync /** @} */
d00167eae3bb1cbd4b7b5d0837eeffee1e7276aavboxsync
2f3e13b744091a6c1d3bc4b9dc6ef4e7f25bf1cdvboxsync
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsyncprivate:
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync /**
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync * VM state callback function.
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync *
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync * You are not allowed to call any function which changes the VM state from a
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync * state callback, except VMR3Destroy().
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync *
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync * @param pVM The VM handle.
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync * @param enmState The new state.
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync * @param enmOldState The old state.
1d94ccd0c6d838a45dea3a79ba295adc4caabcf9vboxsync * @param pvUser The user argument.
5328f9f73c4625bdcc8ea1d4a95c34c6eeac9ec9vboxsync */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync static DECLCALLBACK(void) atStateChange(PVM pVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
private:
/** The VM handle. */
PVM m_pVM;
/** The handle of the GUI thread. */
RTNATIVETHREAD m_hGUIThread;
};
#endif