1

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!

Ekin
  • 407
  • 1
  • 6
  • 17

1 Answers1

3

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

Eric
  • 1,343
  • 1
  • 11
  • 19
  • thank you for the response. However, I was wondering if there is an option to give the Java project as an input and recieve it the output as CFG. Because what I saw from the Javadoc is that I have to assign each class as SootClass and each method as SootMethod. Or maybe I am on the wrong path? – Ekin Jul 09 '17 at 07:31
  • Yes you seem to have misunderstood. Soot converts classes into SootClasses automatically. Please have a look at the tutorials in the Wiki on Github. – Eric Jul 10 '17 at 13:14
  • I followed the tutorials in the Wiki on Github. First I tried to run Soot on command line by following the instructions at https://github.com/Sable/soot/wiki/Introduction:-Soot-as-a-command-line-tool . It is important to mention that I run Soot on Win7. When I type the given command `java -cp soot-2.5.0.jar soot.Main -cp . -process-dir ..\MyProject` I get a `Error loading java.util.regex.Pattern`. However, if I use it with `-pp`, then I get a `Could not load classfile: java.io.ObjectInputStream` and unfortunately I couldn't find a way to get over the issues. – Ekin Jul 11 '17 at 12:52
  • Also, if I achieve to fix this problem I planning to go through `dump-cfg`. – Ekin Jul 11 '17 at 12:55
  • I think it would be best to move the discussion to Soot's mailing list. There you will be able to get help faster on such issues. (and in fact, browsing the archive might answer many of your questions) – Eric Jul 12 '17 at 14:59
  • Thanks for the advice, I will move the discussion to Soot's mailing list. – Ekin Jul 13 '17 at 18:09