mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.3.x] fixed : pykd::breakpoint class
git-svn-id: https://pykd.svn.codeplex.com/svn@88333 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
a6f4139bab
commit
a4ad0db86e
@ -384,28 +384,18 @@ void breakPointRemove( kdlib::BREAKPOINT_ID id )
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
kdlib::BreakpointPtr Breakpoint::setSoftwareBreakpoint( kdlib::MEMOFFSET_64 offset )
|
Breakpoint::Breakpoint( kdlib::MEMOFFSET_64 offset )
|
||||||
{
|
{
|
||||||
Breakpoint *bp = new Breakpoint();
|
AutoRestorePyState pystate(&m_pystate);
|
||||||
|
set(offset);
|
||||||
AutoRestorePyState pystate(&bp->m_pystate);
|
|
||||||
|
|
||||||
bp->set(offset);
|
|
||||||
|
|
||||||
return kdlib::BreakpointPtr(bp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
kdlib::BreakpointPtr Breakpoint::setHardwareBreakpoint( kdlib::MEMOFFSET_64 offset, size_t size, kdlib::ACCESS_TYPE accessType )
|
Breakpoint::Breakpoint( kdlib::MEMOFFSET_64 offset, size_t size, kdlib::ACCESS_TYPE accessType )
|
||||||
{
|
{
|
||||||
Breakpoint *bp = new Breakpoint();
|
AutoRestorePyState pystate(&m_pystate);
|
||||||
|
set(offset, size, accessType);
|
||||||
AutoRestorePyState pystate(&bp->m_pystate);
|
|
||||||
|
|
||||||
bp->set(offset, size, accessType);
|
|
||||||
|
|
||||||
return kdlib::BreakpointPtr(bp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -21,8 +21,6 @@ namespace pykd {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class EventHandler;
|
|
||||||
typedef boost::shared_ptr<EventHandler> EventHandlerPtr;
|
|
||||||
|
|
||||||
class EventHandler : public python::wrapper<kdlib::EventHandler>, public kdlib::EventHandler
|
class EventHandler : public python::wrapper<kdlib::EventHandler>, public kdlib::EventHandler
|
||||||
{
|
{
|
||||||
@ -48,17 +46,17 @@ kdlib::BREAKPOINT_ID setHardwareBreakpoint( kdlib::MEMOFFSET_64 offset, size_t s
|
|||||||
void breakPointRemove( kdlib::BREAKPOINT_ID id );
|
void breakPointRemove( kdlib::BREAKPOINT_ID id );
|
||||||
|
|
||||||
|
|
||||||
class Breakpoint : public python::wrapper<kdlib::Breakpoint>, public kdlib::BaseBreakpoint {
|
class Breakpoint : public python::wrapper<kdlib::BaseBreakpoint>, public kdlib::BaseBreakpoint {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static kdlib::BreakpointPtr setSoftwareBreakpoint( kdlib::MEMOFFSET_64 offset );
|
Breakpoint( kdlib::MEMOFFSET_64 offset );
|
||||||
static kdlib::BreakpointPtr setHardwareBreakpoint( kdlib::MEMOFFSET_64 offset, size_t size, kdlib::ACCESS_TYPE accessType );
|
Breakpoint( kdlib::MEMOFFSET_64 offset, size_t size, kdlib::ACCESS_TYPE accessType );
|
||||||
|
|
||||||
|
virtual kdlib::DebugCallbackResult onHit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
kdlib::DebugCallbackResult onHit();
|
|
||||||
|
|
||||||
PyThreadState* m_pystate;
|
PyThreadState* m_pystate;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define PYKD_VERSION_MAJOR 0
|
#define PYKD_VERSION_MAJOR 0
|
||||||
#define PYKD_VERSION_MINOR 3
|
#define PYKD_VERSION_MINOR 3
|
||||||
#define PYKD_VERSION_SUBVERSION 0
|
#define PYKD_VERSION_SUBVERSION 0
|
||||||
#define PYKD_VERSION_BUILDNO 5
|
#define PYKD_VERSION_BUILDNO 6
|
||||||
|
|
||||||
#define __VER_STR2__(x) #x
|
#define __VER_STR2__(x) #x
|
||||||
#define __VER_STR1__(x) __VER_STR2__(x)
|
#define __VER_STR1__(x) __VER_STR2__(x)
|
||||||
|
@ -854,7 +854,7 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
.value("PageExecuteWriteCopy", kdlib::PageExecuteWriteCopy)
|
.value("PageExecuteWriteCopy", kdlib::PageExecuteWriteCopy)
|
||||||
.export_values();
|
.export_values();
|
||||||
|
|
||||||
python::class_<EventHandler, EventHandlerPtr, boost::noncopyable>(
|
python::class_<EventHandler, boost::noncopyable>(
|
||||||
"eventHandler", "Base class for overriding and handling debug notifications" )
|
"eventHandler", "Base class for overriding and handling debug notifications" )
|
||||||
.def( "onBreakpoint", &EventHandler::onBreakpoint,
|
.def( "onBreakpoint", &EventHandler::onBreakpoint,
|
||||||
"Triggered breakpoint event. Parameter is int: ID of breakpoint\n"
|
"Triggered breakpoint event. Parameter is int: ID of breakpoint\n"
|
||||||
@ -879,11 +879,11 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
// "There is no return value");
|
// "There is no return value");
|
||||||
;
|
;
|
||||||
|
|
||||||
python::class_<kdlib::Breakpoint, kdlib::BreakpointPtr, boost::noncopyable>( "breakpoint",
|
python::class_<Breakpoint, boost::noncopyable>( "breakpoint",
|
||||||
"class for breakpoint representation", python::no_init )
|
"class for breakpoint representation", python::no_init )
|
||||||
.def("__init__", python::make_constructor(pykd::Breakpoint::setSoftwareBreakpoint) )
|
.def( python::init<kdlib::MEMOFFSET_64>() )
|
||||||
.def("__init__", python::make_constructor(pykd::Breakpoint::setHardwareBreakpoint) )
|
.def( python::init<kdlib::MEMOFFSET_64, size_t, kdlib::ACCESS_TYPE>() )
|
||||||
.def("onHit", &kdlib::Breakpoint::onHit,
|
.def("onHit", &Breakpoint::onHit,
|
||||||
"Breakpoint hit callback")
|
"Breakpoint hit callback")
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -123,15 +123,35 @@ class BreakpointTest( unittest.TestCase ):
|
|||||||
|
|
||||||
bp = MyBreakpoint( targetModule.CdeclFunc )
|
bp = MyBreakpoint( targetModule.CdeclFunc )
|
||||||
|
|
||||||
pykd.setBp( targetModule.CdeclFunc )
|
|
||||||
|
|
||||||
self.assertEqual( pykd.Break, pykd.go() )
|
self.assertEqual( pykd.Break, pykd.go() )
|
||||||
|
|
||||||
self.assertEqual( 1, bp.count )
|
self.assertEqual( 1, bp.count )
|
||||||
|
|
||||||
|
def testBreakpointCondition(self):
|
||||||
|
|
||||||
|
def makebpcallback(n):
|
||||||
|
|
||||||
|
def bpcallback():
|
||||||
|
if pykd.getParam("b") > n:
|
||||||
|
return pykd.eventResult.Break
|
||||||
|
return pykd.eventResult.Proceed
|
||||||
|
return bpcallback
|
||||||
|
|
||||||
|
processId = pykd.startProcess( target.appPath + " breakhandlertest" )
|
||||||
|
targetModule = pykd.module( target.moduleName )
|
||||||
|
targetModule.reload()
|
||||||
|
with testutils.ContextCallIt( testutils.KillProcess(processId) ) as killStartedProcess :
|
||||||
|
pykd.go()
|
||||||
|
bp = pykd.setBp( targetModule.CdeclFunc, makebpcallback(1) )
|
||||||
|
self.assertEqual( pykd.Break, pykd.go() )
|
||||||
|
|
||||||
|
|
||||||
|
processId = pykd.startProcess( target.appPath + " breakhandlertest" )
|
||||||
|
targetModule = pykd.module( target.moduleName )
|
||||||
|
targetModule.reload()
|
||||||
|
with testutils.ContextCallIt( testutils.KillProcess(processId) ) as killStartedProcess :
|
||||||
|
pykd.go()
|
||||||
|
bp = pykd.setBp( targetModule.CdeclFunc, makebpcallback(100) )
|
||||||
|
self.assertEqual( pykd.NoDebuggee, pykd.go() )
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user