-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into feature/InvokesCG
# Conflicts: # sootup.callgraph/src/main/java/sootup/callgraph/RapidTypeAnalysisAlgorithm.java # sootup.core/src/main/java/sootup/core/jimple/common/expr/JNewMultiArrayExpr.java # sootup.tests/pom.xml
- Loading branch information
Showing
472 changed files
with
37,586 additions
and
2,608 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
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,147 @@ | ||
# Analysis Input | ||
i.e. What should be analyzed. An `AnalysisInputLocation` points to code input SootUp can analyze. | ||
We ship multiple Implementations that can handle different input. | ||
|
||
Additionally you can specify a SourceType. This determines what is considered e.g. in the CallGraphs generation. | ||
Further you can specify a List of [BodyInterceptors](bodyinterceptors.md), which will optimize the raw Jimple IR that was transformed from the input. | ||
|
||
### Java Runtime | ||
#### Java <=8 | ||
The `DefaultRTJaAnalysisInputLocation` points to the rt.jar of the executing JVM. | ||
|
||
|
||
```java | ||
AnalysisInputLocation inputLocation = new DefaultRTJaAnalysisInputLocation(); | ||
JavaView view = new JavaView(inputLocation); | ||
``` | ||
|
||
To include a different Java Runtime library point to any rt.jar via a `JavaClassPathAnalysisInputLocation` as its a usual .jar file. | ||
|
||
#### Java >=9 | ||
The `JRTFilesystemAnalysisInputLocation` points to the jigsawed java runtime of the executing JVM. | ||
|
||
```java | ||
AnalysisInputLocation inputLocation = new JrtFileSystemAnalysisInputLocation(); | ||
JavaView view = new JavaView(inputLocation); | ||
``` | ||
|
||
|
||
!!! info "If you have errors like Java.lang.String, Java.lang.Object, ... you are most likely missing this AnalysisInputLocation." | ||
|
||
### Java Bytecode | ||
File-Extensions: `.class, .jar, .war` | ||
|
||
The `JavaClassPathAnalysisInputLocation` is the equivalent of the classpath you would pass to the java executable i.e. point to root(s) of package(s). | ||
|
||
=== "Directory" | ||
```java | ||
AnalysisInputLocation inputLocation = | ||
new JavaClassPathAnalysisInputLocation("target/"); // points to | ||
JavaView view = new JavaView(inputLocation); | ||
``` | ||
|
||
=== ".jar File" | ||
```java | ||
AnalysisInputLocation inputLocation = new JavaClassPathAnalysisInputLocation("myCode.jar"); | ||
JavaView view1 = new JavaView(inputLocation); | ||
|
||
// if you want to analyze a specific language level of a multi release jar | ||
AnalysisInputLocation inputLocation = | ||
new MultiReleaseJarAnalysisInputLocation("myCode.jar", new JavaLanguage(10) ); | ||
JavaView view2 = new JavaView(inputLocation); | ||
``` | ||
|
||
=== ".class File" | ||
```java | ||
// if you omit the package structure while pointing to a file, | ||
// you have to pass the omitted directories as a parameter | ||
AnalysisInputLocation inputLocation = new PathBasedAnalysisInputLocation. | ||
ClassFileBasedAnalysisInputLocation("Banana.class", "packageName.subPackage", SourceType.Application); | ||
JavaView view = new JavaView(inputLocation); | ||
``` | ||
|
||
=== "Complete class path" | ||
```java | ||
String cp = "myCode.jar" + File.pathSeparator + "dependency.jar" + File.pathSeparator + "target/classes/"; | ||
AnalysisInputLocation inputLocation = new JavaClassPathAnalysisInputLocation(cp); | ||
JavaView view = new JavaView(inputLocation); | ||
``` | ||
|
||
### Java Sourcecode | ||
File-Extensions: `.java` | ||
|
||
With the `OTFCompileAnalysisInputLocation` you can point directly to .java files or pass a String with Java sourcecode. | ||
The AnalysisInputLocation delegates the data to the `JavaCompiler` and transform the bytecode from the compiler to Jimple. | ||
|
||
=== "Single File" | ||
```java | ||
AnalysisInputLocation inputLocation = new OTFCompileAnalysisInputLocation("Banana.java"); | ||
JavaView view = new JavaView(inputLocation); | ||
``` | ||
|
||
=== "Multiple Files" | ||
```java | ||
List<Path> files = Arrays.asList(Paths.get("Apple.java"), Paths.get("Banana.java")); | ||
AnalysisInputLocation inputLocation = new OTFCompileAnalysisInputLocation(files); | ||
JavaView view = new JavaView(inputLocation); | ||
``` | ||
=== "File as String" | ||
```java | ||
String content = "public class B{ }"; | ||
AnalysisInputLocation location = new OTFCompileAnalysisInputLocation("B.java", content ); | ||
JavaView view = new JavaView(location); | ||
``` | ||
|
||
`JavaSourcePathInputLocation` [***experimental!***]{Has huge problems with exceptional flow!} - points to a directory that is the root source directory (containing the package directory structure). | ||
|
||
### Jimple | ||
File-Extensions: `.jimple` | ||
|
||
The `JimpleAnalysisInputLocation` needs a Path to a .jimple file or a directory. | ||
|
||
```java | ||
Path path = Paths.get("Banana.java"); | ||
AnalysisInputLocation jimpleLocation = new JimpleAnalysisInputLocation(path); | ||
JavaView view = new JavaView(jimpleLocation); | ||
``` | ||
|
||
|
||
### Android Bytecode | ||
File-Extensions: `.apk` | ||
|
||
The `ApkAnalysisInputLocation` currently uses dex2jar internally | ||
|
||
```java | ||
Path path = Paths.get("Banana.apk"); | ||
AnalysisInputLocation inputLocation = new ApkAnalysisInputLocation(path); | ||
JavaView view = new JavaView(inputLocation); | ||
``` | ||
|
||
!!! info "A SootUp solution to directly generate Jimple is WIP!" | ||
|
||
|
||
### Combining Multiple AnalysisInputLocations | ||
But what if I want to point to multiple AnalysisInputLocations? | ||
|
||
```java | ||
AnalysisInputLocation mainJar = new JavaClassPathAnalysisInputLocation("myCode.jar"); | ||
AnalysisInputLocation jarA = new JavaClassPathAnalysisInputLocation("dependencyA.jar"); | ||
AnalysisInputLocation jarB = new JavaClassPathAnalysisInputLocation("dependencyB.jar"); | ||
|
||
List<AnalysisInputLocation> inputlocationList = Arrays.asList(mainJar, jarA, jarB); | ||
|
||
JavaView view = new JavaView(inputlocationList); | ||
``` | ||
!!! note "Of course you can combine different types of `AnalysisInputLocation`s as well!" | ||
|
||
|
||
### Maven Project as Analysis Input in SootUp | ||
This uses `#!shell mvn compile` + `JavaClassPathAnalysisInputLocation` under the hood to include a maven project. | ||
```java | ||
TODO: let the code sail with the upstream boat to this doc. | ||
``` | ||
|
||
Unfortunately its harder to extract the path of the binary result of Gradle projects in a unified way for all kinds of models - If you have a solution are looking forward to merge your contribution :-). | ||
|
||
### Java cli arguments to configure SootUp | ||
We created a [Utility](tool_setup.md) that parses a String of java command line arguments and configures SootUp respectively. |
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
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
# Functionalities and Utilities | ||
# BuiltIn Analyses | ||
More to come! | ||
|
||
#### LocalLivenessAnalyser | ||
### LocalLivenessAnalyser | ||
|
||
LocalLivenessAnalyser is used for querying for the list of live local variables before and after a given <code>Stmt</code>. | ||
|
||
Example: | ||
|
||
![LocalLiveness Example](./figures/LocalLiveness%20Example.png) | ||
![LocalLiveness Example](assets/figures/LocalLiveness%20Example.png) | ||
|
||
The live local variables before and after each <code>Stmt</code> will be calculated after generating an instance of LocalLivenessAnalyser as shown the example above. They can be queried by using the methods <code>getLiveLocalsBeforeStmt</code> and <code>getLiveLocalsAfterStmt</code>. | ||
|
||
#### DominanceFinder | ||
### DominanceFinder | ||
|
||
DomianceFinder is used for querying for the immediate dominator and dominance frontiers for a given basic block. | ||
|
||
Example: ![DominanceFinder Example](figures/DominanceFinder%20Example.png) | ||
Example: ![DominanceFinder Example](assets/figures/DominanceFinder%20Example.png) | ||
|
||
After generating an instance of DominanceFinder for a <code>BlockGraph</code>, we will get the immediate dominator and dominance frontiers for each basic block. The both properties can be queried by using the methods<code>getImmediateDominator</code>and<code>getDominanceFrontiers</code>. |
Oops, something went wrong.