mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.2.x] added : eval routine
git-svn-id: https://pykd.svn.codeplex.com/svn@78887 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
048becd504
commit
be7d58a4e8
@ -17,6 +17,7 @@ bool isKernelDebugging();
|
|||||||
|
|
||||||
void debugGo();
|
void debugGo();
|
||||||
void debugBreak();
|
void debugBreak();
|
||||||
|
ULONG64 evaluate( const std::wstring &expression );
|
||||||
|
|
||||||
// debug output
|
// debug output
|
||||||
void dprint( const std::wstring &str, bool dml = false );
|
void dprint( const std::wstring &str, bool dml = false );
|
||||||
|
@ -73,6 +73,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
|
|
||||||
python::def( "breakin", &debugBreak,
|
python::def( "breakin", &debugBreak,
|
||||||
"Break into debugger" );
|
"Break into debugger" );
|
||||||
|
python::def( "expr", &evaluate,
|
||||||
|
"Evaluate windbg expression" );
|
||||||
python::def( "go", &debugGo,
|
python::def( "go", &debugGo,
|
||||||
"Go debugging" );
|
"Go debugging" );
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ void debugGo()
|
|||||||
} while( currentStatus != DEBUG_STATUS_BREAK && currentStatus != DEBUG_STATUS_NO_DEBUGGEE );
|
} while( currentStatus != DEBUG_STATUS_BREAK && currentStatus != DEBUG_STATUS_NO_DEBUGGEE );
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void debugBreak()
|
void debugBreak()
|
||||||
{
|
{
|
||||||
@ -184,7 +184,55 @@ void debugBreak()
|
|||||||
throw DbgException( "IDebugControl::SetInterrupt" );
|
throw DbgException( "IDebugControl::SetInterrupt" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ULONG64 evaluate( const std::wstring &expression )
|
||||||
|
{
|
||||||
|
PyThreadState *pystate = PyEval_SaveThread();
|
||||||
|
|
||||||
|
HRESULT hres;
|
||||||
|
ULONG64 value = 0;
|
||||||
|
|
||||||
|
DEBUG_VALUE debugValue = {};
|
||||||
|
ULONG remainderIndex = 0;
|
||||||
|
|
||||||
|
hres = g_dbgEng->control->IsPointer64Bit();
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::IsPointer64Bit failed" );
|
||||||
|
|
||||||
|
if ( hres == S_OK )
|
||||||
|
{
|
||||||
|
hres = g_dbgEng->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 = g_dbgEng->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 findModuleBase( const std::string &moduleName )
|
ULONG64 findModuleBase( const std::string &moduleName )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user