1 / 38

Program Slicing – Based Techniques

By Corey Rahberger. Program Slicing – Based Techniques. Overview. What is program slicing? History How to extract a slice Program slicing techniques Applications Program slicing tools Current Problems Future. What is program slicing?. The process of computing a slice of a program

dot
Download Presentation

Program Slicing – Based Techniques

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. By Corey Rahberger Program Slicing – Based Techniques

  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 inti; int sum = 0; int product = 1; for(i = 0; i < N; i++) { sum = sum + 1; product = product * I; } write(sum); write(product); inti; int sum = 0; for(i = 0; i < N; i++) { sum = sum + 1; } write(sum); Original Program Slice on statement “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 http://www-sul.stanford.edu/weiser/

  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 • read(text); • read(n); • lines = 1; • chars = 1; • subtext = “”; • c = getChar(text); • while ( c != ‘\eof’) • if (c == ‘\n’) then • lines = lines + 1; • chars = chars + 1; • else chars = chars + 1; • if (n != 0) then • subtext = subtext + c; • n = n – 1; • c = getChar(text); • write(lines); • write(chars); • 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 • read(text); • read(n); • lines = 1; • chars = 1; • subtext = “”; • c = getChar(text); • while ( c != ‘\eof’) • if (c == ‘\n’) then • lines = lines + 1; • chars = chars + 1; • else chars = chars + 1; • if (n != 0) then • subtext = subtext + c; • n = n – 1; • c = getChar(text); • write(lines); • write(chars); • 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 • read(n); • i := 1; • sum := 0; • product := 1; • while i <= n do begin • sum := sum + 1; • product := product * i; • i := i + 1; end; • write(sum); • write(product); read(n); i:= 1; product := 1; while i <= n do begin product := product * i; i:= i + 1; end; write(product); Original Program Slice of program w.r.t. criterion (10, 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 • (si, v, {ai, …, an}) • ‘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 • ‘{ai, …, an}’ represents the initial values or inputs • Example • (71, sum, {x = 1})

  20. Dynamic Slicing Example • read(n); • i := 1; • while (i <= n) do begin • if (i mod 2 = 0) then • x := 17; else • x := 18; • i := i + 1; end; • 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); Original Program Slice of program w.r.t. criterion (81, x, {n = 2})

  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 • read(text); • read(n); • lines = 1; • chars = 1; • subtext = “”; • c = getChar(text); • while ( c != ‘\eof’) • if (c == ‘\n’) then • lines = lines + 1; • chars = chars + 1; • else chars = chars + 1; • if (n != 0) then • subtext = subtext + c; • n = n – 1; • c = getChar(text); • write(lines); • write(chars); • 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); Original Program Slice of program w.r.t. criterion ((text, n), F, 18, {subtext}), where F = (∀c ∈text, c != ‘\n’ . n > 0)

  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 • National Institute of Standards and Technology • CodeSurfer • University of Wisconsin Slicing Tool • GrammaTech

  28. CodeSurfer • University of Wisconsin Slicing Tool • Developed 1996-2000 • 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

  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, 105-178. Retrieved October 27, 2012, from http://eres.lndproxy.org/edoc/FacPubs/loy/BinkleyDW/SurveyOfEmpirical-04.pdf • Harman, M., & Hierons, R. (2001). An Overview of Program Slicing. Software Focus, 2(3), 85-92. Retrieved October 27, 2012, from http://docis.info/strip/docis/lib/ligo/rclis/dbl/soffoc/(2001)2%253A3%253C85%253AAOOPS%253E/www.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), 50-64. Retrieved October 21, 2012, from http://airccse.org/journal/ijsea/papers/0711ijsea04.pdf • 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 http://dl.acm.org/citation.cfm?id=2187674 • Tip, F. (1995). A Survey of Program Slicing Techniques. Java Programming Language, 3, 121-189. Retrieved October 27, 2012, from http://www.cse.buffalo.edu/LRG/CSE705/Papers/Tip-Slicing-Survey.pdf • Weiser, M. (1984, July). Program Slicing. IEEE Transactions of Software Engineering, 10(4), 352-357. Retrieved October 21, 2012, from http://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. 1998. Web. 10 Dec. 2012. http://hissa.nist.gov/unravel/ • Brown, Aaron. "CodeSurfer: It Slices, It Chops, But Doesn't Make Julienne Fries." GrammaTech, n.d. Web. 10 Dec. 2012. http://hiper.cis.udel.edu/lp/lib/exe/fetch.php/courses/cisc879/codesurfer-demo.pdf • 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. 2012.  http://www.nasa.gov/centers/ivv/ppt/172689main_CanXCodeSurferXIncreaseXCodeXInspectionXEfficiencyV31.ppt • "Wisconsin Program-Slicing Project." N.p., n.d. Web. 10 Dec. 2012. http://research.cs.wisc.edu/wpis/html/ • "CodeSurfer." GrammaTech. N.p., 2012. Web. 12 Dec. 2012. http://www.grammatech.com/products/codesurfer/overview.html

More Related