winIDEA SDK
global_symbols.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import isystem.connect as ic
6
7
8winidea_id = ''
9
10
11def printVariables(partitionIdx, dataCtrl):
12 vars = ic.VariableVector()
13 dataCtrl.getVariables(partitionIdx, vars)
14 for var in vars:
15 print(' Var name: ', var.getName())
16 print(' Var type: ', var.getType())
17 print(' ------------------')
18
19
20def printLabels(partitionIdx, dataCtrl):
21 labels = ic.VariableVector()
22 dataCtrl.getLabels(partitionIdx, labels)
23 for label in labels:
24 print(' Label name: ', label.getName())
25 print(' Label type: ', label.getType())
26 print(' ------------------')
27
28
29def printModules(partitionIdx, dataCtrl):
30 modules = ic.ModuleVector()
31 dataCtrl.getModules(partitionIdx, modules)
32 for module in modules:
33 print(' Module name: ', module.getName())
34 print(' Module path: ', module.getPath())
35 print(' ------------------')
36
37
38def printFunctions(partitionIdx, dataCtrl):
39 functions = ic.FunctionVector()
40 dataCtrl.getFunctions(partitionIdx, functions)
41
42 for function in functions:
43 print(' Function: ', function.getName())
44 print(' Scope: ', function.getScope())
45 print(' Type: ', function.getReturnType())
46 print(' Module idx: ', function.getModuleIndex())
47 print(' Parameters:')
48 params = function.getParameters()
49 for param in params:
50 print(' Name: ', param.getName())
51 print(' Type: ', param.getType())
52 print(' ----')
53
54 print(' ------------------')
55
56
57def printTypes(partitionIdx, dataCtrl):
58 types = ic.TypeVector()
59 dataCtrl.getTypes(partitionIdx, types)
60 for ctype in types:
61 print(' Type name: ', ctype.getName())
62 stype = ctype.getType()
63 # see globdefs.h, struct SType2
64 # for type enum definitions. From Python
65 # the type enums are accessible as object members: dir(type).
66 print(' type: ', stype.m_byType)
67 print(' type2: ', stype.m_byType2)
68 print(' bitSize: ', stype.m_byBitSize)
69 print(' ------------------')
70
71
72def printTypedefs(partitionIdx, dataCtrl):
73 typedefs = ic.TypedefVector()
74 dataCtrl.getTypes(partitionIdx, typedefs)
75 for typedef in typedefs:
76 print(' Typedef name: ', typedef.getTypedefName())
77 print(' Type name: ', typedef.getTypeName())
78 print(' ------------------')
79
80
81cmgr = ic.ConnectionMgr()
82cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
83debugCtrl = ic.CDebugFacade(cmgr)
84
85debugCtrl.download()
86
87dataCtrl = ic.CDataController(cmgr)
88
89
90paths = ic.StrVector()
91dlFileNames = ic.StrVector()
92dataCtrl.getPartitions(paths, dlFileNames)
93
94partitionIdx = 0
95for dlFile in dlFileNames:
96 print('Download file: ', dlFile)
97 printVariables(partitionIdx, dataCtrl)
98 printLabels(partitionIdx, dataCtrl)
99 printModules(partitionIdx, dataCtrl)
100 printFunctions(partitionIdx, dataCtrl)
101 printTypes(partitionIdx, dataCtrl)
102 printTypedefs(partitionIdx, dataCtrl)
103
104 partitionIdx += 1