dependence-cache slicing: a slicing method using lightweight dynamic information

26
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University Dependence-Cache Slicing: A Slicing Method Using Lightweight Dynamic Information Tomonori Takada, Fumiaki Ohata, Katsuro Inoue Osaka University

Upload: xavier-caldwell

Post on 03-Jan-2016

41 views

Category:

Documents


1 download

DESCRIPTION

Dependence-Cache Slicing: A Slicing Method Using Lightweight Dynamic Information. Tomonori Takada, Fumiaki Ohata, Katsuro Inoue Osaka University. Background of Research. Software Systems are becoming large and complex Debugging, testing, and maintaining costs are increasing - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Dependence-Cache Slicing: A Slicing Method Using Lightweight Dynamic

Information

Tomonori Takada, Fumiaki Ohata, Katsuro Inoue

Osaka University

Page 2: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Background 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

Page 3: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Comprehension

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

Page 4: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

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

Program Slicing

Page 5: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

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).

To evaluate the validity of slice

With two independent groups

Measured bug detection timewith slice: 122 minutes

without slice: 165 minutes

Experiment Using Program Slice

Page 6: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Static 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.

Page 7: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Program Dependence Graph

PDG shows dependence relations between statements in a source program.

nodes statements

conditional predicates

edges control dependence edges

data dependence edges

Page 8: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Dependences

Control Dependence (CD)Statement s1 has a control dependence to statement s2 if the execution of s2 is decided by s1’s result.

Data Dependence (DD) Def-Use relation.

s1: if a=0 thens2: b :=1;

s1 s2

s3: a := 1;s4: writeln(a);

s3 s4a

Page 9: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Example of PDGprogram test(input, output);var a : array [0..9] of integer;var b, i, c : integer;begin writeln("input array : "); for i:=0 to 9 do a[i] := i * i; writeln("input number : "); readln(b); if b < 10 then c := a[b] else c := -1;

writeln(c)end.

writeln(“inp..

a[i] := i * i

readln(b)

writeln(“inp..

c := a[b]

a[]b

i

if b<10

c := -1

writeln(c)

c

c

for i:=0 to 9

CD DD

b

Page 10: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Example of static sliceprogram test(input, output);var a : array [0..9] of integer;var b, i, c : integer;begin writeln("input array : "); for i:=0 to 9 do a[i] := i * i; writeln("input number : "); readln(b); if b < 10 then c := a[b] else c := -1;

writeln(c)end.

writeln(“inp..

a[i] := i * i

readln(b)

writeln(“inp..

c := a[b]

a[]b

i

if b<10

c := -1

writeln(c)

c

c

for i:=0 to 9

b

Slicing Criteria writeln(c)

writeln(c)

for i:=0 to 9 do a[i] := i * i;

readln(b); if b < 10 then c := a[b] else c := -1;

Page 11: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Dynamic 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.

Page 12: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

writeln("input array : ");for i:=0 to 9 doa[0] := 0 *0;for i:=0 to 9 doa[1] := 1 *1;for i:=0 to 9 doa[2] :=2 *2;for i:=0 to 9 doa[3] := 3 *3;for i:=0 to 9 doa[4] := 4 *4;for i:=0 to 9 doa[5] := 5 *5;for i:=0 to 9 doa[6] := 6 *6;for i:=0 to 9 doa[7] := 7 *7;for i:=0 to 9 doa[8] := 8 *8;for i:=0 to 9 doa[9] := 9 *9;writeln("input number : ");readln(b);if b < 10 thenc := a[b]writeln(c)

Example of dynamic sliceprogram test(input, output);var a : array [0..9] of integer;var b, i, c : integer;begin writeln("input array : "); for i:=0 to 9 do a[i] := i * i; writeln("input number : "); readln(b); if b < 10 then c := a[b] else c := -1;

writeln(c)end.

for i:=0 to 9 do a[i] := i * i;

readln(b); if b < 10 then c := a[b]

readln(b) writeln(“inp..

c := a[5]

a[]b

i

if b<10

writeln(c)

c

b

b

a[5]

for i:=0 to 9

writeln(“inp..

a[0] := 0*0

for a[1] := 1 * 1

for a[2] := 2 * 2

for a[3] := 3 * 3

for a[4] := 4 * 4

fora[5] := 5 * 5

fora[6] := 6 * 6

fora[7] := 7 * 7

for a[8] := 8 * 8for

a[9] := 9 * 9

inputb=5

writeln(c)

writeln(c)

Page 13: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Static and Dynamic Slicing

Analysis cost: static < dynamicRecording execution trace is exhaustive

Determining data dependence and cotrol dependence on execution trace is expensive

Slice size: static > dynamicStatic slicing considers all possible flows

Dynamic slicing only considers one trace

Efficient and Effective SlicingEfficient and Effective Slicing

unify

Page 14: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Unified Slicing MethodsFocusing on Dynamic Control-Flow Information

Hybird Slicing (Gupta, 1997)Collect all traces between break points and procedure callsNeed 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

Page 15: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Dependence-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

Page 16: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

s1: a[0]:=0;s2: a[1]:=3;s3: readln(b);s4: a[b]:=2;s5: c:=a[0]+4;s6: writeln(c);

a[0] a[1] b c

s1s1 s2s1 s2 s3

Data Dependence Collection

Input: b=0

b

a[0]

c

Value of cache

s4 s2 s3s4 s2 s3 s5

Each cache holds the statement where the variable is defined

Page 17: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Example of DC sliceprogram test(input, output);var a : array [0..9] of integer;var b, i, c : integer;begin writeln("input array : "); for i:=0 to 9 do a[i] := i * i; writeln("input number : "); readln(b); if b < 10 then c := a[b] else c := -1;

writeln(c)end.

writeln(“inp..

a[i] := i * i

readln(b)

writeln(“inp..

c := a[b]

if b<10

c := -1

writeln(c)

for i:=0 to 9

inputb=5

a[5]

b

i

c

b

writeln(c)writeln(c)

for i:=0 to 9 do a[i] := i * i;

readln(b); if b < 10 then c := a[b]

Page 18: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

ExperimentMeasured 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 programsP1: calendar program (85 lines)

P2 : wholesaler program (387 lines)

P3 : wholesaler program2 (871 lines)

Slicing criterion were randomly chosen

Page 19: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Slice Size

21

182 187

17

162 166

15 16

61

5 5 80

20

40

60

80

100

120

140

160

180

200

P1 P2 P3

staticcall-markdependence-cachedynamic

lines

static > call-mark >> DC > dynamic

DC and dynamic slicing can analyze actual dependence.P2, P3 use array variables.

Page 20: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Pre-Execution Analysis Time

11

213

710

14

215

698

5 19 48N/AN/AN/A

0

100

200

300

400

500

600

700

800

P1 P2 P3

static

call-mark

dependence-cache

dynamic

time(ms)

static call-mark ≒ > DC

DC slicing analyses only control dependence relations.

Page 21: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

47 43

4700

47 43

4731

51 45174

4540

206464

4834

0

1000

2000

3000

4000

5000

6000

P1 P2 P3

staticcall-markdependence-cachedynamic

Execution time

time(ms)

Static CM DC ≒ ≒ << Dynamic

DC slicing can be computed with small overhead increase.

Execution time for static slicing shows the execution time for “original” program.

Page 22: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Slice Computation Time

0.4

1.93.0

0.6

1.8

3.0

0.3 0.71.2

76 101 24969

0

2

4

6

8

10

P1 P2 P3

static

call-mark

dependence-cachedynamic

time(ms)

DC < static call-mark ≒ << dynamic

DC slicing uses PDG that has less DD edges than that of static slicing.

Page 23: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

DiscussionAnalysis cost: static DC << dynamic

Collect dynamic data dependence relatios by simple method

Slice size: static DC dynamiconly “actual” data dependence relations are added to PDG

Reasonable slice results with reasonable analysis timePromising approach to get effective program localization

Page 24: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Limit of DC slicing

DC slice’s accuracy is less than dynamic slice’s.s1: a[0] := 0;s2: a[1] := 1;s3: i:= 0;s4: while i<2 do begins5: b := a[i];s6: i := i + 1 end;s7: writeln(b);

DC slicing analyse dependence relations between statements, not between execution trace.

For this program, DC slicing can’t distinct between first and second execution of s5. (Dynamic slicing can distinct it.)

Page 25: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

ApplicationsWe 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

Page 26: Dependence-Cache Slicing:  A Slicing Method Using Lightweight Dynamic Information

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Conclusions and Future Works

Proposed dependence-cache slicingPractical 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