Source code diffs are used on a daily basis as part of code review, inspection, and auditing. To facilitate understanding, they are typically accompanied by explanations that describe the essence of what is changed in the program. As manually crafting high-quality explanations is a cumbersome task, researchers have proposed automatic techniques to generate code diff explanations. Existing explanation generation methods solely focus on static analysis, i.e., they do not take advantage of runtime information to explain code changes. In this paper, we propose Collector-Sahab, a novel tool that augments code diffs with runtime difference information. Collector-Sahab compares the program states of the original (old) and patched (new) versions of a program to find unique variable values. Then, Collector-Sahab adds this novel runtime information to the source code diff as shown, for instance, in code reviewing systems. As an evaluation, we run Collector-Sahab on 584 code diffs for Defects4J bugs and find it successfully augments the code diff for 95% (555/584) of them. We also perform a user study and ask eight participants to score the augmented code diffs generated by Collector-Sahab. Per this user study, we conclude that developers find the idea of adding runtime data to code diffs promising and useful. Overall, our experiments show the effectiveness and usefulness of Collector-Sahab in augmenting code diffs with runtime difference information. Publicly-available repository: https://github.com/ASSERT-KTH/collector-sahab.
翻译:源代码差异(code diffs)每日用于代码审查、检查与审计中。为便于理解,通常需附带描述程序变更本质的解释说明。由于手工编写高质量解释是一项繁琐任务,研究者已提出自动生成代码差异解释的技术。现有解释生成方法仅聚焦于静态分析,即未利用运行时信息来解释代码变更。本文提出新型工具Collector-Sahab,其通过运行时差异信息增强代码差异。Collector-Sahab通过比较程序原始(旧版本)与补丁后(新版本)的程序状态,以发现唯一变量值,随后将此新增运行时信息添加至源代码差异中(如图示例,在代码审查系统中应用)。为评估效果,我们针对Defects4J缺陷集中的584个代码差异运行Collector-Sahab,发现其中95%(555/584)的差异被成功增强。我们还开展用户研究,邀请八名参与者对Collector-Sahab生成的增强代码差异进行评分。根据此用户研究,我们得出结论:开发者认为向代码差异添加运行时数据这一构想具有前景且实用。总体而言,实验表明Collector-Sahab在利用运行时差异信息增强代码差异方面有效且有用。公开仓库地址:https://github.com/ASSERT-KTH/collector-sahab。