diff --git a/pykd/typedvar.cpp b/pykd/typedvar.cpp index ec5db53..4b9675b 100644 --- a/pykd/typedvar.cpp +++ b/pykd/typedvar.cpp @@ -79,6 +79,12 @@ BaseTypeVariant BasicTypedVar::getValue() if ( m_typeInfo->getName() == "WChar" ) 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" ) return (LONG)*(PSHORT)&val; diff --git a/pykd/typeinfo.cpp b/pykd/typeinfo.cpp index a6357be..8c307a4 100644 --- a/pykd/typeinfo.cpp +++ b/pykd/typeinfo.cpp @@ -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 TypeInfo::getBaseTypeInfo( const std::string &symName ) @@ -126,36 +126,42 @@ TypeInfo::getBaseTypeInfo( const std::string &symName ) return TypeInfoPtr( new TypeInfoWrapper("WChar") ); if ( baseMatchResult[3].matched ) - return TypeInfoPtr( new TypeInfoWrapper("Int2B") ); + return TypeInfoPtr( new TypeInfoWrapper("Int1B") ); if ( baseMatchResult[4].matched ) - return TypeInfoPtr( new TypeInfoWrapper("UInt2B") ); + return TypeInfoPtr( new TypeInfoWrapper("UInt1B") ); if ( baseMatchResult[5].matched ) - return TypeInfoPtr( new TypeInfoWrapper("Int4B") ); + return TypeInfoPtr( new TypeInfoWrapper("Int2B") ); if ( baseMatchResult[6].matched ) - return TypeInfoPtr( new TypeInfoWrapper("UInt4B") ); + return TypeInfoPtr( new TypeInfoWrapper("UInt2B") ); if ( baseMatchResult[7].matched ) - return TypeInfoPtr( new TypeInfoWrapper<__int64>("Int8B") ); + return TypeInfoPtr( new TypeInfoWrapper("Int4B") ); if ( baseMatchResult[8].matched ) - return TypeInfoPtr( new TypeInfoWrapper("UInt8B") ); + return TypeInfoPtr( new TypeInfoWrapper("UInt4B") ); if ( baseMatchResult[9].matched ) - return TypeInfoPtr( new TypeInfoWrapper("Long") ); + return TypeInfoPtr( new TypeInfoWrapper<__int64>("Int8B") ); if ( baseMatchResult[10].matched ) - return TypeInfoPtr( new TypeInfoWrapper("ULong") ); + return TypeInfoPtr( new TypeInfoWrapper("UInt8B") ); if ( baseMatchResult[11].matched ) - return TypeInfoPtr( new TypeInfoWrapper("Float") ); + return TypeInfoPtr( new TypeInfoWrapper("Long") ); if ( baseMatchResult[12].matched ) - return TypeInfoPtr( new TypeInfoWrapper("Bool") ); + return TypeInfoPtr( new TypeInfoWrapper("ULong") ); if ( baseMatchResult[13].matched ) + return TypeInfoPtr( new TypeInfoWrapper("Float") ); + + if ( baseMatchResult[14].matched ) + return TypeInfoPtr( new TypeInfoWrapper("Bool") ); + + if ( baseMatchResult[15].matched ) return TypeInfoPtr( new TypeInfoWrapper("Double") ); } diff --git a/test/scripts/typedvar.py b/test/scripts/typedvar.py index 033b24a..803bb72 100644 --- a/test/scripts/typedvar.py +++ b/test/scripts/typedvar.py @@ -11,6 +11,16 @@ class TypedVarTest( unittest.TestCase ): def testCtor( self ): tv = target.module.typedVar( "structTest", target.module.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 ): tv = target.module.typedVar( "structTest", target.module.g_structTest ) diff --git a/test/scripts/typeinfo.py b/test/scripts/typeinfo.py index c1fc821..f27f008 100644 --- a/test/scripts/typeinfo.py +++ b/test/scripts/typeinfo.py @@ -11,7 +11,18 @@ class TypeInfoTest( unittest.TestCase ): def testCtor( self ): """ typeInfo class can not be created direct """ 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 ): """ creating typeInfo by the type name """ diff --git a/test/targetapp/targetapp.cpp b/test/targetapp/targetapp.cpp index 86ee12c..19c0b56 100644 --- a/test/targetapp/targetapp.cpp +++ b/test/targetapp/targetapp.cpp @@ -19,6 +19,11 @@ USHORT g_ushortValue = 2; ULONG g_ulongValue = 4; ULONGLONG g_ulonglongValue = 8; +CHAR g_charValue = -1; +SHORT g_shortValue = -2; +LONG g_longValue = -4; +LONGLONG g_longlongValue = -8; + std::string g_string; struct structWithBits { @@ -195,6 +200,10 @@ void FuncWithName0() std::cout << g_ushortValue; std::cout << g_ulongValue; 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_testArray[1].m_field3;