arXivDaily arXiv每日学术速递 周一至周五更新
北美退伍军人节(Veterans Day),12 日无更新
arXiv 2501.09475cs.SE
收藏

基于差分测试的自动翻译代码引导式调试

Guided Debugging of Auto-Translated Code Using Differential Testing

Shengnan Wu, Xinyu Sun, Xin Wang, Yangfan Zhou

AI总结:

针对大语言模型代码翻译错误难定位的问题,提出结合模糊测试与启发式差分测试的调试工具tHinter,可大幅减少开发者审查代码量并提升错误修复效率。

摘要:

大语言模型(LLM)在代码翻译任务中展现出巨大潜力。然而,其可解释性的缺失使得定位不可避免的翻译错误变得复杂。本文提出tHinter,一款用于定位自动翻译代码中翻译错误的调试工具。tHinter的核心思路是:若翻译正确,源代码与翻译后代码应具备相同功能,对相同输入给出相同输出。因此,翻译后代码中导致输出差异的行可能存在翻译错误。首先,tHinter采用模糊测试生成多样化测试用例,以全面探索翻译后代码。随后,tHinter依托启发式算法,结合这些测试用例的覆盖率信息与差分测试执行结果,精准定位翻译错误。该启发式算法旨在同时利用统计数据与开发者的专业知识。针对真实代码的综合实验验证了其有效性:它减少了开发者调试时需审查的71%代码行,并将LLM单次查询修复翻译错误的概率提升了59%。开发者普遍认为该工具令人满意且颇具帮助。

英文摘要:

Large Language Models (LLMs) hold great promise in the task of code translation. However, the lack of explainability complicates the identification of the inevitable translation errors. In this paper, we propose tHinter, a debugging tool to locate translation errors in auto-translated code. The core idea of tHinter is that correctly translated, the source and translated code should present the same functionalities, giving the same output for the same input. Hence, lines in the translated code responsible for output differences are possibly translation errors. First, tHinter employs fuzzing to generate diverse test cases that thoroughly explore the translated code. Then, tHinter relies on a heuristic algorithm to pinpoint translation errors from coverage information and differential testing execution results of those test cases. This heuristic algorithm is designed to leverage both the statistics and the expertise of developers. Comprehensive experiments with real code show its effectiveness. It reduces 71% lines developers need to review during debugging and increases the likelihood of the LLM fixing translation errors in a single query by 59%. Developers generally consider it satisfactory and helpful.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑