import sys
import isystem.connect as ic
winidea_id = ''
def callTarget(connectionMgr, functionName, params, traceCtrl):
"""
This function executes function on the target, and also
starts trace. Use it instead of CExecutionController.call(),
when you have to record trace.
Parameters:
connectionMgr - isntance of ConnectionMgr()
functionName - name of the function to execute
params - values of function parameters, can be empty list: []
traceCtrl - analyzer document, which will record trace
"""
retValName = "isystem___test_ret_val"
paramPrefix = "isystem___test_param_"
ic.CTestCaseController.clearAllTests(cmgr)
testCtrl = ic.CTestCaseController(connectionMgr, functionName, retValName)
try:
for idx in range(0, len(params)):
parameterName = paramPrefix + str(idx)
testCtrl.createParameter(idx, parameterName)
testCtrl.init()
traceCtrl.start()
idx = 0
for param in params:
parameterName = paramPrefix + str(idx)
testCtrl.modify(parameterName, param)
idx += 1
testCtrl.run()
testCtrl.waitUntilStopped(0, 50)
if testCtrl.getStatus() != ic.IConnectTest.stateEnded:
raise Exception("Function call didn't finish normally!" +
testCtrl.testState2str(testCtrl.getStatus()))
testCtrl.destroy()
return
except Exception:
testCtrl.destroy()
raise
def main():
cmgr = ic.ConnectionMgr()
cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
debugCtrl = ic.CDebugFacade(cmgr)
if len(sys.argv) == 1:
debugCtrl.download()
debugCtrl.runUntilFunction("main")
debugCtrl.waitUntilStopped()
print(ic.getModuleVersion())
traceCtrl = ic.CTraceController(cmgr, 'tracedoc_hw.trd', 'w')
callTarget(cmgr, 'test_debug', [], traceCtrl)
if __name__ == "__main__":
main()