mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 11:53:23 +08:00
[0.2.x] added : expr support cplusplus syntax
git-svn-id: https://pykd.svn.codeplex.com/svn@85176 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
17e82d1ee1
commit
1f45804a5b
@ -24,7 +24,7 @@ void debugStep();
|
||||
void debugStepIn();
|
||||
void debugBreak();
|
||||
std::string debugCommand( const std::wstring &command );
|
||||
ULONG64 evaluate( const std::wstring &expression );
|
||||
BaseTypeVariant evaluate( const std::wstring &expression, bool cplusplus = false );
|
||||
|
||||
// debug output
|
||||
void dprint( const std::wstring &str, bool dml = false );
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Version="9,00"
|
||||
Name="pykd"
|
||||
ProjectGUID="{FE961905-666F-4908-A212-961465F46F13}"
|
||||
RootNamespace="pykd"
|
||||
@ -71,7 +71,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="dbgeng.lib diaguids.lib psapi.lib"
|
||||
AdditionalDependencies="dbgeng.lib diaguids.lib psapi.lib comsuppw.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName).pyd"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""$(DIA_SDK_ROOT)\lib";"$(DBG_SDK_ROOT)\lib\i386";"$(PYTHON_ROOT)\x86\libs";"$(BOOST_ROOT)\stage\lib""
|
||||
@ -153,7 +153,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="dbgeng.lib diaguids.lib psapi.lib"
|
||||
AdditionalDependencies="dbgeng.lib diaguids.lib psapi.lib comsuppw.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName).pyd"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""$(DIA_SDK_ROOT)\lib\amd64";"$(DBG_SDK_ROOT)\lib\amd64";"$(PYTHON_ROOT)\x64\libs";"$(BOOST_ROOT)\stage64\lib""
|
||||
@ -230,7 +230,7 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/pdbpath:none"
|
||||
AdditionalDependencies="dbgeng.lib diaguids.lib psapi.lib"
|
||||
AdditionalDependencies="dbgeng.lib diaguids.lib psapi.lib comsuppw.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName).pyd"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""$(DIA_SDK_ROOT)\lib";"$(DBG_SDK_ROOT)\lib\i386";"$(PYTHON_ROOT)\x86\libs";"$(BOOST_ROOT)\stage\lib""
|
||||
@ -310,7 +310,7 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/pdbpath:none"
|
||||
AdditionalDependencies="dbgeng.lib diaguids.lib psapi.lib"
|
||||
AdditionalDependencies="dbgeng.lib diaguids.lib psapi.lib comsuppw.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName).pyd"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""$(DIA_SDK_ROOT)\lib\amd64";"$(DBG_SDK_ROOT)\lib\amd64";"$(PYTHON_ROOT)\x64\libs";"$(BOOST_ROOT)\stage64\lib""
|
||||
|
@ -41,6 +41,7 @@ static const std::string pykdVersion = PYKD_VERSION_BUILD_STR
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( attachKernel_, attachKernel, 0, 1 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( detachProcess_, detachProcess, 0, 1 );
|
||||
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( evaluate_, pykd::pysupport::evaluate, 1, 2 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( dprint_, dprint, 1, 2 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( dprintln_, dprintln, 1, 2 );
|
||||
|
||||
@ -115,8 +116,8 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
|
||||
python::def( "breakin", &debugBreak,
|
||||
"Break into debugger" );
|
||||
python::def( "expr", &evaluate,
|
||||
"Evaluate windbg expression" );
|
||||
python::def( "expr", &pykd::pysupport::evaluate, evaluate_( boost::python::args( "expression", "cplusplus" ),
|
||||
"Evaluate windbg expression" ) );
|
||||
python::def( "dbgCommand", &debugCommand,
|
||||
"Run a debugger's command and return it's result as a string" );
|
||||
python::def( "go", &debugGo,
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "dbgengine.h"
|
||||
#include "typeinfo.h"
|
||||
#include <vector>
|
||||
#include <variant.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -71,4 +72,12 @@ std::string printSystemVersion(SystemVersionPtr sysVer)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string evaluate( const std::wstring &expression, bool cplusplus )
|
||||
{
|
||||
BaseTypeVariant var = pykd::evaluate( expression, cplusplus );
|
||||
|
||||
return boost::apply_visitor( pykd::VariantToStr(), var );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} } //pykd::support namespace end
|
@ -20,6 +20,8 @@ python::tuple moduleFindSymbolAndDisp( pykd::Module &module, ULONG64 offset );
|
||||
|
||||
std::string printSystemVersion(SystemVersionPtr sysVer);
|
||||
|
||||
std::string evaluate( const std::wstring &expression, bool cplusplus = false );
|
||||
|
||||
} } //pykd::support namespace end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -198,7 +198,7 @@ void debugBreak()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ULONG64 evaluate( const std::wstring &expression )
|
||||
BaseTypeVariant evaluate( const std::wstring &expression, bool cplusplus )
|
||||
{
|
||||
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||
|
||||
@ -207,41 +207,60 @@ ULONG64 evaluate( const std::wstring &expression )
|
||||
|
||||
DEBUG_VALUE debugValue = {};
|
||||
ULONG remainderIndex = 0;
|
||||
ULONG expresionSyntax;
|
||||
|
||||
hres = g_dbgEng->control->IsPointer64Bit();
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugControl::IsPointer64Bit failed" );
|
||||
|
||||
if ( hres == S_OK )
|
||||
hres = g_dbgEng->control->GetExpressionSyntax( &expresionSyntax );
|
||||
if ( FAILED(hres) )
|
||||
{
|
||||
throw DbgException( "IDebugControl3::GetExpressionSyntax failed" );
|
||||
}
|
||||
|
||||
hres = g_dbgEng->control->SetExpressionSyntax( cplusplus ? DEBUG_EXPR_CPLUSPLUS : DEBUG_EXPR_MASM );
|
||||
if ( FAILED(hres) )
|
||||
{
|
||||
throw DbgException( "IDebugControl3::GetExpressionSyntax failed" );
|
||||
}
|
||||
|
||||
hres = g_dbgEng->control->EvaluateWide(
|
||||
expression.c_str(),
|
||||
DEBUG_VALUE_INT64,
|
||||
DEBUG_VALUE_INVALID,
|
||||
&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 ) )
|
||||
g_dbgEng->control->SetExpressionSyntax( expresionSyntax );
|
||||
throw DbgException( "IDebugControl::Evaluate failed" );
|
||||
|
||||
if ( remainderIndex == expression.length() )
|
||||
value = debugValue.I32;
|
||||
}
|
||||
|
||||
return value;
|
||||
BaseTypeVariant var;
|
||||
|
||||
switch( debugValue.Type )
|
||||
{
|
||||
case DEBUG_VALUE_INT8:
|
||||
var = BaseTypeVariant( (LONG)debugValue.I8 );
|
||||
break;
|
||||
|
||||
case DEBUG_VALUE_INT16:
|
||||
var = BaseTypeVariant( (LONG)debugValue.I16 );
|
||||
break;
|
||||
|
||||
case DEBUG_VALUE_INT32:
|
||||
var = BaseTypeVariant( debugValue.I32 );
|
||||
break;
|
||||
|
||||
case DEBUG_VALUE_INT64:
|
||||
var = BaseTypeVariant( debugValue.I64 );
|
||||
break;
|
||||
|
||||
default:
|
||||
g_dbgEng->control->SetExpressionSyntax( expresionSyntax );
|
||||
throw DbgException("unsupported type");
|
||||
}
|
||||
|
||||
g_dbgEng->control->SetExpressionSyntax( expresionSyntax );
|
||||
|
||||
return var;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user