winIDEA SDK
test_reset_and_run.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2# (c) TASKING Germany GmbH, 2023
3#
4# This Python example creates a winIDEA instance, prints a message to the console,
5# and calls the resetAndRun() method on the ExecutionController class. It then gets the address of the
6# main function and sets a breakpoint at that address. It then calls the resetAndRun() method again,
7# this time with a 1-second timeout, and prints a message to the console depending on the result.
8# At the end, it deletes all breakpoints.
9
10import isystem.connect as ic
11import time
12
13
14winidea_id = ''
15
16
17def test_resetAndRun():
18 connMgr = ic.ConnectionMgr()
19 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
20
21 execCtrl = ic.CExecutionController(connMgr)
22 sessionCtrl = ic.CSessionCtrl(connMgr)
23 addCtrl = ic.CAddressController(connMgr)
24 bpCtrl = ic.CBreakpointController(connMgr)
25
26 sessionCtrl.begin_prepare()
27 execCtrl.runUntilFunction('main')
28
29 print("`resetAndRun` the CPU without timeout (not expecting `STOP` state)...")
30 execCtrl.resetAndRun()
31
32 address = addCtrl.getFunctionAddress("main").getAddress()
33 print(f"Setting BP at function 'main': {hex(address)}")
34 bpCtrl.setBP(0, address)
35 sessionCtrl.begin_reset()
36
37 print("`resetAndRun` the CPU with 1 sec timeout (expecting stop at function 'main')...")
38 if execCtrl.resetAndRun(ic.CExecutionController.TOUT_1s) == 0:
39 print("\tSuccess.")
40 else:
41 print("\tTIMEOUT!")
42
43 bpCtrl.deleteAll()
44
45
46if __name__ == "__main__":
47 test_resetAndRun()