• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

J4 ›› 2011, Vol. 33 ›› Issue (3): 94-102.doi: 10.3969/j.issn.1007130X.2011.

• 论文 • 上一篇    下一篇

一个面向C和Fortran数值程序的静态分析工具

侯苏宁,陈立前,王昭飞,王戟   

  1. (并行与分布处理国防科技重点实验室,湖南 长沙 410073)
  • 收稿日期:2009-10-17 修回日期:2009-12-15 出版日期:2011-03-25 发布日期:2011-03-25
  • 作者简介:侯苏宁(1985),男,河南郸城人,硕士,助理工程师,研究方向为高可信软件。陈立前(1982),男,湖南茶陵人,博士,助理研究员,研究方向为软件分析与验证。王昭飞(1981),男,河北元氏人,硕士,研究方向为程序分析与编译。王戟(1969),男,上海人,博士,教授,研究方向为高可信软件验证、分布式计算。
  • 基金资助:

    国家自然科学基金资助项目(90818024,60803042)

A Static Analyzer for Numerical Programs in C and Fortran

HOU Suning,CHEN Liqian,WANG Zhaofei,WANG Ji   

  1. (National Laboratory for Parallel and Distributed Processing,Changsha 410073,China)
  • Received:2009-10-17 Revised:2009-12-15 Online:2011-03-25 Published:2011-03-25

摘要:

程序的正确性验证一直以来都是计算机科学中的一个挑战性问题,抽象解释理论为程序静态分析提供了一个通用框架,可以在编译时自动地推导程序的动态性质。基于抽象解释的数值程序分析可以自动推导程序中数值变量间的不变式关系,这对于编译优化、程序错误检查至关重要。本文建立并实现了一个面向C和Fortran程序并支持过程间分析的数值程序分析框架和工具,C或Fortran源程序经过预处理后转化为具有统一格式的中间表示形式,然后基于该中间表示抽取与源程序语义等价的语义等式,最后在该语义等式上进行不动点迭代计算从而得到程序不变式。在此基础上,本文还对数组等复杂语法结构进行了建模和抽象。实验结果表明,该工具具有较高的可扩展性、精度,并能够处理大部分因数组的使用而带来的程序分析上的问题。

关键词: 静态分析, 抽象解释, 值范围分析, 数值抽象域, 数组抽象

Abstract:

The validation of program correctness is a challenge problem in computer science. The theory of abstract interpretation provides a general framework for static analysis which can deduce programs’ dynamic property automatically. A value range analysis based on abstract interpretation can give the invariant relationship of variables at every program point, which is very important to compilation optimization and error examination. We propose an interprocedural framework that analyses the value range information of numerical programs, which can process C and Fortran programs. The C or Fortran source program is first preprocessed to an uniform representation, and then we draw the semantic equation which is equivalent to the source semantics. Finally, the iterative computation is done on this syntax equation to get the program invariant. Besides, we model some complex syntax structures such as array. The experiment indicates that our framework is very extensive and precise, and can process most problems brought by the usage of array.

Key words: static analysis;abstract interpretation;value range analysis;numeric abstract domain;array abstraction