Presentation is loading. Please wait.

Presentation is loading. Please wait.

By Corey Rahberger. Overview  What is program slicing?  History  How to extract a slice  Program slicing techniques  Applications  Program slicing.

Similar presentations


Presentation on theme: "By Corey Rahberger. Overview  What is program slicing?  History  How to extract a slice  Program slicing techniques  Applications  Program slicing."— Presentation transcript:

1 By Corey Rahberger

2 Overview  What is program slicing?  History  How to extract a slice  Program slicing techniques  Applications  Program slicing tools  Current Problems  Future

3 What is program slicing?  The process of computing a slice of a program  A slice is a subset of the original program, which contains portions of the program that are related to the slicing criterion used to create the slice  The slicing criterion is the point of interest or variable(s) that are being investigated

4 Program Slicing Example Original ProgramSlice on statement “write(sum)” int i; int sum = 0; int product = 1; for(i = 0; i < N; i++) { sum = sum + 1; product = product * I; } write(sum); write(product); int i; int sum = 0; for(i = 0; i < N; i++) { sum = sum + 1; } write(sum);

5 History  First introduced by Mark Weiser in 1984 through publication in IEEE Transactions on Software Engineering  Original ideas were in his Ph.D. dissertation (1979) from University of Michigan, Ann Arbor  Chief scientist at Xerox PARC  Switched his focus to ubiquitous computing

6 History  Researchers have expanded on Weiser’s original definition into multiple directions  Huge amounts of program slicing techniques have been created to encompass all programming paradigms  Different surveys have been made to compare the techniques, but the results have been inconclusive

7 How to extract a slice  First, the dependences must be found between the different statements  These dependences can be represented in a data structure called a control flow graph (CFG)  A control flow graph shows all the execution paths that a program might take

8 Control Flow Graph 1) read(text); 2) read(n); 3) lines = 1; 4) chars = 1; 5) subtext = “”; 6) c = getChar(text); 7) while ( c != ‘\eof’) 8) if (c == ‘\n’) then 9) lines = lines + 1; 10) chars = chars + 1; 11) else chars = chars + 1; 12) if (n != 0) then 13) subtext = subtext + c; 14) n = n – 1; 15) c = getChar(text); 16) write(lines); 17) write(chars); 18) write(subtext);  In the CFG, each node is represented by a number that corresponds to a line number of the program

9 Problem with Control Flow Graph  Problem with control flow graph Does not include data dependences  Solution Add data dependencies to the graph

10 Program Dependence Graph  This new data structure is called a program dependence graph (PDG)  “A PDG is an oriented graph where the nodes represent statements in the source code [and the] edges represent control and data flow dependencies between statements in such a way that they induce a partial ordering in the nodes, preserving the semantics of the program.” (Silva)

11 Program Dependence Graph 1) read(text); 2) read(n); 3) lines = 1; 4) chars = 1; 5) subtext = “”; 6) c = getChar(text); 7) while ( c != ‘\eof’) 8) if (c == ‘\n’) then 9) lines = lines + 1; 10) chars = chars + 1; 11) else chars = chars + 1; 12) if (n != 0) then 13) subtext = subtext + c; 14) n = n – 1; 15) c = getChar(text); 16) write(lines); 17) write(chars); 18) write(subtext);

12 Program Dependence Graph  Since both flow and data dependences are now found for the program, the program dependence graph can be used to compute slices of the program according to the slicing criterion  Graphs can get quite large and complex

13 Program Slicing Techniques  There are a huge amount of different techniques  We will look more closely into the three main techniques Static slicing Dynamic slicing Conditioned slicing

14 Static Slicing  Similar to what Weiser originally introduced  The resulting slice will work for all inputs  Usually results in a bigger slice

15 Static Slicing – Slicing Criterion  (s,v) ‘s’ represents the line number in the program ‘v’ represents the variable(s) that are of interest  Example (7, x)

16 Static Slicing Example Original ProgramSlice of program w.r.t. criterion (10, product) 1) read(n); 2) i := 1; 3) sum := 0; 4) product := 1; 5) while i <= n do begin 6) sum := sum + 1; 7) product := product * i; 8) i := i + 1; end; 9) write(sum); 10) write(product); read(n); i := 1; product := 1; while i <= n do begin product := product * i; i := i + 1; end; write(product);

17 Static Slicing Uses  Debugging  Dead code removal  Program analysis  Software maintenance  Module cohesion analysis  Many more

18 Dynamic Slicing  Input(s) for the program are used to help determine the slice  Removes portions of the program that are not reached for the given input(s)  The resulting slice will not work for all executions of the program  Resulting slice is usually smaller than static slicing, but takes longer to compute

19 Dynamic Slicing – Slicing Criterion  (s i, v, {a i, …, a n }) ‘s’ represents the line number in the program ‘i’ represents the position in the execution history of statement ‘s’ ‘v’ represents the variable(s) that are of interest ‘{a i, …, a n }’ represents the initial values or inputs  Example (7 1, sum, {x = 1})

20 Dynamic Slicing Example Original ProgramSlice of program w.r.t. criterion (8 1, x, {n = 2}) (1) read(n); (2) i := 1; (3) while (i <= n) do begin (4) if (i mod 2 = 0) then (5) x := 17; else (6) x := 18; (7) i := i + 1; end; (8) write(x); read(n); i := 1; while (i <= n) do begin if (i mod 2 = 0) then x := 17; else ; i := i + 1; end; write(x);

21 Dynamic Slicing Uses  Debugging  Testing  Tuning Compilers

22 Conditioned Slicing  Combination of static and dynamic slicing  Provides information about the inputs values, but does not specify them exactly  Resulting slice is ranges between static and dynamic in size

23 Conditioned Slicing – Slicing Criterion  (i, F, s, v) ‘i’ represents the input variable(s) ‘F’ represents a logical formula on ‘i’ ‘s’ represents the line number in the program ‘v’ represents the variable(s) that are of interest  Example (sales, F, 11, {total}), where F = (sales > 0)

24 Conditioned Slicing Example Original Program Slice of program w.r.t. criterion ((text, n), F, 18, {subtext}), where F = ( ∀ c ∈ text, c != ‘\n’. n > 0) 1) read(text); 2) read(n); 3) lines = 1; 4) chars = 1; 5) subtext = “”; 6) c = getChar(text); 7) while ( c != ‘\eof’) 8) if (c == ‘\n’) then 9) lines = lines + 1; 10) chars = chars + 1; 11) else chars = chars + 1; 12) if (n != 0) then 13) subtext = subtext + c; 14) n = n – 1; 15) c = getChar(text); 16) write(lines); 17) write(chars); 18) write(subtext); (1) read(text); (2) read(n); (5) subtext = “”; (6) c = getChar(text); (7) while ( c != ‘\eof’) (8) if (c == ‘\n’) then (12) if (n != 0) then (13) subtext = subtext + c; (14) n = n – 1; (15) c = getChar(text); (18) write(subtext);

25 Conditioned Slicing Uses  Debugging  Software reuse  Ripple effect analysis  Understanding legacy code  Program comprehension

26 Applications  All the different techniques have made program slicing a useful tool in all areas of programming  Examples Debugging Cohesion measurement Comprehension Maintenance and reengineering Testing

27 Program Slicing Tools  Sprite Open source  Unravel Unravel National Institute of Standards and Technology  CodeSurfer CodeSurfer University of Wisconsin Slicing Tool GrammaTech

28 CodeSurfer  University of Wisconsin Slicing Tool Developed Susan Horwitz, Thomas Reps and others  CodeSurfer 1.0 Released in June 1999 Derived from Wisconsin’s Slicing Tool

29 CodeSurfer  Language C/C++  Platforms Windows Linux Solaris  Cost Basic – (Locked) $795 (Floating) $1495 Suite – (Locked) $3995 (Floating) $5995

30 NASA’s evaluation of CodeSurfer  Johnson Space Center Safety and Mission Assurance Directorate, Flight Equipment Division  Reviewed the efficiency of CodeSurfer compared to doing it manually  Compared results from two projects Space Integrated Global Positioning System/Inertial Navigation System (SIGI) Health Management System Defibrillator (Defib) Power and Data Interface Module (PDIM)

31 NASA’s evaluation of CodeSurfer COMBINED SIGI AND PDIM INSPECTION DATA MetricManual Code inspectionWith CodeSurfer Inspection Time (hr) Lines of Code (LOC)10650 Inspection Rate (LOC/hr) Total Defects Found Using Method818 Defects Found per Hour Unique Defects Found Using Method212

32 NASA’s evaluation of CodeSurfer  Drawbacks from CodeSurfer Must be compiled using on a compiler provided with the tool Training is required, which is expensive Must use it regularly to remain knowledgeable on using CodeSurfer

33 Current Problems  Resources need to compute slices  It can take a while to compute slices  Usability of program slicing tools

34 Future  Rate at which slices can be computed  Usability  Integration into mainstream development tools

35 Conclusion  Program slicing techniques have been and are still constantly improving  Can be used in all the different programming paradigms  As soon as the usability has been increased, program slicing should become a well known and useful tool

36 Questions?

37 References  Binkley, D., & Harman, M. (2004). A Survey of Empirical Results on Program Slicing. Advanced Computing, 62, Retrieved October 27, 2012, from  Harman, M., & Hierons, R. (2001). An Overview of Program Slicing. Software Focus, 2(3), Retrieved October 27, 2012, from w.brunel.ac.uk%252F~cssrllh%252FGusttReview%252FPublications_dir%252Ffocus.pdf w.brunel.ac.uk%252F~cssrllh%252FGusttReview%252FPublications_dir%252Ffocus.pdf  Sasirekha, N., Robert, A. E., & Hemalatha, M. (2011, July). Program Slicing Techniques and Its Applications. International Journal of Software Engineering & Applications, 2(3), Retrieved October 21, 2012, from  Silva, J. (2012, June). A Vocabulary of Program Slicing-Based Techniques. ACM Computing Surveys, 44(3), 12:1-12:41. Retrieved September 12, 2012, from  Tip, F. (1995). A Survey of Program Slicing Techniques. Java Programming Language, 3, Retrieved October 27, 2012, from Survey.pdfhttp://www.cse.buffalo.edu/LRG/CSE705/Papers/Tip-Slicing- Survey.pdf  Weiser, M. (1984, July). Program Slicing. IEEE Transactions of Software Engineering, 10(4), Retrieved October 21, 2012, from Slicing.pdfhttp://www.cse.buffalo.edu/LRG/CSE705/Papers/Weiser-Static- Slicing.pdf

38 References (cont.)  Lyle, Jim. "The Unravel Project." The Unravel Program Slicing Tool. National Institute of Standards and Technology, 37 Mar Web. 10 Dec  Brown, Aaron. "CodeSurfer: It Slices, It Chops, But Doesn't Make Julienne Fries." GrammaTech, n.d. Web. 10 Dec  United States. Johnson Space Center Safety and Mission Assurance Directorate. Flight Equipment Division. Can CodeSurfer Increase Code Inspection Efficiency? By Mark Markovich and Dan Freund. N.p., n.d. Web. 10 Dec odeXInspectionXEfficiencyV31.ppthttp://www.nasa.gov/centers/ivv/ppt/172689main_CanXCodeSurferXIncreaseXC odeXInspectionXEfficiencyV31.ppt  "Wisconsin Program-Slicing Project." N.p., n.d. Web. 10 Dec  "CodeSurfer." GrammaTech. N.p., Web. 12 Dec


Download ppt "By Corey Rahberger. Overview  What is program slicing?  History  How to extract a slice  Program slicing techniques  Applications  Program slicing."

Similar presentations


Ads by Google