winIDEA SDK
get_symbol_at_address.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5"""
6TODO_MK: move one example for sFunctions to test_getSymbolAtAddress, then delete this file.
7
8This script demonstrates obtaining of function at the given memory
9address.
10"""
11
12import isystem.connect as ic
13import sys
14
15# First we obtain connection and controller objects
16
17winidea_id = ''
18
19
20cmgr = ic.ConnectionMgr()
21cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
22
23debugCtrl = ic.CDebugFacade(cmgr)
24
25debugCtrl.download()
26debugCtrl.runUntilFunction('main', ic.CExecutionController.TOUT_10s)
27
28status = debugCtrl.getCPUStatus()
29
30# Both prints statements print 'main' because target stopped at the start
31# address of the function.
32print('Current function, default scope: ' + debugCtrl.getSymbolAtAddress(ic.IConnectDebug.sFunctions,
33 status.getExecutionArea(),
34 status.getExecutionPoint()))
35
36print('Current function, exact scope: ' + debugCtrl.getSymbolAtAddress(ic.IConnectDebug.sFunctions,
37 status.getExecutionArea(),
38 status.getExecutionPoint(),
39 ic.IConnectDebug.sScopeExact))
40# now we performs some steps, to get into the function
41debugCtrl.stepOverHigh()
42debugCtrl.stepOverHigh()
43debugCtrl.stepOverHigh()
44
45status = debugCtrl.getCPUStatus()
46# The first two print statements print empty string as function name, because
47# target stopped somewhere inside of the function. The next two statements print
48# 'main'.
49print('Current function, default scope: ' + debugCtrl.getSymbolAtAddress(ic.IConnectDebug.sFunctions,
50 status.getExecutionArea(),
51 status.getExecutionPoint()))
52
53print('Current function, exact scope: ' + debugCtrl.getSymbolAtAddress(ic.IConnectDebug.sFunctions,
54 status.getExecutionArea(),
55 status.getExecutionPoint(),
56 ic.IConnectDebug.sScopeExact))
57
58print('Current function, narrow scope: ' + debugCtrl.getSymbolAtAddress(ic.IConnectDebug.sFunctions,
59 status.getExecutionArea(),
60 status.getExecutionPoint(),
61 ic.IConnectDebug.sScopeNarrow))
62
63print('Current function, wide scope: ' + debugCtrl.getSymbolAtAddress(ic.IConnectDebug.sFunctions,
64 status.getExecutionArea(),
65 status.getExecutionPoint(),
66 ic.IConnectDebug.sScopeWide))