program slicing

Uses your system voice; voice and rate in settings.

Q1413145Snapshot

≈ 4 min read

Names in other languages

  • EspañolRebanamiento estático
  • DeutschProgram Slicing
  • Englishprogram slicing
  • ItalianoProgram Slicing
  • mkСтатично сечење
  • 中文程式切片
  • 简体中文程序切片

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

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, program analysis, and 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). Other forms of slicing exist, for instance path slicing.

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, program analysis, and 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). Other forms of slicing exist, for instance path slicing. Based on the original definition of Weiser, informally, a static program slice S consists of all statements in program P that may affect the value of variable v in a statement x. The slice is defined for a slicing criterion C=(x,v) where x is a statement in program P and v is variable in x. A static slice includes all the statements that can affect the value of variable v at statement x for any possible input. Static slices are computed by backtracking dependencies between statements. More specifically, to compute the static slice for (x,v), we first find all statements that can directly affect the value of v before statement x is encountered. Recursively, for each statement y which can affect the value of v in statement x, we compute the slices for all variables z in y that affect the value of v. The union of all those slices is the static slice for (x,v). 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 slice( sum = sum + i + w, sum), slice( sum = sum + i + w, i), slice( sum = sum + i + w, w), and { int sum=0 }. It is fairly easy to see that slice( sum = sum + i + w, sum) consists of "sum = sum + i + w" and "int sum = 0" because those are the only two prior statements that can affect the value of sum at "sum = sum + i + w". Similarly, slice( sum = sum + i + w, i) only contains "for(i = 1; i int i; int sum = 0; int product = 1; int w = 7; for(i = 1; i The static executable slice for criteria ( write(sum) , sum) is the new program shown below. int i; int sum = 0; int w = 7; for(i = 1; i In fact, most static slicing techniques, including Weiser's own technique, will also remove the write(sum) statement. Since, at the statement write(sum) , the value of sum is not dependent on the statement itself. Often a slice for a particular statement x will include more than one variable. If V is a set of variables in a statement x, then the slice for (x, V) is the union of all slices with criteria (x, v) where v is a variable in the set V. ==See also== Software maintenance Dependence analysis Reaching definition Data dependency Frama-C a tool which implements slicing algorithms on C programs. Partial dead code elimination ==External links== VALSOFT/Joana Project Indus Project (part of Bandera checker) Wisconsin Program-Slicing Project

Text derived from https://en.wikipedia.org/w/index.php?oldid=1372439640 under CC BY-SA 4.0; modifications have been made.