Skip to content

Commit

Permalink
multiple targets allowed
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Henderson <[email protected]>
  • Loading branch information
timtadh committed Oct 14, 2016
1 parent f480016 commit 2ba6169
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
11 changes: 9 additions & 2 deletions scripts/jpdg/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def shell_str(*args):
'class_dirs': [ 'shell_str' ],
'exclude_pkgs': [ 'shell_str' ],
'target': 'shell_str',
'targets': [ 'shell_str' ],
},
}
}
Expand Down Expand Up @@ -90,15 +91,21 @@ def annotate(self, conf, subject):
':'.join(subject['lib_jars']),
subject['classpath'],
))
targets = list()
if 'target' in subject:
targets.append(subject['target'])
else:
targets.extend(subject['targets'])
subject['jpdg_cmd'] = [
'java',
'-Xmx6g',
'-Xmx8g',
'-jar',
self.jpdg_jar,
'-c', subject['soot_classpath'],
'-b', subject['target'],
'-l', 'op',
]
for t in targets:
subject['jpdg_cmd'] += ['-d', t]
for ex_dir in subject['exclude_pkgs']:
subject['jpdg_cmd'] += ['-e', ex_dir]
return subject
Expand Down
26 changes: 17 additions & 9 deletions source/main/java/edu/cwru/jpdg/JPDG.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class JPDG {
public static void main(String[] argv) throws pDG_Builder.Error {
final Option helpOpt = new Option("h", "help", false, "print this message");
final Option outputOpt = new Option("o", "output", true, "output file location");
final Option baseOpt = new Option("b", "base-dir", true, "base directory to analyze");
final Option baseOpt = new Option("d", "dirs", true, "base directories to analyze");
final Option excludeOpt = new Option("e", "exclude", true, "exclude these directories");
final Option classOpt = new Option("c", "classpath", true, "classpath for soot");
final Option labelOpt = new Option("l", "label-type", true, "label type, valid choices are: expr-tree, inst");
Expand All @@ -93,7 +93,7 @@ public static void main(String[] argv) throws pDG_Builder.Error {
options.addOption(excludeOpt);

String cp = null;
String base_dir = null;
List<String> dirs = new ArrayList<String>();
String label_type = "expr-tree";
String output_file = null;
List<String> excluded = new ArrayList<String>();
Expand All @@ -107,13 +107,16 @@ public static void main(String[] argv) throws pDG_Builder.Error {
}

cp = line.getOptionValue(classOpt.getLongOpt());
base_dir = line.getOptionValue(baseOpt.getLongOpt());
String[] dir_arr = line.getOptionValues(baseOpt.getLongOpt());
label_type = line.getOptionValue(labelOpt.getLongOpt());
output_file = line.getOptionValue(outputOpt.getLongOpt());
String[] ex = line.getOptionValues(excludeOpt.getLongOpt());
if (ex != null) {
excluded = Arrays.asList(ex);
}
if (dir_arr != null) {
dirs = Arrays.asList(dir_arr);
}
} catch (final MissingOptionException e) {
System.err.println(e.getMessage());
Usage(options);
Expand All @@ -125,9 +128,6 @@ public static void main(String[] argv) throws pDG_Builder.Error {
System.exit(1);
}

List<String> dirs = new ArrayList<String>();
dirs.add(base_dir);

soot.Scene S = runSoot(cp, dirs, excluded);
writeGraph(build_PDG(S, excluded, label_type), output_file);
}
Expand Down Expand Up @@ -155,8 +155,13 @@ public static void configure_and_run_soot(soot.Scene S, Options O, String cp, Li
O.set_process_dir(dirs);
// O.set_exclude(excluded);
// O.set_no_bodies_for_excluded(true);
O.set_whole_program(true);
O.setPhaseOption("cg.spark", "enabled:true");
if (true) {
O.set_whole_program(true);
// O.setPhaseOption("cg.spark", "enabled:true");
O.setPhaseOption("cg.cha", "enabled:true");
O.setPhaseOption("cg.spark", "enabled:false");
O.setPhaseOption("cg.paddle", "enabled:false");
}
// O.setPhaseOption("wjtp", "enabled:true");
// O.setPhaseOption("wjtp.myTrans", "enabled:true");
// O.setPhaseOption("jop", "enabled:true");
Expand Down Expand Up @@ -201,7 +206,10 @@ public static Graph build_PDG(soot.Scene S, List<String> excluded, String label_
}
System.out.println("LABEL TYPE " + label_type + " " + lm);
soot.util.Chain<soot.SootClass> classes = S.getApplicationClasses();
CallGraph cg = S.getCallGraph();
CallGraph cg = null;
if (true) {
cg = S.getCallGraph();
}
return PDG_Builder.build(cg, lm, classes, excluded);
}

Expand Down
3 changes: 3 additions & 0 deletions source/main/java/edu/cwru/jpdg/pDG_Builder.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ void assign_uids() {
}

void add_call_edges(int src, soot.Unit to) {
if (cg == null) {
return;
}
for (Iterator<Edge> ie = cg.edgesOutOf(to); ie.hasNext(); ) {
Edge e = ie.next();
soot.SootMethod targ = e.getTgt().method();
Expand Down

0 comments on commit 2ba6169

Please sign in to comment.