- 7
- 0
- 约3.12千字
- 约 7页
- 2018-08-11 发布于福建
- 举报
C代码缺陷自动检测工具研究与实现
C代码缺陷自动检测工具研究与实现
(北京航空航天大学 软件工程研究所 北京 100191)
摘 要:通过编译的??C++??程序代码并不一定保证代码中不存在缺陷。代码中可能依然隐含了安全、设计或是风格上的缺陷,从而导致程序运行时出现内存泄露、指针误用等现象,或导致程序代码不清晰、可读性差。为了有效查找这些缺陷,探讨了可定制缺陷规则的??C++??代码缺陷自动检测技术,介绍了两种缺陷定位方法,给出了一种基于XPath技术的缺陷规则定制方法,设计并实现了一种代码缺陷自动检测工具CDD(??C++?? defect detector),并通过实验证明了缺陷定位方法的有效性以及CDD的易用性。
关键词:静态分析; 抽象语法树; 缺陷检测; 规则扩展
中图分类号:TP311文献标志码:A
文章编号:1001-3695(2009)05-1628-04
Research and implementation of automated C++?? code defect detection tool
GU Ke LIU Chao JIN Mao??zhong
(Software Engineering Institute Beihang University Beijing 100191 China)
Abstract:The C++?? program which is all right in compiling process does not always insure there are no defects in the code. For the reason that there may be defects relative to securities design and code style it may result in memory leak misuse of pointers or make the program code unclearly and unreadable. The defects will place bad impact on the normal running and the maintain ability of the software. This paper introduced a good technology of defect??extendable automated C++?? code defect detection including two methods to detect the defects a description of defect rules based on XPath technology and an introduction of the C++?? defect automation detector. Furthermore analyzed the detector in stability credibility and easy??to??use by experiment.
Key words:static analysis; abstract syntax tree; defect detection; rule extension
0 引言??
软件代码的质量直接关系到软件功能的实现、运行的可靠性、系统的健壮性,以及软件的可维护性等诸多方面。从代码质量的角度讲,程序代码不仅要确保语法和语义的正确性,同时还需保证其在内部数据访问、内存使用等方面的安全性,以及接口定义、编程风格等方面的规范性。因此,在编写代码的过程中及时发现并清除代码缺陷,是提高软件质量和开发效率的重要保证。??
传统的代码缺陷检测都是通过人工代码审查来完成,因此存在过渡依赖个人经验和低效等问题。自动化代码检测工具定位于一种辅助审查的工具,可以通过对源代码的分析来自动发现代码中潜在的多种类型的缺陷。代码缺陷自动检测工具为显著提高软件质量和可维护性提供了有力的支持。??
??C++??是一种功能强大、具有较高执行效率的程序语言,但它同时也是一种语法复杂、类型约束和安全控制机制宽松、编程风格自由的程序语言。即便是有多年编程经验的??C++??程序员也很难保证所写的程序不存在缺陷。编译器一般只能进行程序语法检查,而无法检查代码和设计的一致性、代码对语言标准的符合型、代码的可读性、语义的正确性、代码结构的合理性等方面的问题或缺陷。鉴于人工代码审查的低效以及??C++??语言自身的复杂性,研究针对??C++??代码的缺陷检测工具对于加快软件开发的进度和
原创力文档

文档评论(0)