mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-19 19:13:22 +08:00
added : baseClassOffset ( retrun offset of base class )
added : baseClasses ( return list of tuples ( baseClassName, baseClassOffset, baseClassType ) )
This commit is contained in:
parent
2509de349b
commit
c498137a51
@ -918,6 +918,12 @@ void pykd_init()
|
|||||||
"Return a base class's type by name" )
|
"Return a base class's type by name" )
|
||||||
.def( "baseClass", TypeInfoAdapter::getBaseClassByIndex,
|
.def( "baseClass", TypeInfoAdapter::getBaseClassByIndex,
|
||||||
"Return a base class's type by index" )
|
"Return a base class's type by index" )
|
||||||
|
.def("baseClassOffset", TypeInfoAdapter::getBaseClassOffsetByName,
|
||||||
|
"Return a base class offset by name")
|
||||||
|
.def("baseClassOffset", TypeInfoAdapter::getBaseClassOffsetByIndex,
|
||||||
|
"Return a base class offset by index")
|
||||||
|
.def("baseClasses", TypeInfoAdapter::getBaseClasses,
|
||||||
|
"Return list of tuples ( baseClassName, baseClassOffset, baseClassType)")
|
||||||
.def( "deref", TypeInfoAdapter::deref,
|
.def( "deref", TypeInfoAdapter::deref,
|
||||||
"Return type of pointer" )
|
"Return type of pointer" )
|
||||||
.def( "append", TypeInfoAdapter::appendField,
|
.def( "append", TypeInfoAdapter::appendField,
|
||||||
|
@ -131,6 +131,35 @@ python::list TypeInfoAdapter::getMethods(kdlib::TypeInfo &typeInfo)
|
|||||||
return pylst;
|
return pylst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
python::list TypeInfoAdapter::getBaseClasses(kdlib::TypeInfo &typeInfo)
|
||||||
|
{
|
||||||
|
typedef boost::tuple<std::wstring, kdlib::MEMOFFSET_32, kdlib::TypeInfoPtr> BaseClassTuple;
|
||||||
|
|
||||||
|
std::list<BaseClassTuple> lst;
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < typeInfo.getBaseClassesCount(); ++i)
|
||||||
|
{
|
||||||
|
kdlib::TypeInfoPtr classType = typeInfo.getBaseClass(i);
|
||||||
|
std::wstring name = classType->getName();
|
||||||
|
kdlib::MEMOFFSET_32 offset = typeInfo.getBaseClassOffset(i);
|
||||||
|
|
||||||
|
lst.push_back(BaseClassTuple(name, offset, classType));
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (false);
|
||||||
|
|
||||||
|
python::list pylst;
|
||||||
|
|
||||||
|
for (auto it = lst.begin(); it != lst.end(); ++it)
|
||||||
|
pylst.append(python::make_tuple(it->get<0>(), it->get<1>(), it->get<2>()));
|
||||||
|
|
||||||
|
return pylst;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
kdlib::TypeInfoPtr TypeInfoAdapter::getElementAttr(kdlib::TypeInfo &typeInfo, const std::wstring &name)
|
kdlib::TypeInfoPtr TypeInfoAdapter::getElementAttr(kdlib::TypeInfo &typeInfo, const std::wstring &name)
|
||||||
|
@ -202,6 +202,18 @@ struct TypeInfoAdapter : public kdlib::TypeInfo {
|
|||||||
return typeInfo.getBaseClass(index);
|
return typeInfo.getBaseClass(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static kdlib::MEMOFFSET_32 getBaseClassOffsetByName(kdlib::TypeInfo &typeInfo, const std::wstring& className)
|
||||||
|
{
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
return typeInfo.getBaseClassOffset(className);
|
||||||
|
}
|
||||||
|
|
||||||
|
static kdlib::MEMOFFSET_32 getBaseClassOffsetByIndex(kdlib::TypeInfo &typeInfo, size_t index)
|
||||||
|
{
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
return typeInfo.getBaseClassOffset(index);
|
||||||
|
}
|
||||||
|
|
||||||
static kdlib::TypeInfoPtr ptrTo( kdlib::TypeInfo &typeInfo, size_t ptrSize = 0 )
|
static kdlib::TypeInfoPtr ptrTo( kdlib::TypeInfo &typeInfo, size_t ptrSize = 0 )
|
||||||
{
|
{
|
||||||
AutoRestorePyState pystate;
|
AutoRestorePyState pystate;
|
||||||
@ -316,6 +328,8 @@ struct TypeInfoAdapter : public kdlib::TypeInfo {
|
|||||||
|
|
||||||
static python::list getElementDir(kdlib::TypeInfo &typeInfo);
|
static python::list getElementDir(kdlib::TypeInfo &typeInfo);
|
||||||
|
|
||||||
|
static python::list getBaseClasses(kdlib::TypeInfo &typeInfo);
|
||||||
|
|
||||||
static bool isZero(kdlib::TypeInfo &typeInfo) {
|
static bool isZero(kdlib::TypeInfo &typeInfo) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<InterpreterPath />
|
<InterpreterPath />
|
||||||
<InterpreterArguments>
|
<InterpreterArguments>
|
||||||
</InterpreterArguments>
|
</InterpreterArguments>
|
||||||
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
|
<EnableNativeCodeDebugging>True</EnableNativeCodeDebugging>
|
||||||
<IsWindowsApplication>False</IsWindowsApplication>
|
<IsWindowsApplication>False</IsWindowsApplication>
|
||||||
<InterpreterId>Global|PythonCore|2.7</InterpreterId>
|
<InterpreterId>Global|PythonCore|2.7</InterpreterId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -344,6 +344,13 @@ class TypeInfoTest( unittest.TestCase ):
|
|||||||
def testGetBaseClass(self):
|
def testGetBaseClass(self):
|
||||||
classChild = target.module.type("classChild")
|
classChild = target.module.type("classChild")
|
||||||
self.assertEqual( ["classBase1", "classBase2"], [ classChild.baseClass(i).name() for i in range(classChild.getNumberBaseClasses()) ] )
|
self.assertEqual( ["classBase1", "classBase2"], [ classChild.baseClass(i).name() for i in range(classChild.getNumberBaseClasses()) ] )
|
||||||
|
self.assertEqual( ["classBase1", "classBase2"], [ name for name, _, _ in classChild.baseClasses()] )
|
||||||
|
|
||||||
|
def testGetBaseClassOffset(self):
|
||||||
|
classChild = target.module.type("classChild")
|
||||||
|
self.assertEqual( classChild.baseClassOffset(0), classChild.baseClassOffset('classBase1'))
|
||||||
|
self.assertEqual(classChild.baseClassOffset(1), classChild.baseClassOffset('classBase2'))
|
||||||
|
|
||||||
|
|
||||||
def testPdbTypeProvider(self):
|
def testPdbTypeProvider(self):
|
||||||
pdb = target.module.symfile()
|
pdb = target.module.symfile()
|
||||||
|
Loading…
Reference in New Issue
Block a user