SlideShare a Scribd company logo
1 of 37
Federico Tomassetti, Daniel Ratiu

          Contribution to Mbeddr




                    Image
Extracting variability from C and lifting it to mbeddr
1. Variability in C
   2. Variability in mbeddr
3. Analysis
   4. Results

        5. Case study
The C preprocessor is evil

• It let you obfuscate everything, even
  keywords
• Everything is in global scope
• What a module does, depends on the
  context where it is included
• It operates at token level
• It makes the code very difficult
  to analyze
The C preprocessor is evil

• It let you obfuscate everything, even
  keywords
• Everything is in global scope
• What a module does, depends on the
  context where it is included
• It operates at token level
• It makes the code very difficult
  to analyze
The C preprocessor is evil
#define A             #define B 50
#include «foo.h»      #include «foo.h»


// foo.h

#ifdef A              What foo.h declares
struct SomeStruct {
  …                   depend on where it is
}                     included
#else
int b = B;
void foo();
#endif

What a module does, depends on the
context where it is included
The C preprocessor is evil

• It let you obfuscate everything, even
  keywords
• Everything is in global scope
• What a module does, depends on the
  context where it is included
• It operates at token level
• It makes the code very difficult
  to analyze
The C preprocessor is evil

• It let you obfuscate everything, even
  keywords
• Everything is in global scope
• What a module does, depends on the
  context where it is included
• It operates at token level
• It makes the code very difficult
  to analyze
It is an extensible variant of C built on top of a projectional
editor.

Existing extensions include:
• interfaces with pre- and postconditions,
• components,
• state machines,
• physical units,
• requirements tracing,
• product line variability.
mbeddr introduces
higher-level abstractions



•   Constants with scope
•   Feature models
•   Configuration models
•   Isolated modules
Analysis
We analyzed:
• Linux
• Apache Openoffice
• Quake
• VLC
• Mozilla

For a total of circa 73K files and 30M LOCs.

We analyzed these projects to understand how variability
is used in C and what we can do for lifting it to mbeddr.
Individuate relevant statements

                          Configuration
#define, #undef           processing

#ifdef, #ifndef, #if,     Presence
#elif, #else, #endif      conditions
Parsing PC expressions
   #if A>B && !(C||D)
   #elif D!=10
   #ifndef C


185K expression parsed            3 errors
Extra: parsing define expressions
#define A 5
#define B do {} while(1);
#define C 3 +


82-95% of define values are valid expressions
Exclude non-variability usages
#ifndef FOO_H            #ifndef A
#define FOO_H            #define A 5
…                        #endif
#endif


Double inclusion guard   Override guard
VPs combination
#ifdef A    VP1{
foo1();      then_block: { foo1(); }
#elif B      elif_block: { foo2();
foo2();        VP2 {
#if B>A          then_block: { foo3();}
foo3();          else_block: { foo4();}
#else          }
foo4();      }
#endif      }
#endif
VPs combination
                              // A
VP1{
                              foo1();
 then_block: { foo1(); }
                              // !A && B
 elif_block: { foo2();
                              foo2();
   VP2 {
                              // !A && B && B>A
     then_block: { foo3();}
                              foo3();
     else_block: { foo4();}
                              // !A && B && !(B>A)
   }
                              foo4();
 }
}
RQ1 Which are the typical building blocks in
    presence conditions?




This is important in order to understand which kind
of expressions we need to support in the higher level
configuration language.
RQ1 Which are the typical building blocks in
    presence conditions?


Kind of expressions   Presence conditions
                      containing them
Identifier references        85-98 %
Logical operators            21-66 %
Number literals               6-16 %
Comparison operators           0-6 %
Others                         < 2%
RQ2 Which changes (re- #defines and #undefs) are
    operated on a defined symbol?




Depending on changes upon defined symbols,
defines can be lifted (or not) as constant
configuration values.
RQ2 Which changes (re- #defines and #undefs) are
    operated on a defined symbol?


We want constant to avoid this situation:

#define A 1
#if A>1                         Same condition,
foo1();
                                one is included,
#endif
#define A 2
                                one is not
#if A>1
foo2();
#endif
RQ2 Which changes (re- #defines and #undefs) are
    operated on a defined symbol?


Cases                   Range
Single definition
Multiple definitions to
the same value
Definitions under
different conditions
Total
RQ2 Which changes (re- #defines and #undefs) are
    operated on a defined symbol?


            #if VERS <= 2
            #define A 1
            #elif VERS == 3
            #define A 2
            #else
            #define A 3
            #endif


Definitions under different conditions
RQ2 Which changes (re- #defines and #undefs) are
    operated on a defined symbol?


Cases                   Range
Single definition             69-90 %
Multiple definitions to       2-24 %
the same value
Definitions under              2-9 %
different conditions
Total                         95-99 %
RQ3 Are #error and #warning used in practice?




If they are, it could be possible to extract feature
model constraints from them.
RQ3 Are #error and #warning used in practice?




They are present in 4 out of 5 projects but
they represent between 0 and 0.26% of the
preprocessor statements.

Linux contains more than 800
 #error/#warning
Mozilla more than 700
Results
RQ1) Which are the typical building blocks in presence
conditions?


RQ2) Which changes (re- #defines and #undefs) are
operated on a defined symbol?


RQ3) Are #error and #warning used in practice?
Results
RQ1) Which are the typical building blocks in presence
conditions?

     Identifiers, integers, logical and comparison operations
RQ2) Which changes (re- #defines and #undefs) are
operated on a defined symbol?


RQ3) Are #error and #warning used in practice?
Results
RQ1) Which are the typical building blocks in presence
conditions?

     Identifiers, integers, logical and comparison operations
RQ2) Which changes (re- #defines and #undefs) are
operated on a defined symbol?

           More than 90% of symbols behave like constants
RQ3) Are #error and #warning used in practice?
Results
RQ1) Which are the typical building blocks in presence
conditions?

     Identifiers, integers, logical and comparison operations
RQ2) Which changes (re- #defines and #undefs) are
operated on a defined symbol?

           More than 90% of symbols behave like constants
RQ3) Are #error and #warning used in practice?

                                     Depends on the project
ChibiOS
    ChibiOS is a real-time OS supporting 14 core architectures,
    different compilers and platforms.


OS Kernel module                          Demos/ARMCM3-STM32F103ZG-FATFS
                                          module
41 files
246 presence conditions                   Definitions for 31 of the 53 features
233 definitions                           28 defined to TRUE/FALSE
54 symbols in presence conditions         1 has no value
2 symbols used in definitions of PC       1 has value 0
symbols                                   1 has value 20
53 symbols not defined in the module
(feat.)
3 defined in the module (derived feat.)
Questions?


Extracting variability from C and lifting it
               to mbeddr
        Federico Tomassetti, Daniel Ratiu

More Related Content

What's hot

Generics Tutorial
Generics TutorialGenerics Tutorial
Generics Tutorialwasntgosu
 
Frege Tutorial at JavaOne 2015
Frege Tutorial at JavaOne 2015Frege Tutorial at JavaOne 2015
Frege Tutorial at JavaOne 2015Dierk König
 
Lecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming LanguageLecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming LanguageSURAJ KUMAR
 
The Last Line Effect
The Last Line EffectThe Last Line Effect
The Last Line EffectAndrey Karpov
 
C and CPP Interview Questions
C and CPP Interview QuestionsC and CPP Interview Questions
C and CPP Interview QuestionsSagar Joshi
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlanDeepak Lakhlan
 
C programming decision making
C programming decision makingC programming decision making
C programming decision makingSENA
 
Java apptitude-questions-part-2
Java apptitude-questions-part-2Java apptitude-questions-part-2
Java apptitude-questions-part-2vishvavidya
 
TBar: Revisiting Template-based Automated Program Repair
TBar: Revisiting Template-based Automated Program RepairTBar: Revisiting Template-based Automated Program Repair
TBar: Revisiting Template-based Automated Program RepairDongsun Kim
 

What's hot (18)

Generics Tutorial
Generics TutorialGenerics Tutorial
Generics Tutorial
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Frege Tutorial at JavaOne 2015
Frege Tutorial at JavaOne 2015Frege Tutorial at JavaOne 2015
Frege Tutorial at JavaOne 2015
 
Lecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming LanguageLecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming Language
 
Sp imp gtu
Sp imp gtuSp imp gtu
Sp imp gtu
 
The Last Line Effect
The Last Line EffectThe Last Line Effect
The Last Line Effect
 
Computer programming questions
Computer programming questionsComputer programming questions
Computer programming questions
 
C and CPP Interview Questions
C and CPP Interview QuestionsC and CPP Interview Questions
C and CPP Interview Questions
 
args_types
args_typesargs_types
args_types
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
C++ c#
C++ c#C++ c#
C++ c#
 
C programming decision making
C programming decision makingC programming decision making
C programming decision making
 
Answer key1fer
Answer key1ferAnswer key1fer
Answer key1fer
 
Programming basics
Programming basicsProgramming basics
Programming basics
 
Basics of C porgramming
Basics of C porgrammingBasics of C porgramming
Basics of C porgramming
 
polymorphism
polymorphism polymorphism
polymorphism
 
Java apptitude-questions-part-2
Java apptitude-questions-part-2Java apptitude-questions-part-2
Java apptitude-questions-part-2
 
TBar: Revisiting Template-based Automated Program Repair
TBar: Revisiting Template-based Automated Program RepairTBar: Revisiting Template-based Automated Program Repair
TBar: Revisiting Template-based Automated Program Repair
 

Viewers also liked

Automatically Spotting Cross-language Relations
Automatically Spotting Cross-language RelationsAutomatically Spotting Cross-language Relations
Automatically Spotting Cross-language RelationsFederico Tomassetti
 
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...Federico Tomassetti
 
CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks
CrossLanguageSpotter: A Library for Detecting Relations in Polyglot FrameworksCrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks
CrossLanguageSpotter: A Library for Detecting Relations in Polyglot FrameworksGiuseppe Rizzo
 
Eclipse Florence Day: Modeling in the Italian Industry
Eclipse Florence Day: Modeling in the Italian IndustryEclipse Florence Day: Modeling in the Italian Industry
Eclipse Florence Day: Modeling in the Italian IndustryFederico Tomassetti
 
Estendere Java con il Meta Programming System di JetBrains
Estendere Java con il Meta Programming System di JetBrains Estendere Java con il Meta Programming System di JetBrains
Estendere Java con il Meta Programming System di JetBrains Federico Tomassetti
 
Language Interaction and Quality Issues: An Exploratory Study
Language Interaction and Quality Issues: An Exploratory StudyLanguage Interaction and Quality Issues: An Exploratory Study
Language Interaction and Quality Issues: An Exploratory StudyMarco Torchiano
 
Model Driven Web Development Solutions
Model Driven Web Development SolutionsModel Driven Web Development Solutions
Model Driven Web Development SolutionsFederico Tomassetti
 

Viewers also liked (8)

Automatically Spotting Cross-language Relations
Automatically Spotting Cross-language RelationsAutomatically Spotting Cross-language Relations
Automatically Spotting Cross-language Relations
 
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...
 
CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks
CrossLanguageSpotter: A Library for Detecting Relations in Polyglot FrameworksCrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks
CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks
 
Eclipse Florence Day: Modeling in the Italian Industry
Eclipse Florence Day: Modeling in the Italian IndustryEclipse Florence Day: Modeling in the Italian Industry
Eclipse Florence Day: Modeling in the Italian Industry
 
Estendere Java con il Meta Programming System di JetBrains
Estendere Java con il Meta Programming System di JetBrains Estendere Java con il Meta Programming System di JetBrains
Estendere Java con il Meta Programming System di JetBrains
 
Language Interaction and Quality Issues: An Exploratory Study
Language Interaction and Quality Issues: An Exploratory StudyLanguage Interaction and Quality Issues: An Exploratory Study
Language Interaction and Quality Issues: An Exploratory Study
 
Model Driven Web Development Solutions
Model Driven Web Development SolutionsModel Driven Web Development Solutions
Model Driven Web Development Solutions
 
Death by PowerPoint
Death by PowerPointDeath by PowerPoint
Death by PowerPoint
 

Similar to Extracting Variability from C and Lifting it to Mbeddr

Differences between method overloading and method overriding
Differences between method overloading and method overridingDifferences between method overloading and method overriding
Differences between method overloading and method overridingPinky Anaya
 
Reverse-Engineering Reusable Language Modules from Legacy DSLs
Reverse-Engineering Reusable Language Modules from Legacy DSLsReverse-Engineering Reusable Language Modules from Legacy DSLs
Reverse-Engineering Reusable Language Modules from Legacy DSLsDavid Méndez-Acuña
 
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARF
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARFHES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARF
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARFHackito Ergo Sum
 
Measuring maintainability; software metrics explained
Measuring maintainability; software metrics explainedMeasuring maintainability; software metrics explained
Measuring maintainability; software metrics explainedDennis de Greef
 
Deobfuscation and beyond (ZeroNights, 2014)
Deobfuscation and beyond (ZeroNights, 2014)Deobfuscation and beyond (ZeroNights, 2014)
Deobfuscation and beyond (ZeroNights, 2014)ReCrypt
 
1 - Preprocessor.pptx
1 - Preprocessor.pptx1 - Preprocessor.pptx
1 - Preprocessor.pptxAlAmos4
 
Kernel Recipes 2018 - 10 years of automated evolution in the Linux kernel - J...
Kernel Recipes 2018 - 10 years of automated evolution in the Linux kernel - J...Kernel Recipes 2018 - 10 years of automated evolution in the Linux kernel - J...
Kernel Recipes 2018 - 10 years of automated evolution in the Linux kernel - J...Anne Nicolas
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review ProcessDr. Syed Hassan Amin
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming languageVasavi College of Engg
 
Specialized Compiler for Hash Cracking
Specialized Compiler for Hash CrackingSpecialized Compiler for Hash Cracking
Specialized Compiler for Hash CrackingPositive Hack Days
 
Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Wei Sun
 
고급컴파일러구성론_개레_230303.pptx
고급컴파일러구성론_개레_230303.pptx고급컴파일러구성론_개레_230303.pptx
고급컴파일러구성론_개레_230303.pptxssuser1e7611
 

Similar to Extracting Variability from C and Lifting it to Mbeddr (20)

Differences between method overloading and method overriding
Differences between method overloading and method overridingDifferences between method overloading and method overriding
Differences between method overloading and method overriding
 
Reverse-Engineering Reusable Language Modules from Legacy DSLs
Reverse-Engineering Reusable Language Modules from Legacy DSLsReverse-Engineering Reusable Language Modules from Legacy DSLs
Reverse-Engineering Reusable Language Modules from Legacy DSLs
 
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARF
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARFHES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARF
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARF
 
C programming session6
C programming  session6C programming  session6
C programming session6
 
Intr fortran90
Intr fortran90Intr fortran90
Intr fortran90
 
C# AND F#
C# AND F#C# AND F#
C# AND F#
 
c# at f#
c# at f#c# at f#
c# at f#
 
Measuring maintainability; software metrics explained
Measuring maintainability; software metrics explainedMeasuring maintainability; software metrics explained
Measuring maintainability; software metrics explained
 
Computer programming questions
Computer programming questionsComputer programming questions
Computer programming questions
 
Deobfuscation and beyond (ZeroNights, 2014)
Deobfuscation and beyond (ZeroNights, 2014)Deobfuscation and beyond (ZeroNights, 2014)
Deobfuscation and beyond (ZeroNights, 2014)
 
1 - Preprocessor.pptx
1 - Preprocessor.pptx1 - Preprocessor.pptx
1 - Preprocessor.pptx
 
Kernel Recipes 2018 - 10 years of automated evolution in the Linux kernel - J...
Kernel Recipes 2018 - 10 years of automated evolution in the Linux kernel - J...Kernel Recipes 2018 - 10 years of automated evolution in the Linux kernel - J...
Kernel Recipes 2018 - 10 years of automated evolution in the Linux kernel - J...
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
 
C# note
C# noteC# note
C# note
 
Specialized Compiler for Hash Cracking
Specialized Compiler for Hash CrackingSpecialized Compiler for Hash Cracking
Specialized Compiler for Hash Cracking
 
Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02
 
No comment
No commentNo comment
No comment
 
고급컴파일러구성론_개레_230303.pptx
고급컴파일러구성론_개레_230303.pptx고급컴파일러구성론_개레_230303.pptx
고급컴파일러구성론_개레_230303.pptx
 
Preprocessor
PreprocessorPreprocessor
Preprocessor
 

More from Federico Tomassetti

Jariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlinJariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlinFederico Tomassetti
 
JavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java codeJavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java codeFederico Tomassetti
 
How do you create a programming language for the JVM?
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?Federico Tomassetti
 
Xtext Un Framework Per La Creazione Di Dsl
Xtext   Un Framework Per La Creazione Di DslXtext   Un Framework Per La Creazione Di Dsl
Xtext Un Framework Per La Creazione Di DslFederico Tomassetti
 

More from Federico Tomassetti (7)

Jariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlinJariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlin
 
JavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java codeJavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java code
 
How do you create a programming language for the JVM?
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?
 
Building languages with Kotlin
Building languages with KotlinBuilding languages with Kotlin
Building languages with Kotlin
 
Building languages with Kotlin
Building languages with KotlinBuilding languages with Kotlin
Building languages with Kotlin
 
What is Federico doing?
What is Federico doing?What is Federico doing?
What is Federico doing?
 
Xtext Un Framework Per La Creazione Di Dsl
Xtext   Un Framework Per La Creazione Di DslXtext   Un Framework Per La Creazione Di Dsl
Xtext Un Framework Per La Creazione Di Dsl
 

Recently uploaded

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Recently uploaded (20)

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

Extracting Variability from C and Lifting it to Mbeddr

  • 1. Federico Tomassetti, Daniel Ratiu Contribution to Mbeddr Image Extracting variability from C and lifting it to mbeddr
  • 2. 1. Variability in C 2. Variability in mbeddr 3. Analysis 4. Results 5. Case study
  • 3.
  • 4. The C preprocessor is evil • It let you obfuscate everything, even keywords • Everything is in global scope • What a module does, depends on the context where it is included • It operates at token level • It makes the code very difficult to analyze
  • 5. The C preprocessor is evil • It let you obfuscate everything, even keywords • Everything is in global scope • What a module does, depends on the context where it is included • It operates at token level • It makes the code very difficult to analyze
  • 6. The C preprocessor is evil #define A #define B 50 #include «foo.h» #include «foo.h» // foo.h #ifdef A What foo.h declares struct SomeStruct { … depend on where it is } included #else int b = B; void foo(); #endif What a module does, depends on the context where it is included
  • 7. The C preprocessor is evil • It let you obfuscate everything, even keywords • Everything is in global scope • What a module does, depends on the context where it is included • It operates at token level • It makes the code very difficult to analyze
  • 8. The C preprocessor is evil • It let you obfuscate everything, even keywords • Everything is in global scope • What a module does, depends on the context where it is included • It operates at token level • It makes the code very difficult to analyze
  • 9. It is an extensible variant of C built on top of a projectional editor. Existing extensions include: • interfaces with pre- and postconditions, • components, • state machines, • physical units, • requirements tracing, • product line variability.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. mbeddr introduces higher-level abstractions • Constants with scope • Feature models • Configuration models • Isolated modules
  • 16. Analysis We analyzed: • Linux • Apache Openoffice • Quake • VLC • Mozilla For a total of circa 73K files and 30M LOCs. We analyzed these projects to understand how variability is used in C and what we can do for lifting it to mbeddr.
  • 17. Individuate relevant statements Configuration #define, #undef processing #ifdef, #ifndef, #if, Presence #elif, #else, #endif conditions
  • 18. Parsing PC expressions #if A>B && !(C||D) #elif D!=10 #ifndef C 185K expression parsed 3 errors
  • 19. Extra: parsing define expressions #define A 5 #define B do {} while(1); #define C 3 + 82-95% of define values are valid expressions
  • 20. Exclude non-variability usages #ifndef FOO_H #ifndef A #define FOO_H #define A 5 … #endif #endif Double inclusion guard Override guard
  • 21. VPs combination #ifdef A VP1{ foo1(); then_block: { foo1(); } #elif B elif_block: { foo2(); foo2(); VP2 { #if B>A then_block: { foo3();} foo3(); else_block: { foo4();} #else } foo4(); } #endif } #endif
  • 22. VPs combination // A VP1{ foo1(); then_block: { foo1(); } // !A && B elif_block: { foo2(); foo2(); VP2 { // !A && B && B>A then_block: { foo3();} foo3(); else_block: { foo4();} // !A && B && !(B>A) } foo4(); } }
  • 23. RQ1 Which are the typical building blocks in presence conditions? This is important in order to understand which kind of expressions we need to support in the higher level configuration language.
  • 24. RQ1 Which are the typical building blocks in presence conditions? Kind of expressions Presence conditions containing them Identifier references 85-98 % Logical operators 21-66 % Number literals 6-16 % Comparison operators 0-6 % Others < 2%
  • 25. RQ2 Which changes (re- #defines and #undefs) are operated on a defined symbol? Depending on changes upon defined symbols, defines can be lifted (or not) as constant configuration values.
  • 26. RQ2 Which changes (re- #defines and #undefs) are operated on a defined symbol? We want constant to avoid this situation: #define A 1 #if A>1 Same condition, foo1(); one is included, #endif #define A 2 one is not #if A>1 foo2(); #endif
  • 27. RQ2 Which changes (re- #defines and #undefs) are operated on a defined symbol? Cases Range Single definition Multiple definitions to the same value Definitions under different conditions Total
  • 28. RQ2 Which changes (re- #defines and #undefs) are operated on a defined symbol? #if VERS <= 2 #define A 1 #elif VERS == 3 #define A 2 #else #define A 3 #endif Definitions under different conditions
  • 29. RQ2 Which changes (re- #defines and #undefs) are operated on a defined symbol? Cases Range Single definition 69-90 % Multiple definitions to 2-24 % the same value Definitions under 2-9 % different conditions Total 95-99 %
  • 30. RQ3 Are #error and #warning used in practice? If they are, it could be possible to extract feature model constraints from them.
  • 31. RQ3 Are #error and #warning used in practice? They are present in 4 out of 5 projects but they represent between 0 and 0.26% of the preprocessor statements. Linux contains more than 800 #error/#warning Mozilla more than 700
  • 32. Results RQ1) Which are the typical building blocks in presence conditions? RQ2) Which changes (re- #defines and #undefs) are operated on a defined symbol? RQ3) Are #error and #warning used in practice?
  • 33. Results RQ1) Which are the typical building blocks in presence conditions? Identifiers, integers, logical and comparison operations RQ2) Which changes (re- #defines and #undefs) are operated on a defined symbol? RQ3) Are #error and #warning used in practice?
  • 34. Results RQ1) Which are the typical building blocks in presence conditions? Identifiers, integers, logical and comparison operations RQ2) Which changes (re- #defines and #undefs) are operated on a defined symbol? More than 90% of symbols behave like constants RQ3) Are #error and #warning used in practice?
  • 35. Results RQ1) Which are the typical building blocks in presence conditions? Identifiers, integers, logical and comparison operations RQ2) Which changes (re- #defines and #undefs) are operated on a defined symbol? More than 90% of symbols behave like constants RQ3) Are #error and #warning used in practice? Depends on the project
  • 36. ChibiOS ChibiOS is a real-time OS supporting 14 core architectures, different compilers and platforms. OS Kernel module Demos/ARMCM3-STM32F103ZG-FATFS module 41 files 246 presence conditions Definitions for 31 of the 53 features 233 definitions 28 defined to TRUE/FALSE 54 symbols in presence conditions 1 has no value 2 symbols used in definitions of PC 1 has value 0 symbols 1 has value 20 53 symbols not defined in the module (feat.) 3 defined in the module (derived feat.)
  • 37. Questions? Extracting variability from C and lifting it to mbeddr Federico Tomassetti, Daniel Ratiu

Editor's Notes

  1. My contribution