From feb9e84a6eac8ef3848ecbe74d35ce975f68b77f Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Thu, 17 Oct 2013 08:26:50 +0000 Subject: [PATCH] [0.2.x] added : IPython adaptation git-svn-id: https://pykd.svn.codeplex.com/svn@85804 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dbgext.cpp | 6 ++++++ pykd/python/pymod.cpp | 3 ++- pykd/win/dbgio.h | 5 +++++ snippets/ipython.py | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 snippets/ipython.py diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index 8ffc5fd..901ca82 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -193,6 +193,10 @@ CALLBACK py( PDEBUG_CLIENT4 client, PCSTR args ) { + ULONG mask = 0; + client->GetOutputMask( &mask ); + client->SetOutputMask( mask & ~DEBUG_OUTPUT_PROMPT ); // убрать эхо ввода + WindbgGlobalSession::RestorePyState(); PyThreadState *globalInterpreter = PyThreadState_Swap( NULL ); @@ -305,6 +309,8 @@ py( PDEBUG_CLIENT4 client, PCSTR args ) WindbgGlobalSession::SavePyState(); + client->SetOutputMask( mask ); + return S_OK; } diff --git a/pykd/python/pymod.cpp b/pykd/python/pymod.cpp index 00d69f0..be10781 100644 --- a/pykd/python/pymod.cpp +++ b/pykd/python/pymod.cpp @@ -139,7 +139,8 @@ BOOST_PYTHON_MODULE( pykd ) python::class_( "dout", "dout", python::no_init ) .def( "write", &DbgErr::write ); python::class_( "din", "din", python::no_init ) - .def( "readline", &DbgIn::readline ); + .def( "readline", &DbgIn::readline ) + .add_property( "encoding", &DbgIn::encoding ); // system properties python::def( "ptrSize", &ptrSize, diff --git a/pykd/win/dbgio.h b/pykd/win/dbgio.h index ebab51c..b5f412d 100644 --- a/pykd/win/dbgio.h +++ b/pykd/win/dbgio.h @@ -44,6 +44,11 @@ public: return dreadline(); } + std::string + encoding() { + return "ascii"; + } + }; /////////////////////////////////////////////////////////////////////////////// diff --git a/snippets/ipython.py b/snippets/ipython.py new file mode 100644 index 0000000..e07ac04 --- /dev/null +++ b/snippets/ipython.py @@ -0,0 +1,14 @@ +from IPython.config.loader import Config +from IPython.terminal.embed import InteractiveShellEmbed +from pykd import * + +cfg = Config() + +cfg.InteractiveShell.colors = 'NoColor' +cfg.PromptManager.in_template = 'In <\\#>: ' +cfg.PromptManager.in2_template = ' .\\D.: ' +cfg.PromptManager.out_template = 'Out<\\#>: ' + +ipshell = InteractiveShellEmbed(config=cfg) + +ipshell()