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.

Slides:



Advertisements
Similar presentations
CSCE 3110 Data Structures & Algorithm Analysis
Advertisements

A Survey of Program Slicing Techniques A Survey of Program Slicing Techniques Sections 3.1,3.6 Swathy Shankar
Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
Register Usage Keep as many values in registers as possible Register assignment Register allocation Popular techniques – Local vs. global – Graph coloring.
P3 / 2004 Register Allocation. Kostis Sagonas 2 Spring 2004 Outline What is register allocation Webs Interference Graphs Graph coloring Spilling Live-Range.
Context-Sensitive Interprocedural Points-to Analysis in the Presence of Function Pointers Presentation by Patrick Kaleem Justin.
Static Single Assignment CS 540. Spring Efficient Representations for Reachability Efficiency is measured in terms of the size of the representation.
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. 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.
Presented By: Krishna Balasubramanian
1 Cost Effective Dynamic Program Slicing Xiangyu Zhang Rajiv Gupta The University of Arizona.
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,
Dynamic Slicing Khanh Nguyen Donald Bren School of Information & Computer Science University of California, Irvine.
Carnegie Mellon Lecture 6 Register Allocation I. Introduction II. Abstraction and the Problem III. Algorithm Reading: Chapter Before next class:
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 Slicing Xiangyu Zhang. CS590F Software Reliability What is a slice? S: …. = f (v)  Slice of v at S is the set of statements involved in computing.
CS4723 Software Engineering Lecture 10 Debugging and Fault Localization.
1 Integrating Influence Mechanisms into Impact Analysis for Increased Precision Ben Breech Lori Pollock Mike Tegtmeyer University of Delaware Army Research.
A Comparison of Online and Dynamic Impact Analysis Algorithms Ben Breech Mike Tegtmeyer Lori Pollock University of Delaware.
Pruning Dynamic Slices With Confidence Xiangyu Zhang Neelam Gupta Rajiv Gupta The University of Arizona.
Program Representations Xiangyu Zhang. CS590F Software Reliability Why Program Representations  Initial representations Source code (across languages).
1 CS 201 Compiler Construction Lecture 12 Global Register Allocation.
1 “White box” or “glass box” tests “White Box” (or “Glass Box”) Tests.
Program Representations Xiangyu Zhang. CS590Z Software Defect Analysis Program Representations  Static program representations Abstract syntax tree;
Load-Reuse Analysis design and evaluation Rastislav Bodík Rajiv Gupta Mary Lou Soffa.
Survey of program slicing techniques
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
Data Structures & AlgorithmsIT 0501 Algorithm Analysis I.
CS5103 Software Engineering Lecture 17 Debugging.
1 A Static Analysis Approach for Automatically Generating Test Cases for Web Applications Presented by: Beverly Leung Fahim Rahman.
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.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
Detecting Equality of Variables in Programs Bowen Alpern, Mark N. Wegman, F. Kenneth Zadeck Presented by: Abdulrahman Mahmoud.
Chapter 11: Dynamic Analysis Omar Meqdadi SE 3860 Lecture 11 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
References: “Pruning Dynamic Slices With Confidence’’, by X. Zhang, N. Gupta and R. Gupta (PLDI 2006). “Locating Faults Through Automated Predicate Switching’’,
CASE/Re-factoring and program slicing
Lecture Notes - Copyright © S. C. Kothari, All rights reserved.1 Efficient Debugging CPRE 556 Lecture 19.
Software Engineering Research Group, Graduate School of Engineering Science, Osaka University A Slicing Method for Object-Oriented Programs Using Lightweight.
Spatiotemporal Saliency Map of a Video Sequence in FPGA hardware David Boland Acknowledgements: Professor Peter Cheung Mr Yang Liu.
Software Engineering Department Graph-Less Dynamic Dependence-Based Dynamic Slicing Algorithms Árpád Beszédes, Tamás Gergely and Tibor Gyimóthy University.
Program Slicing Techniques CSE 6329 Spring 2013 Parikksit Bhisay
CS412/413 Introduction to Compilers Radu Rugina Lecture 18: Control Flow Graphs 29 Feb 02.
1 Control Flow Graphs. 2 Optimizations Code transformations to improve program –Mainly: improve execution time –Also: reduce program size Can be done.
The Hashemite University Computer Engineering Department
Image Processing A Study in Pixel Averaging Building a Resolution Pyramid With Parallel Computing Denise Runnels and Farnaz Zand.
Pruning Dynamic Slices With Confidence Original by: Xiangyu Zhang Neelam Gupta Rajiv Gupta The University of Arizona Presented by: David Carrillo.
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 Iterative Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of Program.
Points-to Analysis as a System of Linear Equations Rupesh Nasre. Computer Science and Automation Indian Institute of Science Advisor: Prof. R. Govindarajan.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Phoenix Based Dynamic Slicing Debugging Tool Eric Cheng Lin Xu Matt Gruskin Ravi Ramaseshan Microsoft Phoenix Intern Team (Summer '06)
SwE 455 Program Slicing.
Antonia Zhai, Christopher B. Colohan,
A Survey of Program Slicing Techniques: Section 4
Topic 10: Dataflow Analysis
Arrays and Linked Lists
Program Slicing Baishakhi Ray University of Virginia
Performance Optimization for Embedded Software
“White box” or “glass box” tests
Program Slicing Xiangyu Zhang.
CS 201 Compiler Construction
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Final Code Generation and Code Optimization
CPRE 416-Software Evolution and Maintenance-Lecture 11
CS 201 Compiler Construction
Presentation transcript:

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 dependences Data dependences Traverse dependence graph to compute slice Transitive closure over control and data dependences

Dynamic Slicing Dynamic slice is the set of statements that DID affect the value of a variable at a program point for ONE specific execution. [Korel and Laski, 1988] Execution trace control flow trace -- dynamic control dependences memory reference trace -- dynamic data dependences Construct a dynamic dependence graph Traverse dynamic dependence graph to compute slices Smaller, more precise, slices are more helpful

Slice Sizes: Static vs. Dynamic Program Statements Avg. of 25 slices Static / Dynamic Static 126.gcc 099.go 134.perl 130.li 008.espresso 585,491 95,459 116,182 31,829 74,039 51,098 16,941 5,242 2,450 2,353 6,614 5,382 765 206 350 7.72 3.14 6.85 11.89 6.72 Static slice can be much larger than the dynamic slice

Applications of Dynamic Slicing Debugging [Korel & Laski - 1988] Detecting Spyware [Jha - 2003] Installed without users’ knowledge Software Testing [Duesterwald, Gupta, & Soffa - 1992] Dependence based structural testing - output slices. Module Cohesion [N.Gupta & Rao - 2001] Guide program structuring Performance Enhancing Transformations Instruction criticality [Ziles & Sohi - 2000] Instruction isomorphism [Sazeides - 2003] Others…

Dynamic Slicing Example -background For input N=2, 11: b=0 [b=0] 21: a=2 31: for i = 1 to N do [i=1] 41: if ( (i++) %2 == 1) then [i=1] 51: a=a+1 [a=3] 32: for i=1 to N do [i=2] 42: if ( i%2 == 1) then [i=2] 61: b=a*2 [b=6] 71: z=a+b [z=9] 81: print(z) [z=9] 1: b=0 2: a=2 3: for i= 1 to N do 4: if ((i++)%2==1) then 5: a = a+1 else 6: b = a*2 endif done 7: z = a+b 8: print(z)

Issues about Dynamic Slicing Precision – perfect Running history – very big ( GB ) Algorithm to compute dynamic slice - slow and very high space requirement.

Efficiency How are dynamic slices computed? Execution traces control flow trace -- dynamic control dependences memory reference trace -- dynamic data dependences Construct a dynamic dependence graph Traverse dynamic dependence graph to compute slices

Statements Executed (Millions) Dynamic Dependence Graph Size(MB) The Graph Size Problem Program Statements Executed (Millions) Dynamic Dependence Graph Size(MB) 300.twolf 256.bzip2 255.vortex 197.parser 181.mcf 164.gzip 134.perl 130.li 126.gcc 099.go 140 67 108 123 118 71 220 124 131 138 1,568 1,296 1,442 1,816 1,535 835 1,954 1,745 1,534 1,707 Graphs of realistic program runs do not fit in memory.

Conventional Approaches [Agrawal &Horgan, 1990] presented three algorithms to trade-off the cost with precision. Algo.I Algo.II Algo.III Precise dynamic analysis Static Analysis high Cost: low Precision: low high

Algorithm One This algorithm uses a static dependence graph in which all executed nodes are marked dynamically so that during slicing when the graph is traversed, nodes that are not marked are avoided as they cannot be a part of the dynamic slice. Limited dynamic information - fast, imprecise (but more precise than static slicing)

Algorithm I Example 11 1: b=0 For input N=1, the trace is: 2: a=2 21 31 T 4: if ((i++)%2= =1) 41 F T F 5: a=a+1 51 6: b=a*2 32 71 7: z=a+b 81 8: print(z)

DS={1,2,5,7,8} Algorithm I Example 1: b=0 2: a=2 3: 1 <=i <=N Precise! 4: if ((i++)%2= =1) 5: a=a+1 6: b=a*2 7: z=a+b 8: print(z)

Imprecision introduced by Algorithm I Input N=2: for (a=1; a<N; a++) { … if (a % 2== 1) { b=1; } if (a % 3 ==1) { b= 2* b; } else { c=2*b+1; 4 1 2 3 4 5 6 7 8 9 7 9 Killed definition counted as reaching!

Algorithm II A dependence edge is introduced from a load to a store if during execution, at least once, the value stored by the store is indeed read by the load (mark dependence edge) No static analysis is needed.

Algorithm II Example 11 1: b=0 71 For input N=1, the trace is: 2: a=2 21 51 3: 1 <=i <=N 31 T 41 4: if ((i++)%2= =1) F T F 5: a=a+1 6: b=a*2 7: z=a+b 81 8: print(z)

Algorithm II – Compare to Algorithm I More precise Algo. II Algo. I x=… x=… …=x …=x …=x …=x

Efficiency: Summary For an execution of 130M instructions: space requirement: reduced from 1.5GB to 94MB (I further reduced the size by a factor of 5 by designing a generic compression technique [MICRO’05]). time requirement: reduced from >10 Mins to <30 seconds.

Algorithm III First preprocess the execution trace and introduces labeled dependence edges in the dependence graph. During slicing the instance labels are used to traverse only relevant edges.

Dynamic Dep. Graph Representation 1: sum=0 2: i=1 1: sum=0 2: i=1 3: while ( i<N) do 3: while ( i<N) do 4: i=i+1 5: sum=sum+i 4: i=i+1 5: sum=sum+i 3: while ( i<N) do 4: i=i+1 5: sum=sum+i 6: print (sum) 3: while ( i<N) do 6: print (sum)

Dynamic Dep. Graph Representation Timestamps N=2: 1: sum=0 2: i=1 1: sum=0 2: i=1 1 1 3: while ( i<N) do 3: while ( i<N) do 4: i=i+1 5: sum=sum+i 2 2 4: i=i+1 5: sum=sum+i (2,2) (4,4) 3 3 3: while ( i<N) do 4: i=i+1 5: sum=sum+i (4,6) 4 4 6: print (sum) 5 5 3: while ( i<N) do 6 6 6: print (sum) A dynamic dep. edge is represented as by an edge annotated with a pair of timestamps <definition timestamp, use timestamp>

Infer: Local Dependence Labels: Full Elimination (...,20) ... X = Y= X X = Y= X (10,10) (20,20) (30,30) X = Y= X =Y 21 (20,21) ... 10,20,30

Transform: Local Dependence Labels: Elimination In Presence of Aliasing X = *P = Y= X X = *P = Y= X (10,10) (20,20) X = *P = Y= X =Y 11,21 (20,21) ... 10,20

Transform: Local Dependence Labels: Elimination In Presence of Aliasing X = *P = Y= X X = *P = Y= X (10,10) (20,20) X = *P = Y= X X = *P = Y= X 11,21 (10,11) (20,21) =Y 11,21 =Y (20,21) (10,11) 10,20 10 20

Transform: Coalescing Multiple Nodes into One 2 1 10 3 4 6 7 9 5 8 2 1 10 3 4 6 7 9 5 8 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 9 10

Group: Labels Across Non-Local Dependence Edges X = Y = = Y = X X = Y = = Y = X (10,21) (20,11) X = Y = = Y = X (20,11) (10,21) 10 20 11,21