[0.1.x] added : typeInfo class can be created directly

git-svn-id: https://pykd.svn.codeplex.com/svn@75084 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2012-03-27 13:26:02 +00:00 committed by Mikhail I. Izmestev
parent 98d0848f10
commit 512131bbdb
6 changed files with 33 additions and 4 deletions

View File

@ -493,6 +493,20 @@ void DebugClient::splitSymName( const std::string &fullName, std::string &module
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
TypeInfoPtr DebugClient::getTypeInfoByName( const std::string &typeName )
{
std::string moduleName;
std::string symName;
splitSymName( typeName, moduleName, symName );
Module module = loadModuleByName( moduleName );
return module.getTypeByName( symName );
}
///////////////////////////////////////////////////////////////////////////////////
TypedVarPtr DebugClient::getTypedVarByName( const std::string &varName ) TypedVarPtr DebugClient::getTypedVarByName( const std::string &varName )
{ {
std::string moduleName; std::string moduleName;

View File

@ -327,6 +327,8 @@ public:
void splitSymName( const std::string &fullName, std::string &moduleName, std::string &symbolName ); void splitSymName( const std::string &fullName, std::string &moduleName, std::string &symbolName );
TypeInfoPtr getTypeInfoByName( const std::string &typeName );
TypedVarPtr getTypedVarByName( const std::string &varName ); TypedVarPtr getTypedVarByName( const std::string &varName );
TypedVarPtr getTypedVarByTypeName( const std::string &typeName, ULONG64 addr ); TypedVarPtr getTypedVarByTypeName( const std::string &typeName, ULONG64 addr );

View File

@ -520,6 +520,7 @@ BOOST_PYTHON_MODULE( pykd )
"Remove all breapoints" ); "Remove all breapoints" );
python::class_<TypeInfo, TypeInfoPtr, python::bases<intBase>, boost::noncopyable >("typeInfo", "Class representing typeInfo", python::no_init ) python::class_<TypeInfo, TypeInfoPtr, python::bases<intBase>, boost::noncopyable >("typeInfo", "Class representing typeInfo", python::no_init )
.def("__init__", python::make_constructor(TypeInfo::getTypeInfoByName ) )
.def( "name", &TypeInfo::getName ) .def( "name", &TypeInfo::getName )
.def( "size", &TypeInfo::getSize ) .def( "size", &TypeInfo::getSize )
.def( "offset", &TypeInfo::getOffset ) .def( "offset", &TypeInfo::getOffset )

View File

@ -1,11 +1,19 @@
#include "stdafx.h" #include "stdafx.h"
#include "typeinfo.h" #include "typeinfo.h"
#include "dbgclient.h"
namespace pykd { namespace pykd {
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
TypeInfoPtr TypeInfo::getTypeInfoByName( const std::string &typeName )
{
return g_dbgClient->getTypeInfoByName( typeName );
}
/////////////////////////////////////////////////////////////////////////////////////
TypeInfoPtr TypeInfo::getTypeInfo( pyDia::SymbolPtr &typeSym ) TypeInfoPtr TypeInfo::getTypeInfo( pyDia::SymbolPtr &typeSym )
{ {
const ULONG symTag = typeSym->getSymTag(); const ULONG symTag = typeSym->getSymTag();

View File

@ -18,6 +18,9 @@ class TypeInfo : boost::noncopyable, public intBase {
public: public:
static
TypeInfoPtr getTypeInfoByName( const std::string &symName );
static static
TypeInfoPtr getTypeInfo( pyDia::SymbolPtr &symScope, const std::string &symName ); TypeInfoPtr getTypeInfo( pyDia::SymbolPtr &symScope, const std::string &symName );

View File

@ -9,9 +9,10 @@ import pykd
class TypeInfoTest( unittest.TestCase ): class TypeInfoTest( unittest.TestCase ):
def testCtor( self ): def testCtor( self ):
""" typeInfo class can not be created direct """ self.assertEqual( "structTest", pykd.typeInfo( "structTest" ).name() )
try: pykd.typeInfo() self.assertEqual( "structTest", pykd.typeInfo( target.moduleName + "!structTest" ).name() )
except RuntimeError: pass self.assertEqual( "structTest", pykd.typeInfo( "g_structTest" ).name() )
self.assertEqual( "structTest", pykd.typeInfo( target.moduleName + "!g_structTest" ).name() )
def testCreateByName( self ): def testCreateByName( self ):
""" creating typeInfo by the type name """ """ creating typeInfo by the type name """