mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 19:53:22 +08:00
[0.2.x] added : exception callback
git-svn-id: https://pykd.svn.codeplex.com/svn@80215 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
90f6329bec
commit
b4241945a2
@ -76,6 +76,7 @@ struct DEBUG_EVENT_CALLBACK {
|
||||
virtual DEBUG_CALLBACK_RESULT OnBreakpoint( ULONG bpId ) = 0;
|
||||
virtual DEBUG_CALLBACK_RESULT OnModuleLoad( ULONG64 offset, const std::string &name ) = 0;
|
||||
virtual DEBUG_CALLBACK_RESULT OnModuleUnload( ULONG64 offset, const std::string &name ) = 0;
|
||||
virtual DEBUG_CALLBACK_RESULT OnException( ULONG64 offset, ULONG code ) = 0;
|
||||
};
|
||||
|
||||
void eventRegisterCallbacks( const DEBUG_EVENT_CALLBACK *callbacks );
|
||||
|
@ -24,6 +24,7 @@ private:
|
||||
virtual DEBUG_CALLBACK_RESULT OnBreakpoint( ULONG bpId ) = 0;
|
||||
virtual DEBUG_CALLBACK_RESULT OnModuleLoad( ULONG64 offset, const std::string &name ) = 0;
|
||||
virtual DEBUG_CALLBACK_RESULT OnModuleUnload( ULONG64 offset, const std::string &name ) = 0;
|
||||
virtual DEBUG_CALLBACK_RESULT OnException( ULONG64 offset, ULONG code ) = 0;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
@ -46,6 +47,10 @@ public:
|
||||
return handler("onModuleUnload", offset, name );
|
||||
}
|
||||
|
||||
virtual DEBUG_CALLBACK_RESULT OnException( ULONG64 offset, ULONG code ) {
|
||||
return handler("onException", offset, code );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
template<typename Arg1Type>
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define PYKD_VERSION_MAJOR 0
|
||||
#define PYKD_VERSION_MINOR 2
|
||||
#define PYKD_VERSION_SUBVERSION 0
|
||||
#define PYKD_VERSION_BUILDNO 0
|
||||
#define PYKD_VERSION_BUILDNO 1
|
||||
|
||||
|
||||
#define __VER_STR2__(x) #x
|
||||
|
@ -437,10 +437,13 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
"Triggered breakpoint event. Parameter is int: ID of breakpoint\n"
|
||||
"For ignore event method must return False value" )
|
||||
.def( "onModuleLoad", &EventHandlerWrap::OnModuleLoad,
|
||||
"Triggered module load event. Parameter is long: module base, string: module name\n"
|
||||
"Triggered module load event. Parameter are long: module base, string: module name\n"
|
||||
"For ignore event method must return False value" )
|
||||
.def( "onModuleUnload", &EventHandlerWrap::OnModuleUnload,
|
||||
"Triggered module unload event. Parameter is long: module base, string: module name\n"
|
||||
"Triggered module unload event. Parameter are long: module base, string: module name\n"
|
||||
"For ignore event method must return False value" )
|
||||
.def( "onException", &EventHandlerWrap::OnException,
|
||||
"Triggered exception event. Parameters are long: exception address, long: exception code\n"
|
||||
"For ignore event method must return False value" );
|
||||
|
||||
// wrapper for standart python exceptions
|
||||
|
@ -971,6 +971,9 @@ HRESULT STDMETHODCALLTYPE DebugEngine::LoadModule(
|
||||
return ConvertCallbackResult( result );
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DebugEngine::UnloadModule(
|
||||
__in_opt PCSTR ImageBaseName,
|
||||
__in ULONG64 BaseOffset )
|
||||
@ -995,6 +998,30 @@ HRESULT STDMETHODCALLTYPE DebugEngine::UnloadModule(
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DebugEngine::Exception(
|
||||
__in PEXCEPTION_RECORD64 Exception,
|
||||
__in ULONG FirstChance )
|
||||
{
|
||||
DEBUG_CALLBACK_RESULT result = DebugCallbackNoChange;
|
||||
|
||||
boost::recursive_mutex::scoped_lock l(m_handlerLock);
|
||||
|
||||
HandlerList::iterator it = m_handlers.begin();
|
||||
|
||||
for ( ; it != m_handlers.end(); ++it )
|
||||
{
|
||||
PyThread_StateSave pyThreadSave( it->pystate );
|
||||
|
||||
DEBUG_CALLBACK_RESULT ret = it->callback->OnException( Exception->ExceptionAddress, Exception->ExceptionCode );
|
||||
|
||||
result = ret != DebugCallbackNoChange ? ret : result;
|
||||
}
|
||||
|
||||
return ConvertCallbackResult( result );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ULONG64
|
||||
getCurrentProcess()
|
||||
{
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
*Mask = DEBUG_EVENT_BREAKPOINT;
|
||||
*Mask |= DEBUG_EVENT_LOAD_MODULE;
|
||||
*Mask |= DEBUG_EVENT_UNLOAD_MODULE;
|
||||
*Mask |= DEBUG_EVENT_EXCEPTION;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -74,6 +75,10 @@ public:
|
||||
__in_opt PCSTR ImageBaseName,
|
||||
__in ULONG64 BaseOffset );
|
||||
|
||||
STDMETHOD(Exception)(
|
||||
__in PEXCEPTION_RECORD64 Exception,
|
||||
__in ULONG FirstChance );
|
||||
|
||||
DbgEngBind*
|
||||
operator->()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user