winIDEA SDK
Loading...
Searching...
No Matches
call_hierarchy.py
1# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
2#
3# (c) TASKING Germany GmbH, 2023
4
5"""
6This script demonstrates usage of API for getting call hierarchy
7from symbol information. Analyzer is not required for this
8information to be available.
9"""
10
11import sys
12import isystem.connect as ic
13
14
15winidea_id = ''
16
17
18def printFunctions(addrCtrl, addresses):
19
20 names = ic.StrVector()
21 types = ic.IntVector()
22 addrCtrl.getFunctionNames(addresses, names, types)
23
24 idx = 0
25 for addr in addresses:
26 print(hex(addr), names[idx])
27 idx += 1
28
29if __name__ == "__main__":
30 cmgr = ic.ConnectionMgr()
31 cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
32
33 debugCtrl = ic.CDebugFacade(cmgr)
34
35 debugCtrl.download()
36
37 partition = 0
38 functionName = 'fibonacci' # default
39
40 if len(sys.argv) > 1:
41 functionName = sys.argv[1]
42
43
44 dataCtrl = ic.CDataController(cmgr)
45 addrCtrl = ic.CAddressController(cmgr)
46
47 functions = ic.FunctionVector()
48 dataCtrl.getFunctions(partition, functions)
49
50 major, minor, build, _ = ic.getModuleVersion().split('.')
51
52 for func in functions:
53 if func.getName() == functionName:
54 print('Function info found!')
55
56 addrs = ic.AddressVector()
57
58 func.getCallsFromFunction(addrs)
59 print("Functions called from '" + functionName + "':")
60 printFunctions(addrCtrl, addrs)
61
62 func.getCallsToFunction(addrs)
63 print("\nFunctions which call '" + functionName + "':")
64 printFunctions(addrCtrl, addrs)
65
66 break