Program Slicing: Binoy Ketan Dash
Program Slicing: Binoy Ketan Dash
Outline
What is Program Slicing? Why Program Slicing? How to Slice Program? Slicing Classifications Applications Program Slicing Tools Conclusion
More descriptively, it is a decomposition technique that extracts statements relevant to a particular computation from a program. Slicing Criterion <s, v> Program Slices as Originally introduced by Weiser[1] are known as executable backward static slices
Program Debugging: thats how slicing was discovered! Testing: reduce cost of regression testing after modifications (only run those tests that needed) Parallelization Integration : merging two programs A and B that both resulted from modifications to BASE
Program Understanding Reverse Engineering: comprehending the design by abstracting out of the source code the design decisions Software Maintenance: changing source code without unwanted side effects Software Quality Assurance: validate interactions between safety-critical components
How?
A slice is constructed by deleting those parts of a program which is irrelevant to the program with respect to the chosen set of variables at the chosen point. A slice is taken from a program with the slicing criterion <s , v>, which specifies a location (Statement s) and a variable (v).
How?
Contd...
Data Flow equations are solved Slice is computed as graph reachability problem
Slicing Example
1 main( ) 2{ 3 int i, sum; 4 sum = 0; 5 i = 1; 6 while(i <= 10) 7 { 8 sum = sum + 1; 9 ++ i; 10 } 11 Cout<< sum; 12 Cout<< i; 13 }
Slicing classifications
Types of slices
Direction of slicing
Executabiliy of slice
Levels of slices
Slicing Properties
Static Slicing
Statically available information only No assumptions made on input Computed slice can never be accurate (minimal slice) Problem is undecidable reduction to the halting problem Current static methods can only compute approximations Result may not be usefull
Slicing Properties
Dynamic Slicing
Computed on a given input Deterministic instead of Probabilistic Useful for applications that are input driven (debugging, testing) Slicing Criterion <i, p, v>
9.
10.
read (n) for I := 1 to n do a := 2 if c1==1 then if c2==1 then a := 4 else a := 6 z := a write (z)
Input n is 1; c1, c2 both true Execution history is 11, 21, 31, 41, 51, 61, 91, 22, 101
Criterion<1, 101, z>
A backward slice of a program with respect to a program point p and set of program variables V consists of all statements and predicates in the program that may affect the value of variables in V at p
A forward slice of a program with respect to a program point p and set of program variables V consists of all statements and predicates in the program that may be affected by the value of variables in V at p
Slicing Properties
Intraprocedural Slicing
Computes slice within one procedure Assumes worse case for function calls
Interprocedural Slicing
Compute slice over an entire program Two ways for crossing procedure boundary
Up going from sliced procedure into calling procedure Down going from sliced procedure into called procedure
Applications of Slicing
Differencing Debugging Testing Program understanding Software maintenance Complexity measurement / Functional Cohesion Program integration Reverse engineering Software Quality Assurance
CodeSurfer
Commercial product by GammaTech Inc. GUI Based Scripting language-Tk Static Program Slicer Developed at NIST Slices ANSI C programs Limitations are in the treatment of Unions, Forks and pointers to functions
Unravel
Conclusion
References
[1] M. Weiser. Program Slicing. In Proceedings of the Fifth International Conference on Software Engineering, pages 439-449, May 1981. [2] D. Binkley, K. Gallagher. Program Slicing. In Proceedings of In Advances in Computers, Volume 43, 1996. [3] H.Agrawal, J. Horgan. Dynamic Program Slicing. In Proceedings of the ACM SIGPLAN90 [4] A. DeLucia. Program Slicing: Methods and Applications. IEEE workshop on Source Code Analysis and Manipulation (SCAM 2001) [5] K. B. Gallagher and J. R. Lyle. Using Program Slicing in Software Maintenance. IEEE Transactions on Software Engineering, 17(8), pages 751-761, August 1991.
????