4

In IAR Embedded Workbench (v 8.40.1.21539), I have enabled

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

and have specified "callgraph.xml" as the Call graph output (XML) file. IAR has now produced a lovely (huge) xml files with entries in it of the form:

<?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>

Now: what utility (or utilities) knows how to plot this graphically?

fearless_fool
  • 33,645
  • 23
  • 135
  • 217

1 Answers1

2

i used this python script to convert the xml to a dot graph, which can be converted to an 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()
c.richter
  • 21
  • 3
  • Cool output can directly put into https://dreampuf.github.io/GraphvizOnline and there you have the full visualization of the functions call graph – user1911091 Aug 26 '21 at 18:41