mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[!] fixed : issue #8236 ( dprint/dprintln/print doesn't work with unicode string )
git-svn-id: https://pykd.svn.codeplex.com/svn@60725 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
1afb67fd2e
commit
8cab8ae27d
@ -71,6 +71,8 @@ private:
|
||||
WindbgGlobalSession *windbgGlobalSession = NULL;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( dprint, DbgPrint::dprint, 1, 2 )
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( dprintln, DbgPrint::dprintln, 1, 2 )
|
||||
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( loadBytes, loadArray<unsigned char>, 2, 3 )
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( loadWords, loadArray<unsigned short>, 2, 3 )
|
||||
@ -92,8 +94,8 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
boost::python::def( "createSession", &dbgCreateSession );
|
||||
boost::python::def( "isSessionStart", &dbgIsSessionStart );
|
||||
boost::python::def( "symbolsPath", &dbgSymPath );
|
||||
boost::python::def( "dprint", &DbgPrint::dprint );
|
||||
boost::python::def( "dprintln", &DbgPrint::dprintln );
|
||||
boost::python::def( "dprint", &DbgPrint::dprint, dprint( boost::python::args( "str", "dml" ), "" ) );
|
||||
boost::python::def( "dprintln", &DbgPrint::dprintln, dprintln( boost::python::args( "str", "dml" ), "" ) );
|
||||
boost::python::def( "loadDump", &dbgLoadDump );
|
||||
boost::python::def( "dbgCommand", &dbgCommand );
|
||||
boost::python::def( "is64bitSystem", &is64bitSystem );
|
||||
@ -110,7 +112,7 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
boost::python::def( "getOffset", &findAddressForSymbol );
|
||||
boost::python::def( "findModule", &findModule );
|
||||
boost::python::def( "addr64", &addr64 );
|
||||
boost::python::def( "loadBytes", loadArray<unsigned char>, loadBytes( boost::python::args( "address", "number", "phyAddr" ), "" ) );
|
||||
boost::python::def( "loadBytes", &loadArray<unsigned char>, loadBytes( boost::python::args( "address", "number", "phyAddr" ), "" ) );
|
||||
boost::python::def( "loadWords", &loadArray<unsigned short>, loadWords( boost::python::args( "address", "number", "phyAddr" ), "" ) );
|
||||
boost::python::def( "loadDWords", &loadArray<unsigned long>, loadDWords( boost::python::args( "address", "number", "phyAddr" ), "" ) );
|
||||
boost::python::def( "loadQWords", &loadArray<unsigned __int64>, loadQWords( boost::python::args( "address", "number", "phyAddr" ), "" ) );
|
||||
@ -222,6 +224,7 @@ SetupDebugEngine( IDebugClient4 *client, DbgExt *dbgExt )
|
||||
|
||||
|
||||
client->QueryInterface( __uuidof(IDebugControl), (void **)&dbgExt->control );
|
||||
client->QueryInterface( __uuidof(IDebugControl4), (void **)&dbgExt->control4 );
|
||||
|
||||
client->QueryInterface( __uuidof(IDebugRegisters), (void **)&dbgExt->registers );
|
||||
|
||||
@ -331,7 +334,7 @@ py( PDEBUG_CLIENT4 client, PCSTR args)
|
||||
{
|
||||
PyObject *s = PyObject_Str(errvalue);
|
||||
|
||||
DbgPrint::dprintln( PyString_AS_STRING( s ) );
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "%s/n", PyString_AS_STRING( s ) );
|
||||
|
||||
Py_DECREF(s);
|
||||
}
|
||||
@ -348,7 +351,7 @@ py( PDEBUG_CLIENT4 client, PCSTR args)
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrint::dprintln( "script file not found" );
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "script file not found\n" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,8 +394,8 @@ pycmd( PDEBUG_CLIENT4 client, PCSTR args )
|
||||
{
|
||||
PyObject *s = PyObject_Str(errvalue);
|
||||
|
||||
DbgPrint::dprintln( PyString_AS_STRING( s ) );
|
||||
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "%s\n", PyString_AS_STRING( s ) );
|
||||
|
||||
Py_DECREF(s);
|
||||
}
|
||||
|
||||
@ -442,8 +445,8 @@ pycmd( PDEBUG_CLIENT4 client, PCSTR args )
|
||||
{
|
||||
PyObject *s = PyObject_Str(errvalue);
|
||||
|
||||
DbgPrint::dprintln( PyString_AS_STRING( s ) );
|
||||
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "%s/n", PyString_AS_STRING( s ) );
|
||||
|
||||
Py_DECREF(s);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ struct DbgExt {
|
||||
IDebugClient4 *client4;
|
||||
|
||||
IDebugControl *control;
|
||||
IDebugControl4 *control4;
|
||||
|
||||
IDebugRegisters *registers;
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "dbgprint.h"
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/object.hpp>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -9,12 +11,9 @@ class dbgOut {
|
||||
public:
|
||||
|
||||
void
|
||||
write( const std::string& str ) {
|
||||
write( const boost::python::object &str ) {
|
||||
DbgPrint::dprint( str );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -36,9 +35,6 @@ public:
|
||||
|
||||
return std::string( str );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -7,16 +7,18 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
void DbgPrint::dprint( const string& str )
|
||||
void DbgPrint::dprint( const boost::python::object& obj, bool dml )
|
||||
{
|
||||
HRESULT hres = dbgExt->control->ControlledOutput( DEBUG_OUTCTL_AMBIENT_DML, DEBUG_OUTPUT_NORMAL, str.c_str() );
|
||||
if ( FAILED( hres ) )
|
||||
std::cout << str;
|
||||
std::wstring str = boost::python::extract<std::wstring>( obj );
|
||||
|
||||
dbgExt->control4->ControlledOutputWide( dml ? DEBUG_OUTCTL_AMBIENT_DML : DEBUG_OUTCTL_AMBIENT_TEXT, DEBUG_OUTPUT_NORMAL, str.c_str() );
|
||||
}
|
||||
|
||||
void DbgPrint::dprintln( const std::string& str )
|
||||
void DbgPrint::dprintln( const boost::python::object& obj, bool dml )
|
||||
{
|
||||
DbgPrint::dprint( str );
|
||||
DbgPrint::dprint( "\r\n" );
|
||||
std::wstring str = boost::python::extract<std::wstring>( obj );
|
||||
str += L"\r\n";
|
||||
|
||||
dbgExt->control4->ControlledOutputWide( dml ? DEBUG_OUTCTL_AMBIENT_DML : DEBUG_OUTCTL_AMBIENT_TEXT, DEBUG_OUTPUT_NORMAL, str.c_str() );
|
||||
}
|
||||
|
||||
|
@ -3,14 +3,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/object.hpp>
|
||||
|
||||
class DbgPrint {
|
||||
|
||||
public:
|
||||
|
||||
static void dprint( const std::string& str );
|
||||
|
||||
static void dprintln( const std::string& str );
|
||||
static void dprint( const boost::python::object& obj, bool dml = false );
|
||||
|
||||
static void dprintln( const boost::python::object& obj, bool dml = false );
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user