Skip to main content
QUICK REVIEW

[论文解读] Translating Xd-C programs to MSVL programs

Meng Wang, Cong Tian|arXiv (Cornell University)|Aug 25, 2018
Software Testing and Debugging Techniques被引用 3
一句话总结

本文提出一种翻译框架,可使用 UMC4M 工具将 Xd-C 程序——C 语言的一个受限且语义完整的子集——自动转换为等价的 MSVL 程序,以实现运行时验证。该方法利用形式化操作语义证明 Xd-C 与 MSVL 构造之间的语义等价性,并在名为 C2M 的工具中实现该方法,成功将 13 个实际 C 程序翻译为 MSVL 程序,时间复杂度为线性,且保持了强行为等价性。

ABSTRACT

C language is one of the most popular languages for software systems. In order to verify safety, reliability and security properties of such systems written in C, a tool UMC4M for runtime verification at code level based on Modeling, Simulation and Verification Language (MSVL) and its compiler MC is employed. To do so, a C program $P$ has to be translated to an MSVL program M and the negation of a desired property $Q$ is also translated to an MSVL program M', then "M and M" is compiled and executed armed with MC. Whether $P$ violates $Q$ is checked by evaluating whether there exists an acceptable execution of new MSVL program M and M". Therefore, how to translate a C program to an MSVL program is a critical issue. However, in general, C is of complicated structures with goto statement. In this paper, we confine the syntax of C in a suitable subset called Xd-C without loss of expressiveness. Further, we present a translation algorithm from an Xd-C program to an MSVL program based on translation algorithms for expressions and statements. Moreover, the equivalences between expressions and statements involved in Xd-C and MSVL programs are inductively proved. Subsequently, the equivalence between the original Xd-C program and the translated MSVL program is also proved. In addition, the proposed approach has been implemented by a tool called $C2M$. A benchmark of experiments including 13 real-world Xd-C programs is conducted. The results show that $C2M$ works effectively.

研究动机与目标

  • 通过 MSVL 实现运行时验证,支持在代码级别对 C 程序进行形式化验证。
  • 解决将包含 goto 语句的复杂 C 程序翻译为形式化验证友好语言的挑战。
  • 定义一个受限但表达能力强的 C 语言子集(Xd-C),在保留关键语义的同时,支持可靠地翻译为 MSVL。
  • 基于操作语义,正式证明 Xd-C 程序与其 MSVL 翻译版本之间的语义等价性。
  • 实现并评估一个实用工具(C2M),用于自动化将实际 C 程序翻译为 MSVL 以进行验证。

提出的方法

  • 将 Xd-C 定义为 C 语言的一个受限子集,排除 goto 语句,但保留所有关键数据类型和控制结构。
  • 设计一种翻译算法,使用语法和语义规则将 Xd-C 的声明、表达式和语句映射为等价的 MSVL 构造。
  • 使用大步语义形式化定义 Xd-C 和 MSVL 的操作语义,以捕捉终止与非终止行为。
  • 基于操作语义,通过结构归纳和规则归纳证明语句与表达式的等价性。
  • 在名为 C2M 的工具中实现翻译流水线,包括预处理、使用解析生成器(PG)进行词法和语法分析,以及 MSVL 代码生成。
  • 通过后处理优化输出,并与自定义的 Xd-C 和 MSVL 函数库集成,以支持实际程序的翻译。

实验结果

研究问题

  • RQ1能否定义一个 C 语言的受限子集(Xd-C),使其在保留系统级编程所需表达能力的同时,能够正确翻译为 MSVL?
  • RQ2如何设计一种形式化翻译算法,以在 Xd-C 与 MSVL 程序之间保持语义等价性?
  • RQ3该翻译过程的时间复杂度是多少?其能否扩展到实际程序规模?
  • RQ4C2M 工具在多大程度上保持了原始 C 程序与其 MSVL 对应程序之间的行为等价性?
  • RQ5使用 UMC4M 工具及其 MSVL 编译器 MC,能否有效验证翻译后的 MSVL 程序?

主要发现

  • C2M 工具成功将 13 个实际的 Xd-C 程序(包括 RERS 和 SPEC2000 的基准程序)翻译为等价的 MSVL 程序。
  • 生成的 MSVL 程序平均大小约为原始 Xd-C 程序的 2.6 倍,时间复杂度为 O(n),其中 n 为语句数量。
  • 最大程序(twolf,约 17k LOC)的翻译耗时 7.11 秒,全部 13 个程序的总耗时为 95.15 秒。
  • 形式化证明通过在表达式和语句上进行归纳推理,建立了 Xd-C 与 MSVL 程序之间的语义等价性。
  • 该工具保持了强行为对应关系,使得通过 UMC4M 实现准确的运行时验证成为可能,且不会因模型抽象产生误报或漏报。
  • 基准测试结果表明,C2M 对工业规模的 C 程序具有有效性与可扩展性,支持未来集成到完整的验证流水线中。

更好的研究,从现在开始

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

无需绑定信用卡

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