From 0c548cefb607d7d1609e16d84dffca5844b6fe3a Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Tue, 12 Mar 2013 07:32:26 +0000 Subject: [PATCH] [0.2.x] fixed : eventHandler.onExecutionStatusChange method git-svn-id: https://pykd.svn.codeplex.com/svn@82899 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/win/dbgeng.cpp | 11 ++++++++--- pykd/win/dbgeng.h | 6 ++++++ test/scripts/ehexcepttest.py | 2 -- test/scripts/ehstatustest.py | 4 ++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/pykd/win/dbgeng.cpp b/pykd/win/dbgeng.cpp index 61b97ff..5ab11b4 100644 --- a/pykd/win/dbgeng.cpp +++ b/pykd/win/dbgeng.cpp @@ -1521,15 +1521,20 @@ HRESULT STDMETHODCALLTYPE DebugEngine::ChangeEngineState( HandlerList::iterator it = m_handlers.begin(); - for ( ; it != m_handlers.end(); ++it ) + if ( ( ( Flags & DEBUG_CES_EXECUTION_STATUS ) != 0 ) && + ( ( Argument & DEBUG_STATUS_INSIDE_WAIT ) == 0 ) && + (ULONG)Argument != previousExecutionStatus ) { - if ( ( Flags & DEBUG_CES_EXECUTION_STATUS ) != 0 && - ( Argument & DEBUG_STATUS_INSIDE_WAIT ) == 0 ) + + for ( ; it != m_handlers.end(); ++it ) { + PyThread_StateSave pyThreadSave( it->pystate ); it->callback->onExecutionStatusChange( (ULONG)Argument ); } + + previousExecutionStatus = (ULONG)Argument; } return S_OK; diff --git a/pykd/win/dbgeng.h b/pykd/win/dbgeng.h index 474a65c..eba1e61 100644 --- a/pykd/win/dbgeng.h +++ b/pykd/win/dbgeng.h @@ -104,6 +104,10 @@ public: void registerCallbacks( const DEBUG_EVENT_CALLBACK *callbacks ); void removeCallbacks( const DEBUG_EVENT_CALLBACK *callbacks ); + DebugEngine() : + previousExecutionStatus( DebugStatusNoChange ) + {} + private: std::auto_ptr m_bind; @@ -123,6 +127,8 @@ private: boost::recursive_mutex m_handlerLock; HandlerList m_handlers; + + ULONG previousExecutionStatus; }; /////////////////////////////////////////////////////////////////////////////////// diff --git a/test/scripts/ehexcepttest.py b/test/scripts/ehexcepttest.py index fd03601..4ca4485 100644 --- a/test/scripts/ehexcepttest.py +++ b/test/scripts/ehexcepttest.py @@ -15,8 +15,6 @@ class ExceptionHandler(pykd.eventHandler): self.accessViolationOccured = exceptInfo.ExceptionCode == 0xC0000005 - print exceptInfo - if self.accessViolationOccured: self.param0 = exceptInfo.Parameters[0] self.param1 = exceptInfo.Parameters[1] diff --git a/test/scripts/ehstatustest.py b/test/scripts/ehstatustest.py index 1c0947c..b119e04 100644 --- a/test/scripts/ehstatustest.py +++ b/test/scripts/ehstatustest.py @@ -10,11 +10,14 @@ class StatusChangeHandler(pykd.eventHandler): def __init__(self): pykd.eventHandler.__init__(self) self.breakCount = 0 + self.goCount = 0 def onExecutionStatusChange(self, executionStatus): if executionStatus == pykd.executionStatus.Break: self.breakCount = self.breakCount + 1 + if executionStatus == pykd.executionStatus.Go: + self.goCount = self.goCount + 1 class EhStatusTest(unittest.TestCase): @@ -33,4 +36,5 @@ class EhStatusTest(unittest.TestCase): pykd.go() self.assertEqual( 2, statusChangeHandler.breakCount ) + self.assertEqual( statusChangeHandler.breakCount, statusChangeHandler.goCount ) \ No newline at end of file