SlideShare une entreprise Scribd logo
1  sur  64
Photo (cc) Horia Varlan




Virtual Separation of Concerns




Christian Kästner
Feature-Oriented
Product Lines
Database
 Engine
Printer
Firmware
Linux
Kernel
7
Variability = Complexity
33 features
       optional, independent




a unique configuration for every
person on this planet
320 features
     optional, independent




                      more configurations than estimated
                    atoms in the universe
Correctness?
Maintenance?
Comprehension?
Conditional Compilation
static int _rep_queue_filedone(...)
   DB_ENV *dbenv;
   REP *rep;
   __rep_fileinfo_args *rfp; {
#ifndef HAVE_QUEUE
   COMPQUIET(rep, NULL);
   COMPQUIET(rfp, NULL);
   return (__db_no_queue_am(dbenv));
#else
   db_pgno_t first, last;
   u_int32_t flags;
   int empty, ret, t_ret;
#ifdef DIAGNOSTIC
   DB_MSGBUF mb;
#endif
                    ...
                Excerpt from Oracle’s Berkeley DB
Objections / Criticism

  Designed in the 70th and hardly evolved since

    “#ifdef considered harmful”
                                                             “#ifdef hell”
  “maintenance becomes a „hit or miss‟ process”

                                 “is difficult to determine if the code being
                                  viewed is actually compiled into the system”

               “incomprehensible source texts”
   “programming errors are easy                “CPP makes maintenance difficult”
    to make and difficult to detect”
                                                   “source code rapidly
“preprocessor diagnostics are poor”                 becomes a maze”
Academia: Compositional Approaches
Base / Platform
class Stack {
  void push(Object o) {
    elementData[size++] = o;
  }
  ...
}


                                                class Stack {
                                                  void push(Object o) {
                                                    Lock l = lock(o);
Feature: Queue                                      elementData[size++] = o;
refines class Stack {          Composition        }
                                                    l.unlock();
                                                  ...
  void push(Object o) {
    Lock l = lock(o);                           }
    Super.push(o);
    l.unlock();
  }
  ...
}

                                   Module
                                   Components
Feature: Diagnostic                Frameworks, Plug-ins
aspect Diagnostics {
  ...                              Feature-Modules / Mixin Layers / …
}
                                   Aspects / Subjects, Hyper/J, Deltas
A CLOSER LOOK AT PREPROCESSORS
Separation of Concerns
class Stack {
   void push(Object o
#ifdef SYNC                      Obfuscation
   , Transaction txn
#endif
   ) {
      if (o==null
#ifdef SYNC
         || txn==null
#endif
         ) return;
#ifdef SYNC
      Lock l=txn.lock(o);
#endif
      elementData[size++] = o;
#ifdef SYNC
      l.unlock();
#endif
      fireStackChanged();
   }
}
Obfuscation




       Femto OS
static int _rep_queue_filedone(...)
   DB_ENV *dbenv;
   REP *rep;                            Error-Prone
   __rep_fileinfo_args *rfp; {
#ifndef HAVE_QUEUE
   COMPQUIET(rep, NULL);
   COMPQUIET(rfp, NULL);
   return (__db_no_queue_am(dbenv));
#else
   db_pgno_t first, last;
                #ifdef TABLES
   u_int32_t flags;
                class Table {
   int empty, ret,void insert(Object data, Txn txn) {
                   t_ret;
#ifdef DIAGNOSTIC     storage.set(data, txn.getLock());
   DB_MSGBUF mb; }
#endif          }
   // over 100 lines of add. code
                #endif
}               class Storage {
#endif          #ifdef WRITE
                   boolean set(…) { ... }
                #endif
                }
Advantages
• Easy to use
  • “annotate and remove”
  • Already part of many languages / simple tools
  • Most developers already familiar

• Flexible / Expressive
• Language-independent / Uniform

• Low Adoption Barrier
  • esp. with legacy code
IMPROVING TOOL SUPPORT
[ICSE‟08, ViSPLE‟08]




Views
View on Feature Eval
View on Configuration
       “Add and Eval”
[ICSE‟08, ICSE„10, EASE„11]
FeatureCommander
Controlled

3 Experiments

                    Faster?




Scaling?         How Used?
ERROR DETECTION / PREVENTION
Disciplined
          Annotations
#ifdef WORLD
int main() {
   printf(“Hello World”);
}
#endif

int main() {
#ifdef WORLD
   printf(“Hello World”);
#endif
}                                                          greet.c




                               printf                                VBYE       main


Align with variability model
                                              VWORLD




                                        msg            ε      msg           ε   printf




 Align with code structure                                                      msg
Disciplined    Undisciplined
          Annotations
#ifdef WORLD                   int main() {
int main() {                   #ifdef DYNAMIC
   printf(“Hello World”);         if (enabled) {
}                              #endif
#endif                               printf(“Hello World”);
                               #ifdef DYNAIC
int main() {                      }
#ifdef WORLD                   #endif
   printf(“Hello World”);      }
#endif
}                              int a =
                               #ifdef DYNAMIC
Align with variability model      enabled? 3 : 4 +
                               #endif
 Align with code structure        5;
static int _rep_queue_filedone(...)
   DB_ENV *dbenv;
   REP *rep;
   __rep_fileinfo_args *rfp; {
#ifndef HAVE_QUEUE
   COMPQUIET(rep, NULL);
   COMPQUIET(rfp, NULL);
   return (__db_no_queue_am(dbenv));
#else
   db_pgno_t first, last;
   u_int32_t flags;
   int empty, ret, t_ret;
#ifdef DIAGNOSTIC
   DB_MSGBUF mb;
#endif
   // over 100 lines of add. code
}
#endif
Parser
Variability-Aware   Type System
                    Static Analysis
                    Bug Finding
                    Testing
                    Model Checking
                    Theorem Proving
                    …
References



             Conflicts
Presence Conditions
       WORLD


               BYE
true




                     true
Reachability: pc(caller) -> pc(target)
 Conflicts: ¬(pc(def1) ˄pc(def2))




                                      ¬ (WORLD ˄BYE)



                 true -> (WORLD v BYE)

true -> true
P

              Variability Model:
                                          WORLD       BYE




                                    VM ->¬ (WORLD ˄BYE)



                  VM -> (true -> (WORLD v BYE))

VM -> (true -> true)
AST with Variability Information
                                             true -> true
                         greet.c

         …
printf       VWORLD             VBYE          main

         msg         ε       msg         ε    printf
¬ (WORLD ˄BYE)
                 true -> (WORLD v BYE)
                                               msg




                                     WORLD
                                     BYE            40




   Extended Lookup Mechanism
[ASE‟08, TOSEM„11]

Formalization: CFJ
Surface Complexity

                          Inherent
                          Complexity




                SAT
                Problem
Variability-Aware Analysis
                 Type System
                 Static Analysis
                 Bug Finding
                 Testing
                 Model Checking
                 Theorem Proving
                 …
CIDE                         open source, fosd.net/cide




       http://fosd.de/cide
[GPCE‟09]
                Automated Refactorings
       • Feature Module                • Annotationen
       class Stack {                     class Stack {
          int[] data;                        int[] data;
Base




          void push(int o) { … }         #ifdef UNDO
          int pop() { /*...*/ }              int backup;
       }                                     void undo() { /*...*/ }
                                         #endif
       refines class Stack {             #ifdef TOP
                           Automated Transformation
Top




          int top() { /*...*/ }              int top() { /*...*/ }
       }                                 #endif
                                             void push(int o) {
       refines class Stack {             #ifdef UNDO
          int backup;                            backup = top();
          void undo() { /*...*/ }        #endif
Undo




          void push(int o) {                     /*...*/
              backup = top();                }
              original(v);                   int pop() { /*...*/ }
          }                              }
THE REAL-WORLD CHALLENGE
Parse and Type check
      all configurations of the
           entire Linux              kernel

   10,000 features, 6 million lines of C code
[OOPSLA„11]




                      greet.c

         …
printf       VWORLD        VBYE       main

         msg     ε      msg       ε   printf

                                      msg

 AST with Variability Information
Macro expansion               Undisciplined
needed for parsing             annotations                                         Alternative macros




                                                     ?
                     ?                                                         ?
                                                     greet.c



                         + printf           VWORLD         VBYE       + main


                                    + msg        ε     + msg      ε   printf


                                                                       msg
Parsing C without Preprocessing
Previous Solutions

Disciplined Subset
  Requires Code Preparation

Heuristics and Partial Analysis
  Inaccurate, False Positives

Brute Force
  Infeasible Effort
TypeChef


                                    (                                                           +
                                        2
                Variability-Aware           *                   Variability-Aware
                                                3                                       *               VA
                        Lexer                       )
                                                        +
                                                                       Parser
                                                         4A
                                                          5¬A                       2       3       4        5


                                                                                    Variability-Aware
                                                                                            Analysis

https://github.com/ckaestne/TypeChef
4A   (¬A 4¬A˄B +¬A˄ 6¬A
                                            B        )¬A       true
(            3       +                                     )
                                    4¬A˄ +¬A˄ 6¬A
                                        B    B
    +                    4A   (¬A                    )¬A
3       VA                          4¬A˄B +¬A˄ 6¬A
                                              B

    4       VB
        +        6
    4        6
Variability-Aware   Parsers
GNU C + cpp     Java + Antenna
Parsing Linux



Variability in Build System (kbuild)
         and with #ifdef
                                       2.6.33.3
                                       X86
Variability Model (kconfig)
353 included header files per C file
      0
   8590 macros per C file
      0
   1387 conditional macros per C file
      0
    340 alternative macros per C file
      0
335490 token per C file
     0                              2.6.33.3
                                    X86
    72 % conditional
     0
7665 C files (x86)
   0
  30 seconds per file (median)
   0
  85 hours total
   0
 4.1 % overhead (undiscipl.)
   0
     0
     0 syntax errors         2.6.33.3
                             X86
Type Checking Linux




                  2.6.33.3
                  X86
SUMMARY AND PERSPECTIVE
Summary
• Problems:                  • Improvements:
  • Separation of Concerns      • Views
  • Obfuscation                 • Visual representation
  • Error-proneness             • Variability-aware analysis


• Retained advantages:
                             • Remaining Problems:
  •   Easy to use
                                • Modular Type Checking
  •   Flexible
                                • Separate Compilation
  •   Language-independent      • Black-box Reuse
  •   Low adoption barrier

           “Virtual Separation of Concerns”
Perspective

 •   Preprocessors common in practice, despite criticism
 •   Neglected by researchers
 •   Tool support can address most problems
 •   Currently scaling to Linux

 • Interim solution or serious alternative?


Give preprocessors a second chance!
Questions?




             http://fosd.de/cide
Picture Credits

© Stuck in Customs (cc by-nc-sa 2.0)



© Horia Varlan (cc by 2.0)

Contenu connexe

Tendances

Pysmbc Python C Modules are Easy
Pysmbc Python C Modules are EasyPysmbc Python C Modules are Easy
Pysmbc Python C Modules are EasyRoberto Polli
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHPWim Godden
 
Ejemplo completo de integración JLex y CUP
Ejemplo completo de integración JLex y CUPEjemplo completo de integración JLex y CUP
Ejemplo completo de integración JLex y CUPEgdares Futch H.
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developersChris Ramakers
 
Insecure coding in C (and C++)
Insecure coding in C (and C++)Insecure coding in C (and C++)
Insecure coding in C (and C++)Olve Maudal
 
from java to c
from java to cfrom java to c
from java to cVõ Hòa
 
Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)Oky Firmansyah
 
Welcome to Modern C++
Welcome to Modern C++Welcome to Modern C++
Welcome to Modern C++Seok-joon Yun
 
Rust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineRust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineMatt Provost
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptSeok-joon Yun
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheeltcurdt
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?Andrey Karpov
 

Tendances (20)

Pysmbc Python C Modules are Easy
Pysmbc Python C Modules are EasyPysmbc Python C Modules are Easy
Pysmbc Python C Modules are Easy
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
 
Core java
Core javaCore java
Core java
 
AMIS definer invoker rights
AMIS definer invoker rightsAMIS definer invoker rights
AMIS definer invoker rights
 
Ejemplo completo de integración JLex y CUP
Ejemplo completo de integración JLex y CUPEjemplo completo de integración JLex y CUP
Ejemplo completo de integración JLex y CUP
 
E:\Plp 2009 2\Plp 9
E:\Plp 2009 2\Plp 9E:\Plp 2009 2\Plp 9
E:\Plp 2009 2\Plp 9
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developers
 
Insecure coding in C (and C++)
Insecure coding in C (and C++)Insecure coding in C (and C++)
Insecure coding in C (and C++)
 
from java to c
from java to cfrom java to c
from java to c
 
Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)
 
Welcome to Modern C++
Welcome to Modern C++Welcome to Modern C++
Welcome to Modern C++
 
06 Loops
06 Loops06 Loops
06 Loops
 
Rust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineRust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command Line
 
Java Annotations and Pre-processing
Java  Annotations and Pre-processingJava  Annotations and Pre-processing
Java Annotations and Pre-processing
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScript
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
 
Building Custom PHP Extensions
Building Custom PHP ExtensionsBuilding Custom PHP Extensions
Building Custom PHP Extensions
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?
 
Tiramisu概要
Tiramisu概要Tiramisu概要
Tiramisu概要
 
PVS-Studio
PVS-Studio PVS-Studio
PVS-Studio
 

En vedette

Variability-Aware Parsing -- OOPSLA Talk
Variability-Aware Parsing -- OOPSLA TalkVariability-Aware Parsing -- OOPSLA Talk
Variability-Aware Parsing -- OOPSLA Talkchk49
 
Semseo socialamedier-hr
Semseo socialamedier-hrSemseo socialamedier-hr
Semseo socialamedier-hrPeter Tilling
 
Parsing and Type checking all 2^10000 configurations of the Linux kernel
Parsing and Type checking all 2^10000 configurations of the Linux kernelParsing and Type checking all 2^10000 configurations of the Linux kernel
Parsing and Type checking all 2^10000 configurations of the Linux kernelchk49
 
Variability-Aware Analysis (FOSD Dagstuhl 2011)
Variability-Aware Analysis (FOSD Dagstuhl 2011)Variability-Aware Analysis (FOSD Dagstuhl 2011)
Variability-Aware Analysis (FOSD Dagstuhl 2011)chk49
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerLuminary Labs
 

En vedette (6)

Variability-Aware Parsing -- OOPSLA Talk
Variability-Aware Parsing -- OOPSLA TalkVariability-Aware Parsing -- OOPSLA Talk
Variability-Aware Parsing -- OOPSLA Talk
 
Semseo socialamedier-hr
Semseo socialamedier-hrSemseo socialamedier-hr
Semseo socialamedier-hr
 
Parsing and Type checking all 2^10000 configurations of the Linux kernel
Parsing and Type checking all 2^10000 configurations of the Linux kernelParsing and Type checking all 2^10000 configurations of the Linux kernel
Parsing and Type checking all 2^10000 configurations of the Linux kernel
 
Seeing Software
Seeing SoftwareSeeing Software
Seeing Software
 
Variability-Aware Analysis (FOSD Dagstuhl 2011)
Variability-Aware Analysis (FOSD Dagstuhl 2011)Variability-Aware Analysis (FOSD Dagstuhl 2011)
Variability-Aware Analysis (FOSD Dagstuhl 2011)
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Similaire à Virtual Separation of Concerns (2011 Update)

Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Courseparveen837153
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingGarth Gilmour
 
Pydiomatic
PydiomaticPydiomatic
Pydiomaticrik0
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesGanesh Samarthyam
 
Serializing EMF models with Xtext
Serializing EMF models with XtextSerializing EMF models with Xtext
Serializing EMF models with Xtextmeysholdt
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationEelco Visser
 
Drizzles Approach To Improving Performance Of The Server
Drizzles  Approach To  Improving  Performance Of The  ServerDrizzles  Approach To  Improving  Performance Of The  Server
Drizzles Approach To Improving Performance Of The ServerPerconaPerformance
 
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...Andrey Karpov
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012Tech_MX
 
JNA - Let's C what it's worth
JNA - Let's C what it's worthJNA - Let's C what it's worth
JNA - Let's C what it's worthIdan Sheinberg
 
OOP for Hardware Verification--Demystified!
OOP for Hardware Verification--Demystified! OOP for Hardware Verification--Demystified!
OOP for Hardware Verification--Demystified! DVClub
 
Scalable and Flexible Machine Learning With Scala @ LinkedIn
Scalable and Flexible Machine Learning With Scala @ LinkedInScalable and Flexible Machine Learning With Scala @ LinkedIn
Scalable and Flexible Machine Learning With Scala @ LinkedInVitaly Gordon
 
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Codemotion
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Agora Group
 

Similaire à Virtual Separation of Concerns (2011 Update) (20)

Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional Programming
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
 
Extending and scripting PDT
Extending and scripting PDTExtending and scripting PDT
Extending and scripting PDT
 
Android ndk
Android ndkAndroid ndk
Android ndk
 
Serializing EMF models with Xtext
Serializing EMF models with XtextSerializing EMF models with Xtext
Serializing EMF models with Xtext
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code Generation
 
Drizzles Approach To Improving Performance Of The Server
Drizzles  Approach To  Improving  Performance Of The  ServerDrizzles  Approach To  Improving  Performance Of The  Server
Drizzles Approach To Improving Performance Of The Server
 
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012
 
JNA - Let's C what it's worth
JNA - Let's C what it's worthJNA - Let's C what it's worth
JNA - Let's C what it's worth
 
OOP for Hardware Verification--Demystified!
OOP for Hardware Verification--Demystified! OOP for Hardware Verification--Demystified!
OOP for Hardware Verification--Demystified!
 
Scalable and Flexible Machine Learning With Scala @ LinkedIn
Scalable and Flexible Machine Learning With Scala @ LinkedInScalable and Flexible Machine Learning With Scala @ LinkedIn
Scalable and Flexible Machine Learning With Scala @ LinkedIn
 
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
 
Xtext Webinar
Xtext WebinarXtext Webinar
Xtext Webinar
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
 
Effective Object Oriented Design in Cpp
Effective Object Oriented Design in CppEffective Object Oriented Design in Cpp
Effective Object Oriented Design in Cpp
 

Dernier

Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistandanishmna97
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...SOFTTECHHUB
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuidePixlogix Infotech
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...ScyllaDB
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...ScyllaDB
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?Paolo Missier
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxMasterG
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfAnubhavMangla3
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 

Dernier (20)

Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistan
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 

Virtual Separation of Concerns (2011 Update)

  • 1. Photo (cc) Horia Varlan Virtual Separation of Concerns Christian Kästner
  • 2.
  • 7. 7
  • 9. 33 features optional, independent a unique configuration for every person on this planet
  • 10. 320 features optional, independent more configurations than estimated atoms in the universe
  • 13. Conditional Compilation static int _rep_queue_filedone(...) DB_ENV *dbenv; REP *rep; __rep_fileinfo_args *rfp; { #ifndef HAVE_QUEUE COMPQUIET(rep, NULL); COMPQUIET(rfp, NULL); return (__db_no_queue_am(dbenv)); #else db_pgno_t first, last; u_int32_t flags; int empty, ret, t_ret; #ifdef DIAGNOSTIC DB_MSGBUF mb; #endif ... Excerpt from Oracle’s Berkeley DB
  • 14. Objections / Criticism Designed in the 70th and hardly evolved since “#ifdef considered harmful” “#ifdef hell” “maintenance becomes a „hit or miss‟ process” “is difficult to determine if the code being viewed is actually compiled into the system” “incomprehensible source texts” “programming errors are easy “CPP makes maintenance difficult” to make and difficult to detect” “source code rapidly “preprocessor diagnostics are poor” becomes a maze”
  • 15. Academia: Compositional Approaches Base / Platform class Stack { void push(Object o) { elementData[size++] = o; } ... } class Stack { void push(Object o) { Lock l = lock(o); Feature: Queue elementData[size++] = o; refines class Stack { Composition } l.unlock(); ... void push(Object o) { Lock l = lock(o); } Super.push(o); l.unlock(); } ... } Module Components Feature: Diagnostic Frameworks, Plug-ins aspect Diagnostics { ... Feature-Modules / Mixin Layers / … } Aspects / Subjects, Hyper/J, Deltas
  • 16. A CLOSER LOOK AT PREPROCESSORS
  • 18. class Stack { void push(Object o #ifdef SYNC Obfuscation , Transaction txn #endif ) { if (o==null #ifdef SYNC || txn==null #endif ) return; #ifdef SYNC Lock l=txn.lock(o); #endif elementData[size++] = o; #ifdef SYNC l.unlock(); #endif fireStackChanged(); } }
  • 19. Obfuscation Femto OS
  • 20. static int _rep_queue_filedone(...) DB_ENV *dbenv; REP *rep; Error-Prone __rep_fileinfo_args *rfp; { #ifndef HAVE_QUEUE COMPQUIET(rep, NULL); COMPQUIET(rfp, NULL); return (__db_no_queue_am(dbenv)); #else db_pgno_t first, last; #ifdef TABLES u_int32_t flags; class Table { int empty, ret,void insert(Object data, Txn txn) { t_ret; #ifdef DIAGNOSTIC storage.set(data, txn.getLock()); DB_MSGBUF mb; } #endif } // over 100 lines of add. code #endif } class Storage { #endif #ifdef WRITE boolean set(…) { ... } #endif }
  • 21. Advantages • Easy to use • “annotate and remove” • Already part of many languages / simple tools • Most developers already familiar • Flexible / Expressive • Language-independent / Uniform • Low Adoption Barrier • esp. with legacy code
  • 24.
  • 26. View on Configuration “Add and Eval”
  • 29. Controlled 3 Experiments Faster? Scaling? How Used?
  • 30. ERROR DETECTION / PREVENTION
  • 31. Disciplined Annotations #ifdef WORLD int main() { printf(“Hello World”); } #endif int main() { #ifdef WORLD printf(“Hello World”); #endif } greet.c printf VBYE main Align with variability model VWORLD msg ε msg ε printf Align with code structure msg
  • 32. Disciplined Undisciplined Annotations #ifdef WORLD int main() { int main() { #ifdef DYNAMIC printf(“Hello World”); if (enabled) { } #endif #endif printf(“Hello World”); #ifdef DYNAIC int main() { } #ifdef WORLD #endif printf(“Hello World”); } #endif } int a = #ifdef DYNAMIC Align with variability model enabled? 3 : 4 + #endif Align with code structure 5;
  • 33. static int _rep_queue_filedone(...) DB_ENV *dbenv; REP *rep; __rep_fileinfo_args *rfp; { #ifndef HAVE_QUEUE COMPQUIET(rep, NULL); COMPQUIET(rfp, NULL); return (__db_no_queue_am(dbenv)); #else db_pgno_t first, last; u_int32_t flags; int empty, ret, t_ret; #ifdef DIAGNOSTIC DB_MSGBUF mb; #endif // over 100 lines of add. code } #endif
  • 34. Parser Variability-Aware Type System Static Analysis Bug Finding Testing Model Checking Theorem Proving …
  • 35.
  • 36. References Conflicts
  • 37. Presence Conditions WORLD BYE true true
  • 38. Reachability: pc(caller) -> pc(target) Conflicts: ¬(pc(def1) ˄pc(def2)) ¬ (WORLD ˄BYE) true -> (WORLD v BYE) true -> true
  • 39. P Variability Model: WORLD BYE VM ->¬ (WORLD ˄BYE) VM -> (true -> (WORLD v BYE)) VM -> (true -> true)
  • 40. AST with Variability Information true -> true greet.c … printf VWORLD VBYE main msg ε msg ε printf ¬ (WORLD ˄BYE) true -> (WORLD v BYE) msg WORLD BYE 40 Extended Lookup Mechanism
  • 42. Surface Complexity Inherent Complexity SAT Problem
  • 43. Variability-Aware Analysis Type System Static Analysis Bug Finding Testing Model Checking Theorem Proving …
  • 44. CIDE open source, fosd.net/cide http://fosd.de/cide
  • 45. [GPCE‟09] Automated Refactorings • Feature Module • Annotationen class Stack { class Stack { int[] data; int[] data; Base void push(int o) { … } #ifdef UNDO int pop() { /*...*/ } int backup; } void undo() { /*...*/ } #endif refines class Stack { #ifdef TOP Automated Transformation Top int top() { /*...*/ } int top() { /*...*/ } } #endif void push(int o) { refines class Stack { #ifdef UNDO int backup; backup = top(); void undo() { /*...*/ } #endif Undo void push(int o) { /*...*/ backup = top(); } original(v); int pop() { /*...*/ } } }
  • 47. Parse and Type check all configurations of the entire Linux kernel 10,000 features, 6 million lines of C code
  • 48. [OOPSLA„11] greet.c … printf VWORLD VBYE main msg ε msg ε printf msg AST with Variability Information
  • 49. Macro expansion Undisciplined needed for parsing annotations Alternative macros ? ? ? greet.c + printf VWORLD VBYE + main + msg ε + msg ε printf msg
  • 50. Parsing C without Preprocessing
  • 51.
  • 52. Previous Solutions Disciplined Subset Requires Code Preparation Heuristics and Partial Analysis Inaccurate, False Positives Brute Force Infeasible Effort
  • 53. TypeChef ( + 2 Variability-Aware * Variability-Aware 3 * VA Lexer ) + Parser 4A 5¬A 2 3 4 5 Variability-Aware Analysis https://github.com/ckaestne/TypeChef
  • 54. 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A true ( 3 + ) 4¬A˄ +¬A˄ 6¬A B B + 4A (¬A )¬A 3 VA 4¬A˄B +¬A˄ 6¬A B 4 VB + 6 4 6
  • 55. Variability-Aware Parsers GNU C + cpp Java + Antenna
  • 56. Parsing Linux Variability in Build System (kbuild) and with #ifdef 2.6.33.3 X86 Variability Model (kconfig)
  • 57. 353 included header files per C file 0 8590 macros per C file 0 1387 conditional macros per C file 0 340 alternative macros per C file 0 335490 token per C file 0 2.6.33.3 X86 72 % conditional 0
  • 58. 7665 C files (x86) 0 30 seconds per file (median) 0 85 hours total 0 4.1 % overhead (undiscipl.) 0 0 0 syntax errors 2.6.33.3 X86
  • 59. Type Checking Linux 2.6.33.3 X86
  • 61. Summary • Problems: • Improvements: • Separation of Concerns • Views • Obfuscation • Visual representation • Error-proneness • Variability-aware analysis • Retained advantages: • Remaining Problems: • Easy to use • Modular Type Checking • Flexible • Separate Compilation • Language-independent • Black-box Reuse • Low adoption barrier “Virtual Separation of Concerns”
  • 62. Perspective • Preprocessors common in practice, despite criticism • Neglected by researchers • Tool support can address most problems • Currently scaling to Linux • Interim solution or serious alternative? Give preprocessors a second chance!
  • 63. Questions? http://fosd.de/cide
  • 64. Picture Credits © Stuck in Customs (cc by-nc-sa 2.0) © Horia Varlan (cc by 2.0)