A code-model extractor for KernelHaven.
A simple extractor that extracts #ifdef
blocks in C source files (*.c
).
- Extracts
#if
,#ifdef
,#ifndef
,#elif
and#else
blocks - Preserves the nesting structure
- Parses the conditions of the blocks into Boolean formulas
- Optionally does replacements for integer comparisons ("fuzzy parsing"), e.g.
VAR == 3
becomes the Boolean variableVAR_eq_3
- Optionally considers
IS_ENABLED
,IS_BUILTIN
andIS_MODULE
macros used in the Linux Kernel
- Optionally does replacements for integer comparisons ("fuzzy parsing"), e.g.
- Calculates presence conditions for nested blocks
- Provides the start and end line numbers of blocks
- Optionally (enabled by default) creates a pseudo-block with condition
true
for the whole file if there is code outside of blocks - Considers line continuation of preprocessor directives (a
\
at the end of the line) - Considers comments (commented out blocks are ignored)
- The result is provided as a hierachy of
CodeBlock
s to the analysis
Place CodeBlockExtractor.jar
in the plugins folder of KernelHaven.
To use this extractor, set code.extractor.class
to net.ssehub.kernel_haven.block_extractor.CodeBlockExtractor
in the KernelHaven properties.
In addition to KernelHaven, this plugin has the following dependencies:
This plugin is licensed under the Apache License 2.0.
Note that some of the files in testdata/scenario
may be licensed differently (e.g. because they are taken from the Linux Kernel). They serve only as a test case and are not included in any JAR release of this plugin.