mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-18 01:53:22 +08:00
added : breakpoint.detach method ( convert strong breakpoint reference
to weak )
This commit is contained in:
parent
c498137a51
commit
3305c6d980
@ -654,7 +654,36 @@ void Breakpoint::remove()
|
||||
{
|
||||
m_breakpoint->remove();
|
||||
m_breakpoint = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
throw kdlib::DbgException("Cannot remove breakpoint, it is detached");
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Breakpoint* Breakpoint::detach()
|
||||
{
|
||||
AutoRestorePyState pystate;
|
||||
|
||||
if (m_weakBp)
|
||||
{
|
||||
throw kdlib::DbgException("Cannot detach 'weak' breakpoint");
|
||||
}
|
||||
|
||||
if (m_breakpoint)
|
||||
{
|
||||
if (m_callback)
|
||||
{
|
||||
throw kdlib::DbgException("Cannot detach breakpoint with callback");
|
||||
}
|
||||
|
||||
auto bp = m_breakpoint;
|
||||
m_breakpoint = 0;
|
||||
return new Breakpoint(bp);
|
||||
}
|
||||
|
||||
throw kdlib::DbgException("Cannot remove breakpoint, it is detached");
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -105,6 +105,8 @@ public:
|
||||
|
||||
void remove();
|
||||
|
||||
Breakpoint* detach();
|
||||
|
||||
private:
|
||||
|
||||
PyThreadState* m_pystate;
|
||||
|
@ -1391,6 +1391,8 @@ void pykd_init()
|
||||
"Remove breakpoint" )
|
||||
.def("onHit", &Breakpoint::onHit,
|
||||
"Breakpoint hit callback")
|
||||
.def("detach", &Breakpoint::detach, python::return_value_policy<python::manage_new_object>(),
|
||||
"detach breakpoint")
|
||||
;
|
||||
|
||||
python::class_<kdlib::SyntheticSymbol>(
|
||||
|
@ -184,3 +184,14 @@ class BreakpointTest( unittest.TestCase ):
|
||||
bp = pykd.getBp(0)
|
||||
self.assertEqual(0x100, bp.getOffset())
|
||||
|
||||
def testDoubleRemove(self):
|
||||
bp = pykd.setBp( self.targetModule.CdeclFunc )
|
||||
bp.remove()
|
||||
self.assertRaises( pykd.DbgException, bp.remove )
|
||||
|
||||
def testDetach(self):
|
||||
bp = pykd.setBp( self.targetModule.CdeclFunc ).detach()
|
||||
self.assertEqual(1, pykd.getNumberBreakpoints())
|
||||
self.assertRaises(pykd.DbgException, bp.detach )
|
||||
del bp
|
||||
self.assertEqual(1, pykd.getNumberBreakpoints())
|
Loading…
Reference in New Issue
Block a user