-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
170 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ target/ | |
/SootFXPy/venv/ | ||
assets | ||
eval | ||
input | ||
output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
methodFeatureInclusion: | ||
- MethodAssignStmtCount | ||
#methodFeatureInclusion: | ||
# - MethodAssignStmtCount | ||
wholeProgFeatureInclusion: | ||
- WholeProgramAPICallCount | ||
featureResources: | ||
- {featureName: "WholeProgramAPICallCount", resourcePath: "./input/methods.txt"} | ||
#methodFeatureExclusion: | ||
# - MethodBranchCountK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package api; | ||
|
||
public class FeatureResource { | ||
|
||
private String featureName; | ||
private String resourcePath; | ||
|
||
public String getFeatureName() { | ||
return featureName; | ||
} | ||
|
||
public void setFeatureName(String featureName) { | ||
this.featureName = featureName; | ||
} | ||
|
||
public String getResourcePath() { | ||
return resourcePath; | ||
} | ||
|
||
public void setResourcePath(String resourcePath) { | ||
this.resourcePath = resourcePath; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/core/fx/wholeprogrambased/WholeProgramAPICallCount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package core.fx.wholeprogrambased; | ||
|
||
import com.google.common.collect.Streams; | ||
import core.fx.base.Feature; | ||
import core.fx.base.WholeProgramFEU; | ||
import resource.FileConnector; | ||
import soot.SootMethod; | ||
import soot.jimple.toolkits.callgraph.CallGraph; | ||
import soot.jimple.toolkits.callgraph.Edge; | ||
|
||
import java.util.*; | ||
import java.util.stream.Stream; | ||
|
||
public class WholeProgramAPICallCount implements WholeProgramFEU<Map<String, Long>> { | ||
|
||
private List<String> methodSignatures; | ||
|
||
public WholeProgramAPICallCount(String resourcePath) { | ||
this.methodSignatures = FileConnector.getMethodSignatures(resourcePath); | ||
} | ||
|
||
@Override | ||
public Feature<Map<String, Long>> extract(CallGraph target) { | ||
Iterator<Edge> iterator = target.iterator(); | ||
Map<String, Long> methodCount = new HashMap<>(); | ||
Stream<Edge> stream = Streams.stream(iterator); | ||
stream.forEach(e-> { | ||
if(methodSignatures.contains(e.tgt().getSignature())){ | ||
if(methodCount.containsKey(e.tgt().getSignature())){ | ||
Long count = methodCount.get(e.tgt().getSignature()); | ||
methodCount.put(e.tgt().getSignature(), ++count); | ||
}else{ | ||
methodCount.put(e.tgt().getSignature(), 1L); | ||
} | ||
} | ||
System.out.println(e.tgt()); | ||
}); | ||
return new Feature<>(this.getClass().getSimpleName(), methodCount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package resource; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public class FileConnector { | ||
|
||
public static List<String> getMethodSignatures(String path){ | ||
List<String> result = null; | ||
try (Stream<String> lines = Files.lines(Paths.get(path))) { | ||
result = lines.collect(Collectors.toList()); | ||
}catch (IOException e){ | ||
e.printStackTrace(); | ||
} | ||
return result; | ||
} | ||
|
||
} |