一句话:提出 DeepRL4FL,将故障定位视为图像模式识别,融合代码覆盖率、数据依赖与源码表示学习,显著提升语句级与方法级定位精度。
该论文研究自动化故障定位(FL),目标是在语句与方法粒度上找出缺陷代码。作者提出 DeepRL4FL,其核心思想借鉴犯罪现场调查:既分析失败测试用例与语句构成的“犯罪现场”,又考察与之存在数据依赖的“相关人员”,同时参考训练数据中历史相似缺陷代码这一“惯犯”。方法上,首先对测试用例排序并标记暴露错误的语句,将代码覆盖率矩阵转化为可供卷积神经网络识别的图像模式;其次对语句间的数据依赖进行表示学习,使语句可疑度不仅取决于自身,还考虑执行与数据流中的依赖关系;最后把覆盖率矩阵、数据依赖与源码三者的向量表示拼接,输入基于 CNN 的分类器,实现语句级与方法级缺陷检测。实验表明,DeepRL4FL 在语句级 FL 基线上将 top-1 结果提升 173.1% 至 491.7%,在方法级基线上提升 15.0% 至 206.3%。
In this paper, we propose DeepRL4FL, a deep learning fault localization (FL) approach that locates the buggy code at the statement and method levels by treating FL as an image pattern recognition problem. DeepRL4FL does so via novel code coverage representation learning (RL) and data dependencies RL for program statements. Those two types of RL on the dynamic information in a code coverage matrix are also combined with the code representation learning on the static information of the usual suspicious source code. This combination is inspired by crime scene investigation in which investigators analyze the crime scene (failed test cases and statements) and related persons (statements with dependencies), and at the same time, examine the usual suspects who have committed a similar crime in the past (similar buggy code in the training data). For the code coverage information, DeepRL4FL first orders the test cases and marks error-exhibiting code statements, expecting that a model can recognize the patterns discriminating between faulty and non-faulty statements/methods. For dependencies among statements, the suspiciousness of a statement is seen taking into account the data dependencies to other statements in execution and data flows, in addition to the statement by itself. Finally, the vector representations for code coverage matrix, data dependencies among statements, and source code are combined and used as the input of a classifier built from a Convolution Neural Network to detect buggy statements/methods. Our empirical evaluation shows that DeepRL4FL improves the top-1 results over the state-of-the-art statement-level FL baselines from 173.1% to 491.7%. It also improves the top-1 results over the existing method-level FL baselines from 15.0% to 206.3%.