示例#1
0
def createGraphs(program, basepath):
    import UDrawGraph, ICFGs, Trees, IPGs
    Debug.debugMessage("Creating data structures", 1)
    for cfg in program.getCFGs():
        functionName = cfg.getName()
        UDrawGraph.makeUdrawFile(cfg, basepath,
                                 "%s.%s" % (functionName, "cfg"))
        predomTree = Trees.Dominators(cfg, cfg.getEntryID())
        reverseg = cfg.getReverseCFG()
        postdomTree = Trees.Dominators(reverseg, reverseg.getEntryID())
        UDrawGraph.makeUdrawFile(predomTree, basepath,
                                 "%s.%s" % (functionName, "pre"))
        UDrawGraph.makeUdrawFile(postdomTree, basepath,
                                 "%s.%s" % (functionName, "post"))
        icfg = ICFGs.ICFG(cfg)
        icfg.setEntryID()
        icfg.setExitID()
        icfg.addExitEntryEdge()
        program.addICFG(icfg)
        UDrawGraph.makeUdrawFile(icfg, basepath,
                                 "%s.%s" % (functionName, "icfg"))
        lnt = Trees.LoopNests(icfg, icfg.getEntryID())
        program.addLNT(lnt)
        UDrawGraph.makeUdrawFile(lnt, basepath,
                                 "%s.%s" % (functionName, "lnt"))
        ipg = IPGs.IPG(icfg, lnt)
        program.addIPG(ipg)
        icfg.addBranchDivergenceEdges(lnt)
        ipg.updateWithBranchDivergentPaths()
        UDrawGraph.makeUdrawFile(icfg, basepath,
                                 "%s.%s" % (functionName, "icfg"))
        UDrawGraph.makeUdrawFile(ipg, basepath,
                                 "%s.%s" % (functionName, "ipg"))