From 49e4558428e311060beac613ebcc20acc6cc8bca Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Tue, 9 Jul 2013 15:04:03 +0000 Subject: [PATCH] [0.3.x] added : dbgCommand routine git-svn-id: https://pykd.svn.codeplex.com/svn@84232 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dbgengine.cpp | 26 ++++++++++++++++++++++++++ pykd/dbgengine.h | 3 +++ pykd/pymod.cpp | 8 ++++---- 3 files changed, 33 insertions(+), 4 deletions(-) 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,