predicting data dependences for slice inspection ...€¦ · predicting data dependences for slice...

Post on 01-Aug-2020

20 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Predicting Data Dependences for Slice Inspection Prioritization

Yiji Zhang and Raul Santelices University of Notre Dame

Outline • Introduction • Technique • Evaluation • Future work and Conclusion

1

Introduction • Definitions

2

1. main(int a, int b){ 2. int *p; 3. if (…) 4. p = &a; else 5. p = &b; 6. if (…) 7. swap (p, &a); else 8. if (…) 9. a = b; else 10. swap (&b, &a); 11. print (a,b); }

12. swap (int *p1, int *p2){ 13. int temp = *p2; 14. *p2 = *p1; 15. *p1 = temp; }

data dependence: statement y depends on x iff 1) x writes to variable v (def) 2) y reads from v (use)

Introduction • Definitions

3

1. main(int a, int b){ 2. int *p; 3. if (…) 4. p = &a; else 5. p = &b; 6. if (…) 7. swap (p, &a); else 8. if (…) 9. a = b; else 10. swap (&b, &a); 11. print (a,b); }

12. swap (int *p1, int *p2){ 13. int temp = *p2; 14. *p2 = *p1; 15. *p1 = temp; }

example: data dependence (4,7,p) or simply (4,7)

Introduction • Definitions

4

1. main(int a, int b){ 2. int *p; 3. if (…) 4. p = &a; else 5. p = &b; 6. if (…) 7. swap (p, &a); else 8. if (…) 9. a = b; else 10. swap (&b, &a); 11. print (a,b); }

12. swap (int *p1, int *p2){ 13. int temp = *p2; 14. *p2 = *p1; 15. *p1 = temp; }

program slicing: affecting statements slicing criterion: value and point of interest

Introduction • Definitions

5

1. main(int a, int b){ 2. int *p; 3. if (…) 4. p = &a; else 5. p = &b; 6. if (…) 7. swap (p, &a); else 8. if (…) 9. a = b; else 10. swap (&b, &a); 11. print (a,b); }

12. swap (int *p1, int *p2){ 13. int temp = *p2; 14. *p2 = *p1; 15. *p1 = temp; }

slicing criterion: value p at line 7

Introduction • Definitions

6

1. main(int a, int b){ 2. int *p; 3. if (…) 4. p = &a; else 5. p = &b; 6. if (…) 7. swap (p, &a); else 8. if (…) 9. a = b; else 10. swap (&b, &a); 11. print (a,b); }

12. swap (int *p1, int *p2){ 13. int temp = *p2; 14. *p2 = *p1; 15. *p1 = temp; }

slicing criterion: value p at line 7 slice: lines 1, 2, 3, 4, 5, 6 and 7

Introduction • Motivation

7

1. main(int a, int b){ 2. int *p; 3. if (…) 4. p = &a; else 5. p = &b; 6. if (…) 7. swap (p, &a); else 8. if (…) 9. a = b; else 10. swap (&b, &a); 11. print (a,b); }

12. swap (int *p1, int *p2){ 13. int temp = *p2; 14. *p2 = *p1; 15. *p1 = temp; }

Q: Which statement to examine first?

Introduction • Related Work

– M. Sridharan, S. J. Fink, and R. Bodik, “Thin slicing,” in Proc. of PLDI, Jun. 2007, pp. 112–122

– X. Zhang, N. Gupta, and R. Gupta, “Pruning dynamic slices with confidence,” in PLDI, 2006, pp. 169–180

8

Outline • Introduction • Technique • Evaluation • Future work and Conclusion

9

Technique • PRIODU Process

10

Program

D-U Analyzer data dependences (d1,u1)

(d2,u2) (d3,u3) (d4,u4) (d5,u5)

……

data dependencesd

Technique • PRIODU Process

11

Program

D-U Analyzer

Probabilities, Ranking

data dependences

PRIODU dependence (d,u):

compute P(d,u)

(d1,u1), P(d1,u1) (d2,u2), P(d2,u2) (d3,u3), P(d3,u3) (d4,u4), P(d4,u4) (d5,u5), P(d5,u5)

……

P(d,u) : Coverage Probability (estimated)

):p ( , )compute P((d,u, ))

)

Technique • PRIODU Process

12

Program

D-U Analyzer

Probabilities, Ranking

data dependences

PRIODU dependence (d,u):

compute P(d,u)

p ( , )compute P((d,u, ))

P(d,u) : Coverage Probability (estimated)

):)

decreasing P(d,u)

(d3,u3), P(d3,u3) (d2,u2), P(d2,u2) (d1,u1), P(d1,u1) (d5,u5), P(d5,u5) (d4,u4), P(d4,u4)

……

Technique Coverage Probability P(d,u) = Preach × Palias 1) Preach: Reaching probability 2) Palias: Alias probability

EN d u

d u

Memory

13

EN: entry of the program

Technique 1) Preach = PEN d Pd u

for PEN d: src=EN, tgt=d for Pd u: src=d, tgt=u

14

1. main(int a, int b){ 2. int *p; 3. if (…) 4. p = &a; else 5. p = &b; 6. if (…) 7. swap (p, &a); else 8. if (…) 9. a = b; else 10. swap (&b, &a); 11. print (a,b); } example: data dep (4,7,p)

;

;P(succeeds(6,4)) = 1.0

P(reaches(6,7)) = 0.5

Simplifying assumption: All successors equally likely

Goal: P(d,u) = Preach × Palias achrea h_______

Technique 2) Palias: only for d u

15

d u

Memory

P2Set (points-to set): all possible memory locations

Palias: degree of overlap

Goal: P(d,u) = Preach × Palias aliaaas______

Technique 2) Palias: only for d u

16

d u

Memory

P2Set(d)

P2Set (points-to set): all possible memory locations

Palias: degree of overlap

Goal: P(d,u) = Preach × Palias aliaaas______

Technique 2) Palias: only for d u

17

d u

Memory

P2Set(u)

P2Set (points-to set): all possible memory locations

Palias: degree of overlap

Goal: P(d,u) = Preach × Palias aliaaas______

Technique 2) Palias: only for d u

18

d u

Memory

P2Set (points-to set): all possible memory locations

Palias: degree of overlap

Palias =

Goal: P(d,u) = Preach × Palias aliaaas______

1 4 1

Technique 2) Palias: only for d u

19

1. main(int a, int b){ 2. int *p; 3. if (…) 4. p = &a; else 5. p = &b; 6. if (…) 7. swap (p, &a); else 8. if (…) 9. a = b; else 10. swap (&b, &a); 11. print (a,b); }

12. swap (int *p1, int *p2){ 13. int temp = *p2; 14. *p2 = *p1; 15. *p1 = temp; }

example: dependence (1,14,b)

P2Set(d) = {b} (d) =

P2Set(u) = {a, b} p;P=

Goal: P(d,u) = Preach × Palias aliaaas______

mp == *p1; = tempp;

Outline • Introduction • Technique • Evaluation • Future work and Conclusion

20

Evaluation • Goal: assess prediction effectiveness of PRIODU

– Compare with random order of the dependences

• Research questions: RQ1: Overall accuracy RQ2: Accuracy per inspection budget

21

Evaluation • Experiment Setup

• Two Java subjects from SIR • Tool: DUA-Forensics – PRIODU extension

22

Subject Description LOC Data Dep. Tests

Schedule1 Task scheduler 290 381 2650

NanoXML XML parser 3497 11508 214

Table 1 Subjects, Data Dependences, and Tests

Evaluation • Methodology

23

(d1,u1), P(d1,u1) (d2,u2), P(d2,u2) (d3,u3), P(d3,u3) (d4,u4), P(d4,u4)

…… PRIODU

our predicted ranking

Program, Dependences

ranking

Evaluation • Methodology

24

PRIODU

Program, Dependences

Test Suite Runner

Test Suite

observed ranking

our predicted ranking

Fi = occurrence frequency in [0,1]

(d1,u1), P(d1,u1) (d2,u2), P(d2,u2) (d3,u3), P(d3,u3) (d4,u4), P(d4,u4)

……

(d2,u2), F2 (d1,u1), F1 (d4,u4), F4 (d3,u3), F3

……

ranking

observed rankingo

Evaluation • Methodology

25

PRIODU

Program, Dependences

Test Suite Runner

Test Suite

Error Estimator

observed ranking

our predicted ranking

Prediction Error

(d1,u1), P(d1,u1) (d2,u2), P(d2,u2) (d3,u3), P(d3,u3) (d4,u4), P(d4,u4)

……

(d2,u2), F2 (d1,u1), F1 (d4,u4), F4 (d3,u3), F3

……

Evaluation • Error Estimator

26

# PRIODU Predicted

Runtime Observed

1 (d1,u1) (d2,u2)

2 (d2,u2) (d1,u1)

3 (d3,u3) (d4,u4)

4 (d4,u4) (d3,u3)

1.

(How we evaluate PRIODU)

Evaluation • Methodology

27

PRIODU

Program, Dependences

Test Suite Runner

Test Suite

Error Estimator

observed ranking

our predicted ranking

Prediction Error

Evaluation • compare with the expected error of random

order

28

dep

Random Ranking

Observed Ranking

D ith:

Evaluation • Expected error of random order

29

dep

Random Ranking

Observed Ranking

D ith:

i-1 Case 1: Errordep(i) = (i-1)/2D

Evaluation

30

dep

Random Ranking

Observed Ranking

ith: D

• Expected error of random order

Case 1: Errordep(i) = (i-1)/2D

Case 2: Errordep(i) = 0

Evaluation

31

dep

Random Ranking

Observed Ranking

Case 1: Errordep(i) = (i-1)/2D ith:

D Case 2: Errordep(i) = 0

Case 3: Errordep(i) = (D-i)/2D

• Expected error of random order

D-i

Evaluation •

32

Case 1 Case 2 Case 3

Evaluation • RQ1: Overall accuracy (based on average

error)

33

Subject PRIODU Error Random Error Schedule1 20.9% 33.3% NanoXML 5.9% 33.3%

Evaluation • RQ2. Accuracy per fraction of the ranking

34 Ranking errors from the top of each ranking for Schedule1

Error: 39.51%

Error: 18.90%

Evaluation • RQ2. Accuracy per fraction of the ranking

35 Ranking errors from the top of each ranking for Schedule1

Evaluation • RQ2. Accuracy per fraction of the ranking

36 Ranking errors from the top of each ranking for NanoXML

Outline • Introduction • Technique • Evaluation • Future Work and Conclusion

37

Future Work and Conclusion Future Work

– Case studies and user studies for debugging – Improve the precision of the model

• Reaching probabilities using branch prediction • Experiment with dynamic analysis

– Other applications • Impact analysis • Information flow analysis

38

Future Work and Conclusion Conclusion PRIODU: (1) prioritize data dependences (2) especially good at the top of the ranking

Q & A

39

top related