diff --git a/pykd/bpoint.h b/pykd/bpoint.h index 51d50c2..04e698b 100644 --- a/pykd/bpoint.h +++ b/pykd/bpoint.h @@ -15,6 +15,7 @@ ULONG setSoftwareBp(ULONG64 offset, BpCallback &callback = BpCallback() ); ULONG setHardwareBp(ULONG64 offset, ULONG size, ULONG accessType, BpCallback &callback = BpCallback()); + ////////////////////////////////////////////////////////////////////////////////// // //inline BPOINT_ID setSoftwareBp(ULONG64 addr, BpCallback &callback = BpCallback()) { diff --git a/pykd/dbgengine.h b/pykd/dbgengine.h index 76e35c2..cc644b5 100644 --- a/pykd/dbgengine.h +++ b/pykd/dbgengine.h @@ -64,6 +64,8 @@ void getStackTrace( STACK_FRAME_DESC* frames, ULONG frameCount, ULONG* frameRetu //breakpoints ULONG breakPointSet( ULONG64 offset, bool hardware = false, ULONG size = 0, ULONG accessType = 0 ); +void breakPointRemove( ULONG id ); +void breakPointRemoveAll(); }; diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 5c72467..796aa7f 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -226,7 +226,10 @@ BOOST_PYTHON_MODULE( pykd ) "Set software breakpoint on executiont" ) ); python::def( "setBp", &setHardwareBp, setHardwareBp_( python::args( "offset", "size", "accsessType", "callback" ) , "Set hardware breakpoint" ) ); - + python::def( "removeBp", &breakPointRemove, + "Remove breapoint by IDs" ); + python::def( "removeAllBp", &breakPointRemoveAll, + "Remove all breapoints" ); python::class_( "intBase", "intBase", python::no_init ) .def( python::init() ) diff --git a/pykd/win/dbgeng.cpp b/pykd/win/dbgeng.cpp index b39d00d..da8bc38 100644 --- a/pykd/win/dbgeng.cpp +++ b/pykd/win/dbgeng.cpp @@ -829,6 +829,46 @@ ULONG breakPointSet( ULONG64 offset, bool hardware, ULONG size, ULONG accessType return breakId; } +/////////////////////////////////////////////////////////////////////////////// + +void breakPointRemove( ULONG id ) +{ + PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate ); + + IDebugBreakpoint *bp; + HRESULT hres = g_dbgEng->control->GetBreakpointById(id, &bp); + if (S_OK != hres) + throw DbgException("IDebugControl::GetBreakpointById", hres); + + hres = g_dbgEng->control->RemoveBreakpoint(bp); + if (S_OK != hres) + throw DbgException("IDebugControl::RemoveBreakpoint", hres); +} + +/////////////////////////////////////////////////////////////////////////////// + +void breakPointRemoveAll() +{ + ULONG numberOfBps; + do { + HRESULT hres = g_dbgEng->control->GetNumberBreakpoints(&numberOfBps); + if (S_OK != hres) + throw DbgException("IDebugControl::GetNumberBreakpoints", hres); + + if (!numberOfBps) + break; + + IDebugBreakpoint *bp; + hres = g_dbgEng->control->GetBreakpointByIndex(0, &bp); + if (S_OK != hres) + throw DbgException("IDebugControl::GetBreakpointByIndex", hres); + + hres = g_dbgEng->control->RemoveBreakpoint(bp); + if (S_OK != hres) + throw DbgException("IDebugControl::RemoveBreakpoint", hres); + + } while (numberOfBps); +} ///////////////////////////////////////////////////////////////////////////////