[关键词]
[摘要]
软件在开发和维护过程中会产生大量缺陷报告, 可为开发人员定位缺陷提供帮助. 基于信息检索的缺陷定位方法通过分析缺陷报告内容和源码文件的相似度来定位缺陷所在位置, 已在文件、函数等粗粒度级别上取得了较为精确的定位效果, 但由于其定位粒度较粗, 仍需要耗费大量人力和时间成本检查可疑文件和函数片段. 为此, 提出一种基于历史缺陷信息检索的语句级软件缺陷定位方法STMTLocator, 首先检索出与被测程序缺陷报告相似度较高的历史缺陷报告, 并提取其中的历史缺陷语句; 然后根据被测程序源码文件与缺陷报告的文本相似度检索可疑文件, 并提取其中的可疑语句; 最后计算可疑语句与历史缺陷语句的相似度, 并进行降序排列, 以定位缺陷语句. 为评估STMTLocator的缺陷定位性能, 使用Top@N、MRR等评价指标在基于Defects4J和JIRA构建的数据集上进行对比实验. 实验结果表明, 相比静态缺陷定位方法BugLocator, STMTLocator在MRR指标上提升近4倍, 在Top@1指标上多定位到7条缺陷语句; 相比动态缺陷定位方法Metallaxis和DStar, STMTLocator完成一个版本缺陷定位平均消耗的时间减少98.37%和63.41%, 且具有不需要设计和执行测试用例的显著优势.
[Key word]
[Abstract]
A large number of bug reports are generated during software development and maintenance, which can help developers to locate bugs. Information retrieval based bug localization (IRBL) analyzes the similarity of bug reports and source code files to locate bugs, achieving high accuracy at the file and function levels. However, a lot of labor and time costs are consumed to find bugs from suspicious files and function fragments due to the coarse location granularity of IRBL. This study proposes a statement level software bug localization method based on historical bug information retrieval, STMTLocator. Firstly, it retrieves historical bug reports which are similar to the bug report of the program under test and extracts the bug statements from the historical bug reports. Then, it retrieves the suspicious files according to the text similarity between the source code files and the bug report of the program under test, and extracts the suspicious statements from the suspicious files. Finally, it calculates the similarity between the suspicious statements and the historical bug statements, and arranges them in descending order to localize bug statements. To evaluate the bug localization performance of STMTLocator, comparative experiments are conducted on the Defects4J and JIRA dataset with Top@N, MRR, and other evaluation metrics. The experimental results show that STMTLocator is nearly four times than the static bug localization method BugLocator in terms of MRR and locates 7 more bug statements for Top@1. The average time used by STMTLocator to locate a bug version is reduced by 98.37% and 63.41% than dynamic bug localization methods Metallaxis and DStar, and STMTLocator has a significant advantage of not requiring the construction and execution of test cases.
[中图分类号]
TP311
[基金项目]
江苏省前沿引领技术基础研究专项(BK202002001); 国家自然科学基金(61702041); 北京信息科技大学“勤信人才”培育计划(QXTCP C201906)