From 81fe97052f90963052526f56d8bce326b7816c7f Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Wed, 23 Oct 2013 11:52:00 +0000 Subject: [PATCH] [0.2.x] fixed : issue #12353 ( 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 --- pykd/typedvar.cpp | 2 +- test/scripts/moduletest.py | 4 ++-- test/scripts/typedvar.py | 2 ++ test/scripts/typeinfo.py | 2 +- test/targetapp/targetapp.cpp | 6 ++++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pykd/typedvar.cpp b/pykd/typedvar.cpp index 9cf0cd7..fc8e6e6 100644 --- a/pykd/typedvar.cpp +++ b/pykd/typedvar.cpp @@ -470,7 +470,7 @@ BaseTypeVariant BitFieldVar::getValue() else { val >>= m_typeInfo->getBitOffset(); - val &= ( 1 << m_typeInfo->getBitWidth() ) - 1; + val &= ( 1LL << m_typeInfo->getBitWidth() ) - 1LL; switch ( m_typeInfo->getSize() ) { diff --git a/test/scripts/moduletest.py b/test/scripts/moduletest.py index 1b960b2..ebc203d 100644 --- a/test/scripts/moduletest.py +++ b/test/scripts/moduletest.py @@ -78,11 +78,11 @@ class ModuleTest( unittest.TestCase ): fileName = pykd.getSourceFile(target.module.FuncWithName0 ) self.assertTrue( re.search('targetapp\\.cpp', fileName ) ) 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.assertEqual( 2, displacement ) fileName, lineNo, displacement = pykd.getSourceLine() - self.assertEqual( 698, lineNo ) + self.assertEqual( 700, lineNo ) def testEnumSymbols( self ): lst = target.module.enumSymbols() diff --git a/test/scripts/typedvar.py b/test/scripts/typedvar.py index d3234b0..7c51044 100644 --- a/test/scripts/typedvar.py +++ b/test/scripts/typedvar.py @@ -144,10 +144,12 @@ class TypedVarTest( unittest.TestCase ): self.assertEqual( 4, tv.m_bit0_4 ) self.assertEqual( 1, tv.m_bit5 ) self.assertEqual( 5, tv.m_bit6_8 ) + self.assertEqual( 0xFF00000000, tv.m_bit0_60 ) tv = target.module.typedVar("g_structWithSignBits") self.assertEqual( 4, tv.m_bit0_4 ) self.assertEqual( -1, tv.m_bit5 ) self.assertEqual( -3, tv.m_bit6_8 ) + self.assertEqual( -1, tv.m_bit0_60 ) def testTypedVarList(self): tvl = target.module.typedVarList( target.module.g_listHead, "listStruct", "listEntry" ) diff --git a/test/scripts/typeinfo.py b/test/scripts/typeinfo.py index de75fde..522cffb 100644 --- a/test/scripts/typeinfo.py +++ b/test/scripts/typeinfo.py @@ -147,7 +147,7 @@ class TypeInfoTest( unittest.TestCase ): ti = target.module.type("unionTest") self.assertEqual( 0, ti.fieldOffset("m_doubleValue") ) self.assertEqual( 0, ti.fieldOffset("m_bits") ) - self.assertEqual( ti.size(), ti.m_doubleValue.size() ) + self.assertEqual( 12, ti.size() ) def testAsMap(self): ti = target.module.type("enumType") diff --git a/test/targetapp/targetapp.cpp b/test/targetapp/targetapp.cpp index 92f4688..4c716d7 100644 --- a/test/targetapp/targetapp.cpp +++ b/test/targetapp/targetapp.cpp @@ -45,12 +45,14 @@ struct structWithBits { ULONG m_bit0_4 : 5; ULONG m_bit5 : 1; ULONG m_bit6_8 : 3; + ULONG64 m_bit0_60 : 60; }; struct structWitSignBits { LONG m_bit0_4 : 5; LONG m_bit5 : 1; LONG m_bit6_8 : 3; + LONG64 m_bit0_60 : 60; }; @@ -104,8 +106,8 @@ typedef struct structAbstract *pstructAbstract; pstructAbstract g_structAbstract = 0; -structWithBits g_structWithBits = { 4, 1, 5}; -structWitSignBits g_structWithSignBits = { 4, 1, 5 }; +structWithBits g_structWithBits = { 4, 1, 5, 0xFF00000000 }; +structWitSignBits g_structWithSignBits = { 4, 1, 5, -1LL }; structTest g_structTest = { 0, 500, true, 1, NULL }; structTest g_structTest1 = { 0, 500, true, 1, &g_structTest };