pykd/pykd/dbgeventcb.cpp
SND\kernelnet_cp 60599dcfb6 [pykd] added : callback for bp class ( breakpoint )
[pykd] changed:  refactored callbacks engine


git-svn-id: https://pykd.svn.codeplex.com/svn@63638 9b283d60-5439-405e-af05-b73fd8c4d996
2011-04-08 07:53:37 +00:00

121 lines
3.4 KiB
C++

#include "stdafx.h"
#include "dbgeng.h"
#include "dbgext.h"
#include "dbgeventcb.h"
#include "dbgexcept.h"
#include "dbgmodule.h"
#include "dbgsynsym.h"
#include "dbgcmd.h"
///////////////////////////////////////////////////////////////////////////////////
DbgEventCallbacksManager::DbgEventCallbacksManager( IDebugClient *client )
{
HRESULT hres;
m_debugClient = NULL;
try {
if ( client == NULL )
{
// ñëó÷àé, êîãäà ìû ðàáîòàåì â windbg. Ìû íå õîòèì ìåíÿòü ïîâåäåíèå êëèåíòà îòëàä÷èêà - îí
// äîëæåí ïðîäîëæàòü îáðàáîòêó ñîáûòèé, ïîýòîìó ìû ñîçäàåì ñâîåãî êëèåíòà
hres = DebugCreate( __uuidof(IDebugClient4), reinterpret_cast<PVOID*>(&m_debugClient));
if (FAILED(hres))
throw DbgException( "DebugCreate failed" );
}
else
{
// ñëó÷àé, êîãäà ìû ðàáîòàåì îòäåëüíî.  ýòîì ñëó÷àå êëèåíò âåñü â íàøåì ðàñïîðÿæåíèè
hres =client->QueryInterface( __uuidof(IDebugClient4), reinterpret_cast<PVOID*>(&m_debugClient));
if (FAILED(hres))
throw DbgException( "DebugCreate failed" );
}
hres = m_debugClient->SetEventCallbacks(this);
if (FAILED(hres))
throw DbgException( "IDebugClient::SetEventCallbacks" );
}
catch( std::exception& )
{
//dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
//dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
}
///////////////////////////////////////////////////////////////////////////////////
DbgEventCallbacksManager::~DbgEventCallbacksManager()
{
if ( m_debugClient )
m_debugClient->Release();
}
///////////////////////////////////////////////////////////////////////////////////
HRESULT DbgEventCallbacksManager::GetInterestMask(
__out PULONG Mask
)
{
*Mask = DEBUG_EVENT_CHANGE_SYMBOL_STATE | DEBUG_EVENT_BREAKPOINT;
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////////
HRESULT DbgEventCallbacksManager::ChangeSymbolState(
__in ULONG Flags,
__in ULONG64 Argument
)
{
DbgExt ext( m_debugClient );
if ((DEBUG_CSS_LOADS & Flags))
{
if (Argument)
{
DEBUG_MODULE_PARAMETERS dbgModuleParameters={};
HRESULT hres = dbgExt->symbols3->GetModuleParameters(
1,
&Argument,
0,
&dbgModuleParameters);
if (SUCCEEDED(hres))
{
ModuleInfo moduleInfo(dbgModuleParameters);
restoreSyntheticSymbolForModule(moduleInfo);
}
return S_OK;
}
//// f.e. is case ".reload /f image.exe", if for image.exe no symbols
restoreSyntheticSymbolForAllModules();
return S_OK;
}
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////////
HRESULT DbgEventCallbacksManager::Breakpoint(
__in IDebugBreakpoint * bp
)
{
return dbgBreakpointClass::onBreakpointEvnet( bp );
}
///////////////////////////////////////////////////////////////////////////////////