Software defect positioning auxiliary method and device based on variable value sequence

By introducing variable value sequences and convolutional neural network models into software defect location, calculating the suspiciousness of the variable value sequence and combining it with the statement risk value, the deficiencies of spectrum-based defect location technology in terms of location accuracy are solved, achieving a more efficient and Stable defect positioning effect.

CN119357029AActive Publication Date: 2025-01-24WUHAN UNIV
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411363095.3
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

Technical Problem

Spectrum-based defect positioning technology has shortcomings in positioning accuracy, mainly because there is little information source, which leads to poor positioning effect and stability in actual scenarios.

Method used

Adopting a supporting auxiliary method based on software deficiency positioning based on variable value sequences, through running multiple test cases on the target defect program, collect statement coverage information, variable value sequences, actual execution results, and variable dynamic slices. Then, use convolutional neural network model training and local interpretation technology to calculate the suspiciousness of the variable value sequence, and combine the risk value of the statement to calculate and sort the final risk value to achieve efficient defect positioning.

Benefits of technology

By introducing variable value sequence information, the positioning accuracy of spectrum-based defect location technology is improved, the problem of few information sources is solved, the positioning effect and stability are improved, and a complete set of software defect location based on variable value sequence is formed. Auxiliary tools.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357029A_ABST
    Figure CN119357029A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, in particular to a software defect positioning assisting method and device based on a variable value sequence, and the method comprises the steps: running a plurality of test cases on a defect program to collect statement coverage information, the variable value sequence, an actual execution result and the like of each test case; training a convolutional neural network model according to the variable value sequence and the actual execution result, and performing local explanation on false samples generated by all failed test cases by using a trained convolutional neural network to calculate a variable value sequence suspiciousness; performing initial defect positioning on the defect program according to the statement coverage information to obtain a statement risk value; and according to the variable value sequence suspiciousness and the statement risk value, solving the final risk value of the statement corresponding to each variable value sequence, carrying out sorting, and obtaining final defect location according to a sorting result. Therefore, the problems that an existing frequency spectrum-based defect positioning method is few in information source, poor in positioning effect and stability in an actual scene and the like are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a software defect location auxiliary method and device based on variable value sequence. Background Art

[0002] In the process of ensuring software quality, software debugging is a very important link. Generally speaking, software debugging includes three stages: defect location, defect understanding, and defect repair. Among these stages, defect location requires more time and cost. Because defect location must be completed before defect repair, the defect location task plays a very important role in the software debugging process. However, manual defect location is time-consuming and labor-intensive. Therefore, studying how to automate defect location and improve its effectiveness to better assist debuggers in improving debugging efficiency has become a research hotspot. In the field of automated defect location, researchers have conducted a number of studies and proposed a variety of 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. This allows debuggers to quickly focus on specific parts of the source code instead of checking the entire code base, thereby improving the productivity of debuggers.

[0003] Among these defect localization technologies, spectrum-based defect localization technology accounts for the largest proportion of research. This technology uses two types of information collected during the test case running process to determine the ranking of program entities (statements, branches, basic blocks, etc.): test results and program spectrum. The test result refers to whether the result after each test case is executed is consistent with the expectation, while the program spectrum usually refers to the binary coverage status of the program entity under study. Spectrum-based defect localization technology usually uses a metric formula to calculate the suspicion of the program entity based on the program spectrum information and sort it according to size to determine the program entity that is most likely to have defects, so that debuggers can start checking defects from the program entity with high suspicion. The more popular risk value assessment formulas include Tarantula, Ochiai, and D*.

[0004] In the spectrum-based defect localization technology, an execution trace matrix is ​​generally generated using the program's test case set. By calculating the execution results of each statement under each test case, a matrix about the program execution status can be obtained, and the spectrum-based defect localization technology locates defects in the program by analyzing this matrix. In order to improve the localization effect of this technology, a series of statement risk value measurement formulas have been proposed. These formulas are all based on the calculation of the suspiciousness of the statement coverage information. However, relying solely on coverage information in most cases cannot select defective statements from a large number of statements. There are many factors that will have a significant impact on the localization results. For example, when the coverage information cannot fully distinguish between failed test cases and successful test cases, the reliability of the spectrum-based defect localization technology will be affected; when there are a large number of similar failed test cases or successful test cases with great differences in their coverage information, too many program entities will be misdiagnosed as suspicious entities; some program entities containing defects may be covered by both failed and successful test cases, which makes their suspiciousness lower than that of program entities that are only covered by failed test cases but do not contain defects.

[0005] Therefore, in terms of positioning accuracy, the spectrum-based defect localization technology needs to be further improved. The main reason affecting its positioning accuracy is that for program entities with the same coverage information, the spectrum-based defect localization technology can only assign them the same risk value. Although researchers have alleviated this problem by introducing method call information, the frequency of program entity execution, program control flow graph information, statement execution context information, and code metric information, there is still a lack of research on more program runtime information. Studies have shown that the most important information during manual debugging is often related to variable values. Therefore, introducing variable value information into the defect localization process of spectrum-based defect localization technology is a method worth considering to enhance the effect of spectrum-based defect localization technology. How to design a software defect localization auxiliary method based on variable value sequences is an important issue. Summary of the invention

[0006] The present invention provides a software defect location auxiliary method and device based on variable value sequence, so as to solve the problems of the existing defect location method based on spectrum having few information sources and poor location effect and stability in actual scenarios.

[0007] The first aspect of the present invention provides a software defect location assistance method based on variable value sequence, comprising the following steps: running multiple test cases on a target defective program to collect statement coverage information, variable value sequence, actual execution result and variable dynamic slice of each test case; training 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; using 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; performing initial defect location on the target defective program according to the statement coverage information to obtain a statement risk value; parsing the variable dynamic slice to obtain the statement corresponding to each variable value sequence; solving the final risk value of the statement corresponding to each variable value sequence according to the suspiciousness of the variable value sequence and the statement risk value; sorting the final risk values ​​of the statements corresponding to each variable value sequence to generate a sorting result, and obtaining the final defect location according to the sorting result.

[0008] 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:

[0009] Preprocessing the variable value sequence to obtain a variable information matrix;

[0010] Taking the variable information matrix corresponding to each test case as a sample, taking the actual execution result corresponding to each test case as a label, and constructing the sample and the label into a training set;

[0011] 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.

[0012] 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:

[0013] generating a plurality of false variable value sequences in all failed test cases in the plurality of test cases;

[0014] 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;

[0015] 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;

[0016] The suspiciousness of the variable value sequence is calculated according to the trained linear regression model.

[0017] Optionally, the calculation formula for the variable value sequence suspiciousness is:

[0018]

[0019] 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 i In the test case t j The importance score of the kth value in the sequence of values ​​in .

[0020] Optionally, solving the final risk value of the statement corresponding to each variable value sequence according to the variable value sequence suspicion and the statement risk value includes:

[0021] Updating the statement risk value using the variable value sequence suspicion to obtain an updated statement risk value;

[0022] The final risk value of the statement corresponding to each variable value sequence is solved according to the updated statement risk value.

[0023] Optionally, the solution formula for the final risk value is:

[0024]

[0025] Where s is a statement, Susp(s) is the final risk value of the statement, m is the number of failed test cases covering statement s, |V s | is the set of all variables related to statement s in the failed test case, For test case t j SBFL(s) is the average suspiciousness of all variable value sequences related to statement s, and SBFL(s) is the statement risk value calculated by using multiple spectrum-based defect location methods.

[0026] The second aspect of the present invention provides a software defect location auxiliary device based on variable value sequence, including: a collection module, which is used to run multiple test cases on a target defective program to collect statement coverage information, variable value sequence, actual execution result and variable dynamic slice of each test case; a training module, which is 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, which is 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; an initial positioning module, which is used to perform initial defect positioning on the target defective program according to the statement coverage information to obtain a statement risk value; a parsing module, which is used to parse the variable dynamic slice to obtain the statement corresponding to each variable value sequence; a solution module, which is used to solve the final risk value of the statement corresponding to each variable value sequence according to the suspiciousness of the variable value sequence and the statement risk value; a final positioning module, which is used to sort the final risk values ​​of the statements corresponding to each variable value sequence to generate a sorting result, and obtain the final defect positioning according to the sorting result.

[0027] The third aspect of the present invention provides a software defect location assistance device, including: 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 software defect location assistance method based on variable value sequence as described in the above embodiment.

[0028] A fourth aspect of the present invention provides a computer program product, which, when executed by a processor, implements the above-mentioned software defect location assistance method based on variable value sequence.

[0029] 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 software defect location assistance method based on variable value sequence.

[0030] The software defect location auxiliary method and device based on variable value sequence proposed in the embodiment of the present invention calculate the suspicion of variable value sequence based on convolutional neural network and explainable artificial intelligence technology, and use the suspicion of variable value sequence to enhance the suspicion calculated by spectrum-based defect location technology; compared with traditional defect location methods, when coverage information cannot fully distinguish between failed test cases and successful test cases, the reliability of spectrum-based defect location technology will be affected. The present invention uses variable value sequence to enhance the accuracy of defect location, and combines coverage information to assist in positioning. This method improves the positioning accuracy of spectrum-based defect location, solves the problem of few sources of spectrum-based defect location information, and improves its positioning effect and stability in actual scenarios; finally, a complete set of software defect location auxiliary tools based on variable value sequence is formed, and users can use this set of methods to achieve efficient and automatic defect location, and use it for program debugging and positioning work in actual production.

[0031] 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

[0032] 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:

[0033] Figure 1 A flowchart of a software defect location auxiliary method based on variable value sequence provided by an embodiment of the present invention;

[0034] Figure 2 A specific execution diagram of a software defect location auxiliary method based on variable value sequence provided by an embodiment of the present invention;

[0035] Figure 3 The overall flow chart of variable value sequence preprocessing provided by the embodiment of the present invention;

[0036] Figure 4 A pseudo code diagram for converting a variable value sequence provided by an embodiment of the present invention into a two-dimensional matrix form;

[0037] Figure 5 A schematic diagram of executing the slope analysis algorithm provided by an embodiment of the present invention;

[0038] Figure 6 A schematic diagram of the network architecture of a convolutional neural network provided in an embodiment of the present invention;

[0039] Figure 7 A pseudo code schematic diagram of a failed test case interpretation algorithm based on LIME provided in an embodiment of the present invention;

[0040] Figure 8 A block diagram of a software defect location auxiliary device based on variable value sequence provided by an embodiment of the present invention;

[0041] Fig. 9 A schematic diagram of the structure of a software defect location auxiliary device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0042] 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.

[0043] The following describes a software defect location assisting method and device based on a variable value sequence according to an embodiment of the present invention with reference to the accompanying drawings.

[0044] Figure 1 A flowchart of a software defect location assistance method based on variable value sequence provided by an embodiment of the present invention.

[0045] like Figure 1 As shown, the software defect location auxiliary method based on variable value sequence includes the following steps:

[0046] In step S101, multiple test cases are run on the target defective program to collect statement coverage information, variable value sequence, actual execution result and variable dynamic slice of each test case.

[0047] In the actual implementation process, Figure 2 As shown, when multiple test cases are run on the target defective program, the coverage information collection tool and debugger will record the coverage information and variable value sequence during the program running process and store them in the database. The dynamic slice collection tool obtains the dynamic slice of each variable and stores it in the database, and then the statement coverage information, variable value sequence, actual execution result and variable dynamic slice of each test case can be read from the database.

[0048] The variable value sequence is:

[0049]

[0050] 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(vi ,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 j The 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.

[0051] 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.

[0052] In some embodiments, a 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:

[0053] Preprocess the variable value sequence to obtain the variable information matrix;

[0054] The variable information matrix corresponding to each test case is used as a sample, the actual execution result corresponding to each test case is used as a label, and the samples and labels are constructed into a training set;

[0055] 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.

[0056] In the actual implementation process, Figure 3 As shown, by preprocessing the variable value sequence to generate a non-numeric variable value sequence, from left to right, the first step represents the digitization of the non-numeric variable value sequence, and the second step represents the modification of the variable value sequence to a fixed length. Figure 4 As shown, the value of the fixed length is: based on the sliding window slope analysis algorithm, the 75% quantile of the length of the entire variable value sequence of the current test case is taken as the value of the fixed length. When the variable value sequence is truncated to ensure that the length is consistent with the fixed length, it is necessary to ensure that the retained part can reflect the main change trend of the variable value sequence to ensure the effectiveness of the truncation operation.

[0057] Furthermore, if Figure 5As shown in the figure, the variable value sequence matrix can be generated by normalizing the non-numeric variable value sequence. The red nodes in the figure represent variable value sequences of different data types, and the gray nodes represent operations on the variable value sequence. The variable information matrix is:

[0058]

[0059] 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.

[0060] 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.

[0061] Among them, Figure 6 As shown in the figure, 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, wherein 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 of length 5, and the second convolutional layer contains 64 convolution kernels of length 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:

[0062] 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:

[0063] LR=LR*DropRate (Epoch+1) / EpochDrop

[0064] 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.

[0065] 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.

[0066] In some embodiments, the trained convolutional neural network is used to locally interpret the fake samples generated by all failed test cases to calculate the suspiciousness of the variable value sequence, including:

[0067] Generate multiple sequences of false variable values ​​in all failed test cases in multiple test cases;

[0068] Use the trained convolutional neural network to predict multiple false variable value sequences and obtain the label corresponding to each false variable value sequence;

[0069] Training 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;

[0070] Calculate the suspiciousness of the variable value sequence based on the trained linear regression model.

[0071] In the actual implementation process, Figure 2 and 7 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:

[0072] D={<d1,y1> ,<d2,y2> ,…, <d n ,y n >}

[0073] 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

[0074] 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".

[0075] 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:

[0076]

[0077] Where p and q represent two different variable value sequences of the same length.

[0078] 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:

[0079]

[0080] 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 i In 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.

[0081] In step S104, initial defect location is performed on the target defective program according to the statement coverage information to obtain a statement risk value.

[0082] In the actual execution process, combined with the existing spectrum-based defect location technology, the target defect program is initially located according to the statement coverage information to obtain the statement risk value. The calculation method of the statement risk value is characterized as follows:

[0083]

[0084] Among them, Tarantula(s), Ochiai(s) and D * The calculation methods of (s) are respectively characterized as follows:

[0085]

[0086] Where SBFL(s) represents the statement risk value obtained by combining three spectrum-based risk value calculation formulas, N CF Indicates the number of failed test cases covering the current program entity, N UF Indicates the number of failed test cases that do not cover the current program entity, N CS Indicates the number of successful test cases covering the current program entity, N FRepresents the number of failed test cases, N S Represents the number of successful test cases, Indicates N CF The value after the weight is adjusted.

[0087] In step S105, the variable dynamic slice is parsed to obtain the statement corresponding to each variable value sequence.

[0088] Specifically, Figure 2 As shown, the dynamic slice of each variable is read from the database, and the relationship between the variable and the statement is obtained based on the dynamic slice of the variable, that is, the statement corresponding to each variable value sequence.

[0089] In step S106, the final risk value of the statement corresponding to each variable value sequence is solved according to the variable value sequence suspicion and the statement risk value.

[0090] In some embodiments, solving the final risk value of the statement corresponding to each variable value sequence according to the variable value sequence suspicion and the statement risk value includes:

[0091] The statement risk value is updated using the variable value sequence suspiciousness to obtain an updated statement risk value;

[0092] The final risk value of the statement corresponding to each variable value sequence is solved according to the updated statement risk value.

[0093] In the actual implementation process, Figure 2 As shown, through the correlation between different variable value sequences and statements, the suspiciousness of the variable value sequence is used to update the risk value of the statement based on the spectrum defect location. The final risk value calculation method for solving the statement corresponding to each variable value sequence according to the updated statement risk value is characterized as follows:

[0094]

[0095] Where s represents a statement, Susp(s) represents the final suspiciousness of the statement, m represents the number of failed test cases covering statement s, |V s | represents the set of variables related to statement s in the failed test case. Represents test case t j SBFL(s) is the average suspiciousness of all variable value sequences related to statement s, and SBFL(s) is the statement risk value calculated by using multiple spectrum-based defect location methods.

[0096] In step S107, the final risk values ​​of the statements corresponding to each variable value sequence are sorted to generate a sorting result, and the final defect location is obtained according to the sorting result.

[0097] like Figure 2 As shown, the basic working process of the software defect location auxiliary method based on variable value sequence proposed in the embodiment of the present invention is: first, there is an information collection stage, in which test cases are run on the target defect source code, and data generated when the program is running is collected, including coverage information generated during the execution of the test cases, the execution results of the test cases, the value sequence of program variables, and dynamic slicing of variables; then there is an information processing stage, in which the collected variable value sequence information is preprocessed to train a pre-built convolutional neural network model, including the risk value of the spectrum-based defect location technology of the calculation statement, and the collected variable value sequence is converted into a variable information matrix; finally, the convolutional neural network is trained, and the trained network model can fit the complex relationship between the variable value sequence and the test case execution result, and use the explainable artificial intelligence technology to calculate the importance of different variable values ​​in predicting the test case execution result, so as to calculate the suspiciousness of the variable value sequence. At the same time, combined with the existing spectrum-based defect localization technology, an enhanced spectrum-based defect localization technology based on variable value sequence is proposed. Through the correlation between different variable value sequences and statements, the suspiciousness of the variable value sequence is used to update the risk value of the spectrum-based defect localization of the statement, and the enhanced statement risk value and new statement ranking are obtained, so as to perform the final defect localization according to the sorting results.

[0098] In summary, according to the software defect location auxiliary method based on variable value sequence proposed in the embodiment of the present invention, the suspicion of the variable value sequence is calculated based on convolutional neural network and explainable artificial intelligence technology, and the suspicion of the variable value sequence is used to enhance the suspicion calculated by the spectrum-based defect location technology; compared with the traditional defect location method, when the coverage information cannot fully distinguish between failed test cases and successful test cases, the reliability of the spectrum-based defect location technology will be affected. The present invention uses the variable value sequence to enhance the accuracy of defect location, and combines the coverage information to assist in positioning. This method improves the positioning accuracy of spectrum-based defect location, solves the problem of few sources of spectrum-based defect location information, and improves its positioning effect and stability in actual scenarios; finally, a complete set of software defect location auxiliary tools based on variable value sequence 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.

[0099] Next, a software defect location auxiliary device based on variable value sequence proposed according to an embodiment of the present invention will be described with reference to the accompanying drawings.

[0100] Figure 8 It is a block diagram of a software defect location auxiliary device based on variable value sequence according to an embodiment of the present invention.

[0101] like Figure 8As shown, the software defect location auxiliary device 80 based on variable value sequence includes: a collection module 801, a training module 802, a local interpretation module 803, an initial location module 804, an analysis module 805, a solution module 806 and a final location module 807.

[0102] Among them, the acquisition module 801 is used to run multiple test cases on the target defective program to collect the statement coverage information, variable value sequence, actual execution result and variable dynamic slice of each test case. The training module 802 is used to train the 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 the trained convolutional neural network. The local interpretation module 803 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 suspiciousness of the variable value sequence. The initial positioning module 804 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 parsing module 805 is used to parse the variable dynamic slice to obtain the statement corresponding to each variable value sequence. The solution module 806 is used to solve the final risk value of the statement corresponding to each variable value sequence according to the suspiciousness of the variable value sequence and the statement risk value. The final positioning module 807 is used to sort the final risk value of the statement corresponding to each variable value sequence to generate a sorting result, and obtain the final defect positioning according to the sorting result.

[0103] In some embodiments, the training module 802 includes:

[0104] A preprocessing unit, used for preprocessing the variable value sequence to obtain a variable information matrix;

[0105] A construction unit, used to take the variable information matrix corresponding to each test case as a sample, take the actual execution result corresponding to each test case as a label, and construct the sample and the label into a training set;

[0106] 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.

[0107] In some embodiments, the local interpretation module 803 includes:

[0108] A generating unit, used for generating a plurality of false variable value sequences in all failed test cases in a plurality of test cases;

[0109] 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;

[0110] 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;

[0111] The calculation unit is used to calculate the suspiciousness of the variable value sequence according to the trained linear regression model.

[0112] The calculation formula of the variable value sequence suspicion is:

[0113]

[0114] 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 i In the test case t j The importance score of the kth value in the sequence of values ​​in .

[0115] In some embodiments, the solution module 806 includes:

[0116] An updating unit, used for updating the statement risk value by using the suspiciousness of the variable value sequence to obtain an updated statement risk value;

[0117] The solving unit is used to solve the final risk value of the statement corresponding to each variable value sequence according to the updated statement risk value.

[0118] The final risk value solution formula is:

[0119]

[0120] Where s is a statement, Susp(s) is the final risk value of the statement, m is the number of failed test cases covering statement s, |V s | is the set of all variables related to statement s in the failed test case, For test case t j SBFL(s) is the average suspiciousness of all variable value sequences related to statement s, and SBFL(s) is the statement risk value calculated by using multiple spectrum-based defect location methods.

[0121] It should be noted that the aforementioned explanation of the embodiment of the software defect localization assistance method based on variable value sequence is also applicable to the software defect localization assistance device based on variable value sequence of this embodiment, and will not be repeated here.

[0122] According to the software defect location auxiliary device based on variable value sequence proposed in the embodiment of the present invention, the suspicion of the variable value sequence is calculated based on convolutional neural network and explainable artificial intelligence technology, and the suspicion of the variable value sequence is used to enhance the suspicion calculated by the spectrum-based defect location technology; compared with the traditional defect location method, when the coverage information cannot fully distinguish between failed test cases and successful test cases, the reliability of the spectrum-based defect location technology will be affected. The present invention uses the variable value sequence to enhance the accuracy of defect location, and combines the coverage information to assist in positioning. This method improves the positioning accuracy of the spectrum-based defect location, solves the problem of few sources of spectrum-based defect location information, and improves its positioning effect and stability in actual scenarios; finally, a complete set of software defect location auxiliary tools based on variable value sequence is formed, and users can use this set of methods to achieve efficient and automatic defect location, and use it for program debugging and positioning work in actual production.

[0123] Fig. 9 A schematic diagram of the structure of a software defect location auxiliary device provided by an embodiment of the present invention. The software defect location auxiliary device may include:

[0124] A memory 901 , a processor 902 , and a computer program stored in the memory 901 and executable on the processor 902 .

[0125] When the processor 902 executes the program, the software defect location assistance method based on the variable value sequence provided in the above embodiment is implemented.

[0126] Furthermore, the electronic device further comprises:

[0127] The communication interface 903 is used for communication between the memory 901 and the processor 902 .

[0128] The memory 901 is used to store computer programs that can be executed on the processor 902 .

[0129] The memory 901 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.

[0130] If the memory 901, the processor 902 and the communication interface 903 are implemented independently, the communication interface 903, the memory 901 and the processor 902 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, Fig. 9 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.

[0131] Optionally, in a specific implementation, if the memory 901, the processor 902 and the communication interface 903 are integrated on a chip, the memory 901, the processor 902 and the communication interface 903 can communicate with each other through an internal interface.

[0132] The processor 902 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.

[0133] 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 software defect location assistance method based on variable value sequence is implemented.

[0134] 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 software defect location auxiliary method based on variable value sequence is implemented as described above.

[0135] 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.

[0136] 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.

[0137] 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.

[0138] 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.

[0139] 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.

[0140] 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.

[0141] 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.

[0142] 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 software defect location auxiliary method based on variable value sequence, 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, actual execution results, and variable dynamic slices for 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; Performing initial defect location on the target defective program according to the statement coverage information to obtain a statement risk value; Parsing the variable dynamic slice to obtain a statement corresponding to each variable value sequence; Calculating a final risk value of the statement corresponding to each variable value sequence according to the variable value sequence suspicion and the statement risk value; The final risk values ​​of the statements corresponding to each variable value sequence are sorted to generate a sorting result, and the final defect location is obtained according to the sorting result.

2. The software defect location auxiliary method based on variable value sequence according to claim 1, 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; Taking the variable information matrix corresponding to each test case as a sample, taking the actual execution result corresponding to each test case as a label, and constructing the sample and the label into 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 software defect location auxiliary method based on variable value sequence according to claim 1, 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 software defect location auxiliary method based on variable value sequence according to claim 3 is characterized in that: The calculation formula of the variable value sequence suspiciousness is: 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 i In the test case t j The importance score of the kth value in the sequence of values ​​in .

5. The software defect location auxiliary method based on variable value sequence according to claim 1, characterized in that: The step of solving the final risk value of the statement corresponding to each variable value sequence according to the variable value sequence suspicion and the statement risk value includes: Updating the statement risk value using the variable value sequence suspicion to obtain an updated statement risk value; The final risk value of the statement corresponding to each variable value sequence is solved according to the updated statement risk value.

6. The software defect location auxiliary method based on variable value sequence according to claim 5, characterized in that: The solution formula for the final risk value is: Where s is a statement, Susp(s) is the final risk value of the statement, m is the number of failed test cases covering statement s, |V s | is the set of all variables related to statement s in the failed test case, For test case t j SBFL(s) is the average suspiciousness of all variable value sequences related to statement s, and SBFL(s) is the statement risk value calculated by using multiple spectrum-based defect location methods.

7. A software defect location auxiliary device based on variable value sequence, 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, actual execution result and variable dynamic slice 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; 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 parsing module, used for parsing the variable dynamic slice to obtain a statement corresponding to each variable value sequence; A solution module, used for solving the final risk value of the statement corresponding to each variable value sequence according to the suspiciousness of the variable value sequence and the statement risk value; The final positioning module is used to sort the final risk values ​​of the statements corresponding to each variable value sequence to generate a sorting result, and obtain the final defect positioning according to the sorting result.

8. A 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 software defect location assisting method based on variable value sequence 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 software defect location auxiliary method based on variable value sequence 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 software defect location assistance method based on variable value sequence as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method and device for carrying out context positioning on software fault

    CN106339288A

  • A method and apparatus for software fault location based on program invariants

    CN109144882A

  • Software fault positioning method based on frequency spectrum

    CN110008120A

  • Software defect positioning method and device, electronic equipment and storage medium

    CN112711537A

  • Software bug positioning method and device based on variable separation

    CN114741302A