[~] 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: public:
static HRESULT Start();
static void Stop();
private:
// may generate HRESULT exception if not registered // may generate HRESULT exception if not registered
DbgEventCallbacks(); DbgEventCallbacks();
void Deregister(); void Deregister();
private:
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// IUnknown interface implementation // IUnknown interface implementation
@ -42,11 +45,11 @@ private:
IDebugClient *m_dbgClient; IDebugClient *m_dbgClient;
IDebugSymbols3 *m_dbgSymbols3; IDebugSymbols3 *m_dbgSymbols3;
/////////////////////////////////////////////////////////////////////////////////
// global singleton
static DbgEventCallbacks *dbgEventCallbacks;
/////////////////////////////////////////////////////////////////////////////////
}; };
/////////////////////////////////////////////////////////////////////////////////
// global singleton
extern DbgEventCallbacks *dbgEventCallbacks;
/////////////////////////////////////////////////////////////////////////////////

View File

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

View File

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