Skip to main content
QUICK REVIEW

[论文解读] Reverse Engineering Code Dependencies: Converting Integer-Based Variability to Propositional Logic

Adam Krafczyk, Sascha El-Sharkawy|arXiv (Cornell University)|Oct 12, 2021
Advanced Software Engineering Methodologies参考文献 14被引用 3
一句话总结

本文提出一种将C-预处理器代码中基于整数的可变性条件转换为等价命题逻辑公式的办法,使现有的基于SAT的分析工具能够处理使用整数值配置变量的软件产品线。通过为每个允许的取值建模整数变量为布尔变量,并为算术和比较表达式构建命题公式,该方法在受限整数变量下保持可满足性,并在不受限的情况下仍保留有用的可变性信息,已在工业案例研究中得到验证。

ABSTRACT

A number of SAT-based analysis concepts and tools for software product lines exist, that extract code dependencies in propositional logic from the source code assets of the product line. On these extracted conditions, SAT-solvers are used to reason about the variability. However, in practice, a lot of software product lines use integer-based variability. The variability variables hold integer values, and integer operators are used in the conditions. Most existing analysis tools can not handle this kind of variability; they expect pure Boolean conditions. This paper introduces an approach to convert integer-based variability conditions to propositional logic. Running this approach as a preparation on an integer-based product line allows the existing SAT-based analyses to work without any modifications. The pure Boolean formulas, that our approach builds as a replacement for the integer-based conditions, are mostly equivalent to the original conditions with respect to satisfiability. Our approach was motivated by and implemented in the context of a real-world industrial case-study, where such a preparation was necessary to analyze the variability. Our contribution is an approach to convert conditions, that use integer variables, into propositional formulas, to enable easy usage of SAT-solvers on the result. It works well on restricted variables (i.e. variables with a small range of allowed values); unrestricted integer variables are handled less exact, but still retain useful variability information.

研究动机与目标

  • 许多软件产品线使用基于整数的可变性(例如,取值范围较小的配置值),但现有的基于SAT的分析工具要求完全为布尔条件。
  • 现有工具如Undertaker、TypeChef以及特性影响分析器无法处理#if条件中的整数算术或比较。
  • 本研究旨在通过使基于SAT的分析能够应用于基于整数的产品线,而无需修改工具本身,来弥合这一差距。
  • 目标是在从整数表达式到命题逻辑的转换过程中,保持可满足性和可变性信息。
  • 该方法必须能有效处理受限(取值范围小)和不受限(取值范围大或无界)的整数变量。

提出的方法

  • 对于具有受限取值范围的每个整数变量,引入布尔变量以表示该变量是否取其范围内某个特定值。
  • 该方法对抽象语法树(AST)进行自底向上的遍历,以评估整数子表达式,并跟踪所有有效的取值组合。
  • 对于每个比较或算术运算,构建一个命题公式,以捕获所有满足条件的取值组合。
  • 当两个操作数都是受限变量时,考虑所有成对的取值组合,导致组合数量呈二次方增长。
  • 对于不受限或取值范围较大的整数变量,使用单个布尔标志来表示该变量是否被定义,从而保留部分可变性信息。
  • 该转换作为开源插件实现在KernelHaven框架中,将源文件中的#if条件替换为等价的命题逻辑公式。

实验结果

研究问题

  • RQ1C-预处理器代码中的基于整数的可变性条件能否被准确转换为命题逻辑,以支持基于SAT的分析?
  • RQ2如何在命题逻辑中对具有小取值范围的受限整数变量进行建模,同时保持可满足性?
  • RQ3在无法完整枚举所有取值的情况下,处理不受限或高范围整数变量的有效策略是什么?
  • RQ4该转换在多大程度上保留了原始的可变性语义,特别是在边界情况中?
  • RQ5转换后的代码能否在不修改现有基于SAT的分析工具的情况下被有效使用?

主要发现

  • 该转换方法与产品线规模呈线性增长,与后续分析步骤相比性能开销可忽略不计。
  • 对于受限整数变量,命题公式与原始整数条件大多具有等满足性,从而在分析中保持正确性。
  • 即使对于不受限的整数变量,该方法通过使用单个布尔标志表示变量是否被定义,仍能保留有用的可变性信息。
  • 在Bosch PS-EC产品线的真实工业案例研究中,该方法成功使现有基于SAT的工具生成了有意义的分析结果。
  • 作为KernelHaven插件的实现证明了其在工业环境中的实际可行性与可重用性。
  • 在高复杂度情况下限制取值组合可降低性能影响,尽管会损失部分精度,但可通过回退策略加以缓解。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。