Skip to content

Commit

Permalink
Add driver for building indirection-bounded call graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Jul 12, 2024
1 parent bf03ded commit 34bc18c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ jar {

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
def walaVersion = '1.6.4'
def walaVersion = '1.6.5'

implementation "com.ibm.wala:com.ibm.wala.shrike:${walaVersion}"
implementation "com.ibm.wala:com.ibm.wala.util:${walaVersion}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.ibm.wala.examples.drivers;

import com.ibm.wala.cast.js.callgraph.fieldbased.FieldBasedCallGraphBuilder;
import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
import com.ibm.wala.cast.js.util.CallGraph2JSON;
import com.ibm.wala.cast.js.util.FieldBasedCGUtil;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.CallGraphStats;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.NullProgressMonitor;
import com.ibm.wala.util.WalaException;

import java.io.IOException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;

public class BoundedJSCallGraphDriver {

/**
* Driver for building indirection-bounded approximate call graphs.
*
* Usage: BoundedJSCallGraphDriver script_directory bound
*/
public static void main(String[] args)
throws IllegalArgumentException, IOException, CancelException, WalaException {
Path scriptDir = Paths.get(args[0]);
int bound = Integer.parseInt(args[1]);
FieldBasedCGUtil f = new FieldBasedCGUtil(new CAstRhinoTranslatorFactory());
FieldBasedCallGraphBuilder.CallGraphResult results =
f.buildScriptDirBoundedCG(scriptDir, new NullProgressMonitor(), false, bound);
CallGraph CG = results.getCallGraph();
System.out.println(CallGraphStats.getStats(CG));
System.out.println((new CallGraph2JSON()).serialize(CG));
}
}

0 comments on commit 34bc18c

Please sign in to comment.