"""
This script generates a flow chart for a function from its disassembly information.
Graphwiz must be installed on the system, and its bin directory in system PATH.
"""
import isystem.connect as ic
import isystem.flowChart as fchart
import isystem.diagutils as diagutils
import subprocess as sp
winidea_id = ''
def main():
cmgr = ic.ConnectionMgr()
cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
outFileName = 'flowChart.svg'
graphFileName = diagutils.createGraphFileName(outFileName, 'flow')
functionName = 'Func4'
isExpanded = True
isSingleCallNode = True
isAutoRank = True
isOpenInSystemViewer = True
with open(graphFileName, 'w') as outf:
graph = fchart.analyzeFunction(cmgr,
functionName,
isExpanded,
isSingleCallNode,
isAutoRank,
outf)
diagutils.createGraphImage('',
graphFileName,
outFileName)
if isOpenInSystemViewer:
try:
sp.check_call('start ' + outFileName, shell=True)
except:
sp.check_call('gwenview ' + outFileName, shell=True)
print(' Done!')
if __name__ == "__main__":
main()