Automatic fault localization techniques play a critical role in software development,but existing techniques lack in-depth characterization of program flow and code syntactic structure, making it difficult to understand deep logic and contextual information. They also lack universality in dealing with code entities of different granularity, limiting the information interaction of different levels of error localization and the comprehensive understanding of error characteristics.To addres these issues, this study proposes a graph-based fault localization framework utilizing multi-modal code representations, aiming to enhance fault localization effectiveness in two ways: firstly, leveraging multi-source information such as syntactic structure, semantic information, execution logic, and test coverage details to construct multi-modal code representation graphs using both large and small models, enhancing the ability to identify faults in complex code structures; secondly, forming multi-granularity localization models by sharing parameters between method and statement-level localization models to improve fault localization method accuracy. Experimental results conducted on 395 faults from the Defects4J dataset demonstrate that compared to the best baseline technique, our framework results in an increase of 25 correctly localized faults at the method level with a 1.12% improvement in mean first rank (MFR), and an increase of 34 correctly localized faults at the statement level with a 5.34% improvement in MFR.
然而不同的代码行由不同数量的Token组成,为实现代码行统一维度的向量表示,本文将代码行的Token进行拼接,形成的矩阵表示,再利用主成分分析(principal component analysis,PCA)技术对矩阵去中心化,如式(1)所示,计算去中心化的矩阵的协方差矩阵,并如式(2)所示,进行特征分解以求出对应的特征向量。最后将矩阵 X 与特征向量进行点积运算,将数据降维至,同时尽可能保留原始数据的重要信息。
每个代码行不仅包含Token序列信息,还蕴含着语法结构信息。本文通过现有的解析库Antlr4工具将源代码转换为一个集成的AST,然后根据语句粒度将AST分割成一组语句子树。提取后的语句子树被送入一个抽象语法树神经网络(abstract syntax tree neural network,ASTNN),其模型框架如图2所示。对于一个AST子树,本文使用Word2Vec的词嵌入参数表征树节点,以作为ASTNN的原始输入。然后,ASTNN在多路语句树上设计了一个递归编码器,以捕获语句级的语法信息。
O’DELLD H. The debugging mindset: understanding the psychology of learning strategies leads to effective problem-solving skills[J]. ACM Queue, 2017, 15(1): 71-90.
JIANGS J, ZHANGX, WANGR C, et al.Fault localization approach based on path analysis and information entropy[J]. Journal of Software,2021,32(7): 2166-2182.(in Chinese)
[4]
NATANA, STERNR, KALECHM. Distributed spectrum-based fault localization[C]//The Thirty-Seventh AAAI Conference on Artificial Intelligence. Washington D.C., 2023: 6491-6498.
[5]
GHANBARIA, THOMASD G, ARSHADM A, et al. Mutation-based fault localization of deep neural networks[C]//2023 38th IEEE/ACM International Conference on Automated Software Engineering(ASE). Echternach, 2023: 1301-1313.
[6]
WENM, XIEZ F, LUOK X, et al. Effective isolation of fault-correlated variables via statistical and mutation analysis[J]. IEEE Transactions on Software Engineering, 2023,49(4): 2053-2068 .
[7]
LIY, WANGS H, NGUYENT N. Fault localization with code coverage representation learning[C]//2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE). Madrid,2021: 661-673.
[8]
LOUY L, ZHUQ H, DONGJ H, et al. Boosting coverage-based fault localization via graph-based representation learning[C]//Proceedings of the 29th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering. Athens, 2021: 664-676.
[9]
SARHANQ I, BESZÉDESÁ. A survey of challenges in spectrum-based software fault localization[J].IEEE Access, 2022, 10: 10618-10639.
[10]
YANGA Z H, GOUESC L, MARTINSR, et al. Large language models for test-free fault localization[C]//Proceedings of the 46th IEEE/ACM International Conference on Software Engineering(ICSE). Lisbon,2024: 165-176.
[11]
WANGW H, LIG, MAB, et al. Detecting code clones with graph neural network and flow-augmented abstract syntax tree[C]//2020 IEEE 27th International Conference on Software Analysis, Evolution and Reengineering (SANER). London, 2020: 261-271.
[12]
DUTTAA, MANRALR, MITRAP, et al. Hierarchically localizing software faults using DNN[J]. IEEE Transactions on Reliability, 2020, 69(4): 1267-1292.
[13]
WANGY, LEH, GOTMAREA D, et al. CodeT5+: open code large language models for code understanding and generation[C]//Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing. Singapore, 2023: 1069-1088.
[14]
JUSTR, JALALID, ERNSTM D. Defects4J: a database of existing faults to enable controlled testing studies for Java programs[C]//Proceedings of the 2014 International Symposium on Software Testing and Analysis. San Jose, 2014: 437-440.
[15]
KOCHHARP S, XIAX, LOD, et al. Practitioners' expectations on automated fault localization[C]//Proceedings of the 25th International Symposium on Software Testing and Analysis. Saarbrücken, 2016: 165-176.
[16]
ABREUR, ZOETEWEIJP, VAN GEMUNDA J C. On the accuracy of spectrum-based fault localization[C]// Testing: Academic and Industrial Conference Practice and Research Techniques-MUTATION (TAICPART-MUTATION 2007. Windsor,2007: 89-98.
[17]
JONESJ A, HARROLDM J. Empirical evaluation of the Tarantula automatic fault-localization technique[C]//Proceedings of the 20th IEEE/ACM International Conference on Automated Software Engineering.Long Beach, 2005: 273-282.
[18]
XUANJ F, MONPERRUSM. Learning to combine multiple ranking metrics for fault localization[C]//2014 IEEE International Conference on Software Maintenance and Evolution. Victoria, 2014: 191-200.
[19]
SOHNJ, YOOS. FLUCCS: using code and change metrics to improve fault localization[C]//Proceedings of the 26th ACM SIGSOFT International Symposium on Software Testing and Analysis. Santa Barbara, 2017: 273-283.
[20]
LIX, LIW, ZHANGY Q, et al. DeepFL: integrating multiple fault diagnosis dimensions for deep fault localization[C]//Proceedings of the 28th ACM SIGSOFT International Symposium on Software Testing and Analysis. Beijing, 2019: 169-180.
[21]
QIANJ, JUX L, CHENX, et al. AGFL: a graph convolutional neural network-based method for fault localization[C]//2021 IEEE 21st International Conference on Software Quality, Reliability and Security (QRS). Haikou, 2021: 672-680.
[22]
MENGX X, WANGX, ZHANGH Y, et al. Improving fault localization and program repair with deep semantic features and transferred knowledge[C]//2022 IEEE/ACM 44th International Conference on Software Engineering (ICSE). Pittsburgh, 2022: 1169-1180.
[23]
ZHANGS, TONGH H, XUJ J, et al. Graph convolutional networks: a comprehensive review[J]. Computational Social Networks, 2019, 6: 11.
[24]
KIMB H, YEJ C. Understanding graph isomorphism network for rs-fMRI functional connectivity analysis[J]. Frontiers in Neuroscience, 2020, 14: 630.
[25]
LIY J, ZEMELR, BROCKSCHMIDTM, et al. Gated graph sequence neural networks[C]//International Conference on Learning Representations. San Juan,2016.