1 Program Slicing Purvi Patel. 2 Contents Introduction What is program slicing? Principle of dependences Variants of program slicing Slicing classifications.

Slides:



Advertisements
Similar presentations
Analyzing Regression Test Selection Techniques
Advertisements

Overview Structural Testing Introduction – General Concepts
A Survey of Program Slicing Techniques A Survey of Program Slicing Techniques Sections 3.1,3.6 Swathy Shankar
Program Slicing – Based Techniques
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
 Program Slicing Long Li. Program Slicing ? It is an important way to help developers and maintainers to understand and analyze the structure.
Program Slicing; Andreas Linder eXtreme Programming lab course 2004.
Program Slicing. 2 CS510 S o f t w a r e E n g i n e e r i n g Outline What is slicing? Why use slicing? Static slicing of programs Dynamic Program Slicing.
Program Slicing Mark Weiser and Precise Dynamic Slicing Algorithms Xiangyu Zhang, Rajiv Gupta & Youtao Zhang Presented by Harini Ramaprasad.
© SERG Dependable Software Systems (Slicing) Dependable Software Systems Topics in Program Slicing Material drawn from [Weiser84,Gallagher91,DeMillo96]
Introduction to Program Slicing Presenter: M. Amin Alipour Software Design Laboratory
Interprocedural Slicing using Dependence Graphs Susan Horwitz, Thomas Reps, and David Binkley University of Wisconsin-Madison.
Csci 565 Spring  Originally proposed by [Weiser 88]and [Gallagher 91] in software maintenance  Useful for  Software Debugging  Software Maintenance.
SwE 455 Program Slicing. Our Goals Debug your thousands lines of code easily by reducing the complexity of the program Write a robust program before testing.
1 Static Testing: defect prevention SIM objectives Able to list various type of structured group examinations (manual checking) Able to statically.
Next Section: Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis (Wilson & Lam) –Unification.
Program Slicing for Refactoring Advanced SW Tools Seminar Jan 2005Yossi Peery.
Program Representations Xiangyu Zhang. CS590Z Software Defect Analysis Program Representations  Static program representations Abstract syntax tree;
Survey of program slicing techniques
Software Testing and QA Theory and Practice (Chapter 4: Control Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Technical University of Valencia Computer Science Department SOFSEM’07 (22/01/2007) A Program Slicing Based Method to Filter XML/DTD documents.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
1 A Static Analysis Approach for Automatically Generating Test Cases for Web Applications Presented by: Beverly Leung Fahim Rahman.
Foundations of Software Testing Chapter 5: Test Selection, Minimization, and Prioritization for Regression Testing Last update: September 3, 2007 These.
Bug Localization with Machine Learning Techniques Wujie Zheng
Static Program Analyses of DSP Software Systems Ramakrishnan Venkitaraman and Gopal Gupta.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University Dependence-Cache.
1 Program Slicing Amir Saeidi PhD Student UTRECHT UNIVERSITY.
Static Program Analysis of Embedded Software Ramakrishnan Venkitaraman Graduate Student, Computer Science Advisor: Dr. Gopal Gupta
Debugging parallel programs. Breakpoint debugging Probably the most widely familiar method of debugging programs is breakpoint debugging. In this method,
Chapter 11: Dynamic Analysis Omar Meqdadi SE 3860 Lecture 11 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
CASE/Re-factoring and program slicing
Lecture Notes - Copyright © S. C. Kothari, All rights reserved.1 Efficient Debugging CPRE 556 Lecture 19.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Software Engineering Research Group, Graduate School of Engineering Science, Osaka University A Slicing Method for Object-Oriented Programs Using Lightweight.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
1 Control Flow Analysis Topic today Representation and Analysis Paper (Sections 1, 2) For next class: Read Representation and Analysis Paper (Section 3)
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
Program Slicing Techniques CSE 6329 Spring 2013 Parikksit Bhisay
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.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
Foundations of Software Testing Chapter 5: Test Selection, Minimization, and Prioritization for Regression Testing Last update: September 3, 2007 These.
Tempus Software Maintenance and Evolution JMSE-SM&E Unit 2: Selected Topics in Analysis of Software Artifacts Prof. Mohammad A. Mikki Gaza, Palestine.
Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
CS223: Software Engineering Lecture 26: Software Testing.
Phoenix Based Dynamic Slicing Debugging Tool Eric Cheng Lin Xu Matt Gruskin Ravi Ramaseshan Microsoft Phoenix Intern Team (Summer '06)
Data Flow Analysis Suman Jana
Regression Testing with its types
Software Testing.
Software Testing.
Control Flow Testing Handouts
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Software Engineering (CSI 321)
Outline of the Chapter Basic Idea Outline of Control Flow Testing
Aditya P. Mathur Purdue University
Structural testing, Path Testing
SwE 455 Program Slicing.
Types of Testing Visit to more Learning Resources.
Mark Weiser University of Maryland, College Park IEEE CHI, 1981
A Survey of Program Slicing Techniques: Section 4
Program Slicing Baishakhi Ray University of Virginia
University Of Virginia
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
CPRE 416-Software Evolution and Maintenance-Lecture 11
Presentation transcript:

1 Program Slicing Purvi Patel

2 Contents Introduction What is program slicing? Principle of dependences Variants of program slicing Slicing classifications Applications of program slicing Program slicing matrices Program slicing tools Current and future challenges References

3 Introduction [1/3] T he size and complexity of a software today gets harder to understand, maintain and test You might have had questions like  If I change this statement, what pieces of the program are going to be affected?  Where are the values that flow into this statement coming from?  How can I limit the functionality to only what I need?

4 Introduction [2/3] Goals – Debug your thousands lines of code easily by reducing the complexity of the program – Write a robust program before testing your code – Save your regression testing time by limiting the tests to only those that exercise the changed code

5 Introduction [3/3] How ? – “Break larger code into smaller pieces” During program design, some known decomposition techniques are – Information hiding and data abstraction Unlike most other methods, slicing is applied to programs after they are written, and is therefore useful in maintenance rather than design

6 What is program slicing? [1/3] Program slice is a decomposition technique that extracts statements relevant to a particular computation from a program Program slices was first introduced by Mark Weiser (1980) are known as executable backward static slices Program slicing describes a mechanism which allows the automatic generation of a slice

7 What is program slicing? [2/3] Slicing criterion – Where s specifies a location (statement s) and v specifies a variable (v) All statements affecting or affected by the variables mentioned in the slicing criterion becomes a part of the slice

8 What is program slicing? [3/3] Program slice must satisfy the following conditions – Slice S(V,n) must be derived from P by deleting statements from P – Slice S(V,n) must be syntactically correct – For all executions of P, the value of V in the execution of S(V,n) just before the location n must be the same value of V in the execution of the program P just before location n

9 Principle of dependences Data dependence – Definition of variable v at statement s1 reaches a use of v at statement s2 Control dependence – Conditional statement controls whether or not the current statement is executed Synchronization dependence – Dependencies related to threading and locking

10 Example of program slicing Original program: 1 begin 2 read(x,y) 3 total := sum := if x <= 1 6then sum := y 7else begin 8 read(z) 9 total := x*y 10 end 11 write(total, sum) 12 end. Slice criterion: begin read(x,y) if x <= 1 then else read(z) end. Slice criterion: begin read(x,y) end. Slice criterion: begin read(x,y) total := 0 if x <= 1 then else total := x*y end.

11 Variants of program slicing Static slice Dynamic slice Conditioned slice

12 Variants of program slicing Static slices [1/3] Slice criterion – Where p is a program point and V is a subset of program variables Program slice on the slicing criterion is a subset of program statements that preserves the behavior of the original program at the program point p with respect to the program variables in V

13 Variants of program slicing Static slices [2/3] Slices derived from the source code for all possible input values No assumptions about input values May lead to relatively big slices Contains all statements that may affect a variable for every possible execution Current static methods can only compute approximations

14 Variants of program slicing Static slices [3/3] Intermediate representation of programs for slicing – Control Flow Graph (CFG) Data Flow equations are solved – Program Dependence Graph (PDG) Slice is computed as graph reachability problem

15 Recall: control flow graph (CFG) Each program statement is a node A directed edge will connect between any 2 nodes that represent statements with a possible control flow between them Special nodes: start, stop Definitions – : directed path from I to j – : set of nodes that are influenced by i – : all of the variables that are defined (modified) at statement i – : all of the variables that are referenced (used) at statement i

16 Recall: program dependence graphs (PDG) Each node represents a statement (like CFG) Directed edges represent – Control dependence (bold lines) – between a predicate and the statements it controls – Data dependence (Regular Lines) – between statements modifying a variable and those that may reference it Special “entry” node is connected to all nodes that are not control dependant

17 Static slices example Slice criterion (12,i) – 1 main( ) – 2 { – 3 int i, sum; – 4 sum = 0; – 5 i = 1; – 6 while(i <= 10) – 7 { – 8sum = sum + 1; – 9++ i; – 10 } – 11Cout<< sum; – 12Cout<< i; – 13}

18 PDG of previous static slice example Slice Point Control Dep. Edge Data Dep. Edge

19 Variants of program slicing Dynamic slices Dynamic slice preserve the meaning of the variable in the slicing criterion for a single input to the program Slicing criterion: – Where I is input, p is program point and v is program variable Deterministic instead of probabilistic Allow an easier localization of the bugs Another advantage of dynamic slicing is the run-time handling of arrays and pointer variables

20 Example of dynamic slices 1. read (n) 2. for I := 1 to n do 3. a := 2 4. if c1==1 then 5. if c2==1 then 6. a := 4 7. else 8. a := 6 9. z := a 10. write (z) Assumptions – Input n is 1 – C1, c2 both true – Execution history is 1 1, 2 1, 3 1, 4 1, 5 1, 6 1, 9 1, 2 2, 10 1 – Slice criterion

21 Variants of program slicing Conditioned Slices Conditioned slicing can be viewed as filling the gap between static and dynamic slicing Conditioned slice preserves the semantics of the slicing criterion only for those inputs that satisfy a boolean condition

22 Example of conditioned slice 1. read(a) 2. if (a < 0) 3. a = -a 4. x = 1/a Assumptions – Input ‘a’ is positive number

23 Slicing classifications Levels of slices – Intraprocedural slicing – Interprocedural slicing Direction of slicing – Backward – Forward

24 Slicing classifications Levels of slices Intraprocedural slicing – Computes slice within one procedure – Assumes worse case for function calls Interprocedural slicing – Compute slice over an entire program – Two ways for crossing procedure boundary Up: going from sliced procedure into calling procedure Down: going from sliced procedure into called procedure – Must be context sensitive

25 Slicing classifications Direction of slicing Backward slicing – Backward slice of a program with respect to a program point p and set of program variables V consists of all statements and predicates in the program that may affect the value of variables in V at p – Answer the question “what program components might effect a selected computation?” – Preserve the meaning of the variable (s) in the slicing criterion for all possible inputs to the program – Useful in debugging

26 Example of backward slicing Slice criterion – 1 main( ) – 2 { – 3 int i, sum; – 4 sum = 0; – 5 i = 1; – 6 while(i <= 10) – 7 { – 8Sum = sum + 1; – 9++ i; – 10 } – 11Cout<< sum; – 12Cout<< i; – 13}

27 Slicing classifications Direction of slicing Forward slicing – Forward slice of a program with respect to a program point p and set of program variables V consists of all statements and predicates in the program that may be affected by the value of variables in V at p – Answers the question “what program components might be effected by a selected computation?” – Useful in determining which all statements in a program can be effected by change in value of v at statement Si

28 Example of forward static slicing Slice criterion – 1 main( ) – 2 { – 3 int i, sum; – 4 sum = 0; – 5 i = 1; – 6 while(i <= 10) – 7 { – 8 sum = sum + 1; – 9 ++ i; – 10 } – 11 Cout<< sum; – 12 Cout<< i; – 13}

29 Applications of program slices [1/2] Program debugging – Was introduced by Mark Weiser as debugging aid – Slicing visualizes control and data dependencies – It highlights statements influencing the slice Testing: reduce cost of regression testing after modifications (only run those tests that needed) Integration : merging two programs A and B that both resulted from modifications to BASE

30 Applications of program slices [2/2] Program understanding Reverse engineering: comprehending the design by abstracting out of the source code the design decisions Software maintenance: changing source code without unwanted side effects Software quality assurance: validate interactions between safety-critical components

31 Program slicing matrices Set of metrics proposed by Weiser in 1981 – Coverage – Overlap – Clustering – Parallelism – Tightness

32 Program slicing tools CodeSurfer – Commercial product by GammaTech Inc. – GUI Based – Scripting language-Tk Unravel – Static program slicer developed at NIST – Slices ANSI C programs – Limitations are in the treatment of Unions, Forks and pointers to functions

33 Current and future challenges Current challenges – Implementation – Size: reducing the size of a slice Future challenges – Increasing dynamic nature of languages – Slicing will become more specialized – Beyond slicing programs – Fundamental program building blocks

34 References M. Weiser., Program Slicing, Proc. of the Fifth International Conference on Software Engineering, pages , May 1981 D. Binkley, K. Gallagher., Program Slicing, Proc. of In Advances in Computers, Volume 43, A. DeLucia., Program Slicing: Methods and Applications, IEEE workshop on Source Code Analysis and Manipulation (SCAM 2001)

35 Thank you, ?