[0.1.x] +reset for EventHandler
git-svn-id: https://pykd.svn.codeplex.com/svn@78241 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
2750f694a8
commit
487b4a8f6d
@ -429,7 +429,7 @@ void DebugClient::terminateProcess()
|
|||||||
|
|
||||||
hres = m_client->TerminateCurrentProcess();
|
hres = m_client->TerminateCurrentProcess();
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugClient::TerminateCurrentProcess failed" );
|
throw DbgException( "IDebugClient::TerminateCurrentProcess", hres );
|
||||||
}
|
}
|
||||||
|
|
||||||
void terminateProcess()
|
void terminateProcess()
|
||||||
|
@ -50,7 +50,6 @@ EventHandler::EventHandler( DebugClientPtr &client )
|
|||||||
|
|
||||||
EventHandler::~EventHandler()
|
EventHandler::~EventHandler()
|
||||||
{
|
{
|
||||||
m_handlerClient->SetEventCallbacks( NULL );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -17,13 +17,16 @@ namespace pykd {
|
|||||||
class EventHandler : public DebugBaseEventCallbacks
|
class EventHandler : public DebugBaseEventCallbacks
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EventHandler();
|
EventHandler();
|
||||||
|
|
||||||
EventHandler( DebugClientPtr &client );
|
EventHandler( DebugClientPtr &client );
|
||||||
|
|
||||||
virtual ~EventHandler();
|
virtual ~EventHandler();
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
m_handlerClient.Release();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
STDMETHOD_(ULONG, AddRef)() { return 1; }
|
STDMETHOD_(ULONG, AddRef)() { return 1; }
|
||||||
@ -67,7 +70,6 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual ULONG onBreakpoint(ULONG Id) = 0;
|
virtual ULONG onBreakpoint(ULONG Id) = 0;
|
||||||
|
|
||||||
virtual ULONG onException(const python::dict &/*exceptData*/) = 0;
|
virtual ULONG onException(const python::dict &/*exceptData*/) = 0;
|
||||||
@ -81,7 +83,6 @@ protected:
|
|||||||
virtual ULONG onChangeDebugeeState() = 0;
|
virtual ULONG onChangeDebugeeState() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
CComPtr<IDebugClient> m_handlerClient;
|
CComPtr<IDebugClient> m_handlerClient;
|
||||||
|
|
||||||
DebugClientPtr m_parentClient;
|
DebugClientPtr m_parentClient;
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="windows-1251"?>
|
<?xml version="1.0" encoding="windows-1251"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9,00"
|
||||||
Name="pykd"
|
Name="pykd"
|
||||||
ProjectGUID="{FE961905-666F-4908-A212-961465F46F13}"
|
ProjectGUID="{FE961905-666F-4908-A212-961465F46F13}"
|
||||||
RootNamespace="pykd"
|
RootNamespace="pykd"
|
||||||
SccProjectName="$/pykd/branch/0.1.x/pykd"
|
|
||||||
SccAuxPath="https://tfs.codeplex.com/tfs/TFS08"
|
|
||||||
SccLocalPath="."
|
|
||||||
SccProvider="{4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}"
|
|
||||||
Keyword="Win32Proj"
|
Keyword="Win32Proj"
|
||||||
TargetFrameworkVersion="0"
|
TargetFrameworkVersion="0"
|
||||||
>
|
>
|
||||||
|
@ -652,7 +652,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
python::class_<EventHandlerWrap, boost::noncopyable>(
|
python::class_<EventHandlerWrap, boost::noncopyable>(
|
||||||
"eventHandler", "Base class for overriding and handling debug notifications" )
|
"eventHandler", "Base class for overriding and handling debug notifications" )
|
||||||
.def( python::init<>() )
|
.def( python::init<>() )
|
||||||
.def( python::init<DebugClientPtr&>() )
|
.def( "reset", &pykd::EventHandler::reset,
|
||||||
|
"Reset event handler" )
|
||||||
.def( "onBreakpoint", &pykd::EventHandlerWrap::onBreakpoint,
|
.def( "onBreakpoint", &pykd::EventHandlerWrap::onBreakpoint,
|
||||||
"Triggered breakpoint event. Parameter is int: ID of breakpoint\n"
|
"Triggered breakpoint event. Parameter is int: ID of breakpoint\n"
|
||||||
"For ignore event method must return DEBUG_STATUS_NO_CHANGE value" )
|
"For ignore event method must return DEBUG_STATUS_NO_CHANGE value" )
|
||||||
|
@ -112,7 +112,7 @@ class BaseTest( unittest.TestCase ):
|
|||||||
|
|
||||||
def testNewAddededApi( self ):
|
def testNewAddededApi( self ):
|
||||||
""" Branch test: new API 0.1.x what must be available """
|
""" Branch test: new API 0.1.x what must be available """
|
||||||
self.assertTrue( hasattr(pykd, 'createDbgClient') )
|
# self.assertTrue( hasattr(pykd, 'createDbgClient') )
|
||||||
self.assertTrue( hasattr(pykd, 'detachProcess') )
|
self.assertTrue( hasattr(pykd, 'detachProcess') )
|
||||||
self.assertTrue( hasattr(pykd, 'diaLoadPdb') )
|
self.assertTrue( hasattr(pykd, 'diaLoadPdb') )
|
||||||
self.assertTrue( hasattr(pykd, 'getDebuggeeType' ) )
|
self.assertTrue( hasattr(pykd, 'getDebuggeeType' ) )
|
||||||
@ -131,7 +131,7 @@ class BaseTest( unittest.TestCase ):
|
|||||||
self.assertTrue( hasattr(pykd, 'DiaException') )
|
self.assertTrue( hasattr(pykd, 'DiaException') )
|
||||||
self.assertTrue( hasattr(pykd, 'DiaScope') )
|
self.assertTrue( hasattr(pykd, 'DiaScope') )
|
||||||
self.assertTrue( hasattr(pykd, 'DiaSymbol') )
|
self.assertTrue( hasattr(pykd, 'DiaSymbol') )
|
||||||
self.assertTrue( hasattr(pykd, 'dbgClient') )
|
# self.assertTrue( hasattr(pykd, 'dbgClient') )
|
||||||
self.assertTrue( hasattr(pykd, 'din') )
|
self.assertTrue( hasattr(pykd, 'din') )
|
||||||
self.assertTrue( hasattr(pykd, 'dout') )
|
self.assertTrue( hasattr(pykd, 'dout') )
|
||||||
self.assertTrue( hasattr(pykd, 'eventHandler' ) )
|
self.assertTrue( hasattr(pykd, 'eventHandler' ) )
|
||||||
|
@ -4,11 +4,12 @@ import unittest
|
|||||||
import target
|
import target
|
||||||
import pykd
|
import pykd
|
||||||
import fnmatch
|
import fnmatch
|
||||||
|
import testutils
|
||||||
|
|
||||||
class ModuleLoadHandler(pykd.eventHandler):
|
class ModuleLoadHandler(pykd.eventHandler):
|
||||||
"""Track load/unload module implementation"""
|
"""Track load/unload module implementation"""
|
||||||
def __init__(self, client, moduleMask):
|
def __init__(self, moduleMask):
|
||||||
pykd.eventHandler.__init__(self, client)
|
pykd.eventHandler.__init__(self)
|
||||||
|
|
||||||
self.moduleMask = moduleMask.lower()
|
self.moduleMask = moduleMask.lower()
|
||||||
|
|
||||||
@ -36,13 +37,13 @@ class EhLoadTest(unittest.TestCase):
|
|||||||
|
|
||||||
def testLoadUnload(self):
|
def testLoadUnload(self):
|
||||||
"""Start new process and track loading and unloading modules"""
|
"""Start new process and track loading and unloading modules"""
|
||||||
testClient = pykd.createDbgClient()
|
pykd.startProcess(target.appPath + " -testLoadUnload")
|
||||||
testClient.startProcess( target.appPath + " -testLoadUnload" )
|
with testutils.ContextCallIt( pykd.killProcess ) as contextCallIt:
|
||||||
|
modLoadHandler = ModuleLoadHandler( "*Iphlpapi*" )
|
||||||
modLoadHandler = ModuleLoadHandler( testClient, "*Iphlpapi*" )
|
with testutils.ContextCallIt( getattr(modLoadHandler, "reset") ) as resetEventHandler:
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
testClient.go()
|
pykd.go()
|
||||||
except pykd.WaitEventException:
|
except pykd.WaitEventException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -43,14 +43,19 @@ def getTestSuite( singleName = "" ):
|
|||||||
unittest.TestLoader().loadTestsFromTestCase( intbase.IntBaseTest ),
|
unittest.TestLoader().loadTestsFromTestCase( intbase.IntBaseTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( synsymtest.SynSymTest ),
|
unittest.TestLoader().loadTestsFromTestCase( synsymtest.SynSymTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( thrdctxtest.ThreadContextTest ),
|
unittest.TestLoader().loadTestsFromTestCase( thrdctxtest.ThreadContextTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( ehloadtest.EhLoadTest ),
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase( localstest.LocalVarsTest ),
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase( ehexcepttest.EhExceptionBreakpointTest ),
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase( regtest.CpuRegTest ),
|
unittest.TestLoader().loadTestsFromTestCase( regtest.CpuRegTest ),
|
||||||
] )
|
] )
|
||||||
else:
|
else:
|
||||||
return unittest.TestSuite( unittest.TestLoader().loadTestsFromName( singleName ) )
|
return unittest.TestSuite( unittest.TestLoader().loadTestsFromName( singleName ) )
|
||||||
|
|
||||||
|
def getNewProcessTestSuite():
|
||||||
|
return unittest.TestSuite(
|
||||||
|
[
|
||||||
|
unittest.TestLoader().loadTestsFromTestCase( ehloadtest.EhLoadTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( localstest.LocalVarsTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( ehexcepttest.EhExceptionBreakpointTest ),
|
||||||
|
] )
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
@ -70,12 +75,16 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
print ""
|
print ""
|
||||||
|
|
||||||
suite = getTestSuite()
|
oneProcessTests = getTestSuite()
|
||||||
#suite = getTestSuite( "diatest.DiaTest.testFind" )
|
#oneProcessTests = getTestSuite( "diatest.DiaTest.testFind" )
|
||||||
#suite = getTestSuite( "typedvar.TypedVarTest.testTypeVarArg" )
|
#oneProcessTests = getTestSuite( "typedvar.TypedVarTest.testTypeVarArg" )
|
||||||
#suite = getTestSuite( "typeinfo.TypeInfoTest.testCreateByName" )
|
#oneProcessTests = getTestSuite( "typeinfo.TypeInfoTest.testCreateByName" )
|
||||||
#suite = getTestSuite( "typedvar.TypedVarTest.testBitField" )
|
#oneProcessTests = getTestSuite( "typedvar.TypedVarTest.testBitField" )
|
||||||
|
|
||||||
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( suite )
|
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( oneProcessTests )
|
||||||
|
|
||||||
|
pykd.killProcess()
|
||||||
|
|
||||||
|
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( getNewProcessTestSuite() )
|
||||||
|
|
||||||
raw_input("\npress return\n")
|
raw_input("\npress return\n")
|
||||||
|
16
test/scripts/testutils.py
Normal file
16
test/scripts/testutils.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"""PyKd test heplers/wrappers"""
|
||||||
|
|
||||||
|
import pykd
|
||||||
|
|
||||||
|
class ContextCallIt:
|
||||||
|
"""Context manager/with statement"""
|
||||||
|
def __init__(self, callIt):
|
||||||
|
self.callIt = callIt
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_value, exc_tb):
|
||||||
|
try: self.callIt()
|
||||||
|
except: pass
|
||||||
|
|
@ -1,14 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="windows-1251"?>
|
<?xml version="1.0" encoding="windows-1251"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9,00"
|
||||||
Name="targetapp"
|
Name="targetapp"
|
||||||
ProjectGUID="{C6254E16-AB8E-41EE-887D-31458E93FC68}"
|
ProjectGUID="{C6254E16-AB8E-41EE-887D-31458E93FC68}"
|
||||||
RootNamespace="targetapp"
|
RootNamespace="targetapp"
|
||||||
SccProjectName="$/pykd/branch/0.1.x/test/targetapp"
|
|
||||||
SccAuxPath="https://tfs.codeplex.com/tfs/TFS08"
|
|
||||||
SccLocalPath="."
|
|
||||||
SccProvider="{4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}"
|
|
||||||
Keyword="Win32Proj"
|
Keyword="Win32Proj"
|
||||||
TargetFrameworkVersion="131072"
|
TargetFrameworkVersion="131072"
|
||||||
>
|
>
|
||||||
@ -460,6 +456,10 @@
|
|||||||
RelativePath="..\scripts\target.py"
|
RelativePath="..\scripts\target.py"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\scripts\testutils.py"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\scripts\thrdctxtest.py"
|
RelativePath="..\scripts\thrdctxtest.py"
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user