diff --git a/pykd/dbgengine.cpp b/pykd/dbgengine.cpp index 3c47d9e..e8612cd 100644 --- a/pykd/dbgengine.cpp +++ b/pykd/dbgengine.cpp @@ -19,6 +19,39 @@ void targetGo() /////////////////////////////////////////////////////////////////////////////// +void targetBreak() +{ + PyThreadState* state = PyEval_SaveThread(); + + kdlib::targetBreak(); + + PyEval_RestoreThread( state ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void targetStep() +{ + PyThreadState* state = PyEval_SaveThread(); + + kdlib::targetStep(); + + PyEval_RestoreThread( state ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void targetStepIn() +{ + PyThreadState* state = PyEval_SaveThread(); + + kdlib::targetStepIn(); + + PyEval_RestoreThread( state ); +} + +/////////////////////////////////////////////////////////////////////////////// + python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset ) { std::wstring fileName; diff --git a/pykd/dbgengine.h b/pykd/dbgengine.h index 71b3231..408b32d 100644 --- a/pykd/dbgengine.h +++ b/pykd/dbgengine.h @@ -10,6 +10,9 @@ namespace pykd { /////////////////////////////////////////////////////////////////////////////// void targetGo(); +void targetBreak(); +void targetStep(); +void targetStepIn(); python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset = 0 ); diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 50bd6a0..ca9bdb6 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -14,32 +14,6 @@ using namespace pykd; - -// -//#include "pykdver.h" -// -//#include "dbgengine.h" -//#include "symengine.h" -// -//#include "module.h" -//#include "variant.h" -//#include "dbgexcept.h" -//#include "dbgmem.h" -//#include "typeinfo.h" -//#include "customtypes.h" -//#include "typedvar.h" -//#include "cpureg.h" -//#include "disasm.h" -//#include "stkframe.h" -//#include "bpoint.h" -//#include "eventhandler.h" -//#include "pysupport.h" -// -//#include "win/dbgio.h" -//#include "win/windbg.h" -// -//using namespace pykd; - /////////////////////////////////////////////////////////////////////////////// static const std::string pykdVersion = PYKD_VERSION_BUILD_STR @@ -49,9 +23,10 @@ static const std::string pykdVersion = PYKD_VERSION_BUILD_STR ; /////////////////////////////////////////////////////////////////////////////// -// -//BOOST_PYTHON_FUNCTION_OVERLOADS( detachProcess_, detachProcess, 0, 1 ); -// + +BOOST_PYTHON_FUNCTION_OVERLOADS( detachProcess_, kdlib::detachProcess, 0, 1 ); +BOOST_PYTHON_FUNCTION_OVERLOADS( terminateProcess_, kdlib::terminateProcess, 0, 1 ); + BOOST_PYTHON_FUNCTION_OVERLOADS( dprint_, kdlib::dprint, 1, 2 ); BOOST_PYTHON_FUNCTION_OVERLOADS( dprintln_, kdlib::dprintln, 1, 2 ); @@ -109,10 +84,10 @@ BOOST_PYTHON_MODULE( pykd ) "Start process for debugging" ); python::def( "attachProcess", &kdlib::attachProcess, "Attach debugger to a exsisting process" ); -// python::def( "detachProcess", &detachProcess, detachProcess_( boost::python::args( "pid" ), -// "Stop process debugging") ); - python::def( "killProcess", &kdlib::terminateProcess, - "Stop debugging and terminate current process" ); + python::def( "detachProcess", &kdlib::detachProcess, detachProcess_( boost::python::args( "pid" ), + "Stop process debugging") ); + python::def( "killProcess", &kdlib::terminateProcess, terminateProcess_( boost::python::args( "pid" ), + "Stop debugging and terminate current process" ) ); python::def( "loadDump", &kdlib::loadDump, "Load crash dump"); python::def( "isDumpAnalyzing", &kdlib::isDumpAnalyzing, @@ -124,18 +99,18 @@ BOOST_PYTHON_MODULE( pykd ) python::def( "writeDump", &kdlib::writeDump, "Create memory dump file" ); - // python::def( "breakin", &debugBreak, - // "Break into debugger" ); - // python::def( "expr", &evaluate, - // "Evaluate windbg expression" ); - // python::def( "dbgCommand", &debugCommand, - // "Run a debugger's command and return it's result as a string" ); + python::def( "breakin", &targetBreak, + "Break into debugger" ); + //python::def( "expr", &evaluate, + // "Evaluate windbg expression" ); + //python::def( "dbgCommand", &debugCommand, + // "Run a debugger's command and return it's result as a string" ); python::def( "go", &targetGo, "Go debugging" ); - // python::def( "step", &debugStep, - // "The target is executing a single instruction or--if that instruction is a subroutine call--subroutine" ); - // python::def( "trace", &debugStepIn, - // "The target is executing a single instruction" ); + python::def( "step", &targetStep, + "The target is executing a single instruction or--if that instruction is a subroutine call--subroutine" ); + python::def( "trace", &targetStepIn, + "The target is executing a single instruction" ); // Debug output python::def( "dprint", &kdlib::dprint, dprint_( python::args( "str", "dml" ),