With the increasing of software demand and scale,software defect becomes an important factor affecting software quality.In the process of software development,software defects are inevitable.Studies show that the repair of software defects accounts for more than half of the software development time and more than 90%of the economic cost.Therefore,in order to reduce personnel burden and repair cost,the research on automatic defect repair technology is particularly important.In order to study efficient automatic defect repair methods,researchers have carried out researches from defect location,patch generation and verification.However,the automatic defect repair technology still faces the following two major challenges:coarse repair granularity and low search efficiency.The existing automatic defect repair methods are mainly based on the statement level by reusing the statements in the program to achieve the purpose of repair.Studies have shown that these methods are too coarse to find the correct repair components.Because the correct repair components tend to exist at a finer granularity than statements(for example,expressions).Furthermore,when fixed at a fine-grained level,the search space expands dramatically(about 400 times).At this time,the search ability of the algorithm is obviously insufficient,and it is difficult to use it directly.In order to solve the above challenges,this paper is based on program syntax tree and genetic programming.The main research contents are as follows:1.To solve the problem of coarse repair granularity,a patch generation method based on expression is proposed(Tiny Repair).In this paper,the existing defect locating technique is improved and the defects are treated in batches.In this method,the program is decomposed in the syntax tree,16 rules are defined to extract repair materials,and a type filtering and context-aware strategy are designed to assign repair components to defective programs.This paper proposes a dynamic patch synthesis method,which directly synthesizes patch statements in the syntax tree and introduces a third party data source to guide the repair operation.2.To solve the problem of low search efficiency,an automatic repair method based on fine-grained patch search is proposed.In this paper,algorithms adapted to fine-grained repair are selected according to patch representation:multi-objective evolutionary algorithm and random algorithm.Based on these two algorithms,automatic repair methods MSRepair and RSRepair are proposed.The experimental results show that MSRpair is superior to RSRepair,and the extended repair method(M_nSRepair)is realized by integrating other multi-objective evolutionary algorithms.In addition,a sorting technique based on longest common subsequence(LCS)is proposed to preprocess candidate patches before patch search.3.In order to verify the effectiveness of fine-grained repair,five experiments were designed to systematically verify the proposed methods on the dataset Defects4j.Experimental results show that the Tiny Repair method generates 36 correct patches,with an accuracy of 73.5%.The MSRepair method correctly repaired 26 errors,with an accuracy of 62%.Compared with Gen Prog,MSRepair improves the number and accuracy of repair by 4.2 times and 2.3 times,respectively. |