[pykd] updated : move all code for input/output operation to dbgio.h/cpp

git-svn-id: https://pykd.svn.codeplex.com/svn@66396 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2011-06-07 16:13:05 +00:00
parent d70b95ec1e
commit 80eaf476cd
12 changed files with 121 additions and 120 deletions

View File

@ -5,7 +5,7 @@
#include "dbgext.h"
#include "dbgcmd.h"
#include "dbgexcept.h"
#include "dbgcallback.h"
#include "dbgio.h"
#include "dbgsystem.h"
///////////////////////////////////////////////////////////////////////////////

View File

@ -7,7 +7,7 @@
#include <dbgeng.h>
#include "dbgmodule.h"
#include "dbgcallback.h"
#include "dbgio.h"
#include "dbgevent.h"
/////////////////////////////////////////////////////////////////////////////////

View File

@ -11,7 +11,6 @@
#include <boost/python/overloads.hpp>
#include "dbgext.h"
#include "dbgprint.h"
#include "dbgreg.h"
#include "dbgtype.h"
#include "dbgmodule.h"
@ -24,12 +23,12 @@
#include "dbgeventcb.h"
#include "dbgcallback.h"
#include "dbgpath.h"
#include "dbginput.h"
#include "dbgprocess.h"
#include "dbgsynsym.h"
#include "dbgclient.h"
#include "dbgevent.h"
#include "dbgbreak.h"
#include "dbgio.h"
//////////////////////////////////////////////////////////////////////////////
@ -41,8 +40,8 @@ dbgClient g_dbgClient;
//////////////////////////////////////////////////////////////////////////////
BOOST_PYTHON_FUNCTION_OVERLOADS( dprint, DbgPrint::dprint, 1, 2 )
BOOST_PYTHON_FUNCTION_OVERLOADS( dprintln, DbgPrint::dprintln, 1, 2 )
BOOST_PYTHON_FUNCTION_OVERLOADS( dprint, dbgPrint::dprint, 1, 2 )
BOOST_PYTHON_FUNCTION_OVERLOADS( dprintln, dbgPrint::dprintln, 1, 2 )
BOOST_PYTHON_FUNCTION_OVERLOADS( loadCharsOv, loadChars, 2, 3 )
BOOST_PYTHON_FUNCTION_OVERLOADS( loadWCharsOv, loadWChars, 2, 3 )
@ -82,9 +81,9 @@ BOOST_PYTHON_MODULE( pykd )
"Check if script works in windbg context" );
boost::python::def( "symbolsPath", &dbgSymPath,
"Return symbol path" );
boost::python::def( "dprint", &DbgPrint::dprint, dprint( boost::python::args( "str", "dml" ),
boost::python::def( "dprint", &dbgPrint::dprint, dprint( boost::python::args( "str", "dml" ),
"Print out string. If dml = True string is printed with dml highlighting ( only for windbg )") );
boost::python::def( "dprintln", &DbgPrint::dprintln, dprintln( boost::python::args( "str", "dml" ),
boost::python::def( "dprintln", &dbgPrint::dprintln, dprintln( boost::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 )" ) );
boost::python::def( "loadDump", &dbgLoadDump,
"Load crash dump (only for console)");
@ -523,15 +522,15 @@ private:
main_namespace[ key ] = pykd_namespace[ key ];
}
// ïåðåíàïðàâëåíèå ñòàíäàðòíûõ ïîòîêîâ ÂÂ
boost::python::object sys = boost::python::import( "sys");
dbgOut dout;
sys.attr("stdout") = boost::python::object( dout );
//// ïåðåíàïðàâëåíèå ñòàíäàðòíûõ ïîòîêîâ ÂÂ
//boost::python::object sys = boost::python::import( "sys");
//
//dbgOut dout;
//sys.attr("stdout") = boost::python::object( dout );
dbgIn din;
sys.attr("stdin") = boost::python::object( din );
//dbgIn din;
//sys.attr("stdin") = boost::python::object( din );
//
g_dbgClient.startEventsMgr();
}
@ -769,7 +768,8 @@ py( PDEBUG_CLIENT4 client, PCSTR args)
}
catch(...)
{
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "unexpected error" );
}
Py_EndInterpreter( localInterpreter );
@ -784,25 +784,30 @@ HRESULT
CALLBACK
pycmd( PDEBUG_CLIENT4 client, PCSTR args )
{
try {
DbgExt ext( client );
DbgExt ext( client );
try {
if ( !std::string( args ).empty() )
{
try
{
OutputReader outputReader( dbgExt->client );
boost::python::exec( args, WindbgGlobalSession::global(), WindbgGlobalSession::global() );
try {
boost::python::object retObj = boost::python::eval( args, WindbgGlobalSession::global(), WindbgGlobalSession::global() );
if ( retObj.ptr() != NULL )
{
PyObject *s = PyObject_Str( retObj.ptr() );
dbgExt->control->Output( DEBUG_OUTPUT_NORMAL, "%s\n", PyString_AS_STRING( s ) );
Py_DECREF( s );
}
}
catch( boost::python::error_already_set const & )
{
// îøèáêà â ñêðèïòå
PyObject *errtype = NULL, *errvalue = NULL, *traceback = NULL;
PyErr_Fetch( &errtype, &errvalue, &traceback );
if(errvalue != NULL)
{
PyObject *s = PyObject_Str(errvalue);
@ -814,9 +819,9 @@ pycmd( PDEBUG_CLIENT4 client, PCSTR args )
Py_XDECREF(errvalue);
Py_XDECREF(errtype);
Py_XDECREF(traceback);
Py_XDECREF(traceback);
}
}
}
else
{
char str[100];
@ -831,7 +836,7 @@ pycmd( PDEBUG_CLIENT4 client, PCSTR args )
do {
OutputReader outputReader( (IDebugClient*)client );
OutputReader outputReader( (IDebugClient*)client );
HRESULT hres = dbgExt->control->Input( str, sizeof(str), &inputSize );
@ -871,15 +876,15 @@ pycmd( PDEBUG_CLIENT4 client, PCSTR args )
}
} while( !stopInput );
}
}
catch(...)
{
}
}
}
return S_OK;
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "unexpected error" );
}
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////////

View File

@ -1,40 +0,0 @@
#pragma once
#include "dbgprint.h"
/////////////////////////////////////////////////////////////////////////////////
class dbgOut {
public:
void
write( const boost::python::object &str ) {
DbgPrint::dprint( str );
}
};
/////////////////////////////////////////////////////////////////////////////////
class dbgIn {
public:
std::string
readline() {
char str[100];
ULONG inputSize;
OutputReader outputReader( dbgExt->client );
dbgExt->control->Input( str, sizeof(str), &inputSize );
return std::string( str );
}
};
/////////////////////////////////////////////////////////////////////////////////

View File

@ -1,13 +1,16 @@
#include "stdafx.h"
#include <iostream>
#include <Fcntl.h>
#include "dbgprint.h"
#include "dbgio.h"
#include "dbgext.h"
using namespace std;
void DbgPrint::dprint( const boost::python::object& obj, bool dml )
/////////////////////////////////////////////////////////////////////////////////
void dbgPrint::dprint( const boost::python::object& obj, bool dml )
{
std::wstring str = boost::python::extract<std::wstring>( obj );
@ -16,7 +19,9 @@ void DbgPrint::dprint( const boost::python::object& obj, bool dml )
std::wcout << str;
}
void DbgPrint::dprintln( const boost::python::object& obj, bool dml )
/////////////////////////////////////////////////////////////////////////////////
void dbgPrint::dprintln( const boost::python::object& obj, bool dml )
{
std::wstring str = boost::python::extract<std::wstring>( obj );
str += L"\r\n";
@ -26,3 +31,4 @@ void DbgPrint::dprintln( const boost::python::object& obj, bool dml )
std::wcout << str;
}
/////////////////////////////////////////////////////////////////////////////////

View File

@ -1,9 +1,21 @@
#pragma once
#include "dbgext.h"
#include "dbgexcept.h"
#include <string>
#include <dbgeng.h>
#include <wdbgexts.h>
#include "dbgext.h"
/////////////////////////////////////////////////////////////////////////////////
class dbgPrint {
public:
static void dprint( const boost::python::object& obj, bool dml = false );
static void dprintln( const boost::python::object& obj, bool dml = false );
};
///////////////////////////////////////////////////////////////////////////////
@ -173,4 +185,40 @@ private:
};
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
class dbgOut {
public:
void
write( const boost::python::object &str ) {
dbgPrint::dprint( str );
}
};
/////////////////////////////////////////////////////////////////////////////////
class dbgIn {
public:
std::string
readline() {
char str[100];
ULONG inputSize;
OutputReader outputReader( dbgExt->client );
dbgExt->control->Input( str, sizeof(str), &inputSize );
return std::string( str );
}
};
/////////////////////////////////////////////////////////////////////////////////

View File

@ -7,7 +7,7 @@
#include "dbgexcept.h"
#include "dbgmem.h"
#include "dbgsystem.h"
#include "dbgcallback.h"
#include "dbgio.h"
using namespace std;

View File

@ -8,7 +8,7 @@
#include "dbgmodule.h"
#include "dbgexcept.h"
#include "dbgsym.h"
#include "dbgcallback.h"
#include "dbgio.h"
#include "dbgsynsym.h"
/////////////////////////////////////////////////////////////////////////////////

View File

@ -1,17 +0,0 @@
// âûâîä èíôîðìàöèè â îòëàä÷èê
#pragma once
#include <string>
class DbgPrint {
public:
static void dprint( const boost::python::object& obj, bool dml = false );
static void dprintln( const boost::python::object& obj, bool dml = false );
};

View File

@ -3,7 +3,6 @@
#include "dbgext.h"
#include "dbgsym.h"
#include "dbgexcept.h"
#include "dbgprint.h"
#include "dbgmem.h"
/////////////////////////////////////////////////////////////////////////////////

View File

@ -6,7 +6,7 @@
#include "dbgext.h"
#include "dbgexcept.h"
#include "dbgsystem.h"
#include "dbgcallback.h"
#include "dbgio.h"
///////////////////////////////////////////////////////////////////////////////////

View File

@ -368,6 +368,10 @@
RelativePath=".\dbgdump.cpp"
>
</File>
<File
RelativePath=".\dbgevent.cpp"
>
</File>
<File
RelativePath=".\dbgeventcb.cpp"
>
@ -381,11 +385,11 @@
>
</File>
<File
RelativePath=".\dbgmem.cpp"
RelativePath=".\dbgio.cpp"
>
</File>
<File
RelativePath=".\dbgevent.cpp"
<File
RelativePath=".\dbgmem.cpp"
>
</File>
<File
@ -396,10 +400,6 @@
RelativePath=".\dbgpath.cpp"
>
</File>
<File
RelativePath=".\dbgprint.cpp"
>
</File>
<File
RelativePath=".\dbgprocess.cpp"
>
@ -474,10 +474,6 @@
RelativePath=".\dbgbreak.h"
>
</File>
<File
RelativePath=".\dbgcallback.h"
>
</File>
<File
RelativePath=".\dbgclient.h"
>
@ -490,6 +486,10 @@
RelativePath=".\dbgdump.h"
>
</File>
<File
RelativePath=".\dbgevent.h"
>
</File>
<File
RelativePath=".\dbgeventcb.h"
>
@ -507,11 +507,11 @@
>
</File>
<File
RelativePath=".\dbgmem.h"
RelativePath=".\dbgio.h"
>
</File>
<File
RelativePath=".\dbgevent.h"
<File
RelativePath=".\dbgmem.h"
>
</File>
<File