mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 19:53:22 +08:00
[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:
parent
98d0848f10
commit
512131bbdb
@ -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 )
|
||||
{
|
||||
std::string moduleName;
|
||||
|
@ -327,6 +327,8 @@ public:
|
||||
|
||||
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 getTypedVarByTypeName( const std::string &typeName, ULONG64 addr );
|
||||
|
@ -520,6 +520,7 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
"Remove all breapoints" );
|
||||
|
||||
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( "size", &TypeInfo::getSize )
|
||||
.def( "offset", &TypeInfo::getOffset )
|
||||
|
@ -1,11 +1,19 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "typeinfo.h"
|
||||
#include "dbgclient.h"
|
||||
|
||||
namespace pykd {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TypeInfoPtr TypeInfo::getTypeInfoByName( const std::string &typeName )
|
||||
{
|
||||
return g_dbgClient->getTypeInfoByName( typeName );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TypeInfoPtr TypeInfo::getTypeInfo( pyDia::SymbolPtr &typeSym )
|
||||
{
|
||||
const ULONG symTag = typeSym->getSymTag();
|
||||
|
@ -18,6 +18,9 @@ class TypeInfo : boost::noncopyable, public intBase {
|
||||
|
||||
public:
|
||||
|
||||
static
|
||||
TypeInfoPtr getTypeInfoByName( const std::string &symName );
|
||||
|
||||
static
|
||||
TypeInfoPtr getTypeInfo( pyDia::SymbolPtr &symScope, const std::string &symName );
|
||||
|
||||
|
@ -9,10 +9,11 @@ import pykd
|
||||
class TypeInfoTest( unittest.TestCase ):
|
||||
|
||||
def testCtor( self ):
|
||||
""" typeInfo class can not be created direct """
|
||||
try: pykd.typeInfo()
|
||||
except RuntimeError: pass
|
||||
|
||||
self.assertEqual( "structTest", pykd.typeInfo( "structTest" ).name() )
|
||||
self.assertEqual( "structTest", pykd.typeInfo( target.moduleName + "!structTest" ).name() )
|
||||
self.assertEqual( "structTest", pykd.typeInfo( "g_structTest" ).name() )
|
||||
self.assertEqual( "structTest", pykd.typeInfo( target.moduleName + "!g_structTest" ).name() )
|
||||
|
||||
def testCreateByName( self ):
|
||||
""" creating typeInfo by the type name """
|
||||
self.assertEqual( "structTest", target.module.type( "structTest" ).name() )
|
||||
|
Loading…
Reference in New Issue
Block a user