Skip to content

Commit 0da5353

Browse files
author
Ra
committed
Split maven projects into modules: seep-system, seep-java2sdg
1 parent 8f1d90f commit 0da5353

File tree

372 files changed

+3461
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

372 files changed

+3461
-4
lines changed
6.01 MB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>soot</groupId>
6+
<artifactId>soot-framework</artifactId>
7+
<version>2.5.0</version>
8+
<description>POM was created from install:install-file</description>
9+
</project>

pom.xml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
3-
<groupId>uk.ac.imperial.lsds.seep-system</groupId>
4-
<artifactId>seep-system</artifactId>
4+
<groupId>uk.ac.imperial.lsds.seep</groupId>
5+
<artifactId>seep</artifactId>
6+
<packaging>pom</packaging>
57
<name>seep</name>
68
<version>0.0.1-SNAPSHOT</version>
79
<repositories>
@@ -13,6 +15,12 @@
1315
<name>Maven Repository Switchboard</name>
1416
<url>http://repo1.maven.org/maven2</url>
1517
</repository>
18+
<!-- Local repo for external jars -->
19+
<repository>
20+
<id>uk.ac.imperial.lsds.seep-system</id>
21+
<name>seep-inprojectrepo</name>
22+
<url>file://${project.basedir}/libs</url>
23+
</repository>
1624
</repositories>
1725
<pluginRepositories>
1826
<pluginRepository>
@@ -28,6 +36,11 @@
2836
</pluginRepository>
2937
</pluginRepositories>
3038

39+
<modules>
40+
<module>seep-system</module>
41+
<module>seep-java2sdg</module>
42+
</modules>
43+
3144
<dependencies>
3245
<dependency>
3346
<groupId>com.esotericsoftware.kryo</groupId>
@@ -86,6 +99,7 @@
8699
</dependency>
87100

88101
<!-- Dependencies for tests -->
102+
89103
<dependency>
90104
<groupId>junit</groupId>
91105
<artifactId>junit</artifactId>
@@ -110,6 +124,19 @@
110124
<version>1.9.5</version>
111125
<scope>test</scope>
112126
</dependency>
127+
128+
<!-- Dependencies for java2sdg -->
129+
130+
<dependency>
131+
<groupId>soot</groupId>
132+
<artifactId>soot-framework</artifactId>
133+
<version>2.5.0</version>
134+
</dependency>
135+
<dependency>
136+
<groupId>javassist</groupId>
137+
<artifactId>javassist</artifactId>
138+
<version>3.12.1.GA</version>
139+
</dependency>
113140
</dependencies>
114141

115142
<url>http://lsds.doc.ic.ac.uk/projects/SEEP</url>
@@ -187,4 +214,4 @@
187214
</plugin>
188215
</plugins>
189216
</build>
190-
</project>
217+
</project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Tue Apr 01 18:42:24 BST 2014
2+
eclipse.preferences.version=1
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4+
org.eclipse.jdt.core.compiler.compliance=1.7
5+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
6+
org.eclipse.jdt.core.compiler.source=1.7
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Tue Apr 01 18:42:23 BST 2014
2+
activeProfiles=
3+
eclipse.preferences.version=1
4+
fullBuildGoals=process-test-resources
5+
resolveWorkspaceProjects=true
6+
resourceFilterGoals=process-resources resources\:testResources
7+
skipCompilerPlugin=true
8+
version=1

seep-java2sdg/pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<artifactId>seep</artifactId>
7+
<groupId>uk.ac.imperial.lsds.seep</groupId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
</parent>
10+
<groupId>uk.ac.imperial.lsds.seep</groupId>
11+
<artifactId>seep-java2sdg</artifactId>
12+
<version>0.0.1-SNAPSHOT</version>
13+
<name>seep-java2sdg</name>
14+
<url>http://maven.apache.org</url>
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
</properties>
18+
<dependencies>
19+
<dependency>
20+
<groupId>junit</groupId>
21+
<artifactId>junit</artifactId>
22+
<version>3.8.1</version>
23+
<scope>test</scope>
24+
</dependency>
25+
</dependencies>
26+
</project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package uk.ac.imperial.lsds.java2sdg;
2+
3+
public class ComputeCallGraph {
4+
// PhaseOptions.v().setPhaseOption("cg", "on"); // Construct a call graph
5+
// PhaseOptions.v().setPhaseOption("wjtp", "on"); // jimple transformation pack
6+
// PhaseOptions.v().setPhaseOption("wjap", "on"); // jimple annotation pack
7+
//PhaseOptions.v().setPhaseOption("wjop", "on"); // jimple optimization pack
8+
// PhaseOptions.v().setPhaseOption("tag.fieldrw", "on"); // tag read/write access to fields
9+
// PhaseOptions.v().setPhaseOption("jap.fieldrw", "on"); // process read/write access to fields
10+
11+
// Scene.v().addBasicClass("java.lang.Object", SootClass.BODIES);
12+
// Scene.v().addBasicClass("java.util.HashMap", SootClass.BODIES);
13+
// Scene.v().addBasicClass("java.util.AbstractMap", SootClass.BODIES);
14+
15+
// String arguments[] = {"-allow-phantom-refs", "-w", "-app", // whole program analysis and ignore missing classes
16+
// "-p", "cg.spark", "enabled", "-annot-side-effect", //stuff to annotate file with fieldRW
17+
// "-print-tags-in-output", "-f", "J", className}; // output in jimple and print tags
18+
// soot.Main.main(arguments);
19+
//
20+
// CallGraph cg = Scene.v().getCallGraph();
21+
22+
// System.out.println("CALL GRAPH");
23+
//
24+
// Iterator<MethodOrMethodContext> methods = cg.sourceMethods();
25+
// while(methods.hasNext()){
26+
// MethodOrMethodContext current = methods.next();
27+
// String decl = current.method().getName();
28+
//// System.out.println(decl);
29+
// if(decl.equals("simpleReadAndWriteState")){
30+
// System.out.println("MATCH");
31+
// System.out.println(current.method().toString());
32+
// List<Tag> tags = current.method().getTags();
33+
// Iterator<Tag> iTags = tags.iterator();
34+
// while(iTags.hasNext()){
35+
// Tag t = iTags.next();
36+
// System.out.println(t.getName()+": "+t.toString());
37+
// }
38+
// System.out.println(current.method().getTag("FieldReadTag"));
39+
// }
40+
//
41+
//// System.out.println();
42+
// }
43+
44+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
package uk.ac.imperial.lsds.java2sdg;
2+
3+
import java.util.Iterator;
4+
import java.util.List;
5+
import java.util.Map;
6+
import java.util.logging.Logger;
7+
8+
import soot.CompilationDeathException;
9+
import soot.PhaseOptions;
10+
import soot.Scene;
11+
import soot.SootClass;
12+
import soot.SootField;
13+
import soot.SootMethod;
14+
import soot.options.Options;
15+
import soot.toolkits.graph.UnitGraph;
16+
import soot.util.Chain;
17+
import uk.ac.imperial.lsds.java2sdg.bricks.InternalStateRepr;
18+
import uk.ac.imperial.lsds.java2sdg.bricks.SDG.OperatorBlock;
19+
import uk.ac.imperial.lsds.java2sdg.bricks.SDG.PartialSDGBuilder;
20+
import uk.ac.imperial.lsds.java2sdg.bricks.SDG.SDGBuilder;
21+
import uk.ac.imperial.lsds.java2sdg.bricks.TaskElement.TaskElementBuilder;
22+
import uk.ac.imperial.lsds.java2sdg.flowanalysis.LiveVariableAnalysis;
23+
import uk.ac.imperial.lsds.java2sdg.flowanalysis.TEBoundaryAnalysis;
24+
import uk.ac.imperial.lsds.java2sdg.input.SourceCodeHandler;
25+
import uk.ac.imperial.lsds.java2sdg.output.DOTExporter;
26+
27+
public class Main {
28+
29+
private final static Logger log = Logger.getLogger(Main.class.getCanonicalName());
30+
31+
public static void main(String args[]){
32+
33+
// Parsing input parameters
34+
String pathToDriverFile = null;
35+
String pathToSeepJar = null;
36+
String className = null;
37+
if(args.length < 3){
38+
System.out.println("USAGE: java2sdg <pathToClass> <pathToSEEP.jar> <ClassName>");
39+
System.exit(0);
40+
}
41+
else{
42+
pathToDriverFile = args[0];
43+
pathToSeepJar = args[1];
44+
className = args[2];
45+
}
46+
47+
// Get java.home to access rt.jar, required by soot
48+
String javaHome = System.getProperty("java.home");
49+
// String sootClassPath = javaHome+"/lib/rt.jar:"+pathToDriverFile+":"+pathToSeepJar;
50+
String sootClassPath = javaHome+"/lib/rt.jar:"+pathToSeepJar+":./";
51+
String pathToSourceCode = pathToDriverFile+"/"+className;
52+
53+
// Parse original source code
54+
log.info("Parsing source code...");
55+
SourceCodeHandler sch = SourceCodeHandler.getInstance(pathToSourceCode);
56+
log.info("Parsing source code...OK");
57+
58+
// With the class loaded, we can then get the SootClass wrapper to work with
59+
log.info("-> Setting soot classpath: "+sootClassPath);
60+
Scene.v().setSootClassPath(sootClassPath);
61+
Options.v().setPhaseOption("jb", "preserve-source-annotations");
62+
log.info("-> Loading class...");
63+
SootClass c = null;
64+
try{
65+
System.out.println();
66+
System.out.println();
67+
System.out.println();
68+
// className = "UT3.java";
69+
c = Scene.v().loadClassAndSupport(className);
70+
c.setApplicationClass();
71+
}
72+
catch(CompilationDeathException cde){
73+
System.out.println();
74+
System.out.println();
75+
System.out.println();
76+
log.severe(cde.getMessage());
77+
System.exit(1);
78+
}
79+
log.info("-> Loading class...OK");
80+
81+
PhaseOptions.v().setPhaseOption("tag.ln", "on"); // tell compiler to include line numbers
82+
83+
// List fields and indicate which one is state
84+
log.info("Extracting state information...");
85+
Chain<SootField> fields = c.getFields();
86+
Iterator<SootField> fieldsIterator = fields.iterator();
87+
Map<String, InternalStateRepr> stateElements = Util.extractStateInformation(fieldsIterator);
88+
log.info("Extracting state information...OK");
89+
90+
// List relevant methods (the ones that need to be analyzed)
91+
log.info("-> Extracting workflows...");
92+
Iterator<SootMethod> methodIterator = c.methodIterator();
93+
List<String> workflows = Util.extractWorkflows(methodIterator, c);
94+
log.info("-> Extracting workflows...OK");
95+
96+
//TODO: Insert a module here that checks for illegal programs (lower level than only parsing source code)
97+
98+
SDGBuilder sdgBuilder = new SDGBuilder();
99+
int workflowId = 0;
100+
// Analyse and extract a partial SDG per workflow
101+
for(String methodName : workflows){
102+
// Build CFG
103+
log.info("Building partialSDG for workflow: "+methodName);
104+
UnitGraph cfg = Util.getCFGForMethod(methodName, c); // get cfg
105+
// Perform live variable analysis
106+
LiveVariableAnalysis lva = LiveVariableAnalysis.getInstance(cfg); //compute livevariables
107+
// Perform TE boundary analysis
108+
TEBoundaryAnalysis oba = TEBoundaryAnalysis.getBoundaryAnalyzer(cfg, stateElements, sch, lva);
109+
List<TaskElementBuilder> sequentialTEList = oba.performTEAnalysis();
110+
List<OperatorBlock> partialSDG = PartialSDGBuilder.buildPartialSDG(sequentialTEList, workflowId);
111+
for(OperatorBlock ob : partialSDG){
112+
System.out.println(ob);
113+
}
114+
workflowId++;
115+
sdgBuilder.addPartialSDG(partialSDG);
116+
}
117+
log.info("Building SDG from "+sdgBuilder.getNumberOfPartialSDGs()+" partialSDGs...");
118+
List<OperatorBlock> sdg = sdgBuilder.synthetizeSDG();
119+
for(OperatorBlock ob : sdg){
120+
System.out.println(ob);
121+
}
122+
log.info("Building SDG from partialSDGs...OK");
123+
// Export SDG to dot
124+
log.info("Exporting SDG to DOT file...");
125+
DOTExporter exporter = DOTExporter.getInstance();
126+
exporter.export(sdg, "test");
127+
log.info("Exporting SDG to DOT file...OK");
128+
//Set<TaskElement> sdg = SDGAssembler.getSDG(oba, lva, sch);
129+
//
130+
//// SDGAssembler sdgAssembler = new SDGAssembler();
131+
//// Set<OperatorBlock> sdg = sdgAssembler.getFakeLinearPipelineOfStatelessOperators(1);
132+
//
133+
// QueryBuilder qBuilder = new QueryBuilder();
134+
// String q = qBuilder.generateQueryPlanDriver(sdg);
135+
// System.out.println("QueryPlan: "+q);
136+
// qBuilder.buildAndPackageQuery();
137+
}
138+
}

0 commit comments

Comments
 (0)