CPRE 416-Software Evolution and Maintenance-Lecture 11

Slides:



Advertisements
Similar presentations
Overview Structural Testing Introduction – General Concepts
Advertisements

1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs Data-flow Analysis – today’s class –Classic analyses.
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.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
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.
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,
Chapter 10 Recursion. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Explain the underlying concepts of recursion.
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
Classifying Triangles Students will classify triangles using the lengths of the sides and the angles. S. Calahan October 2010.
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
Lecture Notes - Copyright © S. C. Kothari, All rights reserved.1 Summary Lecture CPRE 416-Software Evolution and Maintenance-Lecture 6.
TOPIC R Software Maintenance, Evolution, Program Comprehension, and Reverse Engineering SEG4110 Advanced Software Design and Reengineering.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Summarizing “Structural” Testing Now that we have learned to create test cases through both: – a) Functional (blackbox)and – b) Structural (whitebox) testing.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
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.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Triangle Angle Sum Theorem Isosceles Triangles Equilateral Triangle.
Classifying Triangles Math 7 Ms. Conway Math 7 Ms. Conway.
The Hashemite University Computer Engineering Department
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;
Classifying Triangles. Two Ways to Classify Triangles  By Their Sides  By Their Angles.
Lesson 8.3 Concept: How to classify triangles by their sides and angles. An equilateral triangle has three sides of the same length. An isosceles triangle.
Notes Over 10.1 Finding the Distance Between Two Points Find the distance between the two points.
PREPARED BY G.VIJAYA KUMAR ASST.PROFESSOR
14 Compilers, Interpreters and Debuggers
Chapter 6: User-Defined Functions I
Chapter 7: User-Defined Functions II
Testing and Debugging PPT By :Dr. R. Mall.
Static Slicing Static slice is the set of statements that COULD influence the value of a variable for ANY input. Construct static dependence graph Control.
IIT Kharagpur & Kingston Uni
Software Testing and Maintenance 1
Input Space Partition Testing CS 4501 / 6501 Software Testing
Verification and Testing
Faults, Errors, Failures CS 4501 / 6501 Software Testing
Lecture 2 Introduction to Programming
SwE 455 Program Slicing.
User-Defined Functions
A Survey of Program Slicing Techniques: Section 4
Classifying Triangles
Software testing strategies 2
Program Slicing Baishakhi Ray University of Virginia
Paul Ammann & Jeff Offutt
Chapter 10 Data Flow Testing Slice Testing
Human Complexity of Software
Programming Fundamentals (750113) Ch1. Problem Solving
Objectives -triangle names -remote interior -exterior
CS 1111 Introduction to Programming Fall 2018
Classifying Triangles
Java Programming Control Structures Part 1
Objective - To classify triangles.
IMPORTANT NOTICE TO STUDENTS:
Graph Coverage for Design Elements CS 4501 / 6501 Software Testing
Chapter 7: User-Defined Functions II
Chapter 6: User-Defined Functions I
CSE403 Software Engineering Autumn 2000 More Testing
Classifying Triangles
Classifying Triangles
CHAPTER 6 Testing and Debugging.
Area and Perimeter Triangles.
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:

CPRE 416-Software Evolution and Maintenance-Lecture 11 Efficient Debugging CPRE 416-Software Evolution and Maintenance-Lecture 11 Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. Contents Debugging challenge Use of program slicing Static vs. dynamic slicing Reaching definitions Program slice browser Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. Debugging Challenge Debugging is a complex and difficult activity. The failure may be manifested far away from the fault (bug) itself. Analysis is needed determine the cause and the location of a program failure. Analysis is often tedious and time consuming because of many dependencies and many execution paths Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. Sample Program The program computes the sum of the areas of N triangles. It reads the value of N, followed by the lengths of the three sides of each of these N triangles. It classifies each triangle as an equilateral, isosceles, right, or a scalene triangle. Then it computes the area of the triangle using an appropriate formula. Finally, the program prints the sum of the areas. Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. Start Debugging Suppose this program is executed for the test case #1 when N = 2 and sides of the two triangles are (5, 4, 3) and (4, 4, 2) respectively. If the final sum of areas printed is incorrect, how should we go about locating the bug in the program? Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Many Possibilities for Bugs Looking backwards from the printf statement on line 46, there are several possibilities: sum is not being updated properly one or more of the formulas for computing the area of a triangle are incorrect the triangle is being classified incorrectly the values for the three sides of the triangle are not being read correctly. Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. Debugging Steps Determine which statements in the code have an influence on the value of sum at line 46. Select one (or more) of these statements at which to examine the program state. Recreate the program state at those statements to examine specific variables. Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. Program Slicing It is used to find all those statements in a program that directly or indirectly affect the value of a given variable occurrence (variable name and statement location). The statements that affect the value constitute the slice of the program with respect to the given variable occurrence Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Two Types of Program Slices Two types of slices: static and dynamic. A static slice includes all statements that could influence the value of a variable occurrence for all possible inputs to the program. A dynamic slice includes only those statements that influence the value of a variable occurrence for a given test case. Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. Data vs. Control Slices A data slice is one that is defined with respect to a data value—a variable occurrence. Useful when we are trying to determine the source of a wrong value for a variable occurrence. A control slice is one that is defined with respect to control reaching a certain program location. Useful when we are trying to determine why the control has reached a wrong location. Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. Reaching Definitions Looking at the whole slice at once may be overwhelming. It may be useful to analyze the inter-statement program dependencies one at a time – incremental slicing. Reaching definitions are the assignments (or modifications) of variables that reach and affect the given variable occurrence. Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. Terminology Def: a definition of a variable x is a statement that assigns a value to x Use: a use of a variable x is a statement that reads the value of x Kill: a definition of a variable x on a path is said to be killed on a control flow path if we encounter another definition of variable. Reaches: a definition d reaches a point p if there is a path from the point immediately following d to p - such that d is not killed along p. Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. Example 1: I := M - 2; 2: J := N; 3: A:= U1; 4: 5: DO 6: I := I +1; 7: J := J-1; 8: if (E1) then 9: A:= A + 2; 10: else 11: I := u3; 12: endif 13: WHILE e2 def of A at 3 and 9 The definition at line 9 kills the definition of A from line 3 The definition of A from line 3 reaches line 9 Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. Program Slice Browser We developed a program slice browser (PSB) to provide the user a visual representation of the slice. Using the PSB: A slice can be viewed at different levels of granularity: statements, control blocks, and procedures. By coupling the visual representation and the corresponding source one can conveniently navigate through the code. Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.

Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved. References Efficient debugging with slicing and backtracking: http://www2.umassd.edu/SWPI/slicing/purdue/TR80P.pdf Program slice browser: http://doi.ieeecomputersociety.org/10.1109/WPC.2001.921713 Lecture Notes - Copyright © 2005. S. C. Kothari, All rights reserved.