How to create a control-flow graph with Soot?

2019-09-14 11:18发布

问题:

For a while I have been struggling with creating a control-flow graph with Soot and I kinda got lost in its tutorials. Rather than using Soot as an Eclipse plugin, I have been trying to use Soot as a library or API.

What I want to do is, I have a bunch of Java projects and I want to create/generate a control-flow graph of these projects. I also saw that there is a feature in Soot that I can generate control-flow graphs in "DOT" format, which is quite acceptable for me as well.

Any guide or sample of code that shows how to create/generate a control-flow graph with Soot would be great!

回答1:

You can create a method-local CFG by just creating a new ExceptionalUnitGraph, passing it the method's SootBody. The Soot Tutorial in the wiki shows you how to do that.

To get an inter-procedural CFG, i.e., an ICFG, you can use the Soot extension Heros: https://github.com/Sable/heros/blob/develop/src/heros/InterproceduralCFG.java