[Soot-list] How to understand edgesInto()'s results
Fang Zhou
timchou.hit at gmail.com
Wed May 8 12:35:11 EDT 2019
Hi all,
Currently, I'm trying to know all possible calling functions for one
specific function.
I use CHATransformer() to generate the interprocedural callgraph. Then
use edgesInto to get the calling functions. However, I found the
specific function is called by itself.
Is there anything wrong in my code?
Thanks in advance.
Below is my code:
...
configureSoot(classPath);
SootClass sootClass = Scene.v().loadClassAndSupport(args[1]);
sootClass.setApplicationClass();
Scene.v().loadNecessaryClasses();
CHATransformer.v().transform();
CallGraph cg = Scene.v().getCallGraph();
sm =
Scene.v().getSootClass("org.apache.hadoop.conf.Configuration").getMethodByName("getInt");
Iterator sources = new Targets(cg.edgesInto(sm));
while (sources.hasNext()) {
SootMethod source = (SootMethod)sources.next();
System.out.println(sm + " is called by " + source);
}
...
private static void configureSoot(String classpath) {
Options.v().set_whole_program(true); // process whole program
Options.v().set_allow_phantom_refs(true); // load
phantom references
Options.v().set_prepend_classpath(true); // prepend class path
Options.v().set_src_prec(Options.src_prec_class); //
process only .class files
ArrayList<String> list = new ArrayList<>();
list.add(classpath);
//list.add("/mnt/git/hadoop-3.1.2-src/hadoop-common-project/hadoop-common/target/classes");
Options.v().set_process_dir(list); // process all
.class files in directory
Options.v().setPhaseOption("cg.spark", "on"); // use
spark for call graph
Options.v().set_output_dir("/tmp/sootOutput"); // use
spark for call graph
Options.v().set_keep_line_number(true);
}
The results are shown below:
.......
<org.apache.hadoop.conf.Configuration: int
getInt(java.lang.String,int)> is called by
<org.apache.hadoop.conf.Configuration: int
getInt(java.lang.String,int)>
<org.apache.hadoop.conf.Configuration: int
getInt(java.lang.String,int)> is called by
<org.apache.hadoop.conf.Configuration: int
getInt(java.lang.String,int)>
<org.apache.hadoop.conf.Configuration: int
getInt(java.lang.String,int)> is called by
<org.apache.hadoop.conf.Configuration: int
getInt(java.lang.String,int)>
<org.apache.hadoop.conf.Configuration: int
getInt(java.lang.String,int)> is called by
<org.apache.hadoop.conf.Configuration: int
getInt(java.lang.String,int)>
<org.apache.hadoop.conf.Configuration: int
getInt(java.lang.String,int)> is called by
<org.apache.hadoop.conf.Configuration: int
getInt(java.lang.String,int)>
.........
More information about the Soot-list
mailing list