~ [wi:10168] filelds from base class
 ~ list entry to addr64

git-svn-id: https://pykd.svn.codeplex.com/svn@73277 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2012-01-18 15:20:20 +00:00 committed by Mikhail I. Izmestev
parent 6876c4ee3d
commit 15b5736adf
3 changed files with 112 additions and 29 deletions

View File

@ -327,12 +327,12 @@ python::list Module::getTypedVarListByType( ULONG64 listHeadAddress, const TypeI
if ( fieldTypeInfo->getName() == ( typeInfo->getName() + "*" ) ) if ( fieldTypeInfo->getName() == ( typeInfo->getName() + "*" ) )
{ {
for( entryAddress = ptrPtr( listHeadAddress ); entryAddress != listHeadAddress && entryAddress != NULL; entryAddress = ptrPtr( entryAddress + fieldTypeInfo->getOffset() ) ) for( entryAddress = ptrPtr( listHeadAddress ); addr64(entryAddress) != listHeadAddress && entryAddress != NULL; entryAddress = ptrPtr( entryAddress + fieldTypeInfo->getOffset() ) )
lst.append( getTypedVarByType( typeInfo, entryAddress ) ); lst.append( getTypedVarByType( typeInfo, entryAddress ) );
} }
else else
{ {
for( entryAddress = ptrPtr( listHeadAddress ); entryAddress != listHeadAddress && entryAddress != NULL; entryAddress = ptrPtr( entryAddress ) ) for( entryAddress = ptrPtr( listHeadAddress ); addr64(entryAddress) != listHeadAddress && entryAddress != NULL; entryAddress = ptrPtr( entryAddress ) )
lst.append( containingRecordByType( entryAddress, typeInfo, listEntryName ) ); lst.append( containingRecordByType( entryAddress, typeInfo, listEntryName ) );
} }

View File

@ -73,7 +73,6 @@ BaseTypeVariant TypeInfo::getValue()
TypeInfoPtr TypeInfo::getTypeInfo( pyDia::SymbolPtr &symScope, const std::string &symName ) TypeInfoPtr TypeInfo::getTypeInfo( pyDia::SymbolPtr &symScope, const std::string &symName )
{ {
size_t pos = symName.find_first_of( "*[" ); size_t pos = symName.find_first_of( "*[" );
CComVariant constVal;
if ( pos == std::string::npos ) if ( pos == std::string::npos )
{ {
@ -81,33 +80,39 @@ TypeInfoPtr TypeInfo::getTypeInfo( pyDia::SymbolPtr &symScope, const std::strin
if ( basePtr != 0 ) if ( basePtr != 0 )
return basePtr; return basePtr;
pyDia::SymbolPtr typeSym = symScope->getChildByName( symName ); return getTypeInfo( symScope, symScope->getChildByName( symName ) );
if ( typeSym->getSymTag() == SymTagData )
{
if ( typeSym->getLocType() == LocIsBitField )
{
return TypeInfoPtr( new BitFieldTypeInfo(typeSym) );
} }
if ( typeSym->getDataKind() == DataIsConstant ) return getComplexType( symScope, symName );
}
/////////////////////////////////////////////////////////////////////////////////////
TypeInfoPtr TypeInfo::getTypeInfo( pyDia::SymbolPtr &symScope, pyDia::SymbolPtr symChild )
{ {
typeSym->getValue( constVal ); CComVariant constVal;
if ( symChild->getSymTag() == SymTagData )
{
if ( symChild->getLocType() == LocIsBitField )
{
return TypeInfoPtr( new BitFieldTypeInfo(symChild) );
} }
typeSym = typeSym->getType(); if ( symChild->getDataKind() == DataIsConstant )
{
symChild->getValue( constVal );
} }
TypeInfoPtr ptr = getTypeInfo( typeSym ); symChild = symChild->getType();
}
TypeInfoPtr ptr = getTypeInfo( symChild );
ptr->setConstant( constVal ); ptr->setConstant( constVal );
return ptr; return ptr;
} }
return getComplexType( symScope, symName );
}
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
static const boost::regex baseMatch("^(Char)|(WChar)|(Int1B)|(UInt1B)|(Int2B)|(UInt2B)|(Int4B)|(UInt4B)|(Int8B)|(UInt8B)|(Long)|(ULong)|(Float)|(Bool)|(Double)$" ); static const boost::regex baseMatch("^(Char)|(WChar)|(Int1B)|(UInt1B)|(Int2B)|(UInt2B)|(Int4B)|(UInt4B)|(Int8B)|(UInt8B)|(Long)|(ULong)|(Float)|(Bool)|(Double)$" );
@ -337,7 +342,7 @@ TypeInfoPtr TypeInfo::getComplexType( pyDia::SymbolPtr &symScope, const std::str
boost::cmatch matchResult; boost::cmatch matchResult;
if ( !boost::regex_match( symName.c_str(), matchResult, typeMatch ) ) if ( !boost::regex_match( symName.c_str(), matchResult, typeMatch ) )
TypeException( symName, "type name is invalid" ); throw TypeException( symName, "type name is invalid" );
TypeInfoPtr lowestTypeInfo = getTypeInfo( symScope, std::string( matchResult[1].first, matchResult[1].second ) ); TypeInfoPtr lowestTypeInfo = getTypeInfo( symScope, std::string( matchResult[1].first, matchResult[1].second ) );
@ -390,6 +395,78 @@ TypeInfoPtr TypeInfo::getRecurciveComplexType( TypeInfoPtr &lowestType, std::str
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
TypeInfoPtr UdtTypeInfo::getField( const std::string &fieldName )
{
pyDia::SymbolPtr field;
LONG addOffset = 0;
try
{
field = m_dia->getChildByName( fieldName );
}
catch (const pyDia::Exception &)
{
}
if ( !field && !getBaseField( m_dia, fieldName, addOffset, field ) )
throw TypeException( m_dia->getName(), fieldName + ": field not found" );
TypeInfoPtr ti = TypeInfo::getTypeInfo( m_dia, field );
ti->setOffset( addOffset + field->getOffset() );
return ti;
}
/////////////////////////////////////////////////////////////////////////////////////
bool
UdtTypeInfo::getBaseField(
pyDia::SymbolPtr symUdt,
const std::string &fieldName,
LONG &addOffset,
pyDia::SymbolPtr &symField,
ULONG currLevel /*= 0*/
)
{
if (currLevel > 16)
return false;
LONG currOffset = 0;
pyDia::SymbolPtrList lstBases = symUdt->findChildrenImpl(SymTagBaseClass);
pyDia::SymbolPtrList::iterator it = lstBases.begin();
for (; it != lstBases.end(); ++it)
{
// find in direct base
try
{
symField = (*it)->getChildByName( fieldName );
addOffset += currOffset;
return true;
}
catch (const pyDia::Exception &)
{
}
// find in base of base
try
{
if (getBaseField(*it, fieldName, addOffset, symField, currLevel + 1))
{
addOffset += currOffset;
return true;
}
}
catch (const pyDia::Exception &)
{
}
// correct offset
currOffset += static_cast<ULONG>( (*it)->getSize() );
}
return false;
}
/////////////////////////////////////////////////////////////////////////////////////
python::dict EnumTypeInfo::asMap() python::dict EnumTypeInfo::asMap()
{ {
python::dict dct; python::dict dct;

View File

@ -21,6 +21,9 @@ public:
static static
TypeInfoPtr getTypeInfo( pyDia::SymbolPtr &symScope, const std::string &symName ); TypeInfoPtr getTypeInfo( pyDia::SymbolPtr &symScope, const std::string &symName );
static
TypeInfoPtr getTypeInfo( pyDia::SymbolPtr &symScope, pyDia::SymbolPtr symChild );
static static
TypeInfoPtr getTypeInfo( pyDia::SymbolPtr &symbol ); TypeInfoPtr getTypeInfo( pyDia::SymbolPtr &symbol );
@ -205,17 +208,20 @@ protected:
return (ULONG)m_dia->getSize(); return (ULONG)m_dia->getSize();
} }
virtual TypeInfoPtr getField( const std::string &fieldName ) { virtual TypeInfoPtr getField( const std::string &fieldName );
pyDia::SymbolPtr field = m_dia->getChildByName( fieldName );
TypeInfoPtr ti = TypeInfo::getTypeInfo( m_dia, fieldName );
ti->setOffset( field->getOffset() );
return ti;
}
virtual bool isUserDefined() { virtual bool isUserDefined() {
return true; return true;
} }
static bool getBaseField(
pyDia::SymbolPtr symUdt,
const std::string &fieldName,
LONG &addOffset,
pyDia::SymbolPtr &symField,
ULONG currLevel = 0
);
pyDia::SymbolPtr m_dia; pyDia::SymbolPtr m_dia;
}; };