Title: Dependence-Cache Slicing: A Slicing Method Using Lightweight Dynamic Information
1Dependence-Cache Slicing A Slicing Method Using
Lightweight Dynamic Information
- Tomonori Takada, Fumiaki Ohata, Katsuro Inoue
- Osaka University
2Background of Research
- Software Systems are becoming large and complex
- Debugging, testing, and maintaining costs are
increasing - To reduce development costs, techniques for
improving efficiency of such activities are
essential
3Comprehension
- Comprehending large source programs is difficult
- If we could select specific portions in the
source programs and we can concentrate our
attentions only to those portions, the
performance of the activities would increase
4Program Slicing
- A technique of extracting all program statements
affecting the value of a variable - Slicing Extraction
- Slice Collection of extracted statements
- Developers can concentrate their attentions to
the extracted statements
5Experiment Using Program Slice
- To evaluate the validity of slice
- With two independent groups
- Measured bug detection time
- with slice 122 minutes
- without slice 165 minutes
Kusumoto, S., Nishimatsu, A., Nishie, K. and
Inoue, K. Experimental Evaluation of Program
Slicing for Fault Localization'', Empirical
Software Engineering, Vol.7, No.1, pp. 49-76
(2002).
6Static Slicing
- Program is analysed statically (without
execution) - All possible input data sets are assumed.
- Extract all possible statements affecting the
value of the focused statement. - Program Dependence Graph (PDG) is used.
- Static slices are extracted by traversing edges
in PDG.
7Program Dependence Graph
- PDG shows dependence relations between
statements in a source program. - nodes
- statements
- conditional predicates
- edges
- control dependence edges
- data dependence edges
8Dependences
- Control Dependence (CD)
- Statement s1 has a control dependence to
statement s2 if the execution of s2 is decided by
s1s result. - Data Dependence (DD)
- Def-Use relation.
s1 if a0 then s2 b 1
s1
s2
9Example of PDG
program test(input, output) var a array 0..9
of integer var b, i, c integer begin
writeln("input array ") for i0 to 9 do
ai i i writeln("input number ")
readln(b) if b lt 10 then c ab
else c -1 writeln(c) end.
writeln(inp..
for i0 to 9
i
ai i i
writeln(inp..
readln(b)
b
b
a
if blt10
c ab
c
c -1
c
writeln(c)
DD
CD
10Example of static slice
program test(input, output) var a array 0..9
of integer var b, i, c integer begin
writeln("input array ") for i0 to 9 do
ai i i writeln("input number ")
readln(b) if b lt 10 then c ab
else c -1 writeln(c) end.
for i0 to 9 do ai i i
readln(b) if b lt 10 then c ab
else c -1
writeln(inp..
for i0 to 9
i
ai i i
writeln(inp..
readln(b)
b
a
b
if blt10
c ab
c
c -1
c
writeln(c)
11Dynamic Slicing
- Program is analysed dynamically (executed with a
particular input data) - Extract statements actually affecting the value
of a slicing criteria - Execution trace is recorded
- Dynamic Dependence Graph(DDG) is constructed from
the exection trace. - Dynamic slices are extracted by traversing edges
in DDG.
12Example of dynamic slice
writeln("input array ") for i0 to 9 do a0
0 0 for i0 to 9 do a1 1 1 for i0
to 9 do a2 2 2 for i0 to 9 do a3 3
3 for i0 to 9 do a4 4 4 for i0 to 9
do a5 5 5 for i0 to 9 do a6 6
6 for i0 to 9 do a7 7 7 for i0 to 9
do a8 8 8 for i0 to 9 do a9 9
9 writeln("input number ") readln(b) if b lt
10 then c ab writeln(c)
program test(input, output) var a array 0..9
of integer var b, i, c integer begin
writeln("input array ") for i0 to 9 do
ai i i writeln("input number ")
readln(b) if b lt 10 then c ab
else c -1 writeln(c) end.
for i0 to 9 do ai i i
readln(b) if b lt 10 then c ab
input b5
13Static and Dynamic Slicing
- Analysis cost static lt dynamic
- Recording execution trace is exhaustive
- Determining data dependence and cotrol dependence
on execution trace is expensive - Slice size static gt dynamic
- Static slicing considers all possible flows
- Dynamic slicing only considers one trace
unify
Efficient and Effective Slicing
14Unified Slicing Methods
- Focusing on Dynamic Control-Flow Information
- Hybird Slicing (Gupta, 1997)
- Collect all traces between break points and
procedure calls - Need to specify break points / Trace can be huge
- Call-Mark Slicing (Nishimatsu, 1999 our group)
- Dynamically set call-marks (flags that shows a
caller statement is executed or not) - Eliminate non-executed statements from PDG by
using call-mark and execution dependence
relations. - Focusing on Dynamic Data-Flow Information
- Reduced DDG Method (Agrawal, 1990)
- The same sub-structure of DDG is shared with one
structure. - Run-time overhead is serious.
- Dependence-Cache Slicing
15Dependence-Cache Slicing
- Dependence-Cache Slicing (DC slicing) A
slicing method focused on dynamic data-flow
information - Control Dependence
- Easily obtained by syntax analysis
- Data Dependence
- static analysis is difficult
Computation Step1 Pre-Execution
Analysis Statically compute control dependence
relations and construct PDG having control
dependence edges and nodes
Computation Step2 Execution-time
Analysis Collect dynamic data dependence
relations by using Caches and add data dependence
edges to PDG
16Data Dependence Collection
Value of cache
Input b0
a0
a1
b
c
s1 a00 s2 a13 s3 readln(b) s4
ab2 s5 ca04 s6 writeln(c)
s1
Each cache holds the statement where the variable
is defined
17Example of DC slice
program test(input, output) var a array 0..9
of integer var b, i, c integer begin
writeln("input array ") for i0 to 9 do
ai i i writeln("input number ")
readln(b) if b lt 10 then c ab
else c -1 writeln(c) end.
for i0 to 9 do ai i i
readln(b) if b lt 10 then c ab
input b5
18Experiment
- Measured some metric values on our slicing system
Osaka Slicing System (OSS) - OSS had already implemented features to extract
static, call-mark and dynamic slices. - Add function to compute DC slice
- Three sample PASCAL programs
- P1 calendar program (85 lines)
- P2wholesaler program (387 lines)
- P3wholesaler program2 (871 lines)
- Slicing criterion were randomly chosen
-
19Slice Size
lines
187
static
182
200
166
call-mark
162
180
dependence-cache
160
140
dynamic
120
100
80
61
60
21
40
17
15
16
8
5
5
20
0
P1
P2
P3
static gt call-mark gtgt DC gt dynamic
DC and dynamic slicing can analyze actual
dependence. P2, P3 use array variables.
20Pre-Execution Analysis Time
time (ms)
800
710
698
static
700
call-mark
600
dependence-cache
500
dynamic
400
300
213
215
200
48
100
19
14
11
5
N/A
N/A
N/A
0
P1
P2
P3
static ? call-mark gt DC
DC slicing analyses only control dependence
relations.
21Execution time
206464
time (ms)
6000
static
4731
4834
5000
4700
call-mark
4540
dependence-cache
4000
dynamic
3000
2000
1000
174
47
43
47
43
51
45
0
P1
P2
P3
Execution time for static slicing shows the
execution time for original program.
Static ? CM ? DC ltlt Dynamic
DC slicing can be computed with small overhead
increase.
22Slice Computation Time
76
101
24969
time (ms)
10
8
static
6
call-mark
4
dependence-
3.0
3.0
cache
1.9
1.8
dynamic
1.2
2
0.7
0.6
0.4
0.3
0
P1
P2
P3
DC lt static ? call-mark ltlt dynamic
DC slicing uses PDG that has less DD edges than
that of static slicing.
23Discussion
- Analysis cost static DC ltlt dynamic
- Collect dynamic data dependence relatios by
simple method - Slice size static ³ DC ³ dynamic
- only actual data dependence relations are added
to PDG - Reasonable slice results with reasonable analysis
time - Promising approach to get effective program
localization
24Limit of DC slicing
- DC slices accuracy is less than dynamic slices.
DC slicing analyse dependence relations between
statements, not between execution trace. For
this program, DC slicing cant distinct between
first and second execution of s5. (Dynamic
slicing can distinct it.)
s1 a0 0 s2 a1 1 s3 i 0 s4
while ilt2 do begin s5 b ai s6 i
i 1 end s7 writeln(b)
25Applications
- We have applied DC slicing to several language
environments. - Pascal (Interpreter)
- OSS mentioned before.
- Java source code (Preprocessor)
- Translate program to collect dynamic data
dependence relations. - Java byte code (Compiler, VM)
- Virtual Machine collects dynamic data dependence
Relations - Most of Java libraries are provided by byte code
26Conclusions and Future Works
- Proposed dependence-cache slicing
- Practical and efficient approach to get
reasonable slices - Confirmed validity through an experiment
- Applicable to various environments
- Future Works
- Evaluation through user testing
- Apply to other language environments
27(No Transcript)
28Example of DC slice(2)
program test(input, output) var a array 0..9
of integer var b, i, c integer begin
writeln("input array ") for i0 to 9 do
ai i i writeln("input number ")
readln(b) if b lt 10 then c ab
else c -1 writeln(c) end.
writeln(inp..
for i0 to 9
i
ai i i
writeln(inp..
readln(b)
b
if blt10
c ab
input b10
c -1
c
writeln(c)
29(No Transcript)
30Static Slicing
- All statements possibly affecting the value of
Slice Criterion (a variable concerned) - Method
- (1) Construct Program Dependence Graph (PDG)
- Nodes statements in program
- Edges
- Data Dependence (DD) variable definition and
its reference - Control Dependence (CD) predicate and statement
dominated by the predicate - (2) Collect all reachable nodes on PDG to a slice
criterion (statement, variable)
31Example of PDG
s1 begin s2 a3 s3 b3 s4 readln(c) s5 if
c0 then s6 begin s7 dfunctionA(a) s8 e
d s9 end s10 else s11 begin s12 dfunctionB
(b) s13 ed s14 end s15 writeln(e) s16 end.
32Example of Static Slice
Slicing criterion (s13, d)
33Example of Static Slice (2)
Slicing criterion (s15, e)
34Example of Dynamic Slicing
s1 begin s2 a3 s3 b3 s4 readln(c) s5 if
c0 then s6 begin s7 dfunctionA(a) s8 e
d s9 end s10 else s11 begin s12 dfunctionB
(b) s13 ed s14 end s15 writeln(e) s16 end.
e1 begin e2 a3 e3 b3 e4 readln(c) e5 if
c0 then e6 begin e7 dfunctionA(a) e8 e
d e9 end e15 writeln(e) e16 end.
Source
35Example of Dynamic Slicing (cont.)
e1 begin e2 a3 e3 b3 e4 readln(c) e5 if
c0 then e6 begin e7 dfunctionA(a) e8 e
d e9 end e15 writeln(e) e16 end.
(2) Determine DD and CD
36Architecture of Osaka Slicing System
Osaka Slicing System
37Snapshot of Osaka Slicing System
38Call-Mark Slicing
- Dependences
- Control Dependence
- Data Dependence
- Execution Dependenceshows relation that
statement A is never executed if statement B is
not executed. - Dynamically set call-marks (flags that shows a
caller statement is executed or not). - Eliminate non-executed statements from PDG by
using call-mark and ED relations.
39Experiment Using Program Slice
- To evaluate the validity of slice
- With two independent groups
- Measured bug detection time
- Two sub-experiments were conducted.
- trial-1 Group A used slice
- trial-2 Group B used slice
trial-1 with Slice with Slice with Slice without Slice without Slice without Slice
trial-1 subjects A1 A2 A3 B1 B2 B3
trial-1 time 119 128 120 154 175 166
trial-1 average 122.3 122.3 122.3 165 165 165
trial-2 without Slice without Slice without Slice with Slice with Slice with Slice
trial-2 subjects A1 A2 A3 B1 B2 B3
trial-2 time 118 126 155 131 93 118
trial-2 average 133 133 133 114 114 114
Kusumoto, S., Nishimatsu, A., Nishie, K. and
Inoue, K. Experimental Evaluation of Program
Slicing for Fault Localization'', Empirical
Software Engineering, Vol.7, No.1, pp. 49-76
(2002).
40Characteristics of DC slice
- Effectiveness
- only actual Data Dependence relations are
added to PDG - slice size would be small
- Efficiency
- no execution trace is recorded
- faster execution than dynamic slicing
- PDG size is smaller than PDG size of static
slice - faster slice-extraction than static slicing