# Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA

## Presentation on theme: "Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA"— Presentation transcript:

Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu www.cs.wisc.edu/~mulhern

PLDI 2008Effective Slicing1 full slice {n 2} y = 2; if (y == 2) x = 2; ?x full slice {n 1} read(n); if (n == 1) x = 3; ?x program read(n); x = 1; y = 2; if (n == 1) x = 3; y = 1; if (y == 2) x = 2; ?x Two Correct Dynamic Slices typical ^

PLDI 2008Effective Slicing2 full slice {n {1,2}} read(n); y = 2; if (n == 1) x = 3; if (y == 2) x = 2; ?x program read(n); x = 1; y = 2; if (n == 1) x = 3; y = 1; if (y == 2) x = 2; ?x Union of Slices is Incorrect n p/s x p/s y p/s 1 1 1/ 1 1/ 2 132 131/2 13/21/2 3/2

PLDI 2008Effective Slicing3 Why is This a Problem? Given a set of inputs that cause program failure –Want the correct slice for all failures Given a flag that takes multiple values –Want the correct slice for whenever the flag is set, regardless of its value

PLDI 2008Effective Slicing4 relevant slice {n 2} read(n); y = 2; if (n == 1) if (y == 2) x = 2; ?x relevant slice {n 1} read(n); if (n == 1) x = 3; y = 1; if (y == 2) ?x program read(n); x = 1; y = 2; if (n == 1) x = 3; y = 1; if (y == 2) x = 2; ?x Two Correct Relevant Slices

PLDI 2008Effective Slicing5 relevant slice {n {1,2}} read(n); y = 2; if (n == 1) x = 3; y = 1; if (y == 2) x = 2; ?x program read(n); x = 1; y = 2; if (n == 1) x = 3; y = 1; if (y == 2) x = 2; ?x Union of Relevant Slices is Correct

PLDI 2008Effective Slicing6 We Can Slice Twice If we take the union of slices as our program and slice again on the same inputs… we may get a smaller program Example: the union of relevant slices for inputs 2 and 3…

PLDI 2008Effective Slicing7 relevant slice {n 3} y = 2; if (y == 2) x = 2; ?x Fixpoint Computation relevant slice {n 2} y = 2; if (y == 2) x = 2; ?x relevant slice {n {2,3}} read(n); y = 2; if (n == 1) if (y == 2) x = 2; ?x So long as n in {2,3} choice of n is unimportant

PLDI 2008Effective Slicing8 Dynamic slicing algorithms - two arguments –P - the program –σ - the initial state Effective slicing algorithm - an additional argument – - the nodes to consider when calculating potential dependence –effective(P, σ, ) = full(P, σ) –effective(P, σ, P) = relevant(P, σ)

PLDI 2008Effective Slicing9 Effective Slicing for Approximation Potential dependence need only be taken into account when the potential statement is in the union of slices –Choose to be all nodes in the union of execution slices

PLDI 2008Effective Slicing10 effective slice {n 3} y = 2; if (y == 2) x = 2; ?x program read(n); x = 1; y = 2; if (n == 1) x = 3; y = 1; if (y == 2) x = 2; ?x Two Correct Effective Slices effective slice {n 2} y = 2; if (y == 2) x = 2; ?x

PLDI 2008Effective Slicing11 Summary Unions of relevant slices are correct –Take into account potential dependences Relevant slicing can be used in a fixpoint computation –Semantic information can be extracted from the result Effective slicing generalizes full and relevant slicing –Possibly potential statements are an explicit parameter –Effective slicing can be used to find an approximation of the fixpoint

PLDI 2008Effective Slicing12 Future Work Theoretical –How many steps to reach fixpoint? Practical –How big are unions of relevant slices? –How good an approximation can effective slicing give? –How many dynamic semantic facts can be extracted? eg., what choices of initial state are irrelevant for this subset?

Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu www.cs.wisc.edu/~mulhern