effective slicing anne mulhern computer sciences department university of wisconsin-madison madison,...
TRANSCRIPT
Effective Slicing
Anne MulhernComputer Sciences DepartmentUniversity of Wisconsin-Madison
Madison, WI [email protected]
www.cs.wisc.edu/~mulhern
PLDI 2008 Effective Slicing 2
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 Slicestypical
^
PLDI 2008 Effective Slicing 3
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 ✓
✓ ✓
✓ 1 3 2 ✓
✓ 1 3 1/2
✓
1 3/2 1/2 ✓
3/2
PLDI 2008 Effective Slicing 4
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 2008 Effective Slicing 5
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 2008 Effective Slicing 6
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 2008 Effective Slicing 7
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 2008 Effective Slicing 8
relevant slice
{n 3}↦
y = 2;
if (y == 2)
x = 2;
?x✓ ✓
Fixpoint Computationrelevant
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 2008 Effective Slicing 9
Effective Slicing
• 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 2008 Effective Slicing 10
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 2008 Effective Slicing 11
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 Sliceseffective
slice
{n 2}↦
y = 2;
if (y == 2)
x = 2;
?x
PLDI 2008 Effective Slicing 12
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 2008 Effective Slicing 13
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 MulhernComputer Sciences DepartmentUniversity of Wisconsin-Madison
Madison, WI [email protected]
www.cs.wisc.edu/~mulhern