基于谱的错误定位(SBFL)是减小软件调试困难的有效方法。SBFL方法将运行特征组合成不同的错误定位模型,可这些模型受特定程序及测试集影响,性能并不稳定。基于此,提出一种排序学习方法LTR-sbfl,针对不同的程序及其测试集,能学习到相应的错误定位模型。LTR-sbfl首先收集已标注错误语句的程序旧版本,采用与SBFL相同的方法,获得程序语句的运行特征。接着,将错误行与正确行代码的运行特征两两相减,确定为训练数据的一个实例。最后,使用分类算法,从训练数据构造排序模型。在3个基准数据集的实验结果证实,LTR-sbfl的定位精度优于其他SBFL方法。
Spectrum-based fault localization (SBFL) has been proven to be the promising technique during software debugging. SBFL combined various factors in the execution profile to form different fault localization models. However, these models are still agnostic to the particular program and dataset. In this paper we propose a learning to rank method referred to as LTR-sbfl which automatically constructs the SBFL model for each program. Like the existing SBFL methods, we first collect program execution traces and results of test cases. Next, it is directly mapped from the coverage difference in a pair of faulty statement and non-faulty statement to an instance in supervised learning. Finally, the conventional classification algorithm is applied to learn a ranking model for a program based on the training data. The proposed method on three benchmark datasets is evaluated through experiment. Results show that LTR-sbfl can outperform other SBFL approaches in the precision of fault localization.