In many projects, lexical preprocessors are used to manage different configurations of the project with conditional compilation. Unfortunately, while being a simple way to implement variability, conditional compilation and lexical preprocessor macros hinder automatic analysis, even though such analysis is urgently needed to combat variability-induced complexity. To analyze code with its variability, we need to parse it without preprocessing it. However, current parsing solutions use unsound heuristics, support only a subset of the language, or suffer from exponential explosion. We introduce a novel variability-aware parser that can parse unpreprocessed code without heuristics. On top of parsing, which detects syntax errors in all configurations, we have constructed a variability-aware type system and module system that additionally detect other compiler-time errors. With this infrastructure, we are in the process of checking the entire Linux kernel with 10000 compile-time configuration options and, hence, up to 2^10000 configurations for syntax and type errors.
8. Software Product Lines
Boeing
Bosch Group in Industry
Cummins, Inc.
Ericsson
General Dynamics
General Motors
Hewlett Packard
Lockheed Martin
Lucent
NASA
Nokia
Philips
Siemens
âŠ
14. static int _rep_queue_filedone( Excerpt from
DB_ENV *dbenv, Oracleâs Berkeley DB
REP *rep,
__rep_fileinfo_args *rfp) {
#ifdef NO_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
Conditional Compilation
15. static int _rep_queue_filedone( Excerpt from
DB_ENV *dbenv, Oracleâs Berkeley DB
REP *rep,
__rep_fileinfo_args *rfp) {
#ifdef NO_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 X
#ifdef DIAGNOSTIC
DB_MSGBUF mb;void foo();
#endif #endif
// over 100 lines of add. code
} void bar() {
#endif foo();
}
Conditional Compilation
16. 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â
34. P
Variability Model:
WORLD BYE
VM ->ÂŹ (WORLD Ë BYE)
VM -> (true -> (WORLD v BYE))
VM -> (true -> true)
35. AST with Variability Information
true -> true
greet.c
âŠ
printf VWORLD VBYE main
msg Δ msg Δ printf
ÂŹ (WORLD Ë BYE)
true -> (WORLD v BYE)
msg
WORLD
BYE 35
Extended Lookup Mechanism
36. [ASEâ08, TOSEMâ11]
Formalization: CFJ
Theorem (Product Generation Preserves Typing): All
products that are generated for valid feature selections
from a well-typed product line are well typed.
39. [TOSEMâ11]
Product Line LOC Features Products Time per Time f.
Product entire
(sec) Product
Line (sec)
MobileMedia 5700 14 2784 0.3 2
Mobile RSS 20 000 14 2048 1 8
Reader
Lampiro 45 000 11 2048 2 19
Berkeley DB 70 000 42 3.6 billion 3 21
53. 7665 C files (x86)
0
353 included header files per C file
0
8590 distinct macros per C file
0
72 % conditional
0
30 seconds per file (median)
0
2.6.33.3
X86
0 syntax errors