mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.3.x] added alignment-requirement for custom types, added alignment for unions
git-svn-id: https://pykd.svn.codeplex.com/svn@86873 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
5a1c2945e4
commit
ab7fa30e8e
@ -67,6 +67,7 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( findSymbol_, pykd::findSymbol, 1, 2 );
|
|||||||
//BOOST_PYTHON_FUNCTION_OVERLOADS( setHardwareBp_, setHardwareBp, 3, 4 );
|
//BOOST_PYTHON_FUNCTION_OVERLOADS( setHardwareBp_, setHardwareBp, 3, 4 );
|
||||||
//
|
//
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS( createStruct_, kdlib::defineStruct, 1, 2 );
|
BOOST_PYTHON_FUNCTION_OVERLOADS( createStruct_, kdlib::defineStruct, 1, 2 );
|
||||||
|
BOOST_PYTHON_FUNCTION_OVERLOADS( createUnion_, kdlib::defineUnion, 1, 2 );
|
||||||
//
|
//
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS( Module_enumSymbols, ModuleAdapter::enumSymbols, 1, 2 );
|
BOOST_PYTHON_FUNCTION_OVERLOADS( Module_enumSymbols, ModuleAdapter::enumSymbols, 1, 2 );
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS( Module_findSymbol, ModuleAdapter::findSymbol, 2, 3 );
|
BOOST_PYTHON_FUNCTION_OVERLOADS( Module_findSymbol, ModuleAdapter::findSymbol, 2, 3 );
|
||||||
@ -292,8 +293,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
// "Return custom defined struct" );
|
// "Return custom defined struct" );
|
||||||
python::def( "createStruct", &pykd::defineStruct, createStruct_( python::args( "name", "align" ),
|
python::def( "createStruct", &pykd::defineStruct, createStruct_( python::args( "name", "align" ),
|
||||||
"Create custom struct" ) );
|
"Create custom struct" ) );
|
||||||
python::def( "createUnion", &pykd::defineUnion,
|
python::def( "createUnion", &pykd::defineUnion, createUnion_( python::args( "name", "align" ),
|
||||||
"Create custom union" );
|
"Create custom union" ) );
|
||||||
|
|
||||||
// CPU registers
|
// CPU registers
|
||||||
python::def( "reg", pykd::getRegisterByName,
|
python::def( "reg", pykd::getRegisterByName,
|
||||||
|
@ -27,10 +27,10 @@ inline kdlib::TypeInfoPtr defineStruct( const std::wstring &structName, size_t a
|
|||||||
return kdlib::defineStruct(structName, align);
|
return kdlib::defineStruct(structName, align);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline kdlib::TypeInfoPtr defineUnion( const std::wstring& unionName )
|
inline kdlib::TypeInfoPtr defineUnion( const std::wstring& unionName, size_t align = 0 )
|
||||||
{
|
{
|
||||||
AutoRestorePyState pystate;
|
AutoRestorePyState pystate;
|
||||||
return kdlib::defineUnion(unionName);
|
return kdlib::defineUnion(unionName, align);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,4 +113,23 @@ class CustomTypesTest(unittest.TestCase):
|
|||||||
struct.append( "m_field7", baseTypes.UInt1B.arrayOf(5) )
|
struct.append( "m_field7", baseTypes.UInt1B.arrayOf(5) )
|
||||||
self.assertEqual( 20, struct.size() )
|
self.assertEqual( 20, struct.size() )
|
||||||
|
|
||||||
|
def testUnionAlignedSize(self):
|
||||||
|
union = pykd.createUnion("MyCustomUnion", align=4)
|
||||||
|
union.append( "m_field1", baseTypes.UInt2B )
|
||||||
|
self.assertEqual( 2, union.size() )
|
||||||
|
union.append( "m_field2", baseTypes.UInt1B.arrayOf(3) )
|
||||||
|
self.assertEqual( 4, union.size() )
|
||||||
|
|
||||||
|
def testWi12591(self):
|
||||||
|
struct = pykd.createStruct(name ="MyAlignStruct", align=4)
|
||||||
|
struct.append( "m_field1", baseTypes.UInt1B )
|
||||||
|
struct.append( "m_field2", baseTypes.UInt1B.arrayOf(2) )
|
||||||
|
self.assertEqual( struct.size(), 3 )
|
||||||
|
self.assertEqual( struct.fieldOffset("m_field2"), 1 )
|
||||||
|
|
||||||
|
def testWi12592(self):
|
||||||
|
struct = pykd.createStruct(name ="MyAlignStruct", align=4)
|
||||||
|
struct.append( "field1", baseTypes.UInt4B )
|
||||||
|
struct.append( "field2", baseTypes.UInt1B )
|
||||||
|
self.assertEqual( struct.size(), 8 )
|
||||||
|
self.assertEqual( struct.fieldOffset("field2"), 4 )
|
||||||
|
Loading…
Reference in New Issue
Block a user