5import isystem.connect
as ic
12 This class contains type information of C variable.
15 def __init__(self, ivar : ic.IVariable):
18 self.name = ivar.Name()
20 self.qName = ivar.QualifiedName()
21 self.typeName = ivar.TypeName()
23 self.ctype = ivar.Type()
25 self.arrayDim = ivar.ArrayDimension()
27 self.moduleIdx = ivar.Module()
29 self.scope = ivar.Scope()
30 self.memArea = ivar.MemArea()
31 self.address = ivar.Address()
32 self.size = ivar.Size()
33 itype = ivar.GetIType().Type()
35 self.stype = itype.m_byType
37 self.bitSize = itype.m_byBitSize
42 def addChild(self, cvar):
43 self.children.append(cvar)
46 def toString(self, indent: int):
50 return istr +
'- Name: ' + self.name + \
51 '\n' + istr +
' QualifiedName: ' + self.qName + \
52 '\n' + istr +
' TypeName: ' + self.typeName + \
53 '\n' + istr +
' Type: ' + str(self.ctype) + \
54 '\n' + istr +
' rArrayDimension: ' + str(self.arrayDim) + \
55 '\n' + istr +
' Module: ' + str(self.moduleIdx) + \
56 '\n' + istr +
' Scope: ' + self.scope + \
57 '\n' + istr +
' MemArea: ' + str(self.memArea) + \
58 '\n' + istr +
' Address: ' + hex(self.address) + \
59 '\n' + istr +
' Size: ' + str(self.size) + \
60 '\n' + istr +
' SType: ' + str(self.stype) + \
61 '\n' + istr +
' BitSize: ' + str(self.bitSize)
64def getTypeInfo(dataCtrl2 : ic.CDataController2,
65 expressionOrVarName : str,
68 Returns type information for the given string
as hierarchical data
71 typeInfo = dataCtrl2.getExpressionType(0, expressionOrVarName)
73 exprInfo = CVariable(typeInfo.Expression())
74 children = typeInfo.Children()
76 numArrayElements = min(exprInfo.arrayDim, maxArrayLen);
79 numChildren = children.size()
80 for childIdx
in range(numChildren):
81 ivarChild = children.at(childIdx)
82 child = getTypeInfo(dataCtrl2, ivarChild.QualifiedName(), maxArrayLen)
83 exprInfo.addChild(child)
86 for idx
in range(numArrayElements):
88 elementType = exprInfo.typeName;
89 endOfNameIdx = elementType.find(
'[');
90 elementType = elementType[:endOfNameIdx].strip();
91 elementIdx =
"[" + str(idx) +
"]";
93 child = getTypeInfo(dataCtrl2, exprInfo.name + elementIdx, maxArrayLen);
94 exprInfo.addChild(child)
96 dataCtrl2.release(typeInfo)
101def printTree(cvar : CVariable, dataCtrl2, indent = 0):
103 Prints the given cvar and all of its children. If dataCtrl2 !=
None,
104 values of primtive variables are also printed.
107 print(cvar.toString(indent))
109 if dataCtrl2
and cvar.ctype == ic.IVariable.tSimple:
110 cval = dataCtrl2.evaluate(ic.IConnectDebug.fMonitor, cvar.qName)
111 print(
' ' * indent +
' Value: ' + cval.getResult())
114 for child
in cvar.children:
115 printTree(child, dataCtrl2, indent + 2)
119print(
'isystem.connect version: ' + ic.getModuleVersion())
121cmgr = ic.ConnectionMgr()
122cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
124dataCtrl2 = ic.CDataController2(cmgr)
126info = getTypeInfo(dataCtrl2,
'g_complexStruct', 100)
128printTree(info, dataCtrl2)