前文 简单介绍了项目,根据熊英飞的这篇 An Empirical Study of Fault Localization Families and Their Combinations 开展实验。
Our experiments use the JavaSlicer dynamic slicing tool. JavaSlicer is based on the dynamic slicing algorithm of Wang and Roychoudhury, with extensions for object-oriented programs. The JavaSlicer implementation attaches to the program as a Java agent and re-writes classes as they are loaded into the Java VM.
A test fails by throwing an exception, either because of a violated assertion or a runtime crash. If there is only a single failed test, we use the execution of the statement that throws the exception as the slicing criterion. The slice then contains all statements that may have affected the statement that throws the exception.
If there are multiple failed tests, our experiments apply three strategies from a previous study to utilize multiple slices: union, intersection, and frequency . The first two strategies calculate the union or the intersection of the slices and report a set of statements as results. The frequency strategy calculates the inclusion frequency for each statement and reports a ranked list of statements based on the frequency. The more frequently a statement is included in the slice of a failed test, the more suspicious the statement is.
简单来说:单个失败测试,使用抛出异常的语句的执行作为切片准则。多个失败测试,采用并集、交集和频率的策略。
1.实验环境搭建
使用 b046ed3 的 Master 分支,运行环境与说明一致:
> ubuntu@VM-0-8-ubuntu:~$ javac -version
javac 1.6.0_20
> ubuntu@VM-0-8-ubuntu:~$ mvn -version
Apache Maven 2.2.0 (r788681; 2009-06-26 21:04:01+0800)
执行 assemble.sh,报错 Plugin requires Maven version 2.2.1 。
配置换成 javac 1.8.0_281 / Apache Maven 3.3.9 则可以正常使用。
搭建 Defect4J 环境的相关内容不再赘述。
2.项目准备工作
以 Lang-61 为例,首先执行 Checkout:
defects4j checkout -p Lang -v 61b -w /home/ubuntu/lang_61_buggy

本文介绍了一项基于熊英飞的研究,通过JavaSlicer动态切片工具进行故障定位,针对单次和多失败测试采用不同的策略,如并集、交集和频率。以Lang-61项目为例,详细步骤包括环境配置、项目准备、生成跟踪文件及执行切片分析,结果显示切片能有效缩小可疑代码范围。
最低0.47元/天 解锁文章





