mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 11:53:23 +08:00
[+] added : eval routine for evaluation windbg expression
git-svn-id: https://pykd.svn.codeplex.com/svn@59202 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
db10c69deb
commit
8b43407e91
@ -4,6 +4,7 @@
|
||||
#include "dbgcmd.h"
|
||||
#include "dbgexcept.h"
|
||||
#include "dbgcallback.h"
|
||||
#include "dbgsystem.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -168,3 +169,57 @@ dbgBreakpointClass::remove()
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ULONG64
|
||||
evaluate( const std::string &expression )
|
||||
{
|
||||
HRESULT hres;
|
||||
ULONG64 value = 0;
|
||||
|
||||
try {
|
||||
|
||||
DEBUG_VALUE debugValue = {};
|
||||
ULONG remainderIndex = 0;
|
||||
|
||||
if ( is64bitSystem() )
|
||||
{
|
||||
hres = dbgExt->control->Evaluate(
|
||||
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 = dbgExt->control->Evaluate(
|
||||
expression.c_str(),
|
||||
DEBUG_VALUE_INT32,
|
||||
&debugValue,
|
||||
&remainderIndex );
|
||||
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugControl::Evaluate failed" );
|
||||
|
||||
if ( remainderIndex == expression.length() )
|
||||
value = debugValue.I32;
|
||||
}
|
||||
}
|
||||
catch( std::exception &e )
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
@ -99,3 +99,8 @@ private:
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ULONG64
|
||||
evaluate( const std::string &expression );
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
@ -87,7 +87,8 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
{
|
||||
boost::python::def( "go", &setExecutionStatus<DEBUG_STATUS_GO> );
|
||||
boost::python::def( "trace", &setExecutionStatus<DEBUG_STATUS_STEP_INTO> );
|
||||
boost::python::def( "step", &setExecutionStatus<DEBUG_STATUS_STEP_OVER> );
|
||||
boost::python::def( "step", &setExecutionStatus<DEBUG_STATUS_STEP_OVER> );
|
||||
boost::python::def( "eval", &evaluate );
|
||||
boost::python::def( "createSession", &dbgCreateSession );
|
||||
boost::python::def( "isSessionStart", &dbgIsSessionStart );
|
||||
boost::python::def( "symbolsPath", &dbgSymPath );
|
||||
|
Loading…
Reference in New Issue
Block a user