Commit f443f0cb authored by SND\air_max_cp's avatar SND\air_max_cp
Browse files

[pykd] added: TypedVar instantiation by symbol name or by address

[test] added : testTypedVarByAddress and testTypedVarBySymbolName for above-mentioned functionality. 

git-svn-id: https://pykd.svn.codeplex.com/svn@69328 9b283d60-5439-405e-af05-b73fd8c4d996
parent eeac3d5a
......@@ -260,6 +260,10 @@ BOOST_PYTHON_MODULE( pykd )
"constructor" ) )
.def(boost::python::init<std::string,std::string,ULONG64>(boost::python::args("moduleName", "typeName", "address"),
"constructor" ) )
.def(boost::python::init<ULONG64>(boost::python::args("address"),
"constructor" ) )
.def(boost::python::init<std::string>(boost::python::args("symbolName"),
"constructor" ) )
.def("getAddress", &TypedVar::getAddress,
"Return virtual address" )
.def("sizeof", &TypedVar::getSize,
......
......@@ -807,6 +807,49 @@ TypeInfo::printField( size_t index, void* buffer, size_t bufferLength ) const
///////////////////////////////////////////////////////////////////////////////////
TypedVar::TypedVar( ULONG64 targetOffset ) :
m_targetOffset( addr64(targetOffset) )
{
HRESULT hres;
ULONG typeId;
ULONG64 module;
hres = dbgExt->symbols->GetOffsetTypeId( m_targetOffset, &typeId, &module );
if ( FAILED( hres ) )
throw TypeException();
char moduleName[0x100];
hres = dbgExt->symbols2->GetModuleNameString( DEBUG_MODNAME_MODULE, DEBUG_ANY_ID, module,
moduleName, sizeof( moduleName ), NULL );
if ( FAILED( hres ) )
throw TypeException();
m_typeInfo = TypeInfo( moduleName , addr64(module), typeId );
}
///////////////////////////////////////////////////////////////////////////////////
TypedVar::TypedVar( const std::string &symbolName )
{
HRESULT hres;
ULONG typeId;
ULONG64 module;
hres = dbgExt->symbols->GetSymbolTypeId( symbolName.c_str(), &typeId, &module );
if ( FAILED( hres ) )
throw TypeException();
char moduleName[0x100];
hres = dbgExt->symbols2->GetModuleNameString( DEBUG_MODNAME_MODULE, DEBUG_ANY_ID, module,
moduleName, sizeof( moduleName ), NULL );
if ( FAILED( hres ) )
throw TypeException();
m_typeInfo = TypeInfo( moduleName , addr64(module), typeId );
}
///////////////////////////////////////////////////////////////////////////////////
TypedVar::TypedVar( const TypeInfo &typeInfo, ULONG64 targetOffset, char* buffer, size_t bufferLength ) :
m_typeInfo( typeInfo ),
m_targetOffset( addr64(targetOffset) )
......
......@@ -217,6 +217,10 @@ public:
m_typeInfo( moduleName, typeName ),
m_targetOffset( addr64(targetOffset) )
{}
TypedVar( ULONG64 targetOffset );
TypedVar( const std::string &symbolName );
ULONG64
getAddress() const {
......
......@@ -69,3 +69,11 @@ class TypeInfoTest( unittest.TestCase ):
self.assertEqual( v7.field1[5].field2, 20 )
self.assertEqual( v7.field2[1][0].field1, 10 )
self.assertEqual( v7.field2[0][1].field2, 20 )
def testTypedVarByAddress(self):
var5 = pykd.typedVar( pykd.getOffset( target.moduleName, "Namespace3::var5" ) )
self.assertEqual( var5.m_field1, 5 )
def testTypedVarBySymbolName(self):
var5 = pykd.typedVar( "Namespace3::var5" )
self.assertEqual( var5.m_field1, 5 )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment