From aee8b2b1b82ecf24186af51406fdf374af03425e Mon Sep 17 00:00:00 2001 From: "SND\\EreTIk_cp" Date: Wed, 1 May 2013 12:50:44 +0000 Subject: [PATCH] [0.2.x] ~recovered WaitEventException git-svn-id: https://pykd.svn.codeplex.com/svn@83541 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dia/diaexcept.cpp | 3 +++ pykd/python/pymod.cpp | 2 +- pykd/win/dbgeng.cpp | 8 ++++++-- test/scripts/ehstatustest.py | 17 +++++------------ test/scripts/ehsymbolstest.py | 7 ++----- test/scripts/testutils.py | 5 +++++ 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/pykd/dia/diaexcept.cpp b/pykd/dia/diaexcept.cpp index 623da98..a539a51 100644 --- a/pykd/dia/diaexcept.cpp +++ b/pykd/dia/diaexcept.cpp @@ -89,6 +89,9 @@ std::string DiaException::makeFullDesc(const std::string &desc, HRESULT hres, ID _CASE_DIA_ERROR(SYMSRV_CACHE_FULL); #undef _CASE_DIA_ERROR + + case S_FALSE: sstream << ": S_FALSE" << std::endl; break; + default: { PCHAR errMessage = NULL; diff --git a/pykd/python/pymod.cpp b/pykd/python/pymod.cpp index e98b0bd..6011fe4 100644 --- a/pykd/python/pymod.cpp +++ b/pykd/python/pymod.cpp @@ -655,7 +655,7 @@ BOOST_PYTHON_MODULE( pykd ) pykd::exception( "BaseException", "Pykd base exception class" ); pykd::exception( "MemoryException", "Target memory access exception class" ); - //pykd::exception( "WaitEventException", "Debug interface access exception" ); + pykd::exception( "WaitEventException", "None of the targets could generate events" ); pykd::exception( "WrongEventTypeException", "Unknown last event type" ); pykd::exception( "SymbolException", "Symbol exception" ); //pykd::exception( "DiaException", "Debug interface access exception" ); diff --git a/pykd/win/dbgeng.cpp b/pykd/win/dbgeng.cpp index e36a4c2..b9b57d8 100644 --- a/pykd/win/dbgeng.cpp +++ b/pykd/win/dbgeng.cpp @@ -110,12 +110,16 @@ void debugGo() do { hres = g_dbgEng->control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE); if ( FAILED( hres ) ) - throw DbgException( "IDebugControl::WaitForEvent failed" ); + { + if (E_UNEXPECTED == hres) + throw WaitEventException(); + throw DbgException( "IDebugControl::WaitForEvent", hres ); + } hres = g_dbgEng->control->GetExecutionStatus( ¤tStatus ); if ( FAILED( hres ) ) - throw DbgException( "IDebugControl::GetExecutionStatus failed" ); + throw DbgException( "IDebugControl::GetExecutionStatus", hres ); } while( currentStatus != DEBUG_STATUS_BREAK && currentStatus != DEBUG_STATUS_NO_DEBUGGEE ); } diff --git a/test/scripts/ehstatustest.py b/test/scripts/ehstatustest.py index ac7bd11..440decf 100644 --- a/test/scripts/ehstatustest.py +++ b/test/scripts/ehstatustest.py @@ -12,7 +12,7 @@ class StatusChangeHandler(pykd.eventHandler): self.breakCount = 0 self.goCount = 0 self.noDebuggee = 0 - + def onExecutionStatusChange(self, executionStatus): if executionStatus == pykd.executionStatus.Break: self.breakCount += 1 @@ -29,20 +29,13 @@ class EhStatusTest(unittest.TestCase): """Start new process and track exceptions""" _locProcessId = pykd.startProcess( target.appPath + " -testChangeStatus" ) with testutils.ContextCallIt( testutils.KillProcess(_locProcessId) ) as killStartedProcess : - + pykd.go() #skip initial break - + statusChangeHandler = StatusChangeHandler() - - try: - - while True: - pykd.go() - except pykd.BaseException: - pass - + + self.assertRaises(pykd.WaitEventException, testutils.infGo) self.assertEqual( 2, statusChangeHandler.breakCount ) self.assertEqual( 1, statusChangeHandler.noDebuggee ) self.assertEqual( statusChangeHandler.breakCount + statusChangeHandler.noDebuggee , statusChangeHandler.goCount ) - \ No newline at end of file diff --git a/test/scripts/ehsymbolstest.py b/test/scripts/ehsymbolstest.py index 98cd05b..7509b7d 100644 --- a/test/scripts/ehsymbolstest.py +++ b/test/scripts/ehsymbolstest.py @@ -40,9 +40,6 @@ class EhSymbolsTest(unittest.TestCase): pykd.dbgCommand(".reload /u") self.assertTrue( symbolsStateHandler.unloadAllModulesTrigged ) - try: - while True: - pykd.go() - except pykd.BaseException: - pass + self.assertRaises(pykd.WaitEventException, testutils.infGo) + self.assertTrue( "iphlpapi" in symbolsStateHandler.modNames ) diff --git a/test/scripts/testutils.py b/test/scripts/testutils.py index 842520b..557285a 100644 --- a/test/scripts/testutils.py +++ b/test/scripts/testutils.py @@ -23,3 +23,8 @@ class KillProcess: pykd.killProcess( self.processId ) pykd.detachProcess( self.processId ) +def infGo(): + """Infinite pykd.go call""" + while True: + pykd.go() +