winIDEA SDK
test_configure_stack_usage.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 test_configureStackUsage():
12 connMgr = ic.ConnectionMgr()
13 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
14
15 # Initialize controllers
16 addrCtrl = ic.CAddressController(connMgr)
17 cfgCtrl = ic.CConfigurationController(connMgr)
18 dataCtrl = ic.CDataController(connMgr)
19
20 # Get stack end from program symbols
21 STACK_START_ADDR = addrCtrl.getVariableAddress("_sdata").getAddress()
22 STACK_END_ADDR = addrCtrl.getVariableAddress("_edata").getAddress()
23 VALUE = 0x55
24
25 # Get current process and choose option controller for its StackUsage
26 stack_cfg = cfgCtrl.ide_app().opt('StackUsage')
27
28 # Configure stack
29 stack_cfg.set_bool('Use', True)
30 stack_cfg.set_uint('Pattern', VALUE)
31 stack_cfg.set('Position', 'End')
32 stack_cfg.set('Start', str(hex(STACK_START_ADDR)))
33 stack_cfg.set('End', str(hex(STACK_END_ADDR)))
34
35 # NOTE: changes apply only after `download`!
36 # <your code>
37
38 print(f'Disable by setting option `Use` to `False`')
39 stack_cfg.set_bool('Use', False)
40
41
42if __name__ == "__main__":
43 test_configureStackUsage()