added : typeInfo.isTemplate method ( return true if type is template )

added : typeInfo.getTemplateArgs method ( return list of template args name )
This commit is contained in:
ussrhero 2019-07-29 23:34:18 +03:00
parent 852908bb40
commit 10344dbd09
4 changed files with 41 additions and 1 deletions

View File

@ -191,6 +191,8 @@ void pykd_init()
"Create memory dump file" ); "Create memory dump file" );
python::def( "getLocalProcesses", pykd::getLocalProcesses, python::def( "getLocalProcesses", pykd::getLocalProcesses,
"Return list of runnng processes on the host system" ); "Return list of runnng processes on the host system" );
python::def("getHostProcessPath", pykd::getHostProcessPath,
"Return image path of the process running python interpreter with a pykd");
python::def( "getDebugOptions", pykd::getDebugOptions, python::def( "getDebugOptions", pykd::getDebugOptions,
"Return debug options" ); "Return debug options" );
python::def( "changeDebugOptions", pykd::changeDebugOptions, python::def( "changeDebugOptions", pykd::changeDebugOptions,
@ -949,6 +951,8 @@ void pykd_init()
"Return a base class offset by index") "Return a base class offset by index")
.def("baseClasses", TypeInfoAdapter::getBaseClasses, .def("baseClasses", TypeInfoAdapter::getBaseClasses,
"Return list of tuples ( baseClassName, baseClassOffset, baseClassType)") "Return list of tuples ( baseClassName, baseClassOffset, baseClassType)")
.def( "getTemplateArgs", TypeInfoAdapter::getTemplateArgs,
"Return list if template arguments" )
.def( "deref", TypeInfoAdapter::deref, .def( "deref", TypeInfoAdapter::deref,
"Return type of pointer" ) "Return type of pointer" )
.def( "append", TypeInfoAdapter::appendField, .def( "append", TypeInfoAdapter::appendField,
@ -979,6 +983,8 @@ void pykd_init()
"Return true if no type is specified" ) "Return true if no type is specified" )
.def( "isNoType", TypeInfoAdapter::isNoType, .def( "isNoType", TypeInfoAdapter::isNoType,
"Return true if type is virtual table" ) "Return true if type is virtual table" )
.def( "isTemplate", TypeInfoAdapter::isTemplate,
"Return true if type is template" )
.def( "getCallingConvention", TypeInfoAdapter::getCallingConvention, .def( "getCallingConvention", TypeInfoAdapter::getCallingConvention,
"Returns an indicator of a methods calling convention: callingConvention" ) "Returns an indicator of a methods calling convention: callingConvention" )
.def( "getClassParent", TypeInfoAdapter::getClassParent, .def( "getClassParent", TypeInfoAdapter::getClassParent,

View File

@ -118,6 +118,9 @@ python::list TypedVarAdapter::getFields( kdlib::TypedVar& typedVar )
std::wstring name = typedVar.getElementName(i); std::wstring name = typedVar.getElementName(i);
kdlib::MEMOFFSET_32 offset = 0; kdlib::MEMOFFSET_32 offset = 0;
if (typedVar.getType()->isConstMember(i))
continue;
if (!typedVar.getType()->isStaticMember(i) ) if (!typedVar.getType()->isStaticMember(i) )
offset = typedVar.getElementOffset(i); offset = typedVar.getElementOffset(i);

View File

@ -211,6 +211,29 @@ python::list TypeInfoAdapter::getBaseClasses(kdlib::TypeInfo &typeInfo)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
python::list TypeInfoAdapter::getTemplateArgs(const kdlib::TypeInfoPtr &typeInfo)
{
std::list<std::wstring> templateArgs;
{
AutoRestorePyState pystate;
for (size_t i = 0; i < typeInfo->getTemplateArgsCount(); ++i)
{
templateArgs.push_back(typeInfo->getTemplateArg(i));
}
}
python::list pylst;
for (const auto& arg : templateArgs)
pylst.append(arg);
return pylst;
}
///////////////////////////////////////////////////////////////////////////////
kdlib::TypeInfoPtr TypeInfoAdapter::getElementAttr(kdlib::TypeInfo &typeInfo, const std::wstring &name) kdlib::TypeInfoPtr TypeInfoAdapter::getElementAttr(kdlib::TypeInfo &typeInfo, const std::wstring &name)
{ {
AutoRestorePyState pystate; AutoRestorePyState pystate;

View File

@ -302,6 +302,12 @@ struct TypeInfoAdapter : public kdlib::TypeInfo {
return typeInfo.isNoType(); return typeInfo.isNoType();
} }
static bool isTemplate(const kdlib::TypeInfoPtr &typeInfo)
{
AutoRestorePyState pystate;
return typeInfo->isTemplate();
}
static void appendField( kdlib::TypeInfo &typeInfo, const std::wstring &fieldName, kdlib::TypeInfoPtr &fieldType ) static void appendField( kdlib::TypeInfo &typeInfo, const std::wstring &fieldName, kdlib::TypeInfoPtr &fieldType )
{ {
AutoRestorePyState pystate; AutoRestorePyState pystate;
@ -334,6 +340,8 @@ struct TypeInfoAdapter : public kdlib::TypeInfo {
static python::list getBaseClasses(kdlib::TypeInfo &typeInfo); static python::list getBaseClasses(kdlib::TypeInfo &typeInfo);
static python::list getTemplateArgs(const kdlib::TypeInfoPtr &typeInfo);
static bool isZero(kdlib::TypeInfo &typeInfo) { static bool isZero(kdlib::TypeInfo &typeInfo) {
return false; return false;
} }