Softwareproduktlinien Teil 12: Analyse von Produktlinien ChristianKästner (Universität Marburg) Sven Apel (Universität Passau) Gunter Saake (Universität Magdeburg) inkl. Folien von
Das Problem
Database Engine
Printer Firmware
Linux Kernel
Variability = Complexity
33 optional, independent features a unique variant for every person on this planet
320 optional, independent features more variants than estimated atoms in the universe
Correctness?
Maintenance? Comprehension?
Checking Products 2000 Features 100 Printers 30 New Printers per Year Printer Firmware
Checking Products 8000 Features? Products Linux Kernel
Checking Product Line Implementation with 10000 Features #ifdef, Frameworks, FOP, AOP, Linux Kernel
Analyse von Featuremodellen
Fragen an das Featuremodell main Eng g. Do Feature Modell Wiederverwendbare Implementierungsartefakte Application Eng. Feature Auswahl Generator Fertiges Program 16
Fragen an das Featuremodell Feature Modell Ist das Modell konsistent? Welche Features muß man auswählen? Welche Features darf man nicht auswählen? Wieviele gültige Produkte gibt es? Sind zwei Featuremodelle äquivalent?
Fragen an das Featuremodell Feature Modell Feature Auswahl Ist das Modell konsistent? Welche Features muß man auswählen? Welche Features darf man nicht auswählen? Wieviele gültige Produkte gibt es? Sind zwei Featuremodelle äquivalent? Ist eine Feature Auswahl gültig? Welche Features werden durch eine partielle Konfiguration bereits festgelegt? g
Wiederholung: Feature Modelle & Aussagenlogik. Repräsentation von Feature Modellen als Liste von Konfigurationen Aussagenlogischer Ausdruck Feature Diagramm SPL OS ( Ui Unix Win ) ( Ui Unix Win ) ( Txn Write )
Analysen von Featuremodellen Ist Featureauswahl gültig? {Root, Base, F1, F4} {Root, Base, F2, F3} Variablen in Formel ersetzen true wenn Feature in Auswahl, sonst false Formel ergibt true für gültige Auswahl
Ist das Modell konsistent? Gibt es mindestens eine Variante? Formel erfüllbar? Anfrage an SAT SolverSolver SAT(FM)
Tote Features Gegeben ein Feature Model Welche Features können ausgewählt werden? Welche Features müssen ausgewählt werden? Feature F auswählbar wenn SAT(FM ^ F) Feature F abwählbar wenn Feature F abwählbar wenn SAT(FM ^ not(f))
Partielle Konfigurationen Gegeben eine partielle Konfiguration Welche Features können noch ausgewählt werden? Welche Features müssen ausgewählt werden? Ausgewählte Features in Formel aufnehmen, dann wie Tote Features Feature F noch auswählbar wenn SAT(FM ^ PK ^ F) Feature F noch abwählbar wenn SAT(FM ^ PK ^ not(f))
Variantenzahl Wieviele gültige Konfigurationen gibt es? Beispielkonfigurationen Ist diese Zahl sinnvoll? Wofür?
Änderungen von Feature Modellen Welche Konsequenzen hat eine Änderung? Refactorings, Spezialisierungen, Generalisierungen Refactoring wenn: Tautologie(FM1 <=> FM2) = not SAT(not (FM1 <=> FM2))
Demo: Reasoning in FeatureIDE
Analyse der Implementierung
Fragen an die Implementierung main Eng g. Do Feature Modell Wiederverwendbare Implementierungsartefakte Application Eng. Feature Auswahl Generator Fertiges Program 28
Fragen an die Implementierung Kann ein Code Block ausgewählt werden? Ändert ein Feature etwas am Gesamt Code? Wiederverwendbare Implementierungsartefakte
Presence Conditions true WORLD BYE true
Presence Conditions line 1 #ifdef A line 2 #ifndef B line 3 #endif line 4 #elif defined(x) line 5 #else line 6 #endif true A A ^ not B A not A ^ X not A ^ not X
Toter Quelltext line 1 #ifdef A line 2 #ifndef A line 3 #endif line 4 #elif defined(x) line 5 #else line 6 #endif true A A ^ not A A not A ^ X not A ^ not X Kann nicht ausgewählt werden Analyse: SAT(pc(block i))
Fragen an die Implementierung und das Featuremodell main Eng g. Do Feature Modell Wiederverwendbare Implementierungsartefakte Application Eng. Feature Auswahl Generator Fertiges Program 33
Toter Quelltext line 1 #ifdef A line 2 #ifdef B line 3 #endif line 4 #elif defined(x) line 5 #else line 6 #endif true A A ^ B A not A ^ X not A ^ not X Kann nicht ausgewählt werden Kombinierte Analyse von (A v B) ^ not (A ^ B) Analyse: SAT(FM ^ pc(block i)) Featuremodell und Implementierung (Wo liegt der Fehler?)
Weitere Fragestellungen Welche Quelltextblöcke werden nie kompiliert? Welche Featuremodule werden nie kompiliert? Welche Features haben keinen Einfluss auf den Quelltext? Kombinierte Analyse von Featuremodell und Implementierung
Typsysteme y für Produktlinien
Outline Variability aware type systems (that is, for product lines) Type system demo with CIDE Variability aware parsing From our research: Typechef, checking correctness of Linux
Correctness?
Variability Aware Type Checking: Properties / Theorems / Guarantees Novalid productcontains contains typeerrors errors. Soundness: No valid product has run time type errors
Type Checking #include <stdio.h> char *msg = "Hello World"; int main() {Reference printf(msg); } Type errors to prevent: referenced variable ibl does not exist
Variability Aware Type Checking #include <stdio.h> #ifdef WORLD char *msg = "Hello World"; #endif #ifdef BYE char *msg = "Bye bye!"; #endif main() { printf(msg); }
Variability Aware Type Checking #include <stdio.h> #ifdef WORLD char *msg = "Hello World"; #endif #ifdef BYE char *msg = "Bye bye!"; #endif int main() { printf(msg); } Reference? Conflict?
Variability Aware Type Checking Presence conditions: true WORLD BYE true #include <stdio.h> #ifdef WORLD char *msg = "Hello World"; #endif #ifdef BYE char *msg = "Bye bye!"; #endif int main() { printf(msg); } Reference? Conflict?
Variability Aware Type Checking true WORLD BYE true > true true #include <stdio.h> #ifdef WORLD char *msg = "Hello World"; #endif #ifdef BYE char *msg = "Bye bye!"; #endif int main() { printf(msg); } Reference? true > (WORLD v BYE) (WORLD BYE) Conflict?
Reachability: pc(caller) > pc(target) Conflicts: (pc(def1) ( (d pc(def2)) true WORLD BYE true > true true #include <stdio.h> #ifdef WORLD char *msg = "Hello World"; #endif #ifdef BYE char *msg = "Bye bye!"; #endif int main() { printf(msg); } Reference? true > (WORLD v BYE) (WORLD BYE) Conflict?
Feature model P WORLD BYE true WORLD BYE FM -> (true > true) true #include <stdio.h> #ifdef WORLD char *msg = "Hello World"; #endif #ifdef BYE char *msg = "Bye bye!"; #endif int main() { printf(msg); } Reference? FM -> (true > (WORLD v BYE)) FM -> (WORLD BYE) Conflict?
AST with Variability Information WORLD BYE WORLD 47 BYE Extended Reference lookup mechanism
Surface Complexity Inherent Complexity SAT Problem
Demo: Type system in CIDE
Demo: Type system in CIDE public class Test { } private static String msg_hi = "Hello world! ; private static ti String msg_bye = "Bye bye!"; public static void main(string[] args) { } System.out.println(msg_hi); System.out.println(msg_bye);
FOP / AOP Ähnliche Prüfungen für FOP/AOP
-> Glue-Code-Modul
Variability Aware y Aware Parser Type System Static Analysis Bug Finding Testing Model lch Checking Theorem Proving
Variability Aware <Foo> We have seen variability aware type systems. Generalize! <Foo> guarantees sth. for a product Variability aware <Foo> guarantees sth. for all valid products
Variability Aware Static Analysis Static analysis tools study properties of programs, by approximating their behavior In compilers: non void methods always return a value Out of compilers: no dereference of null pointers Prove that: No valid product has methods with missing returns o a d p oduct as et ods t ss g etu s No valid product dereferences null pointer
Variability Aware Parsing No valid product contains syntax errors. Produce AST, to support other analyses
TypeChef
Parsing Unpreprocessed C Code is Hard Macro expansion needed for parsing Undisciplined annotations* Alternative macros??? * Study of 40 open source C projects: 16 % of all annotations are undisciplined 60
An Overview of TypeChef C with #define, #include, #if Partial Preprocessor C with #if Variability Aware Parser AST with Variability Analysis (e.g., Type System) 61
Prototype: Performance on Boa Type check entire SPL: 1 minute (Solving 3193 equations: 6 seconds) Break even at 20 variants Up to 2 110 variants Each 4 seconds compile time (= 10 26 years) Variant A SoftwareProductLine Generation Variant B Variant C 62 TypeChef: Toward Type Checking #ifdef FOSD'10 Variability in C
Performance: Linux >7000 files: avg 30 secs parsing time per file 85 hours total Up to ~2 6000 10 1800 variants: we are immensely faster Challenges for evaluation Extracting feature model Build scripts are also conditional and unstructured SAT solving still not a problem
Variability Aware are Parser Checking Product Line Checking Products Aware Type System Static Analysis Bug Finding Testing Model Checking Theorem Proving Product Line