Defect positioning auxiliary method and device based on fine-grained software
By collecting the variable value sequence and statement coverage information on the target defective program, training the convolutional neural network model, calculating the variable value sequence suspiciousness and combining the statement risk value, the problem of the lack of variable level information and dependency coverage information in the existing technology is solved. , achieving more efficient and accurate defect location.
Patent Information
- Application Number
- CN202411363096.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-09-27
AI Technical Summary
Existing spectrum-based defect positioning methods lack information at the variable level of the program runtime, and rely on coverage information to distinguish failed and successful test cases. If the coverage information is not obvious enough, the confidence will be reduced.
By running multiple test cases on the target defective program, the statement coverage information, variable value sequence and actual execution results are collected, the convolutional neural network model is trained, the variable value sequence suspiciousness is calculated, and combined with the statement risk value for aggregation, to obtain each The final degree of suspicion of a variable.
Provide more fine -grained and accurate suspicious information to help the debugged staff start looking for defects from the most likely error variables, and improve the accuracy and efficiency of defect positioning.
Smart Images

Figure CN119357030A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a defect location auxiliary method and device based on fine-grained software. Background Art
[0002] Software debugging is a key step to ensure software quality. It is generally divided into three stages: defect location, defect understanding, and defect repair. Among them, defect location is the most time-consuming and costly stage, and must be completed before defect repair, so defect location is very important in software debugging. However, manual defect location is difficult and slow, so how to automate defect location and improve its effect to help debuggers improve debugging speed is the focus of research. In the field of automated defect location, researchers have done a lot of research and proposed many defect location technologies. These technologies include spectrum-based, program slicing-based, and machine learning-based defect location technologies. These technologies usually use information from failed and successful test cases to output a list of "suspicious" locations, that is, code locations that may cause defects. In this way, debuggers can quickly focus on specific parts of the source code instead of checking the entire code base, thereby improving the efficiency of debuggers.
[0003] Spectrum-based defect location technology is the mainstream technology in the field of automated defect location. This technology uses two types of information when ranking program entities: test results and program spectrum. Test results refer to whether each test case meets expectations after execution, while program spectrum refers to the coverage status of the program entity under study, which is usually binary. Spectrum-based defect location technology usually uses a metric formula to calculate the suspiciousness of program entities based on program spectrum information and sort them according to the size of the suspiciousness to find the program entities most likely to have defects, allowing debuggers to start looking for defects from program entities with high suspicion. However, spectrum-based defect location technology has great limitations. Studies have shown that existing defect location methods are based on an assumption that checking the statements containing defects alone is sufficient for debuggers to understand and fix the corresponding defects. At the same time, manual debugging often pays the most attention to information related to variable values.
[0004] In view of this, it is necessary to provide debuggers with more fine-grained and more accurate suspicion information. Providing debuggers with more fine-grained (i.e., variable) suspicion is more in line with debuggers' debugging habits in practice than providing suspicious statements. Statement-level defect location reports only provide statements that are unrelated and have no context information, which are arranged by the size of suspicion. Using variable-level defect location reports, developers can check at a finer granularity to determine the location of the defect and repair it. Researchers have enhanced the accuracy of defect location results by introducing method call information, the frequency of program entity execution, program control flow graph information, statement execution context information, and code metric information. However, research on more program runtime variable-level information is still lacking. Therefore, introducing variable value information into the defect location process of spectrum-based defect location technology is a method worth considering to improve the effect of spectrum-based defect location technology. How to design defect location auxiliary tools based on fine-grained software is an important issue. Summary of the invention
[0005] The present invention provides a defect location auxiliary method and device based on fine-grained software to solve the problems that the existing spectrum-based defect location method lacks research on the variable level information during program runtime, and the defect location technology based on the spectrum relies on coverage information to distinguish between failed test cases and successful test cases. If the coverage information is not obvious enough, the credibility will be reduced.
[0006] The first aspect of the present invention provides a defect location assistance method based on fine-grained software, comprising the following steps: running multiple test cases on a target defective program to collect statement coverage information, variable value sequence and actual execution results of each test case; training a pre-constructed convolutional neural network model according to the variable value sequence and the actual execution results until the target training round is reached to obtain a trained convolutional neural network; using the trained convolutional neural network to locally interpret the false samples generated by all failed test cases to calculate the variable value sequence suspicion; aggregating the variable value sequence suspicion to obtain the variable suspicion based on the variable value sequence; performing initial defect location on the target defective program according to the statement coverage information to obtain a statement risk value; aggregating the variable value sequence suspicion and the statement risk value to obtain the coverage-based variable suspicion; solving the final suspicion of each variable according to the variable value sequence-based variable suspicion and the coverage-based variable suspicion; sorting the final suspicion of each variable to generate a sorting result, and obtaining the final defect location according to the sorting result.
[0007] Optionally, the training of a pre-built convolutional neural network model according to the variable value sequence and the actual execution result until a target training round is reached to obtain a trained convolutional neural network includes:
[0008] The variable value sequence is preprocessed to obtain a variable information matrix; the variable information matrix corresponding to each test case is used as a sample, and the actual execution result corresponding to each test case is used as a label to construct a training set; the pre-constructed convolutional neural network model is trained using the training set until a target training round is reached to obtain the trained convolutional neural network.
[0009] Optionally, the using the trained convolutional neural network to locally interpret the fake samples generated by all failed test cases to calculate the suspiciousness of the variable value sequence includes:
[0010] Generate multiple false variable value sequences in all failed test cases in the multiple test cases; use the trained convolutional neural network to predict the multiple false variable value sequences to obtain labels corresponding to each false variable value sequence; train a pre-constructed linear regression model according to the multiple false variable value sequences and the labels corresponding to each false variable value sequence to obtain a trained linear regression model; calculate the suspiciousness of the variable value sequence according to the trained linear regression model.
[0011] Optionally, performing initial defect location on the target defective program according to the statement coverage information to obtain a statement risk value includes:
[0012] The forward slicing algorithm is improved by using the suspiciousness of the variable value sequence to obtain an improved backward slicing algorithm; the statement coverage information is processed by using the improved backward slicing algorithm to obtain a statement spectrum set; and initial defect location is performed on the target defective program based on the statement spectrum set to obtain the statement risk value.
[0013] Optionally, the calculation formula for the coverage-based variable suspicion is:
[0014]
[0015] Among them, SBFL(v) is the variable suspicion based on coverage, s i There are n statements in the improved backward slicing algorithm, SBFL normalized (s i ) is the normalized value of the statement risk value.
[0016] Optionally, the calculation formula for the variable suspiciousness based on the variable value sequence is:
[0017]
[0018] Among them, Susp(v) is the variable suspicion based on the variable value sequence, Susp(E(v,t j )) is the test case t j The suspiciousness of the value sequence of variable v in , there are m value sequences in total.
[0019] The second aspect of the present invention provides a defect location auxiliary device based on fine-grained software, including: a collection module, used to run multiple test cases on the target defective program to collect statement coverage information, variable value sequence and actual execution results of each test case; a training module, used to train a pre-built convolutional neural network model according to the variable value sequence and the actual execution result until the target training round is reached to obtain a trained convolutional neural network; a local interpretation module, used to use the trained convolutional neural network to perform local interpretation on false samples generated by all failed test cases to calculate the suspiciousness of the variable value sequence; a first aggregation module, used to analyze the false samples generated by all failed test cases using the trained convolutional neural network; and a first aggregation module, used to analyze the false samples generated by all failed test cases using the trained convolutional neural network. The variable value sequence suspicion is aggregated to obtain the variable suspicion based on the variable value sequence; an initial positioning module is used to perform initial defect positioning on the target defect program according to the statement coverage information to obtain the statement risk value; a second aggregation module is used to aggregate the variable value sequence suspicion and the statement risk value to obtain the variable suspicion based on coverage; a solution module is used to solve the final suspicion of each variable according to the variable suspicion based on the variable value sequence and the variable suspicion based on coverage; a final positioning module is used to sort the final suspicion of each variable to generate a sorting result, and obtain the final defect positioning according to the sorting result.
[0020] An embodiment of the third aspect of the present invention provides a defect localization assistance device for fine-grained software, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the defect localization assistance method based on fine-grained software as described in the above embodiment.
[0021] A fourth aspect of the present invention provides a computer program product, which implements the above-mentioned fine-grained software-based defect localization assistance method when the computer program / instructions are executed by a processor.
[0022] A fifth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, which, when executed by a processor, implements the above-mentioned fine-grained software-based defect localization assistance method.
[0023] The fine-grained software-based defect location auxiliary method and device proposed in the embodiment of the present invention calculates the suspiciousness of variable value sequences based on convolutional neural networks and explainable artificial intelligence technology, and uses the suspiciousness of variable value sequences combined with spectrum-based defect location to perform defect location at the variable level. Compared with the traditional defect location method, the defect suspiciousness of each variable is provided, which can help debuggers start looking for defects from the variables that are most likely to cause errors, which is more suitable for debuggers' actual debugging methods than only providing suspicious statements; the spectrum-based defect location technology relies on coverage information to distinguish failed test cases from successful test cases. If the coverage information is not obvious enough, the credibility will be reduced. The present invention uses the variable value sequence to improve the accuracy of defect location, and introduces more coverage information during program runtime to assist in location. Compared with the more detailed information of the statement-level suspiciousness, the accuracy of location is improved; finally, a complete set of fine-grained software defect location auxiliary tools is formed, and users can use this method to achieve efficient and automatic defect location, and use it for program debugging and location work in actual production.
[0024] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0026] Figure 1 A flowchart of a defect location auxiliary method based on fine-grained software provided by an embodiment of the present invention;
[0027] Figure 2 A specific execution diagram of a defect location auxiliary method based on fine-grained software provided by an embodiment of the present invention;
[0028] Figure 3 The overall flow chart of variable value sequence preprocessing provided by the embodiment of the present invention;
[0029] Figure 4 A pseudo code schematic diagram of a failed test case interpretation algorithm based on LIME provided in an embodiment of the present invention;
[0030] Figure 5 A pseudo code schematic diagram of a backward slicing algorithm based on variable value suspicion provided by an embodiment of the present invention;
[0031] Figure 6 A block diagram of a defect location auxiliary device based on fine-grained software provided by an embodiment of the present invention;
[0032] Figure 7 A schematic diagram of the structure of a fine-grained software defect location auxiliary device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0033] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0034] The following describes a fine-grained software defect location assisting method and device according to an embodiment of the present invention with reference to the accompanying drawings.
[0035] Figure 1 A schematic flow chart of a fine-grained software defect location assisting method provided by an embodiment of the present invention.
[0036] like Figure 1 As shown, the fine-grained software defect location auxiliary method includes the following steps:
[0037] In step S101, multiple test cases are run on the target defective program to collect statement coverage information, variable value sequence and actual execution result of each test case.
[0038] In the actual implementation process, Figure 2 As shown, when multiple test cases are run on the target defective program, coverage information, variable value sequences and actual execution results are collected, and variable tracking is performed to obtain the value sequence of each variable.
[0039] The variable value sequence is:
[0040]
[0041] The set of all variables in the defective program P to be tested is denoted as V, which contains n variables (v i ∈V, i = 1, 2, ..., n, vi is one of the variables, T is a test case set, T contains k test cases tj∈T, j = 1, 2, ..., k, t j is one of the test cases. E(v i , t j ) is to run the test case t j When a variable v in the defective program P to be tested i The value of is a sequence (if the value of the variable does not change, there is only one value in the sequence), let the variable v i The initial value is (Execute test case t jThe program terminates after m value changes, then the variable v i The last value of the sequence of values is sequence To execute the test case t j Time variable v i A sequence of values.
[0042] In step S102, a pre-built convolutional neural network model is trained according to the variable value sequence and the actual execution result until the target training round is reached to obtain a trained convolutional neural network.
[0043] In some embodiments, a pre-built convolutional neural network model is trained according to a sequence of variable values and actual execution results until a target training round is reached to obtain a trained convolutional neural network, including:
[0044] Preprocess the variable value sequence to obtain the variable information matrix;
[0045] The variable information matrix corresponding to each test case is used as a sample, and the actual execution result corresponding to each test case is used as a label to construct a training set;
[0046] The pre-built convolutional neural network model is trained using the training set until the target training round is reached to obtain the trained convolutional neural network.
[0047] In the actual implementation process, Figure 3 As shown, the variable value sequence is preprocessed to generate a non-numeric variable value sequence. From left to right, the first step represents the numerical conversion of the non-numeric variable value sequence, and the second step represents the modification of the variable value sequence to a fixed length. The variable value sequence matrix can be generated by normalizing the non-numeric variable value sequence, where the variable information matrix is:
[0048]
[0049] Among them, E(v i , t j ) is to run the test case t j When a variable v in program P i A sequence of values.
[0050] Furthermore, the variable information matrix corresponding to each test case is taken as a sample, and the execution result corresponding to the test case is taken as a label (0 for pass, 1 for fail). The samples and labels are constructed into a training set, and the training set is used to train the pre-built convolutional neural network model.
[0051] The pre-built convolutional neural network model includes an input layer, two convolutional layers, an excitation layer, a pooling layer, a fully connected layer and an output layer. The input layer size is n*L, where n is the number of variables and L is the fixed length of each variable value sequence to input the variable information matrix into the network. Each of the two convolutional layers contains multiple convolution kernels, the first convolutional layer contains 32 convolution kernels with a length of 5, and the second convolutional layer contains 64 convolution kernels with a length of 5. The ReLU function ReLU(x)=max(0,x) is used as the excitation function in the excitation layer. The maximum pooling method is used in the pooling layer. The number of layers in the fully connected layer is set to 2, and the number of nodes in each layer is 1024. The Sigmoid function in the output layer is:
[0052] The difference between the output value of the convolutional neural network model and the sample label can be used as the size of the model loss, and the model is trained through the back propagation algorithm, and the weight of each neuron is updated using the gradient descent algorithm, using a dynamic learning rate LR:
[0053] LR=LR*DropRate (Epoch+1) / EpochDrop
[0054] Among them, Epoch represents the number of training rounds, DropRate represents the amount of updating the learning rate LR each time, and EpochDrop represents the frequency of adjusting the learning rate LR. In the embodiment of the present invention, the initial learning rate is set to 0.01, and the DropRate is set to 0.9.
[0055] In step S103, the trained convolutional neural network is used to perform local interpretation on the false samples generated by all failed test cases to calculate the suspiciousness of the variable value sequence.
[0056] In some embodiments, the trained convolutional neural network is used to perform local interpretation on the false samples generated by all failed test cases to calculate the suspiciousness of the variable value sequence, including:
[0057] Generate multiple sequences of false variable values in all failed test cases in multiple test cases;
[0058] Use the trained convolutional neural network to predict multiple false variable value sequences and obtain the label corresponding to each false variable value sequence;
[0059] Training a pre-built linear regression model according to a plurality of dummy variable value sequences and labels corresponding to each dummy variable value sequence to obtain a trained linear regression model;
[0060] Calculate the suspiciousness of the variable value sequence based on the trained linear regression model.
[0061] In the actual implementation process, Figure 2 and 4 As shown in the figure, LIME technology is used to interpret all failed test cases, and several "fake samples" are generated near the samples. Among them, the variable value sequence information of a failed test case is x, and the "fake sample" data set generated near x is:
[0062] D={<d1,y1> ,<d2,y2> , ..., <d n ,y n >}
[0063] Where, d i is the ith false sample generated near x, there are n false samples in total, y i To predict fake samples d using the convolutional neural network model i The label from d i and i Local explanations can be extracted from
[0064] Furthermore, the similarity between the "fake samples" and the original samples is calculated, the labels of the "fake samples" are predicted using the trained convolutional neural network model, and a linear regression model is trained using the data set composed of "fake samples".
[0065] Among them, the distance (i.e. similarity) between the original sample and the fake sample is measured using the cosine distance metric, and the calculation method is characterized as follows:
[0066]
[0067] Where p and q represent two different variable value sequences of the same length.
[0068] According to the trained linear regression model, the value of each variable is used as a feature to obtain the importance score of each variable value. The absolute values of all variable value importance scores in the variable value sequence are summed to obtain the variable value sequence suspicion. The calculation method of the variable value sequence suspicion is characterized as follows:
[0069]
[0070] Among them, E(v i ,t j ) is the test case t j The variable v i The value sequence of Susp(E(v i ,t j )) is E(v i ,t j )'s suspiciousness, Imp(v i ,t j ,k) is the variable v calculated during interpretation iIn the test case t j The importance score of the kth value of the value sequence in . The larger the absolute value, the greater the influence of the variable value on the model prediction result.
[0071] In step S104, the variable value sequence suspicions are aggregated to obtain variable suspicions based on the variable value sequence.
[0072] The calculation formula of variable suspicion based on variable value sequence is:
[0073]
[0074] Where Susp(v) is the variable suspiciousness based on the variable value sequence, Susp(E(v,t j )) is the test case t j The suspiciousness of the value sequence of variable v in , there are m value sequences in total.
[0075] In step S105, initial defect location is performed on the target defective program according to the statement coverage information to obtain a statement risk value.
[0076] In some embodiments, performing initial defect location on a target defective program according to statement coverage information to obtain a statement risk value includes:
[0077] The forward slicing algorithm is improved by using the suspiciousness of the variable value sequence to obtain an improved backward slicing algorithm.
[0078] The sentence coverage information is processed using the improved backward slicing algorithm to obtain a sentence spectrum set;
[0079] Initial defect location is performed on the target defective program according to the statement spectrum set to obtain the statement risk value.
[0080] In the actual implementation process, Figure 2 and 5 As shown, the forward slicing algorithm is improved by using the suspiciousness of the variable value sequence to obtain an improved backward slicing algorithm, wherein the improved backward slicing algorithm is expressed as:
[0081] Slice v ={s1,s2,…,s n}
[0082] In the formula, Slice v is the improved backward slice of variable v, s i The statements contained in the backward slice.
[0083] Furthermore, the improved backward slicing algorithm is used to process the statement coverage information to obtain a set of related statements, that is, a set of statement spectra related to suspicious variables. Combined with the existing spectrum-based defect location technology, the target defective program is initially located according to the statement spectrum set to obtain a statement risk value.
[0084] In step S106, the variable value sequence suspicion and the statement risk value are aggregated to obtain the coverage-based variable suspicion.
[0085] In step S107, the final suspicion of each variable is solved according to the variable suspicion based on the variable value sequence and the variable suspicion based on the coverage.
[0086] In the actual execution process, the variable value sequence suspicion will also be used in the dynamic slicing of variables, and the statement risk value values of the spectrum-based defect location technology of the variable slices will be aggregated and normalized to obtain the coverage-based variable suspicion. Finally, the two suspicions will be weighted and summed to obtain the final suspicion of each variable, and the variables will be ranked according to the size of the suspicion.
[0087] The calculation formula of variable suspicion based on coverage is:
[0088]
[0089] Where SBFL(v) is the variable suspicion based on coverage, s i There are n statements in the improved backward slicing algorithm. is the normalized value of the statement risk value.
[0090] The calculation formula for the final suspiciousness of each variable is:
[0091] Suspicious(v)=SBFL(v)+α*Susp(v)
[0092] In the formula, SBFL(v) is the variable suspicion of variable v based on coverage, Susp(v) is the variable suspicion of variable v based on variable value sequence, and α is the weight parameter that controls the weight of the two. Among them, since the existing defect location based on spectrum and the location based on variable value sequence account for the highest positioning accuracy when the ratio of the final variable suspicion is 10 / 7, the weight parameter can be set to 0.7, that is, α = 0.7.
[0093] In step S108, the final suspiciousness of each variable is sorted to generate a sorting result, and the final defect location is obtained according to the sorting result.
[0094] like Figure 2As shown in FIG. 1 , the basic working process of the defect location auxiliary method for fine-grained software proposed in the embodiment of the present invention is as follows: first, the test case is run on the target defect source code, and the coverage information, the execution result of the test case and the value sequence of each variable are collected. The coverage information is used to calculate the spectrum of each statement, the execution result of the test case is used to determine whether the test case fails, and the variable value sequence is used to record the value change of each variable in each test case; the statement coverage information and variable information matrix of each test case are read from the database, the collected information is preprocessed to train the pre-built convolutional neural network model, and the LIME technology is used to train all The failed test cases are interpreted to obtain the importance score of each variable value and the suspicion of the variable value sequence; the suspicion of the variable value sequence is used to improve the backward slicing algorithm to obtain a set of related statements, that is, a set of statements related to suspicious variables, and the target defect program is initially defect-located according to the set of related statements to obtain the statement risk value, and then the variable suspicion based on coverage is calculated; finally, the suspicion of the variable value sequence is aggregated and weighted to obtain the variable suspicion based on the variable value sequence, and the variable suspicion based on the variable value sequence and the variable suspicion based on coverage are weighted summed and sorted, and the variable most likely to have defects is found from the sorting results.
[0095] In summary, the fine-grained software defect location auxiliary method proposed in the embodiment of the present invention calculates the suspicion of the variable value sequence based on convolutional neural network and explainable artificial intelligence technology, and uses the suspicion of the variable value sequence combined with the spectrum-based defect location to perform defect location at the variable level. Compared with the traditional defect location method, the defect suspicion of each variable is provided, which can help debuggers start looking for defects from the variables that are most likely to fail, which is more suitable for the actual debugging method of debuggers than only providing suspicious statements; the spectrum-based defect location technology relies on coverage information to distinguish failed test cases from successful test cases. If the coverage information is not obvious enough, the credibility will be reduced. In the present invention, the variable value sequence is used to improve the accuracy of defect location, and more coverage information during program runtime is introduced to assist in positioning. Compared with the more detailed information of the suspicion at the statement level, the positioning accuracy is improved; finally, a complete set of fine-grained software defect location auxiliary tools is formed, and users can use this method to achieve efficient and automatic defect location, and use it for program debugging and positioning work in actual production.
[0096] Next, a defect location auxiliary device based on fine-grained software proposed according to an embodiment of the present invention will be described with reference to the accompanying drawings.
[0097] Figure 6 It is a block diagram of a defect location auxiliary device based on fine-grained software according to an embodiment of the present invention.
[0098] like Figure 6As shown, the defect location auxiliary device 60 based on fine-grained software includes: an acquisition module 601, a training module 602, a local interpretation module 603, a first aggregation module 604, an initial positioning module 605, a second aggregation module 606, a solution module 607 and a final positioning module 608.
[0099] Among them, the acquisition module 601 is used to run multiple test cases on the target defective program to collect the statement coverage information, variable value sequence and actual execution results of each test case. The training module 602 is used to train the pre-built convolutional neural network model according to the variable value sequence and the actual execution results until the target training round is reached to obtain the trained convolutional neural network. The local interpretation module 603 is used to use the trained convolutional neural network to perform local interpretation on the false samples generated by all failed test cases to calculate the variable value sequence suspicion. The first aggregation module 604 is used to aggregate the variable value sequence suspicion to obtain the variable suspicion based on the variable value sequence. The initial positioning module 605 is used to perform initial defect positioning on the target defective program according to the statement coverage information to obtain the statement risk value. The second aggregation module 606 is used to aggregate the variable value sequence suspicion and the statement risk value to obtain the variable suspicion based on coverage. The solution module 607 is used to solve the final suspicion of each variable based on the variable suspicion based on the variable value sequence and the variable suspicion based on coverage. The final positioning module 608 is used to sort the final suspiciousness of each variable to generate a sorting result, and obtain the final defect location according to the sorting result.
[0100] In some embodiments, the training module 602 includes:
[0101] A preprocessing unit, used for preprocessing the variable value sequence to obtain a variable information matrix;
[0102] A construction unit, used to use the variable information matrix corresponding to each test case as a sample and the actual execution result corresponding to each test case as a label to construct a training set;
[0103] The first training unit is used to train a pre-built convolutional neural network model using a training set until a target training round is reached to obtain a trained convolutional neural network.
[0104] In some embodiments, the local interpretation module 603 includes:
[0105] A generating unit, used for generating a plurality of false variable value sequences in all failed test cases in a plurality of test cases;
[0106] A prediction unit, used to predict multiple false variable value sequences using the trained convolutional neural network to obtain a label corresponding to each false variable value sequence;
[0107] A second training unit is used to train a pre-built linear regression model according to a plurality of dummy variable value sequences and a label corresponding to each dummy variable value sequence to obtain a trained linear regression model;
[0108] The calculation unit is used to calculate the suspiciousness of the variable value sequence according to the trained linear regression model.
[0109] In some embodiments, the initial positioning module 605 includes:
[0110] An improvement unit, used for improving the forward slicing algorithm by using the suspiciousness of the variable value sequence to obtain an improved backward slicing algorithm;
[0111] A processing unit, used for processing the sentence coverage information by using an improved backward slicing algorithm to obtain a sentence spectrum set;
[0112] The initial positioning unit is used to perform initial defect positioning on the target defect program according to the statement spectrum set to obtain a statement risk value.
[0113] In some embodiments, the calculation formula for the coverage-based variable suspicion is:
[0114]
[0115] Among them, SBFL(v) is the variable suspicion based on coverage, s i There are n statements in the improved backward slicing algorithm, SBFL normalized (s i ) is the normalized value of the statement risk value.
[0116] In some embodiments, the calculation formula of the variable suspiciousness based on the variable value sequence is:
[0117]
[0118] Among them, Susp(v) is the variable suspicion based on the variable value sequence, Susp(E(v,t j )) is the test case t j The suspiciousness of the value sequence of variable v in , there are m value sequences in total.
[0119] It should be noted that the aforementioned explanation of the embodiment of the defect localization assisting method based on fine-grained software is also applicable to the defect localization assisting device based on fine-grained software of this embodiment, and will not be repeated here.
[0120] According to the fine-grained software defect location auxiliary device proposed in the embodiment of the present invention, the suspiciousness of the variable value sequence is calculated based on the convolutional neural network and the explainable artificial intelligence technology, and the suspiciousness of the variable value sequence is combined with the spectrum-based defect location to perform defect location at the variable level. Compared with the traditional defect location method, the defect suspiciousness of each variable is provided, which can help debuggers start to find defects from the variables that are most likely to fail, which is more suitable for the actual debugging method of debuggers than only providing suspicious statements; the spectrum-based defect location technology relies on coverage information to distinguish failed test cases from successful test cases. If the coverage information is not obvious enough, the credibility will be reduced. In the present invention, the variable value sequence is used to improve the accuracy of defect location, and more coverage information during program runtime is introduced to assist in location. Compared with the more detailed information of the statement-level suspiciousness, the accuracy of location is improved; finally, a complete set of fine-grained software defect location auxiliary tools is formed, and users can use this set of methods to achieve efficient and automatic defect location, and use it for program debugging and location work in actual production.
[0121] Figure 7 A schematic diagram of the structure of a fine-grained software defect location auxiliary device provided by an embodiment of the present invention. The fine-grained software defect location auxiliary device may include:
[0122] A memory 701 , a processor 702 , and a computer program stored in the memory 701 and executable on the processor 702 .
[0123] When the processor 702 executes the program, the fine-grained software defect location assistance method provided in the above embodiment is implemented.
[0124] Furthermore, the fine-grained software defect location auxiliary device also includes:
[0125] The communication interface 703 is used for communication between the memory 701 and the processor 702 .
[0126] The memory 701 is used to store computer programs that can be executed on the processor 702 .
[0127] The memory 701 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0128] If the memory 701, the processor 702 and the communication interface 703 are implemented independently, the communication interface 703, the memory 701 and the processor 702 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0129] Optionally, in a specific implementation, if the memory 701, the processor 702 and the communication interface 703 are integrated on a chip, the memory 701, the processor 702 and the communication interface 703 can communicate with each other through an internal interface.
[0130] The processor 702 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.
[0131] An embodiment of the present invention further provides a computer program product, and when the computer program / instructions are executed by a processor, the above-mentioned fine-grained software defect location assistance method is implemented.
[0132] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned fine-grained software defect location auxiliary method is implemented.
[0133] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0134] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "N" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0135] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present invention belong.
[0136] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or N wirings (electronic devices), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways as necessary and then storing it in a computer memory.
[0137] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0138] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0139] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0140] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.
Claims
1. A defect location auxiliary method based on fine-grained software, characterized in that: The following steps are involved: Run multiple test cases on the target defective program to collect statement coverage information, variable value sequence, and actual execution results of each test case; Training a pre-built convolutional neural network model according to the variable value sequence and the actual execution result until a target training round is reached to obtain a trained convolutional neural network; Using the trained convolutional neural network to locally interpret the fake samples generated by all failed test cases to calculate the suspiciousness of the variable value sequence; Aggregating the variable value sequence suspiciousness to obtain the variable suspiciousness based on the variable value sequence; Performing initial defect location on the target defective program according to the statement coverage information to obtain a statement risk value; Aggregating the variable value sequence suspicion and the statement risk value to obtain a coverage-based variable suspicion; Solving the final suspicion of each variable according to the variable suspicion based on the variable value sequence and the variable suspicion based on coverage; The final suspiciousness of each variable is sorted to generate a sorting result, and the final defect location is obtained according to the sorting result.
2. The defect location auxiliary method based on fine-grained software according to claim 1 is characterized in that: The pre-built convolutional neural network model is trained according to the variable value sequence and the actual execution result until a target training round is reached to obtain a trained convolutional neural network, including: Preprocessing the variable value sequence to obtain a variable information matrix; The variable information matrix corresponding to each test case is used as a sample, and the actual execution result corresponding to each test case is used as a label to construct a training set; The pre-constructed convolutional neural network model is trained using the training set until a target training round is reached to obtain the trained convolutional neural network.
3. The defect location auxiliary method based on fine-grained software according to claim 1 is characterized in that: The method of using the trained convolutional neural network to locally interpret the fake samples generated by all failed test cases to calculate the suspiciousness of the variable value sequence includes: generating a plurality of false variable value sequences in all failed test cases in the plurality of test cases; Using the trained convolutional neural network to predict the multiple false variable value sequences, and obtain a label corresponding to each false variable value sequence; Training a pre-built linear regression model according to the multiple dummy variable value sequences and the labels corresponding to each dummy variable value sequence to obtain a trained linear regression model; The suspiciousness of the variable value sequence is calculated according to the trained linear regression model.
4. The defect location auxiliary method based on fine-grained software according to claim 1 is characterized in that: The performing initial defect location on the target defective program according to the statement coverage information to obtain a statement risk value includes: The forward slicing algorithm is improved by using the suspiciousness of the variable value sequence to obtain an improved backward slicing algorithm; Processing the sentence coverage information using the improved backward slicing algorithm to obtain a sentence spectrum set; Initial defect location is performed on the target defective program according to the statement spectrum set to obtain the statement risk value.
5. The defect location auxiliary method based on fine-grained software according to claim 1 is characterized in that: The calculation formula of the coverage-based variable suspicion is: Among them, SBFL(v) is the variable suspicion based on coverage, s i There are n statements in the improved backward slicing algorithm, SBFL normalized (s i ) is the normalized value of the statement risk value.
6. The defect location auxiliary method based on fine-grained software according to claim 1 is characterized in that: The calculation formula of the variable suspiciousness based on the variable value sequence is: Among them, Susp(v) is the variable suspicion based on the variable value sequence, Susp(E(v,t j )) is the test case t j The suspiciousness of the value sequence of variable v in , there are m value sequences in total.
7. A defect location auxiliary device based on fine-grained software, characterized in that: include: A collection module is used to run multiple test cases on the target defective program to collect statement coverage information, variable value sequence and actual execution result of each test case; A training module, used for training a pre-built convolutional neural network model according to the variable value sequence and the actual execution result until a target training round is reached to obtain a trained convolutional neural network; A local explanation module, used to use the trained convolutional neural network to perform local explanation on the false samples generated by all failed test cases to calculate the suspiciousness of the variable value sequence; A first aggregation module, configured to aggregate the variable value sequence suspiciousness to obtain a variable suspiciousness based on the variable value sequence; An initial positioning module, used to perform initial defect positioning on a target defective program according to the statement coverage information to obtain a statement risk value; A second aggregation module, configured to aggregate the variable value sequence suspicion and the statement risk value to obtain a coverage-based variable suspicion; A solution module, used for solving the final suspicion of each variable according to the variable suspicion based on the variable value sequence and the variable suspicion based on coverage; The final positioning module is used to sort the final suspiciousness of each variable to generate a sorting result, and obtain the final defect positioning according to the sorting result.
8. A fine-grained software defect location auxiliary device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the fine-grained software-based defect localization auxiliary method as described in any one of claims 1 to 6.
9. A computer program product, characterized in that When the computer program / instruction is executed by a processor, the fine-grained software-based defect location assistance method described in any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the fine-grained software-based defect location assistance method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
A method and apparatus for software fault location based on program invariants
CN109144882A
Software defect positioning method and device based on convolutional neural network, and medium
CN110232023A
Software defect positioning method and device, electronic equipment and storage medium
CN112711537A
Software defect positioning method and system
CN116643982A
Local interpretation method of time sequence regression model based on Lime algorithm
CN117909682A