[0.1.x] fixed : creating typedVar for the unsigned char type

git-svn-id: https://pykd.svn.codeplex.com/svn@72758 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2011-12-29 13:01:52 +00:00 committed by Mikhail I. Izmestev
parent 380410a521
commit dd66507b4b
5 changed files with 54 additions and 12 deletions

View File

@ -79,6 +79,12 @@ BaseTypeVariant BasicTypedVar::getValue()
if ( m_typeInfo->getName() == "WChar" ) if ( m_typeInfo->getName() == "WChar" )
return (LONG)*(PWCHAR)&val; return (LONG)*(PWCHAR)&val;
if ( m_typeInfo->getName() == "Int1B" )
return (LONG)*(PCHAR)&val;
if ( m_typeInfo->getName() == "UInt1B" )
return (ULONG)*(PUCHAR)&val;
if ( m_typeInfo->getName() == "Int2B" ) if ( m_typeInfo->getName() == "Int2B" )
return (LONG)*(PSHORT)&val; return (LONG)*(PSHORT)&val;

View File

@ -110,7 +110,7 @@ TypeInfoPtr TypeInfo::getTypeInfo( pyDia::SymbolPtr &symScope, const std::strin
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
static const boost::regex baseMatch("^(Char)|(WChar)|(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)$" );
TypeInfoPtr TypeInfoPtr
TypeInfo::getBaseTypeInfo( const std::string &symName ) TypeInfo::getBaseTypeInfo( const std::string &symName )
@ -126,36 +126,42 @@ TypeInfo::getBaseTypeInfo( const std::string &symName )
return TypeInfoPtr( new TypeInfoWrapper<wchar_t>("WChar") ); return TypeInfoPtr( new TypeInfoWrapper<wchar_t>("WChar") );
if ( baseMatchResult[3].matched ) if ( baseMatchResult[3].matched )
return TypeInfoPtr( new TypeInfoWrapper<short>("Int2B") ); return TypeInfoPtr( new TypeInfoWrapper<char>("Int1B") );
if ( baseMatchResult[4].matched ) if ( baseMatchResult[4].matched )
return TypeInfoPtr( new TypeInfoWrapper<unsigned short>("UInt2B") ); return TypeInfoPtr( new TypeInfoWrapper<unsigned char>("UInt1B") );
if ( baseMatchResult[5].matched ) if ( baseMatchResult[5].matched )
return TypeInfoPtr( new TypeInfoWrapper<long>("Int4B") ); return TypeInfoPtr( new TypeInfoWrapper<short>("Int2B") );
if ( baseMatchResult[6].matched ) if ( baseMatchResult[6].matched )
return TypeInfoPtr( new TypeInfoWrapper<unsigned long>("UInt4B") ); return TypeInfoPtr( new TypeInfoWrapper<unsigned short>("UInt2B") );
if ( baseMatchResult[7].matched ) if ( baseMatchResult[7].matched )
return TypeInfoPtr( new TypeInfoWrapper<__int64>("Int8B") ); return TypeInfoPtr( new TypeInfoWrapper<long>("Int4B") );
if ( baseMatchResult[8].matched ) if ( baseMatchResult[8].matched )
return TypeInfoPtr( new TypeInfoWrapper<unsigned __int64>("UInt8B") ); return TypeInfoPtr( new TypeInfoWrapper<unsigned long>("UInt4B") );
if ( baseMatchResult[9].matched ) if ( baseMatchResult[9].matched )
return TypeInfoPtr( new TypeInfoWrapper<long>("Long") ); return TypeInfoPtr( new TypeInfoWrapper<__int64>("Int8B") );
if ( baseMatchResult[10].matched ) if ( baseMatchResult[10].matched )
return TypeInfoPtr( new TypeInfoWrapper<unsigned long>("ULong") ); return TypeInfoPtr( new TypeInfoWrapper<unsigned __int64>("UInt8B") );
if ( baseMatchResult[11].matched ) if ( baseMatchResult[11].matched )
return TypeInfoPtr( new TypeInfoWrapper<float>("Float") ); return TypeInfoPtr( new TypeInfoWrapper<long>("Long") );
if ( baseMatchResult[12].matched ) if ( baseMatchResult[12].matched )
return TypeInfoPtr( new TypeInfoWrapper<bool>("Bool") ); return TypeInfoPtr( new TypeInfoWrapper<unsigned long>("ULong") );
if ( baseMatchResult[13].matched ) if ( baseMatchResult[13].matched )
return TypeInfoPtr( new TypeInfoWrapper<float>("Float") );
if ( baseMatchResult[14].matched )
return TypeInfoPtr( new TypeInfoWrapper<bool>("Bool") );
if ( baseMatchResult[15].matched )
return TypeInfoPtr( new TypeInfoWrapper<double>("Double") ); return TypeInfoPtr( new TypeInfoWrapper<double>("Double") );
} }

View File

@ -12,6 +12,16 @@ class TypedVarTest( unittest.TestCase ):
tv = target.module.typedVar( "structTest", target.module.g_structTest ) tv = target.module.typedVar( "structTest", target.module.g_structTest )
tv = target.module.typedVar( "g_structTest" ) tv = target.module.typedVar( "g_structTest" )
def testBaseTypes(self):
self.assertEqual( 1, target.module.typedVar( "g_ucharValue" ) )
self.assertEqual( 2, target.module.typedVar( "g_ushortValue" ) )
self.assertEqual( 4, target.module.typedVar( "g_ulongValue" ) )
self.assertEqual( 8, target.module.typedVar( "g_ulonglongValue" ) )
self.assertEqual( -1, target.module.typedVar( "g_charValue" ) )
self.assertEqual( -2, target.module.typedVar( "g_shortValue" ) )
self.assertEqual( -4, target.module.typedVar( "g_longValue" ) )
self.assertEqual( -8, target.module.typedVar( "g_longlongValue" ) )
def testGetAddress( self ): def testGetAddress( self ):
tv = target.module.typedVar( "structTest", target.module.g_structTest ) tv = target.module.typedVar( "structTest", target.module.g_structTest )
self.assertEqual( tv.getAddress(), target.module.g_structTest ) self.assertEqual( tv.getAddress(), target.module.g_structTest )

View File

@ -13,6 +13,17 @@ class TypeInfoTest( unittest.TestCase ):
try: pykd.typeInfo() try: pykd.typeInfo()
except RuntimeError: pass except RuntimeError: pass
def testBaseTypes(self):
self.assertEqual("Int1B", target.module.type( "Int1B" ).name() )
self.assertEqual("Int2B", target.module.type( "Int2B" ).name() )
self.assertEqual("Int4B", target.module.type( "Int4B" ).name() )
self.assertEqual("Int8B", target.module.type( "Int8B" ).name() )
self.assertEqual("UInt1B", target.module.type( "UInt1B" ).name() )
self.assertEqual("UInt2B", target.module.type( "UInt2B" ).name() )
self.assertEqual("UInt4B", target.module.type( "UInt4B" ).name() )
self.assertEqual("UInt8B", target.module.type( "UInt8B" ).name() )
def testCreateByName( self ): def testCreateByName( self ):
""" creating typeInfo by the type name """ """ creating typeInfo by the type name """
self.assertEqual( "structTest", target.module.type( "structTest" ).name() ) self.assertEqual( "structTest", target.module.type( "structTest" ).name() )

View File

@ -19,6 +19,11 @@ USHORT g_ushortValue = 2;
ULONG g_ulongValue = 4; ULONG g_ulongValue = 4;
ULONGLONG g_ulonglongValue = 8; ULONGLONG g_ulonglongValue = 8;
CHAR g_charValue = -1;
SHORT g_shortValue = -2;
LONG g_longValue = -4;
LONGLONG g_longlongValue = -8;
std::string g_string; std::string g_string;
struct structWithBits { struct structWithBits {
@ -195,6 +200,10 @@ void FuncWithName0()
std::cout << g_ushortValue; std::cout << g_ushortValue;
std::cout << g_ulongValue; std::cout << g_ulongValue;
std::cout << g_ulonglongValue; std::cout << g_ulonglongValue;
std::cout << g_charValue;
std::cout << g_shortValue;
std::cout << g_longValue;
std::cout << g_longlongValue;
std::cout << g_structTest.m_field0; std::cout << g_structTest.m_field0;
std::cout << g_testArray[1].m_field3; std::cout << g_testArray[1].m_field3;