计算机科学 ›› 2017, Vol. 44 ›› Issue (11): 191-194.doi: 10.11896/j.issn.1002-137X.2017.11.029

• 2016 年全国软件与应用学术会议 • 上一篇    下一篇

采用Clang/LLVM的C++源代码覆盖率分析插装方法

李树芳,安金霞,刘洋,陈良   

  1. 中国酒泉卫星发射中心 酒泉732750,中国酒泉卫星发射中心 酒泉732750,中国酒泉卫星发射中心 酒泉732750,中国酒泉卫星发射中心 酒泉732750
  • 出版日期:2018-12-01 发布日期:2018-12-01

Approach to C++ Code Instrumentation for Coverage Analysis with Clang/LLVM

LI Shu-fang, AN Jin-xia, LIU Yang and CHEN Liang   

  • Online:2018-12-01 Published:2018-12-01

摘要: 近年来,越来越多的安全关键软件系统运行在国产Linux操作系统上,其中大多数采用C++开发,而C++正在扩展新版语言规范,已有的覆盖率统计插装工具不能满足要求。给出一种基于Clang/LLVM的C++源代码覆盖率统计插装方法,利用开源社区Clang/LLVM库提供的C++源代码解析和操作功能,构建面向C++源代码的语句、分支和MC/DC覆盖率统计框架,在运行时采集覆盖率信息并进行统计分析,输出覆盖率分析报告。实际案例表明,该方法简易实用,能够满足真实工程软件的覆盖率测试分析需求。

关键词: C++,Clang,代码插装,覆盖率分析

Abstract: In recent years,many safety-critical software system have been running under domestic Linux operating systems,most of which are developed with C++.As C++ is expanding to new revision of the C++ ISO/IEC stan-dards,the existing source code instrumentation tools for coverage analysis cannot satisfy user’s requirements.In this paper,an approach to C++ source code instrumentation for coverage analysis with Clang/LLVM was proposed.Employing the Clang/LLVM library in open source community,which provides C++ source code parsing and manipulation functions,a framework of C++ coverage analysis for statement coverage,branch coverage and MC/DC coverage was constructed.Coverage information was collected in real-time,and was analyzed and exported to reports.Case study shows that the proposed approach is very convenient and practical in real world software testing activities.

Key words: C++,Clang,Code instrumentation,Coverage analysis

[1] AN J X,ZHU J .Software Reliability Modeling with Integrated Test Coverage [C]∥Proceedings of the 4th IEEE International Conference on Secure Software Integration and Reliability Improvement.Singapore,2012:106-112.
[2] YANG Q,LI J,WEISS D,et al.A Survey of Coverage-Based Testing Tools[J].The Computer Journal,2009,52(5):589-597.
[3] MAHRENHOLZ D,SPINCZYK O,SCHRDER-PREIKSCHAT,et al.Program Instrumentation for Debugging and Monitoring with AspectC++ [C]∥Proceedings of Fifth IEEE InternationalSymposium on Object-Oriented Real-Time Distributed Computing.Washington DC,2002:249-256.
[4] URBAN M,LOHMANN D,SPINCZYK O.The Aspect- Oriented Design of the PUMA C/C++ Parser Framework [C]∥Proceedings of the 9th International Conference on Aspect-Oriented Software Development.New York,NY,USA,2010:217-221.
[5] AN J X,WANG G Q,LI S F,et al.Dynamic Evaluation Method Based Multi-Dimensional Test Coverage for Software Testing[J].Journal of Software,2010,1(9):2135-2147.(in Chinese) 安金霞,王国庆,李树芳,等.基于多维度覆盖率的软件测试动态评价方法[J].软件学报,2010,1(9):2135-2147.
[6] DUAN F L,WU X,ZHANG F,et al.Rapidly Generating Algorithm for Minimum Test Case Set on MC/DC[J].Computer Engineering,2009,35(17):40-42.(in Chinese) 段飞雷,吴晓,张凡,等.MC/DC最小测试用例集快速生成算法[J].计算机工程,2009,35(17):40-42.
[7] LI S F,AN J X,ZHENG P F,et al.An Approach to Rapid Test Coverage Analysis for Large-scale Real-time Software [J].Journal of Southwest University of Science and Technology(Natural Science Edition),2013,28(3):89-94.(in Chinese) 李树芳,安金霞,郑鹏飞,等.面向大型实时软件的测试覆盖率快速分析方法[J].西南科技大学学报(自然科学版),2013,28(3):89-94.
[8] LI S F,CHEN X,AN J X,et al.Real-Time Software Memory Error Analysis with C++ Code Instrumentation[J].Journal of Frontiers of Computer Science and Technology,2014,8(6):704-711.(in Chinese) 李树芳,陈霞,安金霞,等.采用C++代码插装的实时软件内存错误分析[J].计算机科学与探索,2014,8(6):704-711.

No related articles found!
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!