/
review questions assign see schedule for links slicing o review questions assign see schedule for links slicing o

review questions assign see schedule for links slicing o - PDF document

pamella-moone
pamella-moone . @pamella-moone
Follow
362 views
Uploaded On 2016-08-03

review questions assign see schedule for links slicing o - PPT Presentation

1 1 2 Program Slicing 2 3 Types of slices levels of slices4Interproceduralslicing later 4 Types of slicesBackward static sliceForward static sliceDynamic sliceGeneric algorithm for static sliceLev ID: 430918

1 1 2 Program Slicing 2 3 Types slices levels

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "review questions assign see schedule for..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

1 1 •Review; questions•Assign (see Schedule for links)•Slicing overview (cont’d)•Problem Set 3: due 9/8/09 2 Program Slicing 2 3 Types of slices, levels of slices4.Interproceduralslicing (later) 4 Types of slicesBackward static sliceForward static sliceDynamic sliceGeneric algorithm for static sliceLevels of slicesIntraproceduralInterproceduralAuthors of articlesProgram SlicingA Survey of Program Slicing Techniques1.Agrawal2.Binkley3.Gallagher4.Gupta5.Horgan6.Horwitz7.Korel8.Laski9.K. Ottenstein10.L. Ottenstein11.Reps 12.Soffa13.Tip14.Weiser 3 5 Some HistoryWho first defined slicing? 1.Mark Weiser, 1981Experimented with programmers to show that slices are:“The mental abstraction people make when they are debugging a program”[Weiser]Used Data Flow Equations 4 7 1.Mark Weiser, 1981Experimented with programmers to show that slices are:“The mental abstraction people make when they are debugging a program”[Weiser]Used Data Flow Equations2.Ottenstein& Ottenstein–PDG, 1984 8 1.Mark Weiser, 1981Experimented with programmers to show that slices are:“The mental abstraction people make when they are debugging a program”[Weiser]Used Data Flow Equations2.Ottenstein& Ottenstein–PDG, 19843.Horowitz, Reps & Binkley –SDG, 1990 5 9 Coverage, Overlap, Clustering Static SlicingStatically available information onlyNo assumptions made on inputComputed slice is in general inaccurateIdentifying minimal slices is an undecidableproblem approximationsResults may not be usefulDynamic SlicingComputed on a given inputinstead of Useful for applications such as debugging and testing 6 1.read 2.i := 13.sum := 04.product := 15.while i do 6.sum := sum + i7.product := product * i8.i := i + 19.write 10.write Create CFG for 1.read 2.i := 13.sum := 04.product := 15.while i do 6.sum := sum + i7.product := product * i8.i := i + 19.write 10.write 10 and variable product 7 backward sliceof a program with respect to a pand set of program variables Vconsists of all statements and predicates in the VThe program point pand the set of variables V together form the slicing criterion, usually written p, V�Types of Slicing (Backward Static) A backward sliceof a program with respect to a pand set of program variables Vconsists of all statements and predicates in the VThe program point pand the set of variables V together form the slicing criterion, usually written p, V�Types of Slicing (Backward Static) 8 Considers transitive dependencies 1.read 2.i := 13.sum := 04.product := 15.while i do 6.sum := sum + i7.product := product * i8.i := i + 19.write 10.write , ;&#xprod;&#xuct0;Criterion What is the backward slice? 9 i := 13.sum := 0while i do 6.sum := sum + i9.write Types of Slicing (Backward Static), ;&#xprod;&#xuct0;Criterion if the statements in the slice form a syntactically correct program that can be for all inputs. 10 i := 13.sum := 0while i do 6.sum := sum + i9.write , ;&#xprod;&#xuct0;Criterion 1. product := 1while i = n do product := product * ii := i + 1write Types of Slicing (Executable) Is this slice executable? slicing criterion 11 1.read 2.i := 13.sum := 04.product := 15.while i do 6.sum := sum + i7.product := product * i8.i := i + 19.write 10.write Types of Slicing (Forward Static), s;&#xum00;Criterion What is the forward slice? 1.read 2.i := 14.product := 15.while i do sum := sum + i7.product := product * i8.i := i + 1 10.write Types of Slicing (Forward Static), s;&#xum00;Criterion 12 1.read 2.i := 13.sum := 04.product := 15.while i do 6.sum := sum + i7.product := product * i8.i := i + 19.write 10.write Types of Slicing (Forward Static), n;Criterion What is the forward slice? 1. 2.i := 13.sum := 04.product := 1while i do sum := sum + i Types of Slicing (Forward Static), n;Criterion 13 for a particular executioninput ifor , v,p for a particular executioninput ifor , v,p 14 for a particular executioninput ifor , v,p 1.read 2.for I := 1 to n 3.a := 24.if c1 then 5.if c2 then 6.a := 47.else 8.a := 69.z := a10.write Types of Slicing (Dynamic) 15 1.read 2.for I := 1 to n 3.a := 24.if c1 then 5.if c2 then 6.a := 47.else 8.a := 69.z := a10.write , z� What is the dynamic slice? 1.read 2.for I := 1 to n 3.a := 24.if c1 then 5.if c2 then 6.a := 49.z := a2.for I := 1 to n 10.write , z� What is the dynamic slice? 16 I := 1 to n 3.a := 2 c1 then 5. c2 then a := 47.else 8.a := 6z := a , z� I := 1 to n 3.a := 2 c1 then 5. c2 then a := 47.else 8.a := 6z := a Comparison of Static and Dynamic1.read 2.for I := 1 to n 3.a := 24.if c1 then 5.if c2 then 6.a := 47.else 8.a := 69.z := a10.write What is the static,z; slice for 17 I := 1 to n 3.a := 2 c1 then 5. c2 then a := 47.else 8.a := 6z := a Comparison of Static and Dynamic I := 1 to n a := 2 c1 then 5. c2 then a := 4 a := 6z := a Static slice 1.read 2.for I := 1 to n 3.a := 24.if c1 then 5.if c2 then 6.a := 47.else 8.a := 69.z := a10.write , z� What is the dynamic slice? 18 I := 1 to n 3.a := 2 c1 then 5. c2 then a := 47.else 8.a := 6z := a , z� I := 1 to n 3.a := 2 c1 then 5. c2 then a := 47.else 8.a := 6z := a Types of Slicing (Dynamic)1. I := 1 to n a := 2 c1 then 5. c2 then a := 4 a := 6z := a Static slice 19 Types of Slicing (Execution) 1.read 2.for I := 1 to n 3.a := 24.if c1 then 5.if c2 then 6.a := 47.else 8.a := 69.z := a10.write Types of Slicing (Execution) ecution slice? 20 I := 1 to n a := 2 c1 then 5. c2 then a := 47.else 8.a := 6z := a Types of Slicing (Execution) 41 Dynamic 21 Data-flow on the flow graphInterprocedural: interprocedural control-flow graph Intraprocedural: program-dependence graph (PDG) Compute consecutive sets of “relevant”variables for each node in the CFG using data dependenciesControl dependences are not computed explicitlyVariables of control predicates (if, while) are “indirectly relevant”if any one of the statements in their body is relevantw relevant statements) 22 : there is a directed edge from i to j: Indirectly relevant variables: Indirectly relevant statements: Relevant branch statements 45 : there is a directed edge from i to j: Indirectly relevant variables: Indirectly relevant statements: Relevant branch statements Local using CFGPropagated using CFG 23 , ;&#xprod;&#xuct0;Criterion Methods (Data Flow on the CFG)1. i := 1while i do sum := sum + i Methods (Data Flow on the CFG) 24 Methods (Data Flow on the CFG) 49 Methods (Data Flow on the CFG)Iteration 0: (for every� i —j) Variables used at criterion point are added; looking for definitions that affect these uses 25 Methods (Data Flow on the CFG)Iteration 0: (for every� i —j) CFG predecessors 51 Methods (Data Flow on the CFG)Iteration 0: (for every� i —j) CFG predecessors variables used in i to Ref(i) 26 Methods (Data Flow on the CFG)Iteration 0: (for every� i —j) CFG predecessors variables used in i to Ref(i) If variables in Ref(successor) and not defined in i, add variables in Ref(successor) to Ref(i) (propagate) 53 Methods (Data Flow on the CFG)Iteration 0: (for every� i —j) of successor, then add to S 27 Methods (Data Flow on the CFG)Iteration 0: (for every� i —j) If i has an influence (control dependence), it is in this set. Methods (Data Flow on the CFG)Iteration 0:Iteration k+1: (for every� i — 28 Methods (Data Flow on the CFG) 57 Methods (Data Flow on the CFG) Note: You may not get these results for first iteration if propagation is done in a different order.