mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 21:03:23 +08:00
[0.2.x] + align for custom union
git-svn-id: https://pykd.svn.codeplex.com/svn@86872 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
c2c1ec1592
commit
ae1e83e9d5
@ -11,14 +11,14 @@ namespace pykd {
|
|||||||
|
|
||||||
TypeInfoPtr TypeBuilder::createStruct( const std::string &name, ULONG align )
|
TypeInfoPtr TypeBuilder::createStruct( const std::string &name, ULONG align )
|
||||||
{
|
{
|
||||||
return TypeInfoPtr( new CustomStruct( name, m_ptrSize, align ? align : m_ptrSize ) );
|
return TypeInfoPtr( new CustomStruct( name, m_ptrSize, align ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TypeInfoPtr TypeBuilder::createUnion( const std::string &name )
|
TypeInfoPtr TypeBuilder::createUnion( const std::string &name, ULONG align )
|
||||||
{
|
{
|
||||||
return TypeInfoPtr( new CustomUnion( name, m_ptrSize, m_ptrSize ) );
|
return TypeInfoPtr( new CustomUnion( name, m_ptrSize, align ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
TypeInfoPtr createStruct( const std::string &name, ULONG align = 0 );
|
TypeInfoPtr createStruct( const std::string &name, ULONG align = 0 );
|
||||||
|
|
||||||
TypeInfoPtr createUnion( const std::string &name);
|
TypeInfoPtr createUnion( const std::string &name, ULONG align = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ protected:
|
|||||||
UdtTypeInfoBase( name )
|
UdtTypeInfoBase( name )
|
||||||
{
|
{
|
||||||
m_ptrSize = pointerSize;
|
m_ptrSize = pointerSize;
|
||||||
m_align = align;
|
m_align = align ? align : m_ptrSize;
|
||||||
m_size = 0;
|
m_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( setHardwareBp_, setHardwareBp, 3, 4 );
|
|||||||
BOOST_PYTHON_FUNCTION_OVERLOADS( findSymbol_, TypeInfo::findSymbol, 1, 2 );
|
BOOST_PYTHON_FUNCTION_OVERLOADS( findSymbol_, TypeInfo::findSymbol, 1, 2 );
|
||||||
|
|
||||||
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( TypeBuilder_createStruct, TypeBuilder::createStruct, 1, 2 );
|
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( TypeBuilder_createStruct, TypeBuilder::createStruct, 1, 2 );
|
||||||
|
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( TypeBuilder_createUnion, TypeBuilder::createUnion, 1, 2 );
|
||||||
|
|
||||||
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( Module_enumSymbols, Module::enumSymbols, 0, 1 );
|
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( Module_enumSymbols, Module::enumSymbols, 0, 1 );
|
||||||
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( Module_findSymbol, Module::getSymbolNameByVa, 1, 2 );
|
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( Module_findSymbol, Module::getSymbolNameByVa, 1, 2 );
|
||||||
@ -518,8 +519,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
.add_property( "VoidPtr", &TypeBuilder::getVoidPtr )
|
.add_property( "VoidPtr", &TypeBuilder::getVoidPtr )
|
||||||
.def( "createStruct", &TypeBuilder::createStruct, TypeBuilder_createStruct( python::args( "name", "align" ),
|
.def( "createStruct", &TypeBuilder::createStruct, TypeBuilder_createStruct( python::args( "name", "align" ),
|
||||||
"Create custom struct" ) )
|
"Create custom struct" ) )
|
||||||
.def( "createUnion", &TypeBuilder::createUnion,
|
.def( "createUnion", &TypeBuilder::createUnion, TypeBuilder_createUnion( python::args( "name", "align" ),
|
||||||
"Create custom union" );
|
"Create custom union" ) );
|
||||||
|
|
||||||
python::class_<CpuReg, python::bases<intBase> >(
|
python::class_<CpuReg, python::bases<intBase> >(
|
||||||
"cpuReg", "CPU regsiter class", boost::python::no_init )
|
"cpuReg", "CPU regsiter class", boost::python::no_init )
|
||||||
|
@ -142,6 +142,14 @@ class CustomTypesTest(unittest.TestCase):
|
|||||||
struct.append( "m_field7", tb.UInt1B.arrayOf(5) )
|
struct.append( "m_field7", tb.UInt1B.arrayOf(5) )
|
||||||
self.assertEqual( 20, struct.size() )
|
self.assertEqual( 20, struct.size() )
|
||||||
|
|
||||||
|
def testUnionAlignedSize(self):
|
||||||
|
tb = pykd.typeBuilder()
|
||||||
|
union = tb.createUnion("MyCustomUnion", align=4)
|
||||||
|
union.append( "m_field1", tb.UInt2B )
|
||||||
|
self.assertEqual( 2, union.size() )
|
||||||
|
union.append( "m_field2", tb.UInt1B.arrayOf(3) )
|
||||||
|
self.assertEqual( 4, union.size() )
|
||||||
|
|
||||||
def testWi12591(self):
|
def testWi12591(self):
|
||||||
tb = pykd.typeBuilder()
|
tb = pykd.typeBuilder()
|
||||||
struct = tb.createStruct(name ="MyAlignStruct", align=4)
|
struct = tb.createStruct(name ="MyAlignStruct", align=4)
|
||||||
|
Loading…
Reference in New Issue
Block a user