DependenceCache Slicing A Slicing Method Using Lightweight Dynamic

  • Slides: 26
Download presentation
Dependence-Cache Slicing: A Slicing Method Using Lightweight Dynamic Information Tomonori Takada, Fumiaki Ohata, Katsuro

Dependence-Cache Slicing: A Slicing Method Using Lightweight Dynamic Information Tomonori Takada, Fumiaki Ohata, Katsuro Inoue Osaka University 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

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

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 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Program Slicing A technique of extracting all program statements affecting the value of a

Program 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 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Experiment Using Program Slice To evaluate the validity of slice With two independent groups

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

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

Program Dependence Graph PDG shows dependence relations between statements in a source program. nodes statements conditional predicates edges control dependence edges data dependence edges Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Dependences Control Dependence (CD) Statement s 1 has a control dependence to statement s

Dependences Control Dependence (CD) Statement s 1 has a control dependence to statement s 2 if the execution of s 2 is decided by s 1’s result. s 1: if a=0 then s 2: b : =1; s 2 s 1 Data Dependence (DD) Def-Use relation. s 3: a : = 1; s 4: writeln(a); s 3 a s 4 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Example of PDG program test(input, output); var a : array [0. . 9] of

Example of PDG program 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(“inp. . for i: =0 to 9 i a[i] : = i * i writeln(“inp. . readln(b) b writeln("input number : "); readln(b); b a[] if b<10 if b < 10 then c : = a[b] else c : = -1; c : = a[b] c : = -1 writeln(c) end. writeln(c) CD c DD Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University c

Example of static slice program test(input, output); var a : array [0. . 9]

Example of static slice program 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); writeln(“inp. . for i: =0 to 9 i a[i] : = i * i writeln(“inp. . readln(b) b a[] if b<10 if b < 10 then c : = a[b] else c : = -1; writeln(c) end. b c : = a[b] c : = -1 Slicing Criteria writeln(c) c Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University c

Dynamic Slicing Program is analysed dynamically (executed with a particular input data) Extract statements

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. Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Example of dynamic slice program test(input, output); var a : array [0. . 9]

Example of dynamic slice program 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; for writeln("input number : "); readln(b); if b < 10 then c : = a[b] else c : = -1; writeln(c) end. input b=5 writeln("input array : "); writeln(“inp. . for i: =0 to 9 do a[0] : = 0 *0; i: =0 for to i: =0 9 to 9 do for a[1] : =a[0] 1 *1; : = 0*0 a[5] : = 5 * 5 i for i: =0 to 9 do fora[2] : =2 for a[1]*2; : = 1 * 1 a[6] : = 6 * 6 for i: =0 to 9 do 3 *3; fora[3] : = for a[2] : = 2 * 2 for i: =0 to 9 do a[7] : = 7 * 7 fora[4] : = 4 *4; a[3] : = 3 * 3 for a[8] : = 8 * 8 for i: =0 to 9 do 5 *5; b fora[5] : = a[4] for i: =0 to : = 9 do 4 * 4 a[]9 * 9 a[9] : = a[6] : = 6 *6; for i: =0 to 9 do b a[7]readln(b) : = 7 *7; writeln(“inp. . for i: =0 to 9 do b a[8] : = 8 *8; for i: =0 to 9 do a[5] a[9]if : =b<10 9 *9; writeln("input number : "); c : = a[5] c readln(b); if b < 10 then c : = a[b] writeln(c) Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Static and Dynamic Slicing Analysis cost: static < dynamic Recording execution trace is exhaustive

Static and Dynamic Slicing Analysis cost: static < dynamic Recording execution trace is exhaustive Determining data dependence and cotrol dependence on execution trace is expensive Slice size: static > dynamic Static slicing considers all possible flows Dynamic slicing only considers one trace unify Efficient and Effective Slicing Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Unified Slicing Methods Focusing on Dynamic Control-Flow Information Hybird Slicing (Gupta, 1997) Collect all

Unified 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 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Dependence-Cache Slicing (DC slicing) : A slicing method focused on dynamic dataflow information Control

Dependence-Cache Slicing (DC slicing) : A slicing method focused on dynamic dataflow information Control Dependence Computation Step 1: Pre-Execution Analysis Easily obtained by syntax analysis Statically compute control dependence relations and construct PDG having control dependence edges and nodes Data Dependence Computation Step 2: Execution-time static analysis is difficult Analysis Collect dynamic data dependence relations by using Caches and add data dependence edges to PDG Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Data Dependence Collection Input: b=0 b a[0] c s 1: s 2: s 3:

Data Dependence Collection Input: b=0 b a[0] c s 1: s 2: s 3: s 4: s 5: s 6: a[0]: =0; a[1]: =3; readln(b); a[b]: =2; c: =a[0]+4; writeln(c); Value of cache a[0] a[1] s 4 s 1 s 2 b c s 3 s 5 Each cache holds the statement where the variable is defined Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Example of DC slice program test(input, output); var a : array [0. . 9]

Example of DC slice program 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(“inp. . for i: =0 to 9 i a[i] : = i * i writeln(“inp. . readln(b) writeln("input number : "); readln(b); if b < 10 then c : = a[b] else c : = -1; writeln(c) end. b b a[5] if b<10 c : = a[b] input b=5 c : = -1 writeln(c) Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University c

Experiment Measured some metric values on our slicing system “Osaka Slicing System (OSS)” OSS

Experiment 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 P 1: calendar program (85 lines) P 2:wholesaler program (387 lines) P 3:wholesaler program 2 (871 lines) Slicing criterion were randomly chosen Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Slice Size lines 200 180 160 140 static call-mark dependence-cache dynamic 187 182 166

Slice Size lines 200 180 160 140 static call-mark dependence-cache dynamic 187 182 166 162 120 100 80 60 40 20 0 61 21 17 15 P 1 5 16 P 2 8 5 P 3 static > call-mark >> DC > dynamic DC and dynamic slicing can analyze actual dependence. P 2, P 3 use array variables. Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Pre-Execution Analysis Time time (ms) 800 700 600 500 400 710 698 static call-mark

Pre-Execution Analysis Time time (ms) 800 700 600 500 400 710 698 static call-mark dependence-cache dynamic 300 213 215 200 100 0 11 14 5 P 1 N/A 19 48 N/A P 2 N/A P 3 static ≒ call-mark > DC DC slicing analyses only control dependence relations. Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Execution time (ms) 206464 6000 5000 4000 3000 static call-mark dependence-cache dynamic 4540 4731

Execution time (ms) 206464 6000 5000 4000 3000 static call-mark dependence-cache dynamic 4540 4731 4700 4834 2000 1000 0 47 47 51 174 P 1 43 43 45 P 2 P 3 Execution time for static slicing shows the execution time for “original” program. Static ≒ CM ≒ DC << Dynamic DC slicing can be computed with small overhead increase. Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Slice Computation Time time (ms) 76 10 101 24969 8 static 6 call-mark 4

Slice Computation Time time (ms) 76 10 101 24969 8 static 6 call-mark 4 2 0 3. 0 0. 40. 60. 3 P 1 1. 91. 8 0. 7 P 2 1. 2 dependencecache dynamic P 3 DC < static ≒ call-mark << dynamic DC slicing uses PDG that has less DD edges than that of static slicing. Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Discussion Analysis cost: static £ DC << dynamic Collect dynamic data dependence relatios by

Discussion Analysis cost: static £ DC << 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 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. s 1:

Limit of DC slicing DC slice’s accuracy is less than dynamic slice’s. s 1: a[0] : = 0; s 2: a[1] : = 1; s 3: i: = 0; s 4: while i<2 do begin s 5: b : = a[i]; s 6: i : = i + 1 end; s 7: 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 s 5. (Dynamic slicing can distinct it. ) Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Applications We have applied DC slicing to several language environments. Pascal (Interpreter) OSS mentioned

Applications 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 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University

Conclusions and Future Works Proposed dependence-cache slicing Practical and efficient approach to get reasonable

Conclusions 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 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University