gpt4 book ai didi

xml - 如何绘制由 IAR Embedded Workbench 生成的 xml 调用图?

转载 作者:行者123 更新时间:2023-12-04 04:24:30 26 4
gpt4 key购买 nike

在 IAR Embedded Workbench (v 8.40.1.21539) 中,我启用了

Project => Options => Linker => Advanced => Enable stack usage analysis

并已将“callgraph.xml”指定为 Call graph output (XML)文件。
IAR 现在生成了一个可爱的(巨大的)xml 文件,其中包含以下形式的条目:
<?xml version="1.0" encoding="UTF-8"?>

<callGraph>
<version>2</version>
<modules>
...
</modules>
<functions>
...
<function>
<id>771</id>
<name>papi_ssd1675_iface_reset</name>
<address>0x3&apos;6db9</address>
<stack>8</stack>
<callee>759</callee>
<callee>1057</callee>
</function>
...
</functions>
...
</callGraph>

现在:什么实用程序(或实用程序)知道如何以图形方式绘制它?

最佳答案

我使用这个python脚本将xml转换为点图,可以转换为svg

import xml.etree.ElementTree as ET
import code


def parseNodes(functionsNode):
for function in functionsNode:
name = None
identifier = None
for prop in function:
if(prop.tag == "id"):
identifier = prop.text
if(prop.tag == "name"):
name = prop.text
print('f%s [label="%s"]'%(identifier,name))
def parseEdges(functionsNode):
for function in functionsNode:
identifier = None
callees = []
for prop in function:
if(prop.tag == "id"):
identifier = prop.text
if(prop.tag == "callee"):
callees.append("f"+prop.text)
if len(callees)>0:
print('f%s -> %s'%(identifier,"->".join(callees)))

def main():
tree = ET.parse('CallGraphStack_P1.xml')
root = tree.getroot()
functionsNode = None;
for child in root:
if(child.tag == "functions"):
functionsNode = child
parseNodes(functionsNode)
parseEdges(functionsNode)
#code.interact(local=locals())




main()

关于xml - 如何绘制由 IAR Embedded Workbench 生成的 xml 调用图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58103961/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com