Spring 2016 Program Analysis and Verification

Slides:



Advertisements
Similar presentations
Dataflow Analysis for Datarace-Free Programs (ESOP 11) Arnab De Joint work with Deepak DSouza and Rupesh Nasre Indian Institute of Science, Bangalore.
Advertisements

SSA and CPS CS153: Compilers Greg Morrisett. Monadic Form vs CFGs Consider CFG available exp. analysis: statement gen's kill's x:=v 1 p v 2 x:=v 1 p v.
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
CS412/413 Introduction to Compilers Radu Rugina Lecture 37: DU Chains and SSA Form 29 Apr 02.
FIT FIT1002 Computer Programming Unit 19 Testing and Debugging.
O’Reilly – Hadoop: The Definitive Guide Ch.5 Developing a MapReduce Application 2 July 2010 Taewhi Lee.
CS2200 Software Development Lecture 2: Java Program Development Lecturer: Adrian O’Riordan Course Webpage:
Combining Static and Dynamic Data in Code Visualization David Eng Sable Research Group, McGill University PASTE 2002 Charleston, South Carolina November.
X := 11; if (x == 11) { DoSomething(); } else { DoSomethingElse(); x := x + 1; } y := x; // value of y? Phase ordering problem Optimizations can interact.
IPT Readings on Instrumentation, Profiling, and Tracing Seminar presentation by Alessandra Gorla University of Lugano December 7, 2006.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Composing Dataflow Analyses and Transformations Sorin Lerner (University of Washington) David Grove (IBM T.J. Watson) Craig Chambers (University of Washington)
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Introducing Java.
PACKAGES Mimi OpkinsCECS277. What We’ll Cover  Packages and Import Statements  The Package java.lang  Package Names and Directories  The Default Package.
Crystal-izing Sophisticated Code Analyses Ciera Jaspan Kevin Bierhoff Jonathan Aldrich
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 10: Abstract Interpretation II Roman Manevich Ben-Gurion University.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
M1G Introduction to Programming 2 4. Enhancing a class:Room.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Ali Shahrokni Application Components Activities Services Content providers Broadcast receivers.
Dale Roberts Object Oriented Programming using Java - Packages Dale Roberts, Lecturer Computer Science, IUPUI Department.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Java Spring PImage Let’s look at the PImage class in ProcessingPImage –What are the fields (i.e., variables)? –What methods are available? –What.
CSCE 2013L: Lab 1 Overview  Java Basics The JVM Anatomy of a Java Program  Object-Oriented Programming Overview  Example: Payroll.java JDK Tools and.
CSC Java Programming, Fall, 2008 Week 2: Java Data Types, Control Constructs, and their C++ counterparts, September 4.
JAVA Java is a programming language and computing platform first released by Sun Microsystems in It was first developed by James Gosling at Sun Microsystems,
POS 406 Java Technology And Beginning Java Code
CS266 Software Reverse Engineering (SRE) Reversing and Patching Java Bytecode Teodoro (Ted) Cipresso,
Python From the book “Think Python”
COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings.
Group 4 Java Compiler Group Members: Atul Singh(Y6127) Manish Agrawal(Y6241) Mayank Sachan(Y6253) Sudeept Sinha(Y6483)
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 10: Abstract Interpretation II Roman Manevich Ben-Gurion University.
JavaDoc and Contracts Spring Documenting Contracts with JavaDoc Contract model for methods Preconditions Postconditions JavaDoc Industry standard.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 12: Abstract Interpretation IV Roman Manevich Ben-Gurion University.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1 Chapter 5: Defining Classes. 2 Basics of Classes An object is a member of a class type What is a class? Fields & Methods Types of variables: –Instance:
JAVA INTRODUCTION. What is Java? 1. Java is a Pure Object – Oriented language 2. Java is developing by existing languages like C and C++. How Java Differs.
By Mr. Muhammad Pervez Akhtar
Duke CPS From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea l What it is ä O-O language, not a hybrid (cf. C++)
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 13: Abstract Interpretation V Roman Manevich Ben-Gurion University.
Crystal-izing Sophisticated Code Analyses Ciera Jaspan Kevin Bierhoff Jonathan Aldrich
SOOT By Joe Palmer Information taken from
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 8: Static Analysis II Roman Manevich Ben-Gurion University.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Spring 2017 Program Analysis and Verification
Installing Java on a Home machine
The need for Programming Languages
Spring 2016 Program Analysis and Verification
Spring 2017 Program Analysis and Verification
Spring 2016 Program Analysis and Verification
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
CS 153: Concepts of Compiler Design November 30 Class Meeting
CMPE419 Mobile Application Development
PRG 421 GUIDE Lessons in Excellence -- prg421guide.com.
Installing Java on a Home machine
Fall Compiler Principles Lecture 8: Loop Optimizations
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Androsia Securing 'data in process' for your Android Apps
Fall Compiler Principles Lecture 10: Loop Optimizations
Classes 5/5 May 14, 2019 ICS102: Classes 5/5.
Working with Libraries
Computer Programming-1 CSC 111
CMPE419 Mobile Application Development
SPL – PS1 Introduction to C++.
Presentation transcript:

Spring 2016 Program Analysis and Verification Static Analysis of Java via Soot Roman Manevich Ben-Gurion University

Agenda The Soot compiler framework for Java The Jimple intermediate language

Java Java: the high-level language Java bytecode reference Official reference from Oracle

Soot A framework for analyzing and transforming Java and Android Applications Developed at McGill university (Canada) https://sable.github.io/soot/ Supports several input languages Java source code Java bytecode Dalvik bytecode (Android) Jimple intermediate language Supported output languages Support several intermediate languages Jimple – what we will be using Shimple Baf Grimp Supports static analysis: CFG, pointer-analysis, etc. Eclipse plug-in (useful for giving demos and teaching)

Soot documentation and resources Soot survivor’s guide Soot tutorials Soot API Eric Bodden’s blog Running Soot: http://www.bodden.de/2008/08/21/soot-command-line/

Jimple synopsis TAC for Java: 15 statement types Core (intra-procedural) statements NopStmt IdentityStmt (r0 := @this: Foo; i0 := @parameter0: int; ) AssignStmt ($r1 = new Foo;) Intra-procedural control-flow statements IfStmt GotoStmt TableSwitchStmt (JVM tableSwitch instruction) LookupSwithcStmt (JVM lookupswitch instruction) Inter-procedural control-flow statements InvokeStmt ReturnStmt ReturnVoidStmt Monitor statements EnterMonitorStmt ExitMonitorStmt Exceptions ThrowStmt RetStmt

Jimple expressions

Java source

Running Soot – command line

Running Soot – output files output .jimple files go in “sootOutput”

Jimple code Locals IdentityStmts (default) static class initializer

Setting up for development Set up Java Set up Soot Set up abstract interpretation package

Setting up Java Make sure you have version 1.7 If you want to operate from command line make sure you have jdk 1.7 Set environment variable JAVA_HOME to point to your jdk installation path

Example inputs Store input files in a separate directory than the ones you use for implementing the analyses (otherwise, front-end breaks)

Abstract interpretation package

Example analyses Domain constructors Fixed point solvers Soot-specific utilities Infrastructure for implementing static analysis Example Java programs

Existing analyses

Static analysis package Implements Conversion of procedures to equation systems Abstract domain implementations Some examples: variable equalities (VE), constant propagation (CP), simple linear relations (lin), … Chaotic iterations Includes debugging information Domain combinators: Cartesian, Disjunctive completion, and Relational Code for displaying analysis results

Running the VE analysis Example: variable equalities

Running the VE analysis Adds the analysis to Soot’s list of intra-procedural analyses Creates the equation system Runs chaotic iteration Attaches results as StringTags

Running the VE analysis Command-line options: -cp . : adds the current directory to Soot’s CLASSPATH -pp : adds Java’s CLASSPATH to Soot’s CLASSPATH -f jimple : outputs jimple code -p jb use-original-names : keeps local variables names as they are -p jb.ls enabled:false : disables local splitter to reduce number of local variables -keep-line-number : writes source code line numbers in the resulting jimple code -print-tags : writes out tags for each jimple statement (analysis results) TestClass : specifies the class to analyze Enable assertions Which directory to run in

Debug printout 1/2

Debug printout 2/2

Analysis results inlined into .jimple

Implementing abstract domains

Variable equalities analysis

Major classes Variable per CFG node Combines all sub-algorithms to get entire static analysis A transformer for assume statements Converts CFG to equation system Chaotic iteration algorithm to compute fixed point An equation per CFG edge and join point A system of equations A transformer non-assume statements

See you next time