Your SlideShare is downloading. ×
Variability-Aware Parsing -- OOPSLA Talk
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Variability-Aware Parsing -- OOPSLA Talk

167
views

Published on

OOPSLA 2011 talk about variability-aware parsing (i.e., parsing C code without preprocessing it first) …

OOPSLA 2011 talk about variability-aware parsing (i.e., parsing C code without preprocessing it first)

Corresponding paper: http://www.informatik.uni-marburg.de/~kaestner/oopsla11_typechef.pdf

Published in: Technology, Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
167
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Variability-Aware Parsing in the Presence of Lexical Macros and Conditional Compilation Christian Kästner Paolo G. Giarrusso Tillmann Rendel Sebastian Erdweg Klaus Ostermann Thorsten Berger
  • 2. Parsing C Codewithout Preprocessing Christian Kästner Paolo G. Giarrusso Tillmann Rendel Sebastian Erdweg Klaus Ostermann Thorsten Berger
  • 3. Viewer Discretion Is Advised
  • 4. LinuxKernel
  • 5. 10,000 features, 6 million lines of C code
  • 6. Parse and Type check all configurations of the entire Linux kernel 10,000 features, 6 million lines of C code
  • 7. greet.c printf … VWORLD VBYE main AST with msg ε msg ε printfVariability Information ¬ (WORLD ˄BYE) msg true -> (WORLD v BYE)
  • 8. Variability-Aware Analysis Type System Static Analysis Bug Finding Testing Model Checking Theorem Proving …
  • 9. Parsing C without Preprocessing
  • 10. Macro expansion Undisciplinedneeded for parsing annotations Alternative macros ? ? ? greet.c + printf VWORLD VBYE + main + msg ε + msg ε printf msg
  • 11. Previous SolutionsDisciplined Subset Requires Code PreparationHeuristics and Partial Analysis Inaccurate, False PositivesBrute Force Infeasible Effort
  • 12. https://github.com/ckaestne/TypeChefTypeChef Variability-Aware Parser-Framework ( + 2 Variability-Aware * Variability-Aware 3 * VA Lexer ) + Parser 4A 5¬A 2 3 4 5 Variability-Aware Analysis
  • 13. Variability-Aware Lexer ( 2 *
  • 14. Variability-Aware Lexer
  • 15. 353 included header files 0 per C file 8590 macros 0 per C file 1387 conditional macros 0 per C file335490 token 0 per C file 72 % conditional 0 2.6.33.3 X86
  • 16. Variability-Aware Parsing( 2 * 3 ) + 4A 5¬A + * VA 2 3 4 5
  • 17. Undisciplined Annotations2 * (A 3 + 4 )A VA * + 2 + * 4 3 4 2 3
  • 18. Partial Errors2 * (A 3 + 4 ) VA * Parse Error Expected + or EOF, but found ) at 1:7 2 + 3 4
  • 19. true ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  • 20. true( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  • 21. 3 true( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  • 22. 3 true( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  • 23. A3 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 24. 4 A3 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 25. 4 A3 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )( 3 + Next Token: 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ctx -> tok: Consume ¬A ctx ->¬tok: Skip else: Split (ctx ˄pc) andctx ˄ ¬pc) (
  • 26. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 27. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 28. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 29. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 30. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 31. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 32. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A˄¬B
  • 33. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A˄¬B
  • 34. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A˄¬B
  • 35. 4 A3 4A (¬A + 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4 6 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A˄¬B
  • 36. 4 A3 4A (¬A + 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4 6 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ¬A˄¬B
  • 37. 4 A3 4A (¬A + 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4 6 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ¬A˄¬B
  • 38. 4 A3 4A (¬A + 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4 6 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) 6 ¬A˄¬B
  • 39. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4¬A˄ +¬A˄ 6¬A B B 4A (¬A )¬A ) 4¬A˄B +¬A˄ 6¬A B VB ¬A + 6 4 6
  • 40. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4¬A˄ +¬A˄ 6¬A B B 4A (¬A )¬A ) 4¬A˄B +¬A˄ 6¬A B ¬A VB + 6 4 6
  • 41. 3 4A (¬A 4¬A˄B +¬A˄ 6¬A )¬A B true( 3 + ) 4¬A˄ +¬A˄ 6¬A B B 4A (¬A )¬A VA 4¬A˄B +¬A˄ 6¬A B 4 VB + 6 4 6
  • 42. 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A true( 3 + ) 4¬A˄ +¬A˄ 6¬A B B + 4A (¬A )¬A3 VA 4¬A˄B +¬A˄ 6¬A B 4 VB + 6 4 6
  • 43. Variability-AwareParser Combinator Libraryfor Scala
  • 44. Variability-Aware ParsersGNU C + cpp Java + Antenna
  • 45. Parsing LinuxVariability in Build System (kbuild) and with #ifdefVariability Model (kconfig) 2.6.33.3 X86
  • 46. 7665 C files (x86) 0 30 seconds per file 0 (median) 85 hours total 0 4.1 % overhead 0 (undiscipl.) 0 0 syntax errors 2.6.33.3 X86
  • 47. ParserVariability-Aware Type System Module System Static Analysis Bug Finding Testing Model Checking Theorem Proving Editor Support Code Transform. …
  • 48. Variability-Aware Parsing in the Presence of Lexical Macros and Conditional Compilation Variability-Aware Parser-Framework ( + 2 Variability-Aware * Variability-Aware 3 * VA Lexer ) + Parser 4A (macros, includes) 5¬A (split & join) 2 3 4 5https://github.com/ckaestne/TypeChef