[0.1.x] fixed : issue #10521 ( typeInfo returns invalid type name for array's element )

git-svn-id: https://pykd.svn.codeplex.com/svn@74958 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2012-03-19 06:44:18 +00:00 committed by Mikhail I. Izmestev
parent 0834a142bf
commit d44cc55f21
2 changed files with 33 additions and 5 deletions

View File

@ -379,18 +379,46 @@ static const boost::regex ptrMatch("^\\*(.*)$");
static const boost::regex arrayMatch("^(.*)\\[(\\d+)\\]$"); static const boost::regex arrayMatch("^(.*)\\[(\\d+)\\]$");
static const boost::regex symbolMatch("^([\\*]*)([^\\(\\)\\*\\[\\]]*)([\\(\\)\\*\\[\\]\\d]*)$");
TypeInfoPtr TypeInfo::getComplexType( pyDia::SymbolPtr &symScope, const std::string &symName ) TypeInfoPtr TypeInfo::getComplexType( pyDia::SymbolPtr &symScope, const std::string &symName )
{ {
ULONG ptrSize = (symScope->getMachineType() == IMAGE_FILE_MACHINE_AMD64) ? 8 : 4; ULONG ptrSize = (symScope->getMachineType() == IMAGE_FILE_MACHINE_AMD64) ? 8 : 4;
boost::cmatch matchResult; boost::cmatch matchResult;
if ( !boost::regex_match( symName.c_str(), matchResult, typeMatch ) ) if ( !boost::regex_match( symName.c_str(), matchResult, symbolMatch ) )
throw TypeException( symName, "type name is invalid" ); throw TypeException( symName, "symbol name is invalid" );
std::string innerSymName = std::string( matchResult[2].first, matchResult[2].second );
TypeInfoPtr basePtr = getBaseTypeInfo( innerSymName );
if ( basePtr != 0 )
{
return getRecurciveComplexType( basePtr, std::string( matchResult[3].first, matchResult[3].second ), ptrSize );
}
pyDia::SymbolPtr lowestSymbol = symScope->getChildByName( innerSymName );
if ( lowestSymbol->getSymTag() == SymTagData )
{
throw TypeException( symName, "symbol name can not be an expresion" );
}
return getRecurciveComplexType( getTypeInfo( lowestSymbol ), std::string( matchResult[3].first, matchResult[3].second ), ptrSize );
//ULONG ptrSize = (symScope->getMachineType() == IMAGE_FILE_MACHINE_AMD64) ? 8 : 4;
//boost::cmatch matchResult;
//if ( !boost::regex_match( symName.c_str(), matchResult, typeMatch ) )
// 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 ) );
return getRecurciveComplexType( lowestTypeInfo, std::string( matchResult[2].first, matchResult[2].second ), ptrSize ); //return getRecurciveComplexType( lowestTypeInfo, std::string( matchResult[2].first, matchResult[2].second ), ptrSize );
} }
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////

View File

@ -86,8 +86,8 @@ class TypeInfoTest( unittest.TestCase ):
def testVarName( self ): def testVarName( self ):
self.assertEqual( "structTest", target.module.type( "g_structTest").name() ) self.assertEqual( "structTest", target.module.type( "g_structTest").name() )
self.assertEqual( "structTest", target.module.type( "g_testArray[0]").name() ) self.assertRaises( pykd.TypeException, target.module.type, "g_testArray[0]" )
self.assertEqual( "structTest", target.module.type( "*g_structTestPtr").name() ) self.assertRaises( pykd.TypeException, target.module.type, "*g_structTestPtr" )
def testOffset( self ): def testOffset( self ):
ti1 = target.module.type( "structTest" ) ti1 = target.module.type( "structTest" )