[0.3.x] added : dinput routine ( provide input for debugger )

[0.3.x] added : onStartInput callback ( request debug input )
[0.3.x] added : onStopInput callback ( debug input is completed )

git-svn-id: https://pykd.svn.codeplex.com/svn@90701 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2015-07-16 18:16:16 +00:00 committed by Mikhail I. Izmestev
parent 8eab57aa3c
commit 34755cec85
6 changed files with 63 additions and 8 deletions

View File

@ -40,7 +40,15 @@ inline void eprintln( const std::wstring &str )
{ {
pykd::eprint(str + L"\n"); pykd::eprint(str + L"\n");
} }
///////////////////////////////////////////////////////////////////////////////
inline void dinput(const std::wstring &str)
{
AutoRestorePyState pystate;
kdlib::dinput(str);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class DbgOut : public kdlib::windbg::WindbgOut class DbgOut : public kdlib::windbg::WindbgOut

View File

@ -467,6 +467,50 @@ void EventHandler::onDebugOutput(const std::wstring& text)
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
void EventHandler::onStartInput()
{
PyEval_RestoreThread(m_pystate);
try {
python::override pythonHandler = get_override("onStartInput");
if (pythonHandler)
{
pythonHandler();
}
}
catch (const python::error_already_set &)
{
printException();
}
m_pystate = PyEval_SaveThread();
}
/////////////////////////////////////////////////////////////////////////////////
void EventHandler::onStopInput()
{
PyEval_RestoreThread(m_pystate);
try {
python::override pythonHandler = get_override("onStopInput");
if (pythonHandler)
{
pythonHandler();
}
}
catch (const python::error_already_set &)
{
printException();
}
m_pystate = PyEval_SaveThread();
}
/////////////////////////////////////////////////////////////////////////////////
Breakpoint::Breakpoint(kdlib::BreakpointPtr bp) Breakpoint::Breakpoint(kdlib::BreakpointPtr bp)
{ {
m_pystate = PyThreadState_Get(); m_pystate = PyThreadState_Get();

View File

@ -40,8 +40,8 @@ public:
virtual void onChangeLocalScope(); virtual void onChangeLocalScope();
virtual void onChangeBreakpoints(); virtual void onChangeBreakpoints();
virtual void onDebugOutput(const std::wstring& text); virtual void onDebugOutput(const std::wstring& text);
virtual void onStartInput();
virtual void onStopInput();
private: private:

View File

@ -2,7 +2,7 @@
#define PYKD_VERSION_MAJOR 0 #define PYKD_VERSION_MAJOR 0
#define PYKD_VERSION_MINOR 3 #define PYKD_VERSION_MINOR 3
#define PYKD_VERSION_SUBVERSION 0 #define PYKD_VERSION_SUBVERSION 0
#define PYKD_VERSION_BUILDNO 25 #define PYKD_VERSION_BUILDNO 27
#define __VER_STR2__(x) #x #define __VER_STR2__(x) #x
#define __VER_STR1__(x) __VER_STR2__(x) #define __VER_STR1__(x) __VER_STR2__(x)

View File

@ -192,6 +192,9 @@ BOOST_PYTHON_MODULE( pykd )
"Print out string. If dml = True string is printed with dml highlighting ( only for windbg )" ) ); "Print out string. If dml = True string is printed with dml highlighting ( only for windbg )" ) );
python::def( "dprintln", &pykd::dprintln, dprintln_( python::args( "str", "dml" ), python::def( "dprintln", &pykd::dprintln, dprintln_( python::args( "str", "dml" ),
"Print out string and insert end of line symbol. If dml = True string is printed with dml highlighting ( only for windbg )" ) ); "Print out string and insert end of line symbol. If dml = True string is printed with dml highlighting ( only for windbg )" ) );
python::def("dinput", &pykd::dinput,
"Provide input for debugger");
// Python debug output console helper classes // Python debug output console helper classes
python::class_<DbgOut>( "dout", "dout", python::no_init ) python::class_<DbgOut>( "dout", "dout", python::no_init )
@ -1045,6 +1048,10 @@ BOOST_PYTHON_MODULE( pykd )
"Breakpoints is changed for current process" ) "Breakpoints is changed for current process" )
.def( "onDebugOutput", &EventHandler::onDebugOutput, .def( "onDebugOutput", &EventHandler::onDebugOutput,
"Request debug output" ) "Request debug output" )
.def("onStartInput", &EventHandler::onStartInput,
"Request debug input" )
.def("onStopInput", &EventHandler::onStopInput,
"Debug input is completed")
.def("onThreadStart", &EventHandler::onThreadStart, .def("onThreadStart", &EventHandler::onThreadStart,
"New thread is started in the current process" ) "New thread is started in the current process" )
.def("onThreadStop", &EventHandler::onThreadStop, .def("onThreadStop", &EventHandler::onThreadStop,

View File

@ -8,7 +8,7 @@ import zipfile
_name = "pykd" _name = "pykd"
_desc = "python windbg extension" _desc = "python windbg extension"
_version = '0.3.0.26' _version = '0.3.0.27'
def makeWheel(args): def makeWheel(args):
@ -91,10 +91,6 @@ def makeZip(args):
shutil.copy( os.path.join(pykd_dir, 'pykd.pyd'), os.path.join(package_dir, 'pykd.pyd') ) shutil.copy( os.path.join(pykd_dir, 'pykd.pyd'), os.path.join(package_dir, 'pykd.pyd') )
dist_dir = os.path.join(os.path.curdir, 'dist')
if not os.path.exists(dist_dir):
os.mkdir(dist_dir)
with zipfile.ZipFile(os.path.join(os.path.curdir, 'dist', zip_name), mode='w' ) as archive: with zipfile.ZipFile(os.path.join(os.path.curdir, 'dist', zip_name), mode='w' ) as archive:
for srcFile in os.listdir(package_dir): for srcFile in os.listdir(package_dir):
print "zipped %s" % (srcFile) print "zipped %s" % (srcFile)