Professional Documents
Culture Documents
Program Slicing
Program Slicing
Problems
The size and complexity of a software today gets harder to understand, maintain and test - You might have had questions like.. If I change this statement, what pieces of the program are going to be affected? Where are the values that flow into this statement coming from? My code is bloated. How can I limit the functionality to only what I need?
Problems (Contd)
Studies of software maintainers have shown that approximately 50% of their time is spent in the process of understanding the code that they are to maintain
- Jussi Koskinen, Asst Prof, University of Jyvskyl, Finland-
Our Goals
Debug your thousands lines of code easily by reducing the complexity of the program Write a robust program before testing your code Save your regression testing time by limiting the tests to only those that exercise the changed code
Approach
Approach
How?
Program Slicing
What is it?
- A well-known program analysis and transformation
technique that uses program statement dependence information to identify parts of a program that influence or are influenced by an initial set of program points of interest which is called the slice criteria
Slice
Slicing Criterion
Source program
Resulting slice
Dynamic Slicing
Uses information derived from a particular execution of a program Execution is monitored and slices are computed with respect to program history Relatively small slices Contains all statements that actually affect the value of a variable
Conditional Slicing
Acts as bridge between the two extremes of static and dynamic slicing
Backward Slicing
Contains the statements of the program P which may have some effect in the slicing criterion S(V, n)
Forward Slicing
Contains all those statements of P which are affected by S(V, n)
Why is It Useful?
Program slicing is useful in many different states of the software development lifecycle
Debugging:
Slicing visualizes control and data dependencies It highlights statements influencing the slice
Testing:
Tests may be decomposed and test-work gets faster and more efficient
Dependences
Various notions of Dependences
Data dependence Control dependence Synchronization dependence
The usual stuff Dependences related to threading & locking
Data Dependence
public class BoundedBuffer { protected int numSlots = 0; protected Object[] buffer = null; protected int putIn = 0; protected int takeOut = 0; protected int count = 0; public BoundedBuffer(int numSlots) { if (numSlots <= 0) { throw new IllegalArgumentException(); } this.numSlots = numSlots; buffer = new Object[numSlots]; } }
Data Dependence
public class BoundedBuffer { protected int numSlots = 0; protected Object[] buffer = null; protected int putIn = 0; protected int takeOut = 0; protected int count = 0; public BoundedBuffer(int numSlots) { if (numSlots <= 0) { throw new IllegalArgumentException(); } this.numSlots = numSlots; buffer = new Object[numSlots]; } .... }
Control Dependence
public class BoundedBuffer { protected int numSlots = 0; protected Object[] buffer = null; protected int putIn = 0; protected int takeOut = 0; protected int count = 0; public BoundedBuffer(int numSlots) { if (numSlots <= 0) { throw new IllegalArgumentException(); } this.numSlots = numSlots; buffer = new Object[numSlots]; } .... }
Control Dependence A conditional statement controls whether or not the current statement is executed
this statement depends on the conditional which controls whether it is reached or bypassed by throwing an exception
Kaveri provides a featureful Eclipse-based UI front-end for Indus integrated with Eclipse Java development environment
Configuring, invoking and visualizing results of Indus slicing Scripting framework for flexible querying of underlying analysis APIs
Slice Calculation
Supporting Analysis
Output Construction
Eclipse-based Front-end
Visualization of Slice
Eclipse-based Front-end
Eclipse-based Front-end
Navigation of dependences
Conclusions
Program slicing comes from the ability to assist in tedious and error prone tasks such as program debugging, testing, parallelization, integration, software safety, understanding, and software maintenance. A robust program slicer that can be applied to real Java is a sophisticated analysis and transformation framework with many applications. Applying Indus slicing for Java Application
is easy (completely automatic no user intervention) is inexpensive (compared to model checking costs) is effective and orthogonal to other reduction strategies (typical reduction factors range from 2x 5x)
Indus can be downloaded and immediately applied in the context of Java verification efforts
Demo