SwE 455 Program Slicing.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

A Survey of Program Slicing Techniques A Survey of Program Slicing Techniques Sections 3.1,3.6 Swathy Shankar
Program Slicing – Based Techniques
Chair of Software Engineering From Program slicing to Abstract Interpretation Dr. Manuel Oriol.
 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 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]
1 Program Slicing Purvi Patel. 2 Contents Introduction What is program slicing? Principle of dependences Variants of program slicing Slicing classifications.
CS590F Software Reliability What is a slice? S: …. = f (v)  Slice of v at S is the set of statements involved in computing v’s value at S. [Mark Weiser,
Introduction to Program Slicing Presenter: M. Amin Alipour Software Design Laboratory
08/05/2015Dr Andy Brooks1 MSc Software Maintenance MS Viðhald hugbúnaðar Fyrirlestrar 15 & 16 Programmers Use Slices When Debugging.
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.
12/06/20051 Software Configuration Management Configuration management (CM) is the process that controls the changes made to a system and manages the different.
Program Slicing for Refactoring Advanced SW Tools Seminar Jan 2005Yossi Peery.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
C++ fundamentals.
Chapter 13 & 14 Software Testing Strategies and Techniques
1CMSC 345, Version 4/04 Verification and Validation Reference: Software Engineering, Ian Sommerville, 6th edition, Chapter 19.
Testing Dr. Andrew Wallace PhD BEng(hons) EurIng
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
Regression Testing. 2  So far  Unit testing  System testing  Test coverage  All of these are about the first round of testing  Testing is performed.
Bug Localization with Machine Learning Techniques Wujie Zheng
Chapter 13: Regression Testing Omar Meqdadi SE 3860 Lecture 13 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Programming Life Cycle Problem analysisunderstand the problem Requirements definition specify what program will do High- and low-level designhow it meets.
1 Program Slicing Amir Saeidi PhD Student UTRECHT UNIVERSITY.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
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.
Data Structures Using C++ 2E
CSI 1340 Introduction to Computer Science II Chapter 1 Software Engineering Principles.
CS451 Software Maintenance Yugi Lee STB #555 (816) Note: This lecture was designed based on Stephen Schach’s.
Program Slicing Techniques CSE 6329 Spring 2013 Parikksit Bhisay
Classes - Intermediate
Mid-Year Review. Coding Problems In general, solve the coding problems by doing it piece by piece. Makes it easier to think about Break parts of code.
Tempus Software Maintenance and Evolution JMSE-SM&E Unit 2: Selected Topics in Analysis of Software Artifacts Prof. Mohammad A. Mikki Gaza, Palestine.
MUTACINIS TESTAVIMAS Benediktas Knispelis, IFM-2/2 Mutation testing.
Phoenix Based Dynamic Slicing Debugging Tool Eric Cheng Lin Xu Matt Gruskin Ravi Ramaseshan Microsoft Phoenix Intern Team (Summer '06)
Regression Testing with its types
Testing and Debugging PPT By :Dr. R. Mall.
C++ Plus Data Structures
Verification and Testing
Verification and Validation
Testing & Testing Tools
Chapter 13 & 14 Software Testing Strategies and Techniques
Types of Testing Visit to more Learning Resources.
Something about Java Introduction to Problem Solving and Programming 1.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Mark Weiser University of Maryland, College Park IEEE CHI, 1981
Program Slicing Baishakhi Ray University of Virginia
Objective of This Course
Programming Fundamentals (750113) Ch1. Problem Solving
Software Engineering Lecture #12.
Chapter 6 Methods.
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Programming Fundamentals (750113) Ch1. Problem Solving
Regression Testing.
Programming Fundamentals (750113) Ch1. Problem Solving
C. M. Overstreet Old Dominion University Spring 2006
CPRE 416-Software Evolution and Maintenance-Lecture 11
CSE 1020:Software Development
C. M. Overstreet Old Dominion University Fall 2005
C. M. Overstreet Old Dominion University Fall 2007
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Chapter 13 & 14 Software Testing Strategies and Techniques 1 Software Engineering: A Practitioner’s Approach, 6th edition by Roger S. Pressman.
Chapter 6: Methods CS1: Java Programming Colorado State University
Presentation transcript:

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 your code Save your regression testing time by limiting the tests to only those that exercise the changed code

“Break your code into smaller pieces” Approach “Break your code into smaller pieces”

Program Slicing What is it? - A well-known program analysis and transformation technique that uses program statement dependence information to identify parts of a program that influence or are influenced by an initial set of program points of interest which is called the slice criteria - Introduced by Mark Weiser in his Ph.D. thesis (1979) What it essentially means is we first pick a statement to be our slice criteria. Next, we generally are interested in two kinds of situations: All other statements in the program that are affecting the criteria. (Help us to find a bug, criteria is the statement that produce incorrect output) All other statements that are affected by the criteria. (If now the criteria is the fixed statements that used to be buggy)

Program Slicing (cont’d) indirectly relevant Resulting slice Slice Slicing Criterion Source program slicing criterion is provided by the user

Variants of Program Slicing Many different variants of program slicing exist Static Slicing Backward Slicing Forward Slicing Dynamic Slicing Conditional Slicing Chopping Also Many Different tools, however Most program slicing tools are written for C but there are also some for C++ and Java Most of these have problems with dynamic binding, inheritance, polymorphism and performance

Example of backward slicing Static Slice criterion <12,i> 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 }

Backward Slice Example public class SimpleExample { static int add(int a, int b){ return(a+b); } public static void main(final String[] arg){ int i = 1; int sum = 0; while (i < 11) { sum = add(sum, i); i = add(i, 1); System.out.println("sum = " + sum); System.out.println("i = " + i); A backward slice consists of all statements that affect a given point in the program. All other statements that influence the output of variable I. Slicing Criterion

Example of forward static slicing Slice criterion <3,sum> 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}

Forward Slice Example public class SimpleExample { static int add(int a, int b){ return(a+b); } public static void main(final String[] arg){ int i = 1; int sum = 0; while (i < 11) { sum = add(sum, i); i = add(i, 1); System.out.println("sum = " + sum); System.out.println("i = " + i); Slicing Criterion A forward slice consists of all statements that are affected by a given point in the program. In this example, the forward slice indicates exactly which statements are influenced by the initialization of variable sum

What is program slicing? 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

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

Variants of program slicing Static slices Slice criterion <p, V> Where p is a program point and V is a subset of program variables Program slice on the slicing criterion <p, V> 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

Variants of program slicing Static slices 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

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 { 8 sum = sum + 1; 9 ++ i; 10 } 11 Cout<< sum; 12 Cout<< i; 13 }

Example of dynamic slices read (n) for I := 1 to n do a := 2 if c1==1 then if c2==1 then a := 4 else a := 6 z := a write (z) Assumptions Input n is 1 C1, c2 both true Execution history is 11, 21, 31, 41, 51, 61, 91, 22, 101 Slice criterion<1, 101, z>

Applications of program slices 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

Applications of program slices 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