Commit 487b4a8f authored by SND\EreTIk_cp's avatar SND\EreTIk_cp Committed by Mikhail I. Izmestev
Browse files

[0.1.x] +reset for EventHandler

git-svn-id: https://pykd.svn.codeplex.com/svn@78241 9b283d60-5439-405e-af05-b73fd8c4d996
parent 2750f694
......@@ -426,10 +426,10 @@ ULONG ptrSize()
void DebugClient::terminateProcess()
{
HRESULT hres;
hres = m_client->TerminateCurrentProcess();
if ( FAILED( hres ) )
throw DbgException( "IDebugClient::TerminateCurrentProcess failed" );
throw DbgException( "IDebugClient::TerminateCurrentProcess", hres );
}
void terminateProcess()
......
......@@ -50,7 +50,6 @@ EventHandler::EventHandler( DebugClientPtr &client )
EventHandler::~EventHandler()
{
m_handlerClient->SetEventCallbacks( NULL );
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -17,13 +17,16 @@ namespace pykd {
class EventHandler : public DebugBaseEventCallbacks
{
public:
EventHandler();
EventHandler( DebugClientPtr &client );
virtual ~EventHandler();
void reset() {
m_handlerClient.Release();
}
protected:
STDMETHOD_(ULONG, AddRef)() { return 1; }
......@@ -67,7 +70,6 @@ protected:
protected:
virtual ULONG onBreakpoint(ULONG Id) = 0;
virtual ULONG onException(const python::dict &/*exceptData*/) = 0;
......@@ -75,13 +77,12 @@ protected:
virtual ULONG onLoadModule(const ModulePtr &/* module */) = 0;
virtual ULONG onUnloadModule(ULONG64 /*modBase*/) = 0;
virtual ULONG onChangeSessionStatus( ULONG status ) = 0;
virtual ULONG onChangeDebugeeState() = 0;
protected:
CComPtr<IDebugClient> m_handlerClient;
DebugClientPtr m_parentClient;
......
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="pykd"
ProjectGUID="{FE961905-666F-4908-A212-961465F46F13}"
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"
TargetFrameworkVersion="0"
>
......
......@@ -652,7 +652,8 @@ BOOST_PYTHON_MODULE( pykd )
python::class_<EventHandlerWrap, boost::noncopyable>(
"eventHandler", "Base class for overriding and handling debug notifications" )
.def( python::init<>() )
.def( python::init<DebugClientPtr&>() )
.def( "reset", &pykd::EventHandler::reset,
"Reset event handler" )
.def( "onBreakpoint", &pykd::EventHandlerWrap::onBreakpoint,
"Triggered breakpoint event. Parameter is int: ID of breakpoint\n"
"For ignore event method must return DEBUG_STATUS_NO_CHANGE value" )
......
......@@ -112,7 +112,7 @@ class BaseTest( unittest.TestCase ):
def testNewAddededApi( self ):
""" 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, 'diaLoadPdb') )
self.assertTrue( hasattr(pykd, 'getDebuggeeType' ) )
......@@ -131,7 +131,7 @@ class BaseTest( unittest.TestCase ):
self.assertTrue( hasattr(pykd, 'DiaException') )
self.assertTrue( hasattr(pykd, 'DiaScope') )
self.assertTrue( hasattr(pykd, 'DiaSymbol') )
self.assertTrue( hasattr(pykd, 'dbgClient') )
# self.assertTrue( hasattr(pykd, 'dbgClient') )
self.assertTrue( hasattr(pykd, 'din') )
self.assertTrue( hasattr(pykd, 'dout') )
self.assertTrue( hasattr(pykd, 'eventHandler' ) )
......
......@@ -4,11 +4,12 @@ import unittest
import target
import pykd
import fnmatch
import testutils
class ModuleLoadHandler(pykd.eventHandler):
"""Track load/unload module implementation"""
def __init__(self, client, moduleMask):
pykd.eventHandler.__init__(self, client)
def __init__(self, moduleMask):
pykd.eventHandler.__init__(self)
self.moduleMask = moduleMask.lower()
......@@ -36,16 +37,16 @@ class EhLoadTest(unittest.TestCase):
def testLoadUnload(self):
"""Start new process and track loading and unloading modules"""
testClient = pykd.createDbgClient()
testClient.startProcess( target.appPath + " -testLoadUnload" )
modLoadHandler = ModuleLoadHandler( testClient, "*Iphlpapi*" )
try:
while True:
testClient.go()
except pykd.WaitEventException:
pass
self.assertTrue(modLoadHandler.wasLoad)
self.assertTrue(modLoadHandler.wasUnload)
pykd.startProcess(target.appPath + " -testLoadUnload")
with testutils.ContextCallIt( pykd.killProcess ) as contextCallIt:
modLoadHandler = ModuleLoadHandler( "*Iphlpapi*" )
with testutils.ContextCallIt( getattr(modLoadHandler, "reset") ) as resetEventHandler:
try:
while True:
pykd.go()
except pykd.WaitEventException:
pass
self.assertTrue(modLoadHandler.wasLoad)
self.assertTrue(modLoadHandler.wasUnload)
......@@ -43,14 +43,19 @@ def getTestSuite( singleName = "" ):
unittest.TestLoader().loadTestsFromTestCase( intbase.IntBaseTest ),
unittest.TestLoader().loadTestsFromTestCase( synsymtest.SynSymTest ),
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 ),
] )
else:
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__":
......@@ -70,12 +75,16 @@ if __name__ == "__main__":
print ""
suite = getTestSuite()
#suite = getTestSuite( "diatest.DiaTest.testFind" )
#suite = getTestSuite( "typedvar.TypedVarTest.testTypeVarArg" )
#suite = getTestSuite( "typeinfo.TypeInfoTest.testCreateByName" )
#suite = getTestSuite( "typedvar.TypedVarTest.testBitField" )
oneProcessTests = getTestSuite()
#oneProcessTests = getTestSuite( "diatest.DiaTest.testFind" )
#oneProcessTests = getTestSuite( "typedvar.TypedVarTest.testTypeVarArg" )
#oneProcessTests = getTestSuite( "typeinfo.TypeInfoTest.testCreateByName" )
#oneProcessTests = getTestSuite( "typedvar.TypedVarTest.testBitField" )
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( oneProcessTests )
pykd.killProcess()
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( suite )
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( getNewProcessTestSuite() )
raw_input("\npress return\n")
"""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
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="targetapp"
ProjectGUID="{C6254E16-AB8E-41EE-887D-31458E93FC68}"
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"
TargetFrameworkVersion="131072"
>
......@@ -460,6 +456,10 @@
RelativePath="..\scripts\target.py"
>
</File>
<File
RelativePath="..\scripts\testutils.py"
>
</File>
<File
RelativePath="..\scripts\thrdctxtest.py"
>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment