Call Graph Construction
A call graph shows the method calling relationship of a program. It is a directed graph, whose nodes represent different methods, and edges represent caller -> callee relationship.
SootUp contains several call graph construction algorithms. Below, we show how you can use each of these.
Creating the Type Hierarchy
All the call graph construction algorithms require the view to access the type hierarchy for resolving method calls based of sub typing relationship.
Below, we show how to create a type hierarchy:
Defining an Entry Method
All call graph construction algorithms require an entry method to start with. In java application, you usually define the main method. However, it is possible to define arbitrary entry methods depending on your needs. Below, we show how to define such an entry method:
Class Hierarchy Analysis
Class Hierarchy Analysis (CHA) algorithm is the most sound call graph construction algorithm available in SootUp. It soundly includes all implementers of an interface, when resolving a method call on an interface.
You can construct a call graph with CHA as follows:
Rapid Type Analysis
Rapid Type Analysis (RTA) algorithm constructs a rather precise version of the call graph that the CHA constructs. It refines CHA by considering only the instantiated implementers of an interface, when resolving a method call on an interface.
You can construct a call graph with RTA as follows:
Qilin Pointer Analysis
Qilin builds a call graph on the fly with the pointer analysis.
You can construct a call graph with Qilin as follows:
==="SootUp"
| String MAINCLASS = "dacapo.antlr.Main"; // just an example
PTAPattern ptaPattern = new PTAPattern("insens"); // "2o"=>2OBJ, "1c"=>1CFA, etc.
PTA pta = PTAFactory.createPTA(ptaPattern, view, MAINCLASS);
pta.run();
CallGraph cg = pta.getCallGraph();
|