[0.2.x] fixed : issue ( typedVar for bit field returns a wrong result for width >= 32 bits )

git-svn-id: https://pykd.svn.codeplex.com/svn@85967 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2013-10-23 11:52:00 +00:00 committed by Mikhail I. Izmestev
parent 5cb3fc858b
commit 81fe97052f
5 changed files with 10 additions and 6 deletions

View File

@ -470,7 +470,7 @@ BaseTypeVariant BitFieldVar::getValue()
else else
{ {
val >>= m_typeInfo->getBitOffset(); val >>= m_typeInfo->getBitOffset();
val &= ( 1 << m_typeInfo->getBitWidth() ) - 1; val &= ( 1LL << m_typeInfo->getBitWidth() ) - 1LL;
switch ( m_typeInfo->getSize() ) switch ( m_typeInfo->getSize() )
{ {

View File

@ -78,11 +78,11 @@ class ModuleTest( unittest.TestCase ):
fileName = pykd.getSourceFile(target.module.FuncWithName0 ) fileName = pykd.getSourceFile(target.module.FuncWithName0 )
self.assertTrue( re.search('targetapp\\.cpp', fileName ) ) self.assertTrue( re.search('targetapp\\.cpp', fileName ) )
fileName, lineNo, displacement = pykd.getSourceLine( target.module.FuncWithName0 + 2) fileName, lineNo, displacement = pykd.getSourceLine( target.module.FuncWithName0 + 2)
self.assertEqual( 421, lineNo ) self.assertEqual( 423, lineNo )
self.assertTrue( re.search('targetapp\\.cpp', fileName ) ) self.assertTrue( re.search('targetapp\\.cpp', fileName ) )
self.assertEqual( 2, displacement ) self.assertEqual( 2, displacement )
fileName, lineNo, displacement = pykd.getSourceLine() fileName, lineNo, displacement = pykd.getSourceLine()
self.assertEqual( 698, lineNo ) self.assertEqual( 700, lineNo )
def testEnumSymbols( self ): def testEnumSymbols( self ):
lst = target.module.enumSymbols() lst = target.module.enumSymbols()

View File

@ -144,10 +144,12 @@ class TypedVarTest( unittest.TestCase ):
self.assertEqual( 4, tv.m_bit0_4 ) self.assertEqual( 4, tv.m_bit0_4 )
self.assertEqual( 1, tv.m_bit5 ) self.assertEqual( 1, tv.m_bit5 )
self.assertEqual( 5, tv.m_bit6_8 ) self.assertEqual( 5, tv.m_bit6_8 )
self.assertEqual( 0xFF00000000, tv.m_bit0_60 )
tv = target.module.typedVar("g_structWithSignBits") tv = target.module.typedVar("g_structWithSignBits")
self.assertEqual( 4, tv.m_bit0_4 ) self.assertEqual( 4, tv.m_bit0_4 )
self.assertEqual( -1, tv.m_bit5 ) self.assertEqual( -1, tv.m_bit5 )
self.assertEqual( -3, tv.m_bit6_8 ) self.assertEqual( -3, tv.m_bit6_8 )
self.assertEqual( -1, tv.m_bit0_60 )
def testTypedVarList(self): def testTypedVarList(self):
tvl = target.module.typedVarList( target.module.g_listHead, "listStruct", "listEntry" ) tvl = target.module.typedVarList( target.module.g_listHead, "listStruct", "listEntry" )

View File

@ -147,7 +147,7 @@ class TypeInfoTest( unittest.TestCase ):
ti = target.module.type("unionTest") ti = target.module.type("unionTest")
self.assertEqual( 0, ti.fieldOffset("m_doubleValue") ) self.assertEqual( 0, ti.fieldOffset("m_doubleValue") )
self.assertEqual( 0, ti.fieldOffset("m_bits") ) self.assertEqual( 0, ti.fieldOffset("m_bits") )
self.assertEqual( ti.size(), ti.m_doubleValue.size() ) self.assertEqual( 12, ti.size() )
def testAsMap(self): def testAsMap(self):
ti = target.module.type("enumType") ti = target.module.type("enumType")

View File

@ -45,12 +45,14 @@ struct structWithBits {
ULONG m_bit0_4 : 5; ULONG m_bit0_4 : 5;
ULONG m_bit5 : 1; ULONG m_bit5 : 1;
ULONG m_bit6_8 : 3; ULONG m_bit6_8 : 3;
ULONG64 m_bit0_60 : 60;
}; };
struct structWitSignBits { struct structWitSignBits {
LONG m_bit0_4 : 5; LONG m_bit0_4 : 5;
LONG m_bit5 : 1; LONG m_bit5 : 1;
LONG m_bit6_8 : 3; LONG m_bit6_8 : 3;
LONG64 m_bit0_60 : 60;
}; };
@ -104,8 +106,8 @@ typedef struct structAbstract *pstructAbstract;
pstructAbstract g_structAbstract = 0; pstructAbstract g_structAbstract = 0;
structWithBits g_structWithBits = { 4, 1, 5}; structWithBits g_structWithBits = { 4, 1, 5, 0xFF00000000 };
structWitSignBits g_structWithSignBits = { 4, 1, 5 }; structWitSignBits g_structWithSignBits = { 4, 1, 5, -1LL };
structTest g_structTest = { 0, 500, true, 1, NULL }; structTest g_structTest = { 0, 500, true, 1, NULL };
structTest g_structTest1 = { 0, 500, true, 1, &g_structTest }; structTest g_structTest1 = { 0, 500, true, 1, &g_structTest };