winIDEA SDK
Loading...
Searching...
No Matches
stack_frames.py
# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
#
# (c) TASKING Germany GmbH, 2023
import isystem.connect as ic
winidea_id = ''
def initTarget(cmgr):
"""
This function initializes the target. Customize it according to
your needs.
"""
debugCtrl = ic.CDebugFacade(cmgr)
debugCtrl.download()
debugCtrl.runUntilFunction("main")
debugCtrl.waitUntilStopped()
# configure global variables so that required functions will be executed
debugCtrl.modify(ic.IConnectDebug.fMonitor, "debug_flag", "true")
debugCtrl.run()
return debugCtrl
def printVars(dataCtrl, cvars):
for cvar in cvars:
print(' Name: ', cvar.getName())
print(' Type: ', cvar.getType())
print(' Value: ', dataCtrl.evaluate(ic.IConnectDebug.fMonitor, cvar.getName()).getResult())
print(' ----')
def printStackFrame(dataCtrl, stackFrame, partitions):
print('Address: ', stackFrame.getAddress())
print('Mem area: ', stackFrame.getMemArea())
print('File name: ', stackFrame.getFileName())
print('Line num: ', stackFrame.getLineNumber())
print('Partition: ', partitions[1][stackFrame.getPartition()])
function = stackFrame.getFunction()
print('Function: ', function.getName())
print(' Scope: ', function.getScope())
print(' Type: ', function.getReturnType())
print(' Module idx: ', function.getModuleIndex())
print(' Parameters:')
printVars(dataCtrl, function.getParameters())
print(' Local variables:')
printVars(dataCtrl, function.getLocalVars())
def main():
cmgr = ic.ConnectionMgr()
cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
debugCtrl = initTarget(cmgr)
debugCtrl.setBP('test_func1')
debugCtrl.run()
debugCtrl.waitUntilStopped()
debugCtrl.stepHigh()
debugCtrl.stepHigh()
dataCtrl = ic.CDataController2(cmgr)
stackFrames = ic.StackFrameVector()
dataCtrl.getStackFrames(False, False, stackFrames)
paths = ic.StrVector()
fileNames = ic.StrVector()
dataCtrl.getPartitions(paths, fileNames)
downloadFiles = [list(paths), list(fileNames)]
stackFrameIdx = 0
for stackFrame in stackFrames:
dataCtrl.setStackFrameContext(0, stackFrameIdx)
printStackFrame(dataCtrl, stackFrame, downloadFiles)
stackFrameIdx += 1
if __name__ == "__main__":
main()