Skip to content

A small library inspired by VyPR's static analysis machinery that allows the construction of the symbolic control-flow graph of code.

Notifications You must be signed in to change notification settings

joshhdawes/symbolic-control-flow-graphs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to use

from builder import Function
f = Function(module="test_module", function="Test:method")
scfg = f.build_scfg()
scfg.write_to_file("test-scfg.gv")

Working with paths

Convert a list of lines to a list of SCFG edges using

edges = scfg.lines_to_edges([7, 9, 10])

Determining divergence in paths

Once two paths have been obtained, for example by

path1 = scfg.lines_to_path([7, 10, 13])
path2 = scfg.lines_to_path([7, 12, 13])

one can construct their parse trees with

p1 = ParseTree(path1, grammar, scfg.starting_vertices)
p2 = ParseTree(path2, grammar, scfg.starting_vertices)

and intersect them (the process that identified points of divergence in paths)

intersection = p1.intersect([p2])

The parse trees and the final intersection (with points of divergence indicated) can be written to a dot file with

p1.write_to_file("parse-tree-1.gv")
p2.write_to_file("parse-tree-2.gv")
intersection.write_to_file("intersection.gv")

About

A small library inspired by VyPR's static analysis machinery that allows the construction of the symbolic control-flow graph of code.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages