mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.1.x] added : expr routine
git-svn-id: https://pykd.svn.codeplex.com/svn@70302 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
e064126853
commit
bcbe5e7c96
@ -62,6 +62,8 @@ public:
|
|||||||
|
|
||||||
void attachKernel( const std::wstring ¶m );
|
void attachKernel( const std::wstring ¶m );
|
||||||
|
|
||||||
|
ULONG64 evaluate( const std::wstring &expression );
|
||||||
|
|
||||||
Module loadModule( const std::string &moduleName ) {
|
Module loadModule( const std::string &moduleName ) {
|
||||||
return Module( m_client, moduleName );
|
return Module( m_client, moduleName );
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,59 @@ loadExtension( const std::wstring &extPath )
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ULONG64
|
||||||
|
DebugClient::evaluate( const std::wstring &expression )
|
||||||
|
{
|
||||||
|
HRESULT hres;
|
||||||
|
ULONG64 value = 0;
|
||||||
|
|
||||||
|
DEBUG_VALUE debugValue = {};
|
||||||
|
ULONG remainderIndex = 0;
|
||||||
|
|
||||||
|
hres = m_control->IsPointer64Bit();
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::IsPointer64Bit failed" );
|
||||||
|
|
||||||
|
if ( hres == S_OK )
|
||||||
|
{
|
||||||
|
hres = m_control->EvaluateWide(
|
||||||
|
expression.c_str(),
|
||||||
|
DEBUG_VALUE_INT64,
|
||||||
|
&debugValue,
|
||||||
|
&remainderIndex );
|
||||||
|
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::Evaluate failed" );
|
||||||
|
|
||||||
|
if ( remainderIndex == expression.length() )
|
||||||
|
value = debugValue.I64;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hres = m_control->EvaluateWide(
|
||||||
|
expression.c_str(),
|
||||||
|
DEBUG_VALUE_INT32,
|
||||||
|
&debugValue,
|
||||||
|
&remainderIndex );
|
||||||
|
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::Evaluate failed" );
|
||||||
|
|
||||||
|
if ( remainderIndex == expression.length() )
|
||||||
|
value = debugValue.I32;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG64
|
||||||
|
evaluate( const std::wstring &expression )
|
||||||
|
{
|
||||||
|
return g_dbgClient->evaluate( expression );
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
} // end namespace pykd
|
} // end namespace pykd
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@ namespace pykd {
|
|||||||
std::string
|
std::string
|
||||||
dbgCommand( const std::wstring &command );
|
dbgCommand( const std::wstring &command );
|
||||||
|
|
||||||
|
ULONG64
|
||||||
|
evaluate( const std::wstring &expression );
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class DbgExtension : private DbgObject {
|
class DbgExtension : private DbgObject {
|
||||||
|
@ -65,6 +65,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Attach debugger to a exsisting process" )
|
"Attach debugger to a exsisting process" )
|
||||||
.def( "attachKernel", &pykd::DebugClient::attachKernel,
|
.def( "attachKernel", &pykd::DebugClient::attachKernel,
|
||||||
"Attach debugger to a target's kernel" )
|
"Attach debugger to a target's kernel" )
|
||||||
|
.def( "expr", &pykd::DebugClient::evaluate,
|
||||||
|
"Evaluate windbg expression" )
|
||||||
.def ( "loadExt", &pykd::DebugClient::loadExtension,
|
.def ( "loadExt", &pykd::DebugClient::loadExtension,
|
||||||
"Load a debuger extension" )
|
"Load a debuger extension" )
|
||||||
.def( "loadModule", &pykd::DebugClient::loadModule,
|
.def( "loadModule", &pykd::DebugClient::loadModule,
|
||||||
@ -88,6 +90,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Attach debugger to a exsisting process" );
|
"Attach debugger to a exsisting process" );
|
||||||
python::def( "attachKernel", &pykd::attachKernel,
|
python::def( "attachKernel", &pykd::attachKernel,
|
||||||
"Attach debugger to a kernel target" );
|
"Attach debugger to a kernel target" );
|
||||||
|
python::def( "expr", &pykd::evaluate,
|
||||||
|
"Evaluate windbg expression" );
|
||||||
python::def( "loadExt", &pykd::loadExtension,
|
python::def( "loadExt", &pykd::loadExtension,
|
||||||
"Load a debuger extension" );
|
"Load a debuger extension" );
|
||||||
python::def( "loadModule", &pykd::loadModule,
|
python::def( "loadModule", &pykd::loadModule,
|
||||||
|
@ -11,3 +11,7 @@ class DbgcmdTest( unittest.TestCase ):
|
|||||||
# def testDbgExt( self ):
|
# def testDbgExt( self ):
|
||||||
# #ext = pykd.loadExt( "ext" )
|
# #ext = pykd.loadExt( "ext" )
|
||||||
# #self.assertNotEqual( "", ext.call("help", "") )
|
# #self.assertNotEqual( "", ext.call("help", "") )
|
||||||
|
|
||||||
|
def testExpr( self ):
|
||||||
|
self.assertEqual( 8, pykd.expr( "poi(targetapp!g_ulonglongValue)" ) )
|
||||||
|
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
module = None
|
module = None
|
||||||
moduleName = None
|
moduleName = None
|
||||||
|
dbgext = None
|
Loading…
Reference in New Issue
Block a user