pruning dynamic slices with confidence

19
Pruning Dynamic Slices With Confidence Original by: Xiangyu Zhang Neelam Gupta Rajiv Gupta The University of Arizona Presented by: David Carrillo

Upload: tamah

Post on 20-Jan-2016

21 views

Category:

Documents


0 download

DESCRIPTION

Pruning Dynamic Slices With Confidence. Presented by: David Carrillo. Original by: Xiangyu Zhang Neelam Gupta Rajiv Gupta The University of Arizona. Dynamic Slicing. …… 10. A = …... 20. B = …… 30. P = 31. If (P

TRANSCRIPT

Page 1: Pruning Dynamic Slices  With Confidence

Pruning Dynamic Slices

With Confidence

Original by:

Xiangyu Zhang

Neelam Gupta

Rajiv GuptaThe University of Arizona

Presented by:David Carrillo

Page 2: Pruning Dynamic Slices  With Confidence

Dynamic Slicing

Dynamic slice is the set of statements that did affect the value of a variable at a program point for a specific program execution. [Korel and Laski, 1988]

……

10. A =

…...

20. B =

……

30. P =

31. If (P<0) {

......

35. A = A + 1

36. }

37. B=B+1

……

40. Error(A)

Dynamic Slice (A@40) = {10, 30, 31, 35, 40}Dynamic Slice (A@40) = {10, 30, 31, 35, 40}

Page 3: Pruning Dynamic Slices  With Confidence

Effectiveness of Dynamic Slicing

Dynamic slicing is very effective in containing the faulty statement, however it usually produces over-sized slices -- [AADEBUG’05].

Problem:

How to automatically prune dynamic slices?

Many Approaches:

This paper presents: Fine-grained pruning of a backward slice by using confidence analysis.

Page 4: Pruning Dynamic Slices  With Confidence

Types of Evidence Used in Pruning

Buggy Execution

output_x

Classical dynamic slicing algorithms investigate bugs through the evidence of the wrong output.input0

input_x

input2

output2

predicate_x

output0

output1

predicate_x

Literature contains use of many different types of evidence, this paper studies “Partially correct output”.

Benefits of more evidence Narrow the search for faulty

statement. Broaden the applicability of the

tool.

Page 5: Pruning Dynamic Slices  With Confidence

Fine-grained Pruning by Exploiting Correct Outputs

……

10. A = 1 (Correct: A=3)

…...

20. B = A % 2

……

30. C = A + 2

……

40. Print (B)

41. Print (C)

Correct outputs produced in addition to wrong output.

DS(Owrong) – DS (Ocorrect) are all the statements that create wrong output and not correct output.

DS(C@41)= {10, 30, 41}

DS(B@40)= {10, 20, 40}

DS(C@41)-DS(B@40)

= {30,41}

What happens when a statement affects both correct and incorrect output?

Page 6: Pruning Dynamic Slices  With Confidence

Confidence Analysis

Value produced at node n can reach only wrong output nodes

nn

There is no evidence that n is correct, so it should be in the pruned slice.

Should we include n in the slice?

??

Confidence(n)=0

Confidence(n)=?; 0 ≤ ? ≤ 1

Value produced at node n can reach both the correct and wrong output nodes.

nnnn

nn

Confidence(n)=1

Value produced at n can reach only correct outputs There is no evidence of incorrectness of n.

Therefore it cannot be in the slice.

Page 7: Pruning Dynamic Slices  With Confidence

|)(|log1)( )|(| nAltnCf nrange

Confidence Analysis

nnnn Range(n)={ a, b, c, d, e, f, g }

Alt(n)={ a }

Value(n) = a

Value(n) = bValue(n) = c

, c

• When |Alt(n)|==1, we have the highest confidence (=1) on the correctness of n;

• When |Alt(n)|==|Range(n)|, we have the lowest confidence (=0).

• |Range(n)| >= |Alt(n)|>=1

Alt(n) is a set of possible values of the variable defined by n, that when propagated through the dynamic dependence graph, produce the same values for correct outputs.

Experimentally determined function.

Range(n) is all values taken by n during the buggy run.

Page 8: Pruning Dynamic Slices  With Confidence

Confidence Analysis: Example

……

10. A = ...

…...

20. B = A % 2

……

30. C = A + 2

……

40. Print (B)

41. Print (C) 0)41( Cf

1)40( Cf

0)30( Cf

1)20( Cf

2log2

|)(|log1)10( )|(|)|(| ArangeArange

ArangeCf

A+2 is a one-to-one mapping.

A%2 is a one-to-many (2) mapping.

Page 9: Pruning Dynamic Slices  With Confidence

Confidence Analysis: Two Problems

How to decide the Range of values for a node n?• Based on variable type (e.g., Integer).• Static range analysis.• Our choice:

Dynamic analysis based on value profiles (Range of values for a statement is the set of values defined by all of the execution instances of the statement during the program run).

How to compute Alt(n)?• Consider the set of correct output values as constraints.• Compute Alt(n) by backward propagation of constraints

through the dynamic dependence subgraph corresponding to the slice.

Page 10: Pruning Dynamic Slices  With Confidence

Computing Alt(n) Along Data Dependence

S1: T=... 9

S2: X=T+1 10 S3: Y=T%3 0

(X,T)= (6,5) (9,8)

(10,9)

(T,...)= (1,...) (3,...) (5,...) (8,...) (9,...)

(Y,T)=(0,3) (0,9) (1,1) (2,5) (2,8)

alt(T@S2)={9} alt(T@S3)={1,3,9}

alt(S1) = alt(T@S2) ∩ alt (T@S3) = {9}

alt(S2)={10} alt(S3)={0,1}

Page 11: Pruning Dynamic Slices  With Confidence

Computing Alt(n) Along Control Dependence

S1: if (P) … True

S2: X=T+1 10 S3: Y=T%3 0

(X,T)= (6,5) (9,8)

(10,9)

(Y,T)=(0,3) (0,9) (1,1) (2,5) (2,8)

alt(S1) = {True}

alt(S2)={10} alt(S3)={0,1}

Page 12: Pruning Dynamic Slices  With Confidence

Characteristics of Siemens Suite Programs

Program Description LOC Versions Tests

print_tokens Lexical analyzer 565 5 4072

print_tokens2 Lexical analyzer 510 5 4057replace Pattern replacement 563 8 5542

schedule Priority scheduler 412 3 2627schedule2 Priority scheduler 307 3 2683

gzip Unix utility 8009 1 1217flex Unix utility 12418 8 525

• Each faulty version has a single manually injected error.• All the versions are not included:

No output is produced. Faulty statement is not contained in the backward slice.

• For each version three tests were selected.

Page 13: Pruning Dynamic Slices  With Confidence

Results of Pruning

Program DS PDSmax PDSmax / DS

PDSmin %Missed by PDSmin

print_tokens 110 35 31.8% 35 0%print_tokens2 114 55 48.2% 55 0%

replace 131 60 45.8% 43 38.1%schedule 117 70 59.8% 56 20%

schedule2 90 58 64.4% 50 0%gzip 357 121 33.9% 10 100%flex 727 27 3.7% 25 0%

On average, PDSmax = 41.1% of DS

Page 14: Pruning Dynamic Slices  With Confidence

Confidence Based Prioritization

DD – dependence distance

CV – confidence values

Executed statement instances examined (%)

• Prior work have shown that Dependence Distance is an effective way to prioritize statements in order to locate faulty code.

• Experimentation in this paper shows that Prioritizing by Confidence Values outperforms Dependence Distance.

Page 15: Pruning Dynamic Slices  With Confidence

The Potential of Confidence Analysis (1)

Dynamic SlicerWith Confidence

Pruned Slices

User Verified Statements as correct

Buggy Code

Input User

Interactive Pruning.

Incorporate user input into pruning.

Page 16: Pruning Dynamic Slices  With Confidence

The Potential of Confidence Analysis (2)

Relevant slicing (gzip v3 run r1)

Potential dep.Data dep.

Dynamic slices does not capture bugs where data

dependency is incorrect due to incorrect control flow.

Relevant slicing do, but generates Dynamic Slices that are too large. It may

be effective with effective pruning.

Page 17: Pruning Dynamic Slices  With Confidence

Conclusions

Confidence analysis - exploits the correct output values produced in an execution to prune the dynamic slice of an incorrect output.

This novel dynamic analysis based implementation of confidence analysis effectively pruned backward dynamic slices in our experiments.

• Pruned Slices = 41.1% Dynamic Slices, and still contain the faulty statement.

Our study shows that confidence analysis has additional applications beyond pruning – prioritization, interactive pruning & relevant slicing.

Page 18: Pruning Dynamic Slices  With Confidence

Discussion

Creation alternatives relies on known mapping for each type of statement.

• i.e. X = Y + 1 is one-to-one.• i.e. X = X % 3 is one-to-many.• How extensible is this approach?? (floats, objects, etc.)

This approach assumes that:• There is only one error (detected).• The error is detected before it propagates into its

dependencies.• How realistic are this assumptions in real scenarios with

incomplete test coverage?

Page 19: Pruning Dynamic Slices  With Confidence

The End