effective slicing anne mulhern computer sciences department university of wisconsin-madison madison,...

14
Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA [email protected] www.cs.wisc.edu/~mulhern

Upload: sara-west

Post on 27-Mar-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

Effective Slicing

Anne MulhernComputer Sciences DepartmentUniversity of Wisconsin-Madison

Madison, WI [email protected]

www.cs.wisc.edu/~mulhern

Page 2: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@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

^

Page 3: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

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

Page 4: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

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

Page 5: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

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

Page 6: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

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

Page 7: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

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…

Page 8: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

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

Page 9: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

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, σ)

Page 10: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

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

Page 11: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

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

Page 12: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

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

Page 13: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

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?

Page 14: Effective Slicing Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA mulhern@cs.wisc.edu mulhern

Effective Slicing

Anne MulhernComputer Sciences DepartmentUniversity of Wisconsin-Madison

Madison, WI [email protected]

www.cs.wisc.edu/~mulhern