1
2
3
4
5import sys
6import isystem.connect as ic
7
8
9winidea_id = ''
10
11
12def callTarget(connectionMgr, functionName, params, traceCtrl):
13 """
14 This function executes function on the target, and also
15 starts trace. Use it instead of CExecutionController.call(),
16 when you have to record trace.
17
18 Parameters:
19 connectionMgr - isntance of ConnectionMgr()
20 functionName - name of the function to execute
21 params - values of function parameters, can be empty list: []
22 traceCtrl - analyzer document, which will record trace
23 """
24 retValName = "isystem___test_ret_val"
25 paramPrefix = "isystem___test_param_"
26
27
28 ic.CTestCaseController.clearAllTests(cmgr)
29
30 testCtrl = ic.CTestCaseController(connectionMgr, functionName, retValName)
31
32 try:
33
34 for idx in range(0, len(params)):
35 parameterName = paramPrefix + str(idx)
36 testCtrl.createParameter(idx, parameterName)
37
38 testCtrl.init()
39
40 traceCtrl.start()
41
42
43 idx = 0
44 for param in params:
45 parameterName = paramPrefix + str(idx)
46 testCtrl.modify(parameterName, param)
47 idx += 1
48
49 testCtrl.run()
50
51 testCtrl.waitUntilStopped(0, 50)
52
53 if testCtrl.getStatus() != ic.IConnectTest.stateEnded:
54 raise Exception("Function call didn't finish normally!" +
55 testCtrl.testState2str(testCtrl.getStatus()))
56
57 testCtrl.destroy()
58 return
59
60 except Exception:
61 testCtrl.destroy()
62 raise
63
64def main():
65
66 cmgr = ic.ConnectionMgr()
67 cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
68
69 debugCtrl = ic.CDebugFacade(cmgr)
70
71
72
73 if len(sys.argv) == 1:
74 debugCtrl.download()
75 debugCtrl.runUntilFunction("main")
76 debugCtrl.waitUntilStopped()
77
78 print(ic.getModuleVersion())
79
80
81 traceCtrl = ic.CTraceController(cmgr, 'tracedoc_hw.trd', 'w')
82
83 callTarget(cmgr, 'test_debug', [], traceCtrl)
84
85
86if __name__ == "__main__":
87 main()