Program slicing: Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
Add: s2cid, authors 1-1. Removed parameters. Some additions/deletions were parameter name changes. | Use this bot. Report bugs. | Suggested by Whoop whoop pull up | Category:Debugging | #UCB_Category 37/62
Importing Wikidata short description: "Set of software engineering methods"
 
(4 intermediate revisions by 4 users not shown)
Line 1:
{{Short description|Set of software engineering methods}}
{{other uses of|slicing|Slicing (disambiguation)}}
{{more footnotes|date=August 2012}}
Line 4 ⟶ 5:
In [[computer programming]], '''program slicing''' is the computation of the set of program statements, the '''program slice''', that may affect the values at some point of interest, referred to as a '''slicing criterion'''. Program slicing can be used in [[debugging]] to locate source of errors more easily. Other applications of slicing include [[software maintenance]], [[Optimization (computer science)|optimization]], [[Program analysis (computer science)|program analysis]], and [[Non-interference (security)|information flow control]].
 
Slicing techniques have been seeing a rapid development since the original definition by [[Mark Weiser]]. At first, slicing was only static, i.e., applied on the source code with no other information than the source code. [[Bogdan Korel]] and [[Janusz Laski]] introduced ''dynamic slicing'', which works on a specific execution of the program (for a given execution trace).<ref>{{cite journal |last1=Korel |first1=Bogdan |last2=Laski |first2=Janusz |title=Dynamic Program Slicing |journal=Information Processing Letters |date=1988 |volume=29 |issue=3 |pages=155–163 |doi=10.1016/0020-0190(88)90054-3 |citeseerx=10.1.1.158.9078 }}</ref> Other forms of slicing exist, for instance path slicing.<ref>{{Cite book|last1=Jhala|first1=Ranjit|last2=Majumdar|first2=Rupak|date=2005|title=Path Slicing|journal=Proceedings of the 2005 ACM SIGPLAN Conferenceconference on Programming Languagelanguage Designdesign and Implementationimplementation |chapter=Path slicing |date=2005|series=PLDI '05|___location=New York, NY, USA|publisher=ACM|pages=38–47|doi=10.1145/1065010.1065016|isbn=9781595930569|s2cid=5065847 }}</ref>
 
== Static slicing ==
Line 14 ⟶ 15:
For example, consider the C program below. Let's compute the slice for ( write(sum), sum ). The value of sum is directly affected by the statements "sum = sum + i + w" if N>1 and "int sum = 0" if N <= 1. So, slice( write(sum), sum) is the union of three slices and the "int sum = 0" statement which has no dependencies:
<ol>
<li>slice( sum = sum + i + w, sum),</li>,
<li>slice( sum = sum + i + w, i),</li>,
<li>slice( sum = sum + i + w, w), and</li>, and
<li>{ int sum=0 }.</li>
</ol>
Line 53 ⟶ 54:
 
== Dynamic slicing ==
MakesDynamic slicing makes use of information about a particular execution of a program. A dynamic slice contains all statements that actually affect the value of a variable at a program point for a particular execution of the program rather than all statements that may have affected the value of a variable at a program point for any arbitrary execution of the program.
 
An example to clarify the difference between static and dynamic slicing. Consider a small piece of a program unit, in which there is an iteration block containing an if-else block. There are a few statements in both the <code>if</code> and <code>else</code> blocks that have an effect on a variable. In the case of static slicing, since the whole program unit is looked at irrespective of a particular execution of the program, the affected statements in both blocks would be included in the slice. But, in the case of dynamic slicing we consider a particular execution of the program, wherein the <code>if</code> block gets executed and the affected statements in the <code>else</code> block do not get executed. So, that is why in this particular execution case, the dynamic slice would contain only the statements in the <code>if</code> block.
Line 86 ⟶ 87:
* [http://www.cs.wisc.edu/wpis/html/ Wisconsin Program-Slicing Project]
 
{{Program analysis}}
[[Category:Debugging]]
[[Category:Program analysis]]