From 34755cec85ff638d3dd69543ea7b0a8963143768 Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Thu, 16 Jul 2015 18:16:16 +0000 Subject: [PATCH] [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 --- pykd/pydbgio.h | 8 ++++++++ pykd/pyeventhandler.cpp | 44 +++++++++++++++++++++++++++++++++++++++++ pykd/pyeventhandler.h | 4 ++-- pykd/pykdver.h | 2 +- pykd/pymod.cpp | 7 +++++++ setup/setup.py | 6 +----- 6 files changed, 63 insertions(+), 8 deletions(-) diff --git a/pykd/pydbgio.h b/pykd/pydbgio.h index d397583..cd01312 100644 --- a/pykd/pydbgio.h +++ b/pykd/pydbgio.h @@ -40,7 +40,15 @@ inline void eprintln( const std::wstring &str ) { pykd::eprint(str + L"\n"); } + +/////////////////////////////////////////////////////////////////////////////// +inline void dinput(const std::wstring &str) +{ + AutoRestorePyState pystate; + kdlib::dinput(str); +} + /////////////////////////////////////////////////////////////////////////////// class DbgOut : public kdlib::windbg::WindbgOut diff --git a/pykd/pyeventhandler.cpp b/pykd/pyeventhandler.cpp index 09eb8b2..4ddf213 100644 --- a/pykd/pyeventhandler.cpp +++ b/pykd/pyeventhandler.cpp @@ -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) { m_pystate = PyThreadState_Get(); diff --git a/pykd/pyeventhandler.h b/pykd/pyeventhandler.h index 5333108..10ce0e2 100644 --- a/pykd/pyeventhandler.h +++ b/pykd/pyeventhandler.h @@ -40,8 +40,8 @@ public: virtual void onChangeLocalScope(); virtual void onChangeBreakpoints(); virtual void onDebugOutput(const std::wstring& text); - - + virtual void onStartInput(); + virtual void onStopInput(); private: diff --git a/pykd/pykdver.h b/pykd/pykdver.h index 3906302..0803a6c 100644 --- a/pykd/pykdver.h +++ b/pykd/pykdver.h @@ -2,7 +2,7 @@ #define PYKD_VERSION_MAJOR 0 #define PYKD_VERSION_MINOR 3 #define PYKD_VERSION_SUBVERSION 0 -#define PYKD_VERSION_BUILDNO 25 +#define PYKD_VERSION_BUILDNO 27 #define __VER_STR2__(x) #x #define __VER_STR1__(x) __VER_STR2__(x) diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 217e237..8e430ae 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -192,6 +192,9 @@ BOOST_PYTHON_MODULE( pykd ) "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" ), "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::class_( "dout", "dout", python::no_init ) @@ -1045,6 +1048,10 @@ BOOST_PYTHON_MODULE( pykd ) "Breakpoints is changed for current process" ) .def( "onDebugOutput", &EventHandler::onDebugOutput, "Request debug output" ) + .def("onStartInput", &EventHandler::onStartInput, + "Request debug input" ) + .def("onStopInput", &EventHandler::onStopInput, + "Debug input is completed") .def("onThreadStart", &EventHandler::onThreadStart, "New thread is started in the current process" ) .def("onThreadStop", &EventHandler::onThreadStop, diff --git a/setup/setup.py b/setup/setup.py index 040cdc0..c6e76f3 100644 --- a/setup/setup.py +++ b/setup/setup.py @@ -8,7 +8,7 @@ import zipfile _name = "pykd" _desc = "python windbg extension" -_version = '0.3.0.26' +_version = '0.3.0.27' 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') ) - 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: for srcFile in os.listdir(package_dir): print "zipped %s" % (srcFile)