diff --git a/pykd/dbgengine.cpp b/pykd/dbgengine.cpp index 5478275..6a70e41 100644 --- a/pykd/dbgengine.cpp +++ b/pykd/dbgengine.cpp @@ -107,6 +107,32 @@ void loadDump( const std::wstring &fileName ) /////////////////////////////////////////////////////////////////////////////// +std::wstring debugCommand( const std::wstring &command ) +{ + PyThreadState* state = PyEval_SaveThread(); + + std::wstring outstr = kdlib::debugCommand(command); + + PyEval_RestoreThread( state ); + + return outstr; +} + +/////////////////////////////////////////////////////////////////////////////// + +unsigned long long evaluate( const std::wstring &expression ) +{ + PyThreadState* state = PyEval_SaveThread(); + + unsigned long long result = kdlib::evaluate(expression); + + PyEval_RestoreThread( state ); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// + python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset ) { std::wstring fileName; diff --git a/pykd/dbgengine.h b/pykd/dbgengine.h index 5866d3a..4ff2ae7 100644 --- a/pykd/dbgengine.h +++ b/pykd/dbgengine.h @@ -18,6 +18,9 @@ kdlib::PROCESS_DEBUG_ID startProcess( const std::wstring &processName ); kdlib::PROCESS_DEBUG_ID attachProcess( kdlib::PROCESS_ID pid ); void loadDump( const std::wstring &fileName ); +std::wstring debugCommand( const std::wstring &command ); +unsigned long long evaluate( const std::wstring &expression ); + python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset = 0 ); python::tuple findSymbolAndDisp( ULONG64 offset ); diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 36fa2ed..c69c5bc 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -104,10 +104,10 @@ BOOST_PYTHON_MODULE( pykd ) 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( "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", &targetStep,