Program Slicing Baishakhi Ray University of Virginia

Slides:



Advertisements
Similar presentations
DATAFLOW TESTING DONE BY A.PRIYA, 08CSEE17, II- M.s.c [C.S].
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
Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) SSA Guo, Yao.
Analysis of programs with pointers. Simple example What are the dependences in this program? Problem: just looking at variable names will not give you.
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
 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.
Components of representation Control dependencies: sequencing of operations –evaluation of if & then –side-effects of statements occur in right order Data.
Program Representations. Representing programs Goals.
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.
1 Program Slicing Purvi Patel. 2 Contents Introduction What is program slicing? Principle of dependences Variants of program slicing Slicing classifications.
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.
The Application of Graph Criteria: Source Code  It is usually defined with the control flow graph (CFG)  Node coverage is used to execute every statement.
Program Representations Xiangyu Zhang. CS590F Software Reliability Why Program Representations  Initial representations Source code (across languages).
Common Sub-expression Elim Want to compute when an expression is available in a var Domain:
Recap from last time We were trying to do Common Subexpression Elimination Compute expressions that are available at each program point.
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;
Recap from last time: live variables x := 5 y := x + 2 x := x + 1 y := x y...
Schedule Midterm out tomorrow, due by next Monday Final during finals week Project updates next week.
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Survey of program slicing techniques
Testing Dr. Andrew Wallace PhD BEng(hons) EurIng
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
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
Chapter 6 Programming Languages (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Dataflow Analysis Topic today Data flow analysis: Section 3 of Representation and Analysis Paper (Section 3) NOTE we finished through slide 30 on Friday.
 Program Slicing : Analysis technique of extracting parts of a given program, relevant to the aspects being analyzed (the slicing criterion). E.g. slicing.
1 Program Slicing Amir Saeidi PhD Student UTRECHT UNIVERSITY.
Chapter 11: Dynamic Analysis Omar Meqdadi SE 3860 Lecture 11 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Lecture Notes - Copyright © S. C. Kothari, All rights reserved.1 Efficient Debugging CPRE 556 Lecture 19.
1 The System Dependence Graph and its use in Program Slicing.
1 Control Flow Analysis Topic today Representation and Analysis Paper (Sections 1, 2) For next class: Read Representation and Analysis Paper (Section 3)
Program Slicing Techniques CSE 6329 Spring 2013 Parikksit Bhisay
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
1 Software Testing & Quality Assurance Lecture 13 Created by: Paulo Alencar Modified by: Frank Xu.
Control Flow Graphs : The if Statement 1 if (x < y) { y = 0; x = x + 1; } else { x = y; } x >= yx < y x = y y = 0 x = x + 1 if (x < y) { y = 0;
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
Phoenix Based Dynamic Slicing Debugging Tool Eric Cheng Lin Xu Matt Gruskin Ravi Ramaseshan Microsoft Phoenix Intern Team (Summer '06)
Paul Ammann & Jeff Offutt
Basic Program Analysis
Data Flow Analysis Suman Jana
Simone Campanoni Dependences Simone Campanoni
Aditya P. Mathur Purdue University
Structural testing, Path Testing
SwE 455 Program Slicing.
White-Box Testing.
Graph Coverage for Design Elements CS 4501 / 6501 Software Testing
How is a PDG Created? Control Flow Graph (CFG) PDG is union of:
Basic Program Analysis: AST
A Survey of Program Slicing Techniques: Section 4
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
University Of Virginia
Control Flow Analysis CS 4501 Baishakhi Ray.
Chapter 10 Data Flow Testing Slice Testing
Graph Coverage for Design Elements CS 4501 / 6501 Software Testing
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
White-Box Testing.
CPRE 416-Software Evolution and Maintenance-Lecture 11
CSE 1020:Software Development
CSE P 501 – Compilers SSA Hal Perkins Autumn /31/2019
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:

Program Slicing Baishakhi Ray University of Virginia Adopted From U Penn CIS 570: Modern Programming Language Implementation (Autumn 2006)

Program Slicing In computer programming, program slicing is the computation of the set of programs statements, the program slice, that may affect the values at some point of interest, referred to as a slicing criterion. ---- Wikipredia int i; int sum = 0; int product = 1; for(i = 1; i < N; ++i) { sum = sum + i; product = product * i; } write(sum); write(product);

Program Slicing Backward slice Executable Forward slice Dynamic Slice The backward slice at program point p is the program subset that may affect p Executable A slice is executable if the statements in the slice form a syntactically correct program that can be executed. Forward slice The forward slice at program point p is the program subset that may be affected by p Dynamic Slice A dynamic slice of a program with respect to an input value of a variable v at a program point p for a particular execution e of the program is the set of all statements in the program that affect the value of v at p during execution e. Chop The chop between program points p and q is the program subset that may be affected by p and that may affect q

Backward Slice

Forward Slice

Chop

Dynamic Slice read (n) for I := 1 to n do 3. a := 2 if c1 then if c2 then 6. a := 4 7. else 8. a := 6 z := a write (z) Input n is 1; c1, c2 both true Execution history is 11, 21, 31, 41, 51, 61, 91, 22, 101 Criterion<1, 101, z>

Static vs. Dynamic read (n) for I := 1 to n do 3. a := 2 if c1 then 7. else 8. a := 6 z := a write (z) Static slice <10, z>

Uses of Program Slicing Program understanding & debugging What is affected by what? Program restructuring Isolate functionally distinct pieces of code Program specialization and reuse Use slices to represent specialized pieces of code Only reuse relevant slices Program differencing Compare slices to identify program changes

Uses of Program Slicing Test coverage What new test cases would improve code coverage? What regression tests should be run after a change? Model checking Reduce state space by removing irrelevant parts of the program Automatic differentiation Activity analysis– what variables contribute to the derivative of a function?

How Do We Compute Slices? Reachability in a dependence graph Program Dependence Graph (PDG) Represents dependences within one procedure Intra-procedural slicing is reachability in one PDG System Dependence Graph (SDG) Represents dependences within entire system Inter-procedural slicing is reachability in the SDG

Intra-procedural Slicing Program Dependence Graph (PDG) Nodes are statements Edges represent either: Control dependence Data dependence Backward slice at point p: compute backward reachability in the PDG from node p Forward slice at point p: compute forward reachability in the PDG from node p Chop between points p and q: identify all paths between p and q

Control Dependence Graph A node Y is control-dependent on another node X iff X determines whether Y executes there exists a path from X to Y such that every node in the path other than X and Y is post-dominated by Y X is not post-dominated by Y

Control Flow Graph (CFG)

Control Dependence Graph

Data Dependence Graph

Program Dependence Graph (PDG)

Backward Slice

Backward Slice

Backward Slice

Backward Slice

Slice Extraction

Interprocedural Analysis

Interprocedural Slicing System Dependence Graph (SDG) One PDG for each procedure Additional edges Connect calls to entries Connect actual parameters to formal parameters Connect procedure results to call-site return values

Example SDG

Example SDG

Recap Parsing: Parse Tree & Abstract Syntax Tree Control Flow Analysis: Basic Block, Dominant Analysis, natural Loop Data Flow Analysis: Liveness analysis, Def-Use Chain, Reachability Analysis Program Slicing