Soot is a product of the Sable Research Group from McGill University, analyze, instrument, optimize and visualize Java and Android applications. Here we use the tool for Data Flow Analysis on simple Java programs.
|
You can download the latest version of Soot from their website . I recommend downloading the latest nightly build since the latest release version is over 5 years old. Read the tutorial on their github wiki on how to use it. Get familiar with using Soot as a command line tool. Learn what the command line options mean; we would especially be using the options -cp, -pp, -w, -src-prec, -main-class, -f, and -d. You can run Soot on the command line as:
java -cp soot.jar soot.Main -cp path/to/test/class -pp -w -f J test_classThis would convert the test class to a Jimple file (due to the -f J option) and put it in a directory called sootOutput. You can convert to other output formats using the -f option and select the output directory with -d. Run your own test cases to make sure Soot is working. Depending on your OS, version of Soot, and version of Java tyou may need to some modifications. If you are experiencing errors try updating to the latest nightly build of Soot (present on the Soot homepage ), and to the latest version of Java.
Soot provides FlowAnalysis classes for fixed-point computation of static data flow analysis (using the worklist algorithm). Ther are classes for ForwardFlowAnalysis and BackwardFlowAnalysis depending on what kind of analysis is required. We can create a new class for data flow analysis by extending any of these class and filling in the approrpiate methods:
Look into the detailed description of intraprocedural data flow analysis on the github wiki.
A variable is live at a program point if its value may be read later in some execution of the program. Live Variable Analysis is useful in compiler optimizations such as dead code elimination. Implement Live Variable Analysis using Soot and run it on some examples.
Upwards exposed uses serves a similar purpose to reaching definitions analysis. Instead of finding which definitions reach each point, we find which uses of a variable have not yet been matched with one or more definitions. Given a control flow graph the use of the variable x at vertex v is upwards exposed at a vertex u if x is read at v,and there exists a path from u to v along which which no vertex assigns to x.
[Complete Problem] [Base Code]
[ << Prev ] | [ Next >> ] |