Platzhalter für Bild, Bild auf Titelfolie hinter das Logo einsetzen Program Slicing in the Presence of Variability Sandro Schulze, Frederik Kanning, FOSD meeting, 4.-7.05.2014
Problem Testing: incremental pairwise CIT ... Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 2
Motivation Change dd e.g., bug fix, feature request V 1.0 V 2.0 Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 3
Determining the Impact of Change Features affected by a certain change? Variants affected by a certain change? Which tests have to be re-run? Regression Testing Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 4
Program Slicing (Mark Weiser, 1984) ⌥ ⌥ ⌅ ⌅ 1 read(text); 1 read(text); What program statements can 2 read(n); 2 . influence specified variables at 3 lines = 1; 3 lines = 1; a certain statement? 4 . 4 chars = 1; 5 subtext = ""; 5 . 6 c = getChar(text); 6 c = getChar(text); 7 while (c != \eof) 7 while (c != \eof) Slicing criterion: if (c == \n) if (c == \n) 8 8 <16, {lines}> then lines = lines + 1; then lines = lines + 1; 9 9 10 . chars = chars + 1; 10 11 . else chars = chars + 1; 11 12 . if (n != 0) 12 13 . then subtext = subtext ++ c; 13 14 . n = n - 1; 14 c = getChar(text); c = getChar(text); 15 15 write(lines); write(lines); 16 16 write(chars); . 17 17 . write(subtext); 18 18 ⌃ ⌃ ⇧ ⇧ Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 5
Static Forward Slicing ⌥ ⌅ 1 void main() … .determining how a Slicing criterion 2 { modification affects (part of) <7, {b}> int a, b, c; 3 a program. 4 a = 32; 5 6 b = 23; 7 c = 2 * b; 8 9 print(a); 10 print(c); 11 12 a += 1; 13 c = b; 14 15 print(a); 16 print(c); 17 18 } ⌃ ⇧ Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 6
Variability-Aware Forward Slicing ⌥ ⌅ ⌥ ⌅ // lines 1-3 omitted 1 void main() 4 a = 32; 2 { 5 b = 23; int a, b, c; 6 3 c = 2 * b; 7 4 8 a = 32; 5 print(a); 9 6 print(c); 10 b = 23; 7 11 Slicing with c = 2 * b; 8 12 #ifdef X 9 a = b; 13 print(a); 10 #ifdef Z preprocessors 14 print(c); 11 c = b; 15 12 #endif 16 a += 1; 13 17 #else c = b; 14 a = 2*b; 18 15 19 #endif print(a); 16 print(a); 20 print(c); print(c); 17 21 18 } 22 } ⌃ ⇧ ⌃ ⇧ Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 7
General Approach § Data flow dependence § Compute Def-Use-Chains via reachable uses analysis Control dependence analysis § How does dependent predicates affect definitions in subordinate branches? Ø Taking interdependence into account § Slice à transitive closure of all dependencies § Based on TypeChef and Monotone framework Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 8
Data Flow Dependence ⌥ ⌅ // lines 1-3 omitted 4 Slicing criterion a = 32; 5 Which features are affected if <6, {b}> b = 23; 6 there is a change in the c = 2 * b; 7 respective statement? 8 print(a); 9 print(c); 10 Under which configurations 11 particular statements belong 12 #ifdef X {X} to the slice? a = b; 13 #ifdef Z 14 {X && Z} c = b; 15 #endif 16 17 #else {!X} a = 2*b; 18 19 #endif {!X || X} print(a); 20 print(c); 21 22 } ⌃ ⇧ Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 9
Control Flow Dependence ⌥ ⌅ ⌥ ⌅ Slicing criterion 1 void control() Slicing criterion void control() <5, {x}> 2 { 1 <5, {x}> 2 { int x, y, a = 0; 3 int x, y, a = 0; 3 4 x = 0; // <- 4 5 x = 0; 5 6 if(x < 5) { 6 7 if(y < 5) { 8 #ifdef Y 7 {Y} y += 1; y += a; 8 9 9 #ifdef X 10 #endif {X} a = 2*x; 11 #ifdef X 10 {X} 11 #endif a += 1; 12 } 13 #endif 12 } 14 13 print(x); 15 14 print(x); print(y); 16 15 {Y} print(y); 16 } 17 ⌃ ⇧ 18 } ⌃ ⇧ Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 10
Collecting all dependencies ⌥ ⌅ 1 void loop() { Iterating through all indirect int a = 0; int b = 0; int c = 0; 2 dependencies. int x; Slicing criterion 3 4 <5, {x}> x = 5; // <- 5 6 while(foo() == true) 7 { 8 9 #ifdef X {X} c = b; 10 11 #endif {X || Z} b = a; 12 13 #if defined(X) || defined(Z) {X || Z} a = x; 14 15 #endif } 16 17 {X} print(c); 18 print(x); 19 20 } ⌃ ⇧ Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 11
Infrastructure CodeRunner Slicing Variability Analysis Control Dependence Analysis Evolutionary Analysis Reachable Uses Analysis TypeChef AST Source Code Type Monotone Annotations Preprocessor Lexer Parser Checking Framework Macros Includes Feature Model SAT Solver Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 12
A Long Road To Go … Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 13
Current State & Ongoing Work Currently implemented/Ongoing: - Data flow dependency analysis (on statement level) - Control dependence (work in progress) - Changes to function parameters (work in progress) Future work - Support more tricky constructs à pointers, go-to - Interprocedural forward slicing - Optimizations (performance, resolving variability) - Evaluation wrt regression testing Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 14
Ultimate Goal Interprocedural, variability-aware slicing Sandro Schulze | Program Slicing & Variability | FOSD 2014| Slide 15
Recommend
More recommend