[~] singleton dbgEventCallbacks and work with him moved into a class DbgEventCallbacks

git-svn-id: https://pykd.svn.codeplex.com/svn@62103 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2011-03-02 19:58:41 +00:00
parent b73ccc1a37
commit bb0e8328e3
4 changed files with 45 additions and 32 deletions

View File

@ -10,7 +10,37 @@
/////////////////////////////////////////////////////////////////////////////////
DbgEventCallbacks *dbgEventCallbacks = NULL;
DbgEventCallbacks *DbgEventCallbacks::dbgEventCallbacks = NULL;
/////////////////////////////////////////////////////////////////////////////////
HRESULT DbgEventCallbacks::Start()
{
HRESULT hres;
try
{
Stop();
dbgEventCallbacks = new DbgEventCallbacks;
hres = S_OK;
}
catch (HRESULT _hres)
{
hres = _hres;
}
catch (...)
{
hres = E_OUTOFMEMORY;
}
return hres;
}
/////////////////////////////////////////////////////////////////////////////////
void DbgEventCallbacks::Stop()
{
if (dbgEventCallbacks)
dbgEventCallbacks->Deregister();
}
/////////////////////////////////////////////////////////////////////////////////

View File

@ -6,12 +6,15 @@ class DbgEventCallbacks : public DebugBaseEventCallbacks
{
public:
static HRESULT Start();
static void Stop();
private:
// may generate HRESULT exception if not registered
DbgEventCallbacks();
void Deregister();
private:
/////////////////////////////////////////////////////////////////////////////////
// IUnknown interface implementation
@ -42,11 +45,11 @@ private:
IDebugClient *m_dbgClient;
IDebugSymbols3 *m_dbgSymbols3;
/////////////////////////////////////////////////////////////////////////////////
// global singleton
static DbgEventCallbacks *dbgEventCallbacks;
/////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////
// global singleton
extern DbgEventCallbacks *dbgEventCallbacks;
/////////////////////////////////////////////////////////////////////////////////

View File

@ -227,7 +227,7 @@ VOID
CALLBACK
DebugExtensionUninitialize()
{
stopDbgEventMonotoring();
DbgEventCallbacks::Stop();
delete windbgGlobalSession;
windbgGlobalSession = NULL;

View File

@ -6,29 +6,9 @@ dbgCreateSession();
extern
bool dbgSessionStarted;
inline void stopDbgEventMonotoring()
{
if (dbgEventCallbacks)
dbgEventCallbacks->Deregister();
}
inline HRESULT setDbgSessionStarted()
{
HRESULT hres;
try
{
stopDbgEventMonotoring();
dbgEventCallbacks = new DbgEventCallbacks;
hres = S_OK;
}
catch (HRESULT _hres)
{
hres = _hres;
}
catch (...)
{
hres = E_OUTOFMEMORY;
}
HRESULT hres = DbgEventCallbacks::Start();
if (SUCCEEDED(hres))
dbgSessionStarted = true;
return hres;