a slicing method for object-oriented programs using lightweight dynamic information

37
Software Engineering Research Group, Graduate School of Engineering Science, Osaka University A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information Fumiaki OHATA, Kouya HIRO SE, Masato FUJII and Katsuro INOUE Osaka University, JAPAN

Upload: zaynah

Post on 14-Jan-2016

38 views

Category:

Documents


1 download

DESCRIPTION

A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information. Fumiaki OHATA, Kouya HIROSE, Masato FUJII and Katsuro INOUE Osaka University, JAPAN. Contents. Program Slice Dependence-Cache (DC) Slice Object-Oriented Dependence-Cache (OODC) Slice Implementation - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

A Slicing Method forObject-Oriented Programs

UsingLightweight Dynamic

Information

Fumiaki OHATA, Kouya HIROSE, Masato FUJII and Katsuro INOUE

Osaka University, JAPAN

Page 2: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

2

ContentsProgram SliceDependence-Cache (DC) SliceObject-Oriented Dependence-Cache (OODC) SliceImplementationEvaluationSummary and Future Work

Page 3: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

3

Contents (1/6)Program SliceDependence-Cache (DC) SliceObject-Oriented Dependence-Cache (OODC) SliceImplementationEvaluationSummary and Future Work

Page 4: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

4

Program Slice (Slice)Subprogram which affects the value of slicing criterion <s, v> in ps : Statementv : Variablep : Program

ApplicationsProgram understandingProgram debugging…

Page 5: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

5

Application Example [Program Debugging]

Slice is effective on fault localization process.

The slice for <9, max> indicates the statements that might cause the unexpected value of max at line 9, so that we have only to focus on them.

1: scanf("%d", &a);2: scanf("%d", &b); 3: max = a;4: min = b;5: if (a > b) {6: max = b;7: min = a;8: }9: printf("%d", max);

1: scanf("%d", &a);2: scanf("%d", &b); 3: max = a;4: min = b;5: if (a > b) {6: max = b;7: min = a;8: }9: printf("%d", max);

Slice for <9, max>

1: scanf("%d", &a);2: scanf("%d", &b); 3: max = a;4: min = b;5: if (a > b) {6: max = b;7: min = a;8: }9: printf("%d", max);

1: scanf("%d", &a);2: scanf("%d", &b); 3: max = a;4: min = b;5: if (a > b) {6: max = b;7: min = a;8: }9: printf("%d", max);

- Incorrect program -

1: scanf("%d", &a);2: scanf("%d", &b); 3: max = a;4: min = b;5: if (a < b) {6: max = b;7: min = a;8: }9: printf("%d", max);

1: scanf("%d", &a);2: scanf("%d", &b); 3: max = a;4: min = b;5: if (a < b) {6: max = b;7: min = a;8: }9: printf("%d", max);

- Correct program -

Page 6: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

6

Computation ProcessPhase 1 : Defined and referred variables

extractionPhase 2 : Dependence analysis

Data dependence (DD) analysisControl dependence (CD) analysis

Phase 3 : Program dependence graph (PDG) construction

Phase 4 : Slice extraction using PDG traversal

Page 7: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

7

Data Dependence (DD) Analysis

Extract DD relations between two statements

DD relation represents data-flowthrough variable.

1: a = 3; 2: b = 2; 3: scanf("%d", &c); 4: if ( c == 0 ) 5: d = a; 6: else 7: d = a + 1; 8: e = a + b; 9: printf("%d", d);10: printf("%d", e);

1: a = 3; 2: b = 2; 3: scanf("%d", &c); 4: if ( c == 0 ) 5: d = a; 6: else 7: d = a + 1; 8: e = a + b; 9: printf("%d", d);10: printf("%d", e);

dd

Page 8: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

8

Control Dependence (CD) Analysis

Extract CD relations between two statements

CD relation represents control-flowfrom conditional expression to conditional predicateorfrom method invocationto method definition.

1: a = 3; 2: b = 2; 3: scanf("%d", &c); 4: if ( c == 0 ) 5: d = a; 6: else 7: d = a + 1; 8: e = a + b; 9: printf("%d", d);10: printf("%d", e);

1: a = 3; 2: b = 2; 3: scanf("%d", &c); 4: if ( c == 0 ) 5: d = a; 6: else 7: d = a + 1; 8: e = a + b; 9: printf("%d", d);10: printf("%d", e);

Page 9: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

9

Static SliceScope : all possible execution paths

Target : source codeExecution : not required

Dependence analysisDD : staticCD : static

AdvantageSmall analysis cost

DisadvantageImprecise analysis results

1: a = 3; 2: b = 2; 3: scanf("%d", &c); 4: if ( c == 0 ) 5: d = a; 6: else 7: d = a + 1; 8: e = a + b; 9: printf("%d", d);10: printf("%d", e);

1: a = 3; 2: b = 2; 3: scanf("%d", &c); 4: if ( c == 0 ) 5: d = a; 6: else 7: d = a + 1; 8: e = a + b; 9: printf("%d", d);10: printf("%d", e);

dd

Slice for <9, d>

Page 10: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

10

Dynamic SliceScope : single execution path

Target : execution traceExecution : required

Dependence analysisDD : dynamicCD : dynamic

AdvantagePrecise analysis results

DisadvantageLarge analysis cost

1: a = 3; 2: b = 2; 3: scanf("%d", &c); 4: if ( c == 0 ) 5: d = a; 6: else 7: d = a + 1; 8: e = a + b; 9: printf("%d", d);10: printf("%d", e);

1: a = 3; 2: b = 2; 3: scanf("%d", &c); 4: if ( c == 0 ) 5: d = a; 6: else 7: d = a + 1; 8: e = a + b; 9: printf("%d", d);10: printf("%d", e);

- input ‘0’ for c -

dd

Page 11: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

11

Contents (2/6)Program SliceDependence-Cache (DC) SliceObject-Oriented Dependence-Cache (OODC) SliceImplementationEvaluationSummary and Future Work

Page 12: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

12

ProblemsStatic slice has two problems,

array indexes problem : it is difficult for us to determine the values of array indices, andpointer alias problem : it is difficult for us to determine the destination of pointer variables,

so that extracted DD relations are imprecise.Dynamic slice can resolve these problems; however, it requires large analysis cost.

Page 13: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

13

Dependence-Cache (DC) SliceScope : single execution path

Target : source codeExecution : required

Dependence analysisDD : dynamicCD : static

AdvantageMore precise analysis results than static sliceSmaller analysis cost than dynamic slice

1: a = 3; 2: b = 2; 3: scanf("%d", &c); 4: if ( c == 0 ) 5: d = a; 6: else 7: d = a + 1; 8: e = a + b; 9: printf("%d", d);10: printf("%d", e);

1: a = 3; 2: b = 2; 3: scanf("%d", &c); 4: if ( c == 0 ) 5: d = a; 6: else 7: d = a + 1; 8: e = a + b; 9: printf("%d", d);10: printf("%d", e);

- input ‘0’ for c -

Page 14: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

14

Dynamic DD AnalysisDD relation DD(s, t, v) exists when the following conditions are all satisfied:

statement s defines variable v, andstatement t refers v, andat least one execution path from s to t without re-defining v exists.

Dynamic analysisOn program execution, we have only to trace the most-recently defined statement for each variable using cache.

Page 15: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

15

CacheCache(v) : statement that defined variable v most-recently.Operations for cachesBefore program execution,

For each variable v, Cache(v) .On program execution,

For each statement s,- when v is defined, Cache(v) s.- when v is referred, we extract DD relation “DD(Cache(v), s, v)”.

Page 16: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

16

Comparison withStatic Slice & Dynamic Slice¶

Analysis precision (slice size) : Static slice DC slice Dynamic slice

Analysis cost (memory space & computation time) : Static slice < DC slice « Dynamic slice

Static slice

DC sliceDynamic

slice

DD analysis

Static Dynamic Dynamic

CD analysis

Static Static Dynamic

TargetSource code

Source code

Execution trace

¶ Ashida, Y., Ohata, F. and Inoue, K. : “Slicing Methods Using Static and Dynamic Information”, Proceedings of the 6th Asia Pacific Software Engineering Conference, 344-350, 1999.

Page 17: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

17

Contents (3/6)Program SliceDependence-Cache (DC) SliceObject-Oriented Dependence-Cache (OODC) SliceImplementationEvaluationSummary and Future Work

Page 18: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

18

Object-Oriented DC (OODC) Slice

Extended DC slice for Object-Oriented (OO) programs

OO languages have concepts which procedural languages do not have.

Class, Object (Instance)Inheritance, Class hierarchy, Method overridingDynamic binding : based on the reference-type of the object, an appropriate overriding method is selected and invoked.

Page 19: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

19

Analysis PolicyCharacter 1 : object is a collection of

attributes and methods that operate them.Character 2 : dynamic binding feature

exists; however, static analysis can not handle it sufficiently.

Policy 1 : when a variable is created, the corresponding cache is also created.

Policy 2 : we use dynamic CD analysis for method invocation.

Page 20: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

20

Dynamic CD analysis for Method Invocation

CD relation CD(s, t) about method invocation exists when the following conditions are all satisfied:

statement t is a method definition, andstatement s calls t.

Dynamic analysisOn program execution, we have only to watch the execution trace from a method invocation to a method definition.

Page 21: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

21

Contents (4/6)Program SliceDependence-Cache (DC) SliceObject-Oriented Dependence-Cache (OODC) SliceImplementationEvaluationSummary and Future Work

Page 22: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

22

ImplementationDC Slicing System for Java

Analysis librariesGUI

Developing environmentJDK1.3.0_01JavaCC2.0

Program

JavaCompiler

JavaVirtual

Machine

Slice

PDG

GUI (Graphical User Interface)

Program +Analysis Code

[Source]

Program +Analysis Code

[Bytecode]

Preprocessor

Slicing Criterion

Slicer

Analysis Libraries

Page 23: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

23

Analysis Libraries10,000 lines

Analysis method : preprocessor stylePreprocessor loads target program p, and generate program p’ that contains p and the code to analyze p dynamically.

Easily developmentEasily optimization using JIT or JavaVM

Page 24: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

24

Example [Preprocessed Code]

0 : initPDG();1’: def(a, 1); 1 : int a = 10;2’: def(b, 2); 2 : int b = 20;3’: def(c, 3);3 : int c;4’: ref(a, 4); 4’: ref(b, 4); 4’: def(c, 4); 4 : c = a + b;5’: ref(c, 5);5 : printf(“%d\n”, c);

0 : initPDG();1’: def(a, 1); 1 : int a = 10;2’: def(b, 2); 2 : int b = 20;3’: def(c, 3);3 : int c;4’: ref(a, 4); 4’: ref(b, 4); 4’: def(c, 4); 4 : c = a + b;5’: ref(c, 5);5 : printf(“%d\n”, c);

1 : int a = 10;2 : int b = 20;3 : int c;4 : c = a + b;5 : printf(“%d\n”, c);

1 : int a = 10;2 : int b = 20;3 : int c;4 : c = a + b;5 : printf(“%d\n”, c);

- Preprocessed code -- Original code -

DevelopedPreprocessor

For each statement s,when variable v is referred, we insert ref(v, s) before s.when v is defined,we insert def(v, s) before s.

Page 25: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

25

GUI3,000 lines

FeaturesProgram editingSlice computation

Page 26: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

26

Contents (5/6)Program SliceDependence-Cache (DC) SliceObject-Oriented Dependence-Cache (OODC) SliceImplementationEvaluationSummary and Future Work

Page 27: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

27

Metrics Values (1/2)Sample programs

Analysis precision (slice size) [lines]

Program

Classes

Override methods

Lines

Description

P1 2 0 223 CGI program

P2 3 7 226 Paint programSlicing

criterionStatic

DC

Dynamic

P1(1) 26 15 15

P1(2) 83 27 27

P2(1) 48 14 14

P2(2) 45 12 12

Page 28: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

28

Metrics Values (2/2)Analysis cost

Computation cost (execution time) [ms]

T1 : original code, T2 : preprocessed code (original code + analysis code)

Space cost (memory use on execution) [KByte]

Program

T1 T2 T2/T1

P1 138

582

4.22

P2 N/A

N/A

N/A

Program

T1 T2 T2/T1

P1 478

645

1.35

P2 836

920

1.10

Page 29: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

29

EvaluationAnalysis precision

Slice size : 30-60% of Static sliceStatic slice DC slice Dynamic slice¶

Analysis costAdditional cost for dynamic DD analysis and dynamic CD analysis for method invocation is not so large.

- Computation cost : 4.2- Space cost : 1.2

¶ Ashida, Y., Ohata, F. and Inoue, K. : “Slicing Methods Using Static and Dynamic Information”, Proceedings of the 6th Asia Pacific Software Engineering Conference, 344-350, 1999.

Page 30: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

30

Contents (6/6)Program SliceDependence-Cache (DC) SliceObject-Oriented Dependence-Cache (OODC) SliceImplementationEvaluationSummary and Future Work

Page 31: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

31

SummaryClassification of slicing methodsOODC slice

An intermediate slice between static slice and dynamic slice for OO programs

Dynamic DD analysisDynamic CD analysis for method invocationStatic CD analysis (except method invocation)

Implementation (DC Slicing System for Java)Evaluation (Experimentation using sample Java programs)

Page 32: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

32

Future WorkApplication of dynamic CD analysis to other dynamically determined elements in Java

ExceptionThread

Experimental comparison with other slicing methods on analysis costApplication of OODC slice to large programsJavaVM-based (interpreter style) DC Slicing System for Java (now developing)

Page 33: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

33

End.

Page 34: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

34

Example [Phase 2] (DD Analysis)

1: #include <stdio.h> 2: 3: float absolute(float x) 4: { 5: if(x < 0) { 6: x = -1 * x; 7: } 8: return x; 9: }10: 11: float ave(int a, int b, int c)12: {13: int sum;14: float x;15: 16: sum = a + b + c;17: x = (float) sum / 3.0;18: x = absolute(x);19: return x;20: }21: 22: int main(void)23: {24: int a, b, c;25: float x;26: 27: printf("Input a b c ?");28: scanf("%d %d %d", &a, &b, &c);29: 30: x = ave(a, b, c);31: printf("Ave = %9.3f\n", x);32: return 0;33: }

1: #include <stdio.h> 2: 3: float absolute(float x) 4: { 5: if(x < 0) { 6: x = -1 * x; 7: } 8: return x; 9: }10: 11: float ave(int a, int b, int c)12: {13: int sum;14: float x;15: 16: sum = a + b + c;17: x = (float) sum / 3.0;18: x = absolute(x);19: return x;20: }21: 22: int main(void)23: {24: int a, b, c;25: float x;26: 27: printf("Input a b c ?");28: scanf("%d %d %d", &a, &b, &c);29: 30: x = ave(a, b, c);31: printf("Ave = %9.3f\n", x);32: return 0;33: }

16: sum = a + b + c;17: x = (float) sum / 3.0;

Data dependence (DD) relation

sum

Page 35: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

35

Example [Phase 2] (CD Analysis) 1: #include <stdio.h> 2: 3: float absolute(float x) 4: { 5: if(x < 0) { 6: x = -1 * x; 7: } 8: return x; 9: }10: 11: float ave(int a, int b, int c)12: {13: int sum;14: float x;15: 16: sum = a + b + c;17: x = (float) sum / 3.0;18: x = absolute(x);19: return x;20: }21: 22: int main(void)23: {24: int a, b, c;25: float x;26: 27: printf("Input a b c ?");28: scanf("%d %d %d", &a, &b, &c);29: 30: x = ave(a, b, c);31: printf("Ave = %9.3f\n", x);32: return 0;33: }

1: #include <stdio.h> 2: 3: float absolute(float x) 4: { 5: if(x < 0) { 6: x = -1 * x; 7: } 8: return x; 9: }10: 11: float ave(int a, int b, int c)12: {13: int sum;14: float x;15: 16: sum = a + b + c;17: x = (float) sum / 3.0;18: x = absolute(x);19: return x;20: }21: 22: int main(void)23: {24: int a, b, c;25: float x;26: 27: printf("Input a b c ?");28: scanf("%d %d %d", &a, &b, &c);29: 30: x = ave(a, b, c);31: printf("Ave = %9.3f\n", x);32: return 0;33: }

5: if (x < 0) {6: x = -1 * x;7: }

Control dependence (CD) relation[intra-method]

11: float ave(int a, int b, int c)12: {18: x = absolute(x);20: }

3: float absolute(float x)4: {5: if(x < 0) {6: x = -1 * x;7: }8: return x;9: }

Control dependence (CD) relation[inter-method]

return

call

Page 36: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

36

Example [Phase 3]28

30

31

11

16

17

18

19

3

5

6

827

a b

x

c

sum

x

x

x

xx

cb a

DDCD

1: #include <stdio.h> 2: 3: float absolute(float x) 4: { 5: if(x < 0) { 6: x = -1 * x; 7: } 8: return x; 9: }10: 11: float ave(int a, int b, int c)12: {13: int sum;14: float x;15: 16: sum = a + b + c;17: x = (float) sum / 3.0;18: x = absolute(x);19: return x;20: }21: 22: int main(void)23: {24: int a, b, c;25: float x;26: 27: printf("Input a b c ?");28: scanf("%d %d %d", &a, &b, &c);29: 30: x = ave(a, b, c);31: printf("Ave = %9.3f\n", x);32: return 0;33: }

1: #include <stdio.h> 2: 3: float absolute(float x) 4: { 5: if(x < 0) { 6: x = -1 * x; 7: } 8: return x; 9: }10: 11: float ave(int a, int b, int c)12: {13: int sum;14: float x;15: 16: sum = a + b + c;17: x = (float) sum / 3.0;18: x = absolute(x);19: return x;20: }21: 22: int main(void)23: {24: int a, b, c;25: float x;26: 27: printf("Input a b c ?");28: scanf("%d %d %d", &a, &b, &c);29: 30: x = ave(a, b, c);31: printf("Ave = %9.3f\n", x);32: return 0;33: } Node : statement or conditional expression

Edge : dependence relation between two nodes

Node : statement or conditional expressionEdge : dependence relation between two

nodes

Page 37: A Slicing Method for Object-Oriented Programs Using Lightweight Dynamic Information

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University

37

Example [Phase 4] (Slice for <30, x>)

1: #include <stdio.h> 2: 3: float absolute(float x) 4: { 5: if(x < 0) { 6: x = -1 * x; 7: } 8: return x; 9: }10: 11: float ave(int a, int b, int c)12: {13: int sum;14: float x;15: 16: sum = a + b + c;17: x = (float) sum / 3.0;18: x = absolute(x);19: return x;20: }21: 22: int main(void)23: {24: int a, b, c;25: float x;26: 27: printf("Input a b c ?");28: scanf("%d %d %d", &a, &b, &c);29: 30: x = ave(a, b, c);31: printf("Ave = %9.3f\n", x);32: return 0;33: }

1: #include <stdio.h> 2: 3: float absolute(float x) 4: { 5: if(x < 0) { 6: x = -1 * x; 7: } 8: return x; 9: }10: 11: float ave(int a, int b, int c)12: {13: int sum;14: float x;15: 16: sum = a + b + c;17: x = (float) sum / 3.0;18: x = absolute(x);19: return x;20: }21: 22: int main(void)23: {24: int a, b, c;25: float x;26: 27: printf("Input a b c ?");28: scanf("%d %d %d", &a, &b, &c);29: 30: x = ave(a, b, c);31: printf("Ave = %9.3f\n", x);32: return 0;33: }

28

30

31

11

16

17

18

19

3

5

6

827

a b

x

c

sum

x

x

x

x xx

cb a

We start PDG traversal from the slicing criterion node in reverse order.

The corresponding statements to the reachable nodes form the slice.

We start PDG traversal from the slicing criterion node in reverse order.

The corresponding statements to the reachable nodes form the slice.