Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
swissiety committed Jun 18, 2024
1 parent 31d52bf commit 9f67b34
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 33 deletions.
9 changes: 4 additions & 5 deletions docs/bodyinterceptors.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,23 @@ The "raw" generated Jimple from the Bytecodefrontend needs a lot improvements -
- The Locals we get from the Java bytecode are typically untyped. Therefore we have to augment the Local types which is done by the TypeAssigner.
- t.b.c.

Method scoped optimisations:
Optimizations (method scope)

- ConditionalBranchFolder: removes tautologic ifs that are always true/false - if we can determine it in the scope of the method.
- EmptySwitchEliminator: removes switches that are not really switching
- ConstantPropagatorAndFolder: calculates constant values before runtime
- CastAndReturnInliner: Removes merging flows to a single return
- UnreachableCodeEliminator: speaks for itself.
- TrapTightener

Make Local names standardized:
Standardize Jimple appearance

- LocalNameStandardizer: numbers Locals with the scheme: type-initial + number of type occurence

!!! info "Soot Equivalent"

[BodyTransformer](https://github.com/soot-oss/soot/blob/develop/src/main/java/soot/BodyTransformer.java)


Below, we show how these BodyInterceptors work for the users who are interested in their internal workings.

### LocalSplitter

LocalSplitter is a<code>BodyInterceptor</code>that attempts to identify and separate uses of a local variable (as definition) that are independent of each other by renaming local variables.
Expand Down
7 changes: 4 additions & 3 deletions docs/builtin-analyses.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 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>.

Expand All @@ -10,7 +11,7 @@ Example:

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.

Expand Down
11 changes: 7 additions & 4 deletions docs/callgraphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Below, we show how to create a type hierarchy:
=== "SootUp"

```java
String cpString = "src/test/resources/Callgraph/binary";
List<AnalysisInputLocation> inputLocations = new ArrayList();
inputLocations.add(new JavaClassPathAnalysisInputLocation("src/test/resources/Callgraph/binary"));
inputLocations.add(new JavaClassPathAnalysisInputLocation(cpStr));
inputLocations.add(new DefaultRTJarAnalysisInputLocation());

JavaView view = new JavaView(inputLocations);
Expand Down Expand Up @@ -61,7 +62,9 @@ All the call graph construction algorithms require an entry method to start with
=== "SootUp (alternative)"

```java
MethodSignature entryMethodSignature = view.getIdentifierFactory().parseMethodSignature("<packageNameA.A: void calc(packageNameA.A)"));
String methodSigStr = "<packageNameA.A: void calc(packageNameA.A)";
MethodSignature entryMethodSignature = view
.getIdentifierFactory().parseMethodSignature(methodSigStr));
```

=== "Soot"
Expand Down Expand Up @@ -139,9 +142,9 @@ You can construct a call graph with RTA as follows:
Variable Type Analysis (VTA) algorithm further refines the call graph that the RTA constructs. It refines RTA by considering only the assigned instantiations of the implementers of an interface, when resolving a method call on an interface.
When considering assignments, we usually need to consider **pointer** (points-to) relationship.

!!! info
!!! info "WIP"

VTA algorithm was implemented using the [Spark](https://plg.uwaterloo.ca/~olhotak/pubs/thesis-olhotak-msc.pdf) pointer analysis framework.
VTA algorithm will be implemented using the [Spark](https://plg.uwaterloo.ca/~olhotak/pubs/thesis-olhotak-msc.pdf) pointer analysis framework.
A reimplementation of Spark in SootUp is currently under development.

Spark requires an initial call graph to begin with. You can use one of the call graphs that we have constructed above. You can construct a call graph with VTA as follows:
Expand Down
25 changes: 16 additions & 9 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# SootUp Example projects
Example code to help getting start with SootUp
Here we will provide some examples that uses SootUp to provide insights about a Java program.
The Examples can be cloned or downloaded from our [Example Repository](https://github.com/soot-oss/SootUp-Examples.git).
Some examples that use SootUp to get insights about a Java program.

- BasicSetupExample
- BodyInterceptorExample
- CallGraphExample
- ClassHierarchyExample
- MutatingSootClassExample
- Basic setup [Example](https://github.com/soot-oss/SootUp-Examples/blob/main/BasicSetupExample/src/main/java/sootup/examples/BasicSetup.java)
- Configure a BodyInterceptor [Example](https://github.com/soot-oss/SootUp-Examples/blob/main/BodyInterceptorExample/src/main/java/sootup/examples/BodyInterceptor.java)
- CallGraph [Example](https://github.com/soot-oss/SootUp-Examples/blob/main/CallgraphExample/src/main/java/sootup/examples/CallgraphExample.java)
- Class Hierarchy Algoritm [Example](https://github.com/soot-oss/SootUp-Examples/blob/main/ClassHierarchyExample/src/main/java/sootup/examples/ClassHierarchy.java)
- Replace a SootMethod of a SootClass [Example](https://github.com/soot-oss/SootUp-Examples/blob/main/MutatingSootClassExample/src/main/java/sootup/examples/MutatingSootClass.java)


!!! info "Download"
The Examples can be cloned or downloaded from our [Example Repository](https://github.com/soot-oss/SootUp-Examples.git).



<!--
We have included all the five projects in 5 different branches under SootUp-Examples with detailed explanation about the project.
### BasicSetupExample
Expand Down Expand Up @@ -81,4 +86,6 @@ We have included all the five projects in 5 different branches under SootUp-Exam
8. THen we are checking and retrieving the class and method.
9. Then we retrives the existing body of the method and prints it. Then we create a new local variable to add it copy to the method body.
10. Then we are overriding the method body and class. ie this lines creates new sources that overrides teh original method body and class. It replaces the old method in the class with the new method having the modified body.
11. Prints the modified method body and checks if the new local variable (newLocal) exists in the modified method. Depending on the result, it prints a corresponding message.
11. Prints the modified method body and checks if the new local variable (newLocal) exists in the modified method. Depending on the result, it prints a corresponding message.
-->
6 changes: 4 additions & 2 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ or create a convenient link with the exported stmtgraph as HTTP GET Parameter
DotExporter.createUrlToWebeditor( stmtgraph );
```

### The Sourcecodefrontend...
is in a experimental state! If you wish to use it, please consider to contribute.

### Is there a way to use code exploration and syntax highlighting features in my IDE for .jimple files?
Try [JimpeLsp](https://github.com/swissiety/JimpleLsp).
Try [JimpeLsp](https://github.com/swissiety/JimpleLsp) or the [vscode plugin](https://marketplace.visualstudio.com/items?itemName=swissiety.jimplelsp)

### Is there a way to use syntax highlighting of .jimple in my paper, thesis, ...?
Have a look at [LspLexer4Pygments](https://github.com/swissiety/LspLexer4Pygments).
Have a look at [LspLexer4Pygments](https://github.com/swissiety/LspLexer4Pygments). Its the same syntax highlighting you see here in the documentation. You can export it to LaTex as well.

### How to ... add an entry in this list? i.e. Your question is not answered here?
Feel free to start a [Discussion](https://github.com/soot-oss/SootUp/discussions).
Expand Down
3 changes: 1 addition & 2 deletions docs/jimple.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Therefore, Jimple aims to bring the best of both worlds, a non-stack-based and f
For this purpose Jimple was designed as a representation of JVM bytecode which is human readable.

!!! info

To learn more about jimple, refer to the [thesis](https://courses.cs.washington.edu/courses/cse501/01wi/project/sable-thesis.pdf) by Raja Vallee-Rai.
To learn more about jimple, refer to the [thesis](https://courses.cs.washington.edu/courses/cse501/01wi/project/sable-thesis.pdf) by Raja Vallee-Rai.


Lets have a look at the following Jimple code representing Java code of a `HelloWorld` class.
Expand Down
14 changes: 6 additions & 8 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ nav:
- Examples: examples.md
- Configure your Inputs: analysisinputlocations.md

- Basics I:
- Basics:
- Jimple IR: jimple.md
- Jimple Body: jimple-body.md
- Jimple Statements: jimple-stmts.md
- Jimple Types: jimple-types.md
- Jimple Values: jimple-values.md

- Basics II:
- Advanced Topics:
- BodyInterceptors: bodyinterceptors.md
- Callgraphs: callgraphs.md
- BuiltIn Analyses: builtin-analyses.md
Expand All @@ -31,12 +31,10 @@ nav:
# - Implement an AnalysisTool: write_analysis_tool.md
# - From Prototype to Tool: tool_setup.md

- Misc:
- Announcements: announcement.md
- Design Decisions: whatsnew.md
- Migration Help: migrating.md

- More information:
- Misc & More information:
- Announcements: announcement.md
- Design Decisions: whatsnew.md
- Migration Help: migrating.md
- Latest Javadoc: /SootUp/apidocs
- Troubleshooting & FAQ: faq.md
# - Based on SootUp: tools.md
Expand Down

0 comments on commit 9f67b34

Please sign in to comment.