Software Engineering Research Group, Graduate School of Engineering Science, Osaka University A Slicing Method for Object-Oriented Programs Using Lightweight.

Slides:



Advertisements
Similar presentations
DATAFLOW TESTING DONE BY A.PRIYA, 08CSEE17, II- M.s.c [C.S].
Advertisements

Overview Structural Testing Introduction – General Concepts
Slicing Methods Using Static and Dynamic Information Yoshiyuki Ashida, Fumiaki Ohata, † † † ‡ †‡ Katsuro Inoue Osaka University Nara Institute of Science.
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
 Program Slicing Long Li. Program Slicing ? It is an important way to help developers and maintainers to understand and analyze the structure.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
Program Slicing Mark Weiser and Precise Dynamic Slicing Algorithms Xiangyu Zhang, Rajiv Gupta & Youtao Zhang Presented by Harini Ramaprasad.
1 Program Slicing Purvi Patel. 2 Contents Introduction What is program slicing? Principle of dependences Variants of program slicing Slicing classifications.
Presented By: Krishna Balasubramanian
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
VB in Context Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh Pittsburgh, Pa 15260
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Building An Interpreter After having done all of the analysis, it’s possible to run the program directly rather than compile it … and it may be worth it.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 5 Data Flow Testing
C++ fundamentals.
Software Testing and QA Theory and Practice (Chapter 4: Control Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Testing Dr. Andrew Wallace PhD BEng(hons) EurIng
Advanced Database CS-426 Week 2 – Logic Query Languages, Object Model.
Language Evaluation Criteria
Programming Languages and Paradigms Object-Oriented Programming.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.
High-Level Programming Languages: C++
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University ICSE 2003 Java.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Presented By Dr. Shazzad Hosain Asst. Prof., EECS, NSU
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A lightweight.
Chapter 1. Introduction.
BIT 1003 – Presentation 7. Contents GENERATIONS OF LANGUAGES COMPILERS AND INTERPRETERS VIRTUAL MACHINES OBJECT-ORIENTED PROGRAMMING SCRIPTING LANGUAGES.
Adapted from Prof. Necula UCB CS 1641 Overview of COOL ICOM 4029 Lecture 2 ICOM 4029 Fall 2008.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
Software Engineering Research Group, Graduate School of Engineering Science, Osaka University Analysis and Implementation Method of Program to Detect Inappropriate.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Design and Implementation.
Coverage Criteria for Testing of Object Interactions in Sequence Diagrams Atanas (Nasko) Rountev Scott Kagan Jason Sawin Ohio State University.
Introduction to Object Oriented Programming CMSC 331.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University Dependence-Cache.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University July 21, 2008WODA.
Slicing AspectJ Woven Code Luca Cavallaro Mattia Monga Antonio Castaldo D'Ursi Davide Balzarotti Politecnico di Milano.
Chapter 11: Dynamic Analysis Omar Meqdadi SE 3860 Lecture 11 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
1. An Introduction A Programming Language A Technology Java Development Kit Java API One Language: Three Editions Standard Edition Enterprise Edition.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Introduction to OOP CPS235: Introduction.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
1 Software Testing & Quality Assurance Lecture 13 Created by: Paulo Alencar Modified by: Frank Xu.
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
Chapter 2 : Graph Coverage (part 2)
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University A Metric-based Approach for Reconstructing Methods.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Phoenix Based Dynamic Slicing Debugging Tool Eric Cheng Lin Xu Matt Gruskin Ravi Ramaseshan Microsoft Phoenix Intern Team (Summer '06)
Software Testing and QA Theory and Practice (Chapter 5: Data Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Visit for more Learning Resources
Control Flow Testing Handouts
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Outline of the Chapter Basic Idea Outline of Control Flow Testing
Program Slicing Baishakhi Ray University of Virginia
Paul Ammann & Jeff Offutt
Lecture 18 Arrays and Pointer Arithmetic
ICOM 4029 Fall 2003 Lecture 2 (Adapted from Prof. Necula UCB CS 164)
Software Testing and QA Theory and Practice (Chapter 5: Data Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Presentation transcript:

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 HIROSE, Masato FUJII and Katsuro INOUE Osaka University, JAPAN

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 2 Contents Program Slice Dependence-Cache (DC) Slice Object-Oriented Dependence-Cache (OODC) Slice Implementation Evaluation Summary and Future Work

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 3 Contents (1/6) Program Slice Dependence-Cache (DC) Slice Object-Oriented Dependence-Cache (OODC) Slice Implementation Evaluation Summary and Future Work

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 4 Program Slice (Slice) Subprogram which affects the value of slicing criterion in p s : Statement v : Variable p : Program Applications Program understanding Program debugging …

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 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 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 -

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 6 Computation Process Phase 1 : Defined and referred variables extraction Phase 2 : Dependence analysis Data dependence (DD) analysis Control dependence (CD) analysis Phase 3 : Program dependence graph (PDG) construction Phase 4 : Slice extraction using PDG traversal

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-flow through 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); d d

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-flow from conditional expression to conditional predicate or from method invocation to 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);

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 9 Static Slice Scope : all possible execution paths Target : source code Execution : not required Dependence analysis DD : static CD : static Advantage Small analysis cost Disadvantage Imprecise 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); d d Slice for

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 10 Dynamic Slice Scope : single execution path Target : execution trace Execution : required Dependence analysis DD : dynamic CD : dynamic Advantage Precise analysis results Disadvantage Large 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 - d d

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 11 Contents (2/6) Program Slice Dependence-Cache (DC) Slice Object-Oriented Dependence-Cache (OODC) Slice Implementation Evaluation Summary and Future Work

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 12 Problems Static slice has two problems, array indexes problem : it is difficult for us to determine the values of array indices, and pointer 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.

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 13 Dependence-Cache (DC) Slice Scope : single execution path Target : source code Execution : required Dependence analysis DD : dynamic CD : static Advantage More precise analysis results than static slice Smaller 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 -

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 14 Dynamic DD Analysis DD relation DD(s, t, v) exists when the following conditions are all satisfied: statement s defines variable v, and statement t refers v, and at least one execution path from s to t without re-defining v exists. Dynamic analysis On program execution, we have only to trace the most-recently defined statement for each variable using cache.

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 15 Cache Cache(v) : statement that defined variable v most-recently. Operations for caches Before 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)”.

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 16 Comparison with Static 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 sliceDC sliceDynamic slice DD analysisStaticDynamic CD analysisStatic Dynamic TargetSource 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, , 1999.

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 17 Contents (3/6) Program Slice Dependence-Cache (DC) Slice Object-Oriented Dependence-Cache (OODC) Slice Implementation Evaluation Summary and Future Work

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 overriding Dynamic binding : based on the reference-type of the object, an appropriate overriding method is selected and invoked.

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 19 Analysis Policy Character 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.

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, and statement s calls t. Dynamic analysis On program execution, we have only to watch the execution trace from a method invocation to a method definition.

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 21 Contents (4/6) Program Slice Dependence-Cache (DC) Slice Object-Oriented Dependence-Cache (OODC) Slice Implementation Evaluation Summary and Future Work

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 22 Implementation DC Slicing System for Java Analysis libraries GUI Developing environment JDK1.3.0_01 JavaCC2.0 Program Java Compiler Java Virtual Machine Slice PDG GUI (Graphical User Interface) Program + Analysis Code [Source] Program + Analysis Code [Bytecode] Preprocessor Slicing Criterion Slicer Analysis Libraries

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 23 Analysis Libraries 10,000 lines Analysis method : preprocessor style Preprocessor loads target program p, and generate program p’ that contains p and the code to analyze p dynamically. Easily development Easily optimization using JIT or JavaVM

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 - Developed Preprocessor 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.

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 25 GUI 3,000 lines Features Program editing Slice computation

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 26 Contents (5/6) Program Slice Dependence-Cache (DC) Slice Object-Oriented Dependence-Cache (OODC) Slice Implementation Evaluation Summary and Future Work

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 27 Metrics Values (1/2) Sample programs Analysis precision (slice size) [lines] ProgramClassesOverride methodsLinesDescription P1P CGI program P2P Paint program Slicing criterion StaticDCDynamic P 1 (1)2615 P 1 (2)8327 P 2 (1)4814 P 2 (2)4512

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 28 Metrics Values (2/2) Analysis cost Computation cost (execution time) [ms] T 1 : original code, T 2 : preprocessed code (original code + analysis code) Space cost (memory use on execution) [KByte] ProgramT1T1 T2T2 T 2 /T 1 P1P P2P2 N/A ProgramT1T1 T2T2 T 2 /T 1 P1P P2P

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 29 Evaluation Analysis precision Slice size : 30-60% of Static slice Static slice  DC slice  Dynamic slice ¶ Analysis cost Additional cost for dynamic DD analysis and dynamic CD analysis for method invocation is not so large. - Computation cost :  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, , 1999.

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 30 Contents (6/6) Program Slice Dependence-Cache (DC) Slice Object-Oriented Dependence-Cache (OODC) Slice Implementation Evaluation Summary and Future Work

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 31 Summary Classification of slicing methods OODC slice An intermediate slice between static slice and dynamic slice for OO programs Dynamic DD analysis Dynamic CD analysis for method invocation Static CD analysis (except method invocation) Implementation (DC Slicing System for Java ) Evaluation (Experimentation using sample Java programs)

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 32 Future Work Application of dynamic CD analysis to other dynamically determined elements in Java Exception Thread Experimental comparison with other slicing methods on analysis cost Application of OODC slice to large programs JavaVM-based (interpreter style) DC Slicing System for Java (now developing)

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 33 End.

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 34 Example [Phase 2] (DD Analysis) 1: #include 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 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

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 35 Example [Phase 2] (CD Analysis) 1: #include 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 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

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 36 Example [Phase 3] a b x c sum x x x x x c b a DD CD 1: #include 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 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 expression Edge : dependence relation between two nodes

Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 37 Example [Phase 4] (Slice for ) 1: #include 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 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: } a b x c sum x x x x x x c b 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.