1 The System Dependence Graph and its use in Program Slicing.

Slides:



Advertisements
Similar presentations
Overview Structural Testing Introduction – General Concepts
Advertisements

A Survey of Program Slicing Techniques A Survey of Program Slicing Techniques Sections 3.1,3.6 Swathy Shankar
Program Slicing – Based Techniques
The University of Adelaide, School of Computer Science
Pointer Analysis – Part I Mayur Naik Intel Research, Berkeley CS294 Lecture March 17, 2009.
Some Properties of SSA Mooly Sagiv. Outline Why is it called Static Single Assignment form What does it buy us? How much does it cost us? Open questions.
Control Flow Analysis. Construct representations for the structure of flow-of-control of programs Control flow graphs represent the structure of flow-of-control.
1 CS 201 Compiler Construction Lecture Interprocedural Data Flow Analysis.
 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.
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,
Program Analysis via Graph Reachability Thomas Reps University of Wisconsin PLDI 00 Tutorial, Vancouver, B.C., June 18, 2000
Interprocedural Slicing using Dependence Graphs Susan Horwitz, Thomas Reps, and David Binkley University of Wisconsin-Madison.
1 Lecture 06 – Inter-procedural Analysis Eran Yahav.
Program Representations Xiangyu Zhang. CS590F Software Reliability Why Program Representations  Initial representations Source code (across languages).
Recap from last time We were trying to do Common Subexpression Elimination Compute expressions that are available at each program point.
Feedback: Keep, Quit, Start
Interprocedural analyses and optimizations. Costs of procedure calls Up until now, we treated calls conservatively: –make the flow function for call nodes.
Previous finals up on the web page use them as practice problems look at them early.
12/06/20051 Software Configuration Management Configuration management (CM) is the process that controls the changes made to a system and manages the different.
Scaling CFL-Reachability-Based Points- To Analysis Using Context-Sensitive Must-Not-Alias Analysis Guoqing Xu, Atanas Rountev, Manu Sridharan Ohio State.
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;
Interprocedural Analysis Noam Rinetzky Mooly Sagiv.
Interprocedural Analysis Noam Rinetzky Mooly Sagiv Tel Aviv University Textbook Chapter 2.5.
A simple approach Given call graph and CFGs of procedures, create a single CFG (control flow super-graph) by: –connecting call sites to entry nodes of.
From last time: Inlining pros and cons Pros –eliminate overhead of call/return sequence –eliminate overhead of passing args & returning results –can optimize.
Course project presentations Midterm project presentation Originally scheduled for Tuesday Nov 4 th Can move to Th Nov 6 th or Th Nov 13 th.
Schedule Midterm out tomorrow, due by next Monday Final during finals week Project updates next week.
Examples of summaries. Issues with summaries Level of “context” sensitivity: –For example, one summary that summarizes the entire procedure for all call.
Survey of program slicing techniques
From last class. The above is Click’s solution (PLDI 95)
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
February 2001OASIS --- Norfolk1 Dependence Graphs for Information Assurance Paul Anderson GrammaTech, Inc. Ithaca, NY
PRESTO Research Group, Ohio State University Interprocedural Dataflow Analysis in the Presence of Large Libraries Atanas (Nasko) Rountev Scott Kagan Ohio.
Precise Interprocedural Dataflow Analysis via Graph Reachibility
Introduction to Software Testing Chapter 2.4 Graph Coverage for Design Elements Paul Ammann & Jeff Offutt
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
Software Testing and Maintenance Lecture 4 Graph Coverage for Design Element Paul Ammann & Jeff Offutt Instructor: Hossein Momeni Mazandaran.
Bug Localization with Machine Learning Techniques Wujie Zheng
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Merging Equivalent Contexts for Scalable Heap-cloning-based Points-to.
Runtime Environments. Support of Execution  Activation Tree  Control Stack  Scope  Binding of Names –Data object (values in storage) –Environment.
1 Graph Coverage (4). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
Lecture 13: Working with Multiple Programmers. Headers Header files: Each standard library has a corresponding header. The function prototype for all.
Introduction to Software Testing (2nd edition) Chapter 7.4 Graph Coverage for Design Elements Paul Ammann & Jeff Offutt
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Merging Equivalent Contexts for Scalable Heap-cloning-based Points-to.
Reachability Analysis for Callbacks 北京大学 唐浩
1 Software Testing & Quality Assurance Lecture 13 Created by: Paulo Alencar Modified by: Frank Xu.
Runtime Environments Chapter 7. Support of Execution  Activation Tree  Control Stack  Scope  Binding of Names –Data object (values in storage) –Environment.
Inter-procedural analysis
Code Optimization More Optimization Techniques. More Optimization Techniques  Loop optimization  Code motion  Strength reduction for induction variables.
Paul Ammann & Jeff Offutt
Mooly Sagiv html://
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.
Program Analysis via Graph Reachability
Graph Coverage for Design Elements CS 4501 / 6501 Software Testing
How is a PDG Created? Control Flow Graph (CFG) PDG is union of:
A Survey of Program Slicing Techniques: Section 4
Program Slicing Baishakhi Ray University of Virginia
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Program Analysis via Graph Reachability
Multiple Entry Points Multiple entry points allow different function names, different parameter lists, default parameters, etc. Example int fn( int a =
Program Analysis via Graph Reachability
Demand-Driven Context-Sensitive Alias Analysis for Java
Graph Coverage for Design Elements CS 4501 / 6501 Software Testing
Slicing Java Programs that Throw and Catch Exceptions
Program Analysis via Graph Reachability
Presentation transcript:

1 The System Dependence Graph and its use in Program Slicing

2 int main() { int sum = 0; int i = 1; while (i < 11) { sum = add(sum,i); i = add(i,1); } printf( “ %d\n ”,sum); printf( “ %d\n ”,i); } int add(int x, int y) { return x + y; } Slicing Multiple Procedures

3 int main() { int sum = 0; int i = 1; while (i < 11) { sum = add(sum,i); i = add(i,1); } printf( “ %d\n ”,sum); printf( “ %d\n ”,i); } int add(int x, int y) { return x + y; } Slicing Multiple Procedures What is the slice for i at this statement?

4 int main() { int sum = 0; int i = 1; while (i < 11) { sum = add(sum,i); i = add(i,1); } printf( “ %d\n ”,sum); printf( “ %d\n ”,i); } int add(int x, int y) { return x + y; } Slicing Multiple Procedures

5 x = 3 p(x) print(x) start main If … q(a) print(a) start p(a) a =2 Interprocedural Analysis and the Calling Context Problem If … print(d) start q(d)) exit x = 5 q(x) exit print(x) exit

6 Some Solutions 1.In-line called procedures 2.Keep call stack 3.Interval-type analysis (won’t discuss) 4.System dependence graph traversal

7 x = 3 p(x) print(x) start main If … q(a) print(a) start p(a) a =2 In-Line Called Procedures If … print(d) start q(d)) exit x = 5 q(x) exit print(x) exit

8 x = 3 p(x) print(x) start main If … q(a) print(a) start p(a) a =2 Keep Call Stack If … print(d) start q(d)) exit x = 5 q(x) exit print(x) exit 1.Get ICFG 2.Propagate keeping call stack

9 Based on PDGs Each PDG has nodes for –entry point –procedure parameters and function result Each call site has nodes for –call –arguments and function result Appropriate edges –entry node to parameters (control-dependence) –call node to arguments (control-dependence) –call node to entry node (call relation) –arguments to parameters (data-dependence) System Dependence Graph (SDG) Approach

10 System Dependence Graph (SDG) Enter main Call p Enter p

11 SDG for the Sum Program Enter main sum = 0i = 1 while(i < 11) printf(sum) printf(i) Call add x in = sum y in = i sum = x out x in = iy in = 1i = x out Enter add x = x in y = y in x = x + yx out = x

12 Slicing via Reachability Enter main sum = 0i = 1 while(i < 11) printf(sum) printf(i) Call add x in = sum y in = i sum = x out x in = iy in = 1i = x out Enter add x = x in y = y in x = x + yx out = x printf(i)

13 Slicing via Reachability Enter main sum = 0i = 1 while(i < 11) printf(sum) printf(i) Call add x in = sum y in = i sum = x out x in = iy in = 1i = x out Enter add x = x in y = y in x = x + yx out = x

14 Imprecision Enter main sum = 0i = 1 while(i < 11) printf(sum) printf(i) Call add x in = sum y in = i sum = x out x in = iy in = 1i = x out Enter add x = x in y = y in x = x + yx out = x

15 Precise Interprocedural Slicing Enter main sum = 0i = 1 while(i < 11) printf(sum) printf(i) Call add x in = sum y in = i sum = x out x in = iy in = 1i = x out Enter add x = x in y = y in x = x + yx out = x

16 Two-phase Reachability Slicing Algorithm To avoid the mismatches of procedure returns and procedure calls when traversing the graph Phase I: find the statements in the current procedure and the callers of the current procedure that may affect the slicing criterion ŸDo not traverse return edges ŸUse summary information to continue the slicing at each callsite Phase II: Find the statements in the callees of the current procedure that may affect the slicing criterion ŸDo not traverse call edges

17 Add Flow Dependence (Summary, Transitive Dependence) Edges ŸFor each actual-out parameter in the SDG, determine whether that parameter is dependent (data or control) on any actual-in parameters. ŸCould use the linkage grammar, a slice down into called procedures, or the graph reachability method presented in FSE95. ŸIf a dependence exists, introduce flow dependence edges to the SDG.

18 SDG with Summary Edges Enter main sum = 0i = 1 while(i < 11) printf(sum) printf(i) Call add x in = sum y in = i sum = x out x in = iy in = 1i = x out Enter add x = x in y = y in x = x + yx out = x Add summary edges

19 Summary Edges Enter main Call p Enter p

20 SDG with Summary Edges Enter main sum = 0i = 1 while(i < 11) printf(sum) printf(i) Call add x in = sum y in = i sum = x out x in = iy in = 1i = x out Enter add x = x in y = y in x = x + yx out = x 2-phase slicing

21 Two-Phase Slicing: Phase I Enter main sum = 0i = 1 while(i < 11) printf(sum) printf(i) Call add x in = sum y in = i sum = x out x in = iy in = 1i = x out Enter add x = x in y = y in x = x + yx out = x

22 Two-Phase Slicing: Phase II Enter main sum = 0i = 1 while(i < 11) printf(sum) printf(i) Call add x in = sum y in = i sum = x out x in = iy in = 1i = x out Enter add x = x in y = y in x = x + yx out = x

23 Iterative Computation of Summary Edges Step 1: compute the reachability from formal-in nodes to formal-out nodes in each procedure Step 2: create the summary edges in each caller according to the reachability from formal-in nodes to formal-out nodes in a procedure Step 3: update the reachability from fromal-in nodes to formal-out nodes of each caller Step 4: if Step 3 produces new results, go to step 2