
Precise Dynamic Slicing Algorithms
Xiangyu Zhang Rajiv Gupta
The University of Arizona
Dept. of Computer Science
Tucson, Arizona 85721
Youtao Zhang
The Univ. of Texas at Dallas
Dept. of Computer Science
Richardson, TX 75083
Abstract
Dynamic slicing algorithms can greatly reduce the de-
bugging effort by focusing the attention of the user on a rele-
vant subset of program statements. In this paper we present
the design and evaluation of three precise dynamic slicing
algorithms called the full preprocessing (FP), no prepro-
cessing (NP) and limited preprocessing (LP) algorithms.
The algorithms differ in the relative timing of construct-
ing the dynamic data dependence graph and its traversal
for computing requested dynamic slices. Our experiments
show that the LP algorithm is a fast and practical precise
slicing algorithm. In fact we show that while precise slices
can be orders of magnitude smaller than imprecise dynamic
slices, for small number of slicing requests, the LP algo-
rithm is faster than an imprecise dynamic slicing algorithm
proposed by Agrawal and Horgan.
1. Introduction
The concept of program slicing was first introduced by
Mark Weiser [10]. He introduced program slicing as a de-
bugging aid and gave the first static slicing algorithm. Since
then a great deal of research has been conducted on static
slicing and an excellent survey of many of the proposed
techniques and tools can be found in [8] and [5]. Other
works on slicing have explored the applications of slicing
in greater depth. Some examples of such works include the
use of slicing in debugging sequential and distributed pro-
grams as well as testing sequential programs [2,6].
It is widely recognized that for programs that make ex-
tensive use of pointers, the highly conservative nature of
data dependency analysis leads to highly imprecise and con-
siderably larger slices. For program debugging, where the
objective of slicing is to reduce the debugging effort by fo-
cusing the attention of the user on the relevant subset of pro-
gram statements, conservatively computed large slices are
Supported by a grant from IBM and National Science Foundation
grants CCR-0220334, CCR-0208756, CCR-0105355, and EIA-0080123
to the University of Arizona.
clearly undesirable. Recognizing the need for accurate slic-
ing, Korel and Laski proposed the idea of dynamic slicing
[7]. The data dependences that are exercised during a pro-
gram execution are captured precisely and saved. Dynamic
slices are constructed upon users requests by traversing the
captured dynamic dependence information. An exception
to this approach is various works on forward computation
of dynamic slices [11, 12] which precompute all dynamic
slices prior to users requests. While no experimental data
is reported in [11, 12], the execution times of this approach
can be expected to be high. Therefore in this paper we take
the standard approach of computing onlythe dynamic slices
requested by the user.
It has been shown that precise dynamic slices can be
considerably smaller than static slices [9, 5]. The data in
Table 1 shows the effectiveness of dynamic slicing. For
each of the benchmark programs, we computed 25 distinct
dynamic slices half way through the program’s execution
(@Midpoint) and another 25 at the end of program’s ex-
ecution (@End). The average (AVG), minimum (MIN) and
maximum (MAX) precise dynamic slice sizes that were ob-
served are given in the precise dynamic slices PDS column.
In addition, the number of distinct statements in the pro-
gram (Static) and the number of distinct statements that are
executed (Executed) are also given. For example, program
126.gcc contains 585491 static instructions and, during
the collection of the execution trace, 170135 of these in-
structions were executed at least once. When 25 precise dy-
namic slices were computed, they had average, minimum
and maximum sizes of 6614, 2, and 11860 instructions re-
spectively. As we can see, the PDS values are much smaller
that the Static and Executed values. Thus, dynamic slices
greatly help in focusing the attention of the user to a small
subset of statements during debugging.
While precise dynamic slices can be very useful, it is also
well known that computing them is expensive. Therefore
researchers have proposed imprecise dynamic slicing algo-
rithms that trade-off precision of dynamic slicing with the
costs of computing dynamic slicing. However, while such
algorithms have the potential of reducing the cost of slicing,