1 Program Slicing Amir Saeidi PhD Student UTRECHT UNIVERSITY.

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
Programming Paradigms and languages
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
Chair of Software Engineering From Program slicing to Abstract Interpretation Dr. Manuel Oriol.
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.
SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION
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.
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.
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.
Search: Representation and General Search Procedure Jim Little UBC CS 322 – Search 1 September 10, 2014 Textbook § 3.0 –
Parameterized Object Sensitivity for Points-to Analysis for Java Presented By: - Anand Bahety Dan Bucatanschi.
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.
Program Representations Xiangyu Zhang. CS590Z Software Defect Analysis Program Representations  Static program representations Abstract syntax tree;
CS 425/625 Software Engineering Software Testing
1 Software Testing and Quality Assurance Lecture 30 – Testing Systems.
SDLC. Information Systems Development Terms SDLC - the development method used by most organizations today for large, complex systems Systems Analysts.
Survey of program slicing techniques
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 5 Data Flow Testing
This chapter is extracted from Sommerville’s slides. Text book chapter
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
Katanosh Morovat.   This concept is a formal approach for identifying the rules that encapsulate the structure, constraint, and control of the operation.
P ARALLEL P ROCESSING I NSTITUTE · F UDAN U NIVERSITY 1.
Copyright © Siemens AG All rights reserved. Essential Criteria on MBT to Ensure Quality of Software in Industry PVR Murthy Andreas Ulrich Siemens.
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
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
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
1 Introduction to Software Engineering Lecture 1.
Chapter 10 Analysis and Design Discipline. 2 Purpose The purpose is to translate the requirements into a specification that describes how to implement.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University Dependence-Cache.
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
Debugging parallel programs. Breakpoint debugging Probably the most widely familiar method of debugging programs is breakpoint debugging. In this method,
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.
CASE/Re-factoring and program slicing
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
HNDIT23082 Lecture 06:Software Maintenance. Reasons for changes Errors in the existing system Changes in requirements Technological advances Legislation.
Architecture View Models A model is a complete, simplified description of a system from a particular perspective or viewpoint. There is no single view.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
1 Chapter 12 Configuration management This chapter is extracted from Sommerville’s slides. Text book chapter 29 1.
Program Slicing Techniques CSE 6329 Spring 2013 Parikksit Bhisay
1 Software Testing & Quality Assurance Lecture 13 Created by: Paulo Alencar Modified by: Frank Xu.
Chapter – 8 Software Tools.
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
T EST T OOLS U NIT VI This unit contains the overview of the test tools. Also prerequisites for applying these tools, tools selection and implementation.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
Foundations of Software Testing Chapter 5: Test Selection, Minimization, and Prioritization for Regression Testing Last update: September 3, 2007 These.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
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.
Software Testing.
Information systems modeling tools
System Design.
runtime verification Brief Overview Grigore Rosu
Structural testing, Path Testing
SwE 455 Program Slicing.
A Survey of Program Slicing Techniques: Section 4
Program Slicing Baishakhi Ray 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.
Lecture 06:Software Maintenance
Information systems modeling tools
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:

1 Program Slicing Amir Saeidi PhD Student UTRECHT UNIVERSITY

Agenda Introduction History What is program slicing Classifications Applications Slicing Tools Demo

Introduction The 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?

Introduction 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 How? ◦ “Break larger code into smaller pieces”

History Program Slicing was introduced by Mark Weiser as his PhD thesis at the University of Michigan. Mark Weiser (July 23, 1952 – April 27, 1999) was a chief scientist at Xerox PARC in the United States. He is widely considered to be the father of ubiquitous computing, a term he coined in 1988 He argued that a programmer intuitively tries to slice a program to debug it.

What is Program Slicing? Program slicing is a well-known program analysis and transformation technique to decompose programs by analyzing their data and control flow Program slicing describes a mechanism which allows the automatic generation of a slice A program slice consists of those program statements which are (potentially) related to the values computed at some program point and/or variable, referred to as a slicing criterion ◦ Slices may or may not be executable

Slicing Criterion ◦ s specifies a location (statement s) ◦ v specifies a variable (v) All statements affecting or affected by the variables mentioned in the slicing criterion becomes a part of the slice Variables V at statements S can be affected by statements S’ because: ◦ S’ define whether S is executed at all (Control Dependence) ◦ S’ define a variable that is used by S (Data Dependence)

Program Slicing Slicing Criterion is provided by the user

Slicing Example Slicing Criterion:

Principle of Dependences Data dependence ◦ Definition of variable v at statement s 1 reaches a use of v at statement s 2 Control dependence ◦ Conditional statement controls whether or not the current statement is executed Synchronization dependence ◦ Dependencies related to threading and locking 10

Control Flow Graph Control flow graph is a data structure Each node is associated with a program statement A directed edge will connect between any 2 nodes that represent statements with a possible control flow between them Special nodes: start, stop

Program Dependence Graph  Program Dependence Graph: CFG annotated with data flow information  Using PDG, slices may be built in linear time on the number of nodes of the PDG.  A PDG is an oriented graph  Each vertex represents a statement (like CFG)  Control dependence (solid lines) – between a predicate and the statements it controls  Data dependence (dotted lines) – between statements modifying a variable and those that may reference it  Special “start” node is connected to all nodes that are not control dependant

PDG – cont'd

Program Slicing Classification  Techniques of Slicing  Static vs. Dynamic vs. Conditioned Slicing  Direction of Slicing  Forward vs. Backward vs. Chopping Slicing  Levels of Slicing  Intraprocedural vs. Interprocedural Slicing  Executability of Slices  Executable vs. Closure

Static Slicing Static Slicing: No particular input for the program being sliced is considered 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

Dynamic Slicing Uses information derived from a particular execution of a program to produce a slice Execution is monitored and slices are computed with respect to program history Relatively small slices Contains all the statements of the program that affect the slicing criterion for a particular execution in contrast to any execution in static slicing

Dynamic Slicing – cont'd A dynamic slicing criterion:, where i is the position of statement s in the execution history; v is the set of variables we are interested in; {a 1,...,a n } is the initial values of the program's input. Deterministic instead of probabilistic Allow an easier localization of the bugs

Dynamic Slicing Example Program Input: {text = “hello world!\eof”, n = 4} Execution History: (1, 2, 3, 4, 5, 6, 7, (8, 11, 12, 13, 14, 15, 7) 12, 16, 17, 18) Slicing Criterion:

Conditioned Slicing Conditioned slicing can be viewed as a generalization of both static and dynamic slicing Conditioned slicing computes slices w.r.t. a set of initial states that satisfy a boolean condition Condition is specified as a universally quantified formula of first-order predicate logic A conditioned slicing criterion where ◦ i is a subset of the input variables of the program ◦ F is a logic formula on i ◦ s is a statement of the program ◦ v is a subset of the variables in the program

Conditioned Slicing – cont’d Slicing Criterion: Condition: F = (  c  text, c ≠ ‘\n’. n > 0)

Backward Slicing A program can be traversed forwards or backwards from the slicing criterion. Backward Slicing: we are interested in all those statements that could influence the slicing criterion. Answer the question “what program components might effect a selected computation?” Main Application: Debugging Original method by Weiser: static backward slicing

Forward Slicing Forward Slicing: we are interested in all those statements that could be influenced by the slicing criterion. Answers the question “what program components might be effected by a selected computation?” Useful in determining which statements in a program can be effected by a change in the value of v at statement s i Main Application: Dead Code Removal

Forward Slicing – con’t Slicing Criterion:

Chopping Slicing Criterion: source and sink Chopping computes all the statements in the program that being affected by source, they affect sink Chopping is useful to detect those statements that “transmit effects" from one part of the program (source) to another (sink) Chopping is a generalization of both forward and backward slicing where either source or sink is empty Main applications: Program Analysis and Debugging

Chopping – cont’d Slicing Criterion:

Intraprocedural Slicing Original definition of program slicing: Intraprocedural Slicing Computes slice within one procedure Assumes worse case for function calls Loses Precision

Intraprocedural Slicing – cont’d Slicing criterion:

Interprocedural Slicing System Dependence Graph: A new dependence graph incorporating collections of procedures with procedure calls SDG = PDG + Call Graph Compute slices from multi-procedural programs

System Dependence Graph

Interprocedural Slicing Slicing criterion: 30

Interprocedural vs. Intraprocedural Slicing Slicing criterion:

Executability An executable slice is an executable program that behaves identically to the original program with respect to the slicing criterion A closure slice includes all the components that might affect a given computation, but is not necessarily an executable program ◦ Useful in understanding code behavior 32

Applications Debugging ◦ Finding set of statements that changes a variable of concern Dead Code Removal ◦ Removing code which does not affect the program results Program Segmentation ◦ Comprehending the design by abstracting the design decisions out of the source code Software Quality Assurance ◦ Validate interactions between safety-critical components

Applications – cont'd Program Differencing ◦ To capture semantic differences between two programs Software Maintenance ◦ Slicing helps in understanding of existing software and making changes without having a negative impact. Testing ◦ Reduce cost of regression testing after modifications (only run those tests that needed) Program Parallelization, Partial Evaluation, Program Integration, etc.

Some Slicing Tools Wisconsin Program Slicer (CodeSurfer) It can perform forwards and backwards slicing and chopping of C programs Commercial product by GammaTech Inc. Unravel It perform static backward slicing of C programs. Limitations are in the treatment of Unions, Forks and pointers to functions Indus/Kaveri It performs static forward and backward slicing and chopping of Java programs.

Tool Overview – Indus / Kaveri Indus provides a rich collection of program analyses and transformations for Java programs ◦ Platform for static analyses such as points-to analysis, escape analysis and dependence analyses. ◦ Transformations such as program slicing and program specialization via partial evaluation Kaveri provides a featureful Eclipse-based UI front- end for Indus integrated with Eclipse Java development environment ◦ Configuring, invoking and visualizing results of Indus slicing ◦ Scripting framework for flexible querying of underlying analysis APIs

37