Software defect localization assistance method and device based on variable value sequence

Through a software defect localization method based on variable value sequences, utilizing convolutional neural networks and explainable artificial intelligence technology, the problem of insufficient information in existing spectrum localization technology is solved, achieving more efficient defect localization and debugging.

CN119357029BActive Publication Date: 2025-10-10WUHAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411363095.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2025-10-10
Estimated Expiration
2044-09-27

AI Technical Summary

Technical Problem

Existing spectrum-based software defect localization technology has deficiencies in positioning accuracy, especially when coverage information cannot fully distinguish between failed and successful test cases. The positioning effect and stability are poor and there is a lack of sufficient information sources.

Method used

A software defect location method based on variable value sequences is adopted. By utilizing convolutional neural networks and explainable artificial intelligence technology, the suspiciousness of variable value sequences is calculated through training models. Combined with statement coverage information, the statement risk value is updated to improve location accuracy.

Benefits of technology

It improves the accuracy and stability of software defect location, forms a complete set of automated defect location tools, and improves debugging efficiency and location effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357029B_ABST
    Figure CN119357029B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of computer, particularly relates to a kind of based on variable value sequence software defect positioning auxiliary method and device, wherein, method includes: running multiple test cases on defect program, to collect the statement coverage information, variable value sequence, actual execution result etc. of each test case;According to variable value sequence and actual execution result, train convolutional neural network model, utilize the convolutional neural network after training to the local interpretation of the false sample generated by all failure test cases, to calculate variable value sequence suspiciousness;According to statement coverage information, initial defect positioning is carried out to defect program, and statement risk value is obtained;According to variable value sequence suspiciousness and statement risk value, the final risk value of the statement corresponding to each variable value sequence is solved to sort, and final defect positioning is obtained according to the sorting result. Therefore, it solves the problems that the information source of the existing defect positioning method based on spectrum is few, and the positioning effect and stability in actual scene are poor.
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 sequences. Background Art

[0002] Software debugging is a crucial step in ensuring software quality. Generally speaking, software debugging consists of three phases: defect location, defect understanding, and defect repair. Of these phases, defect location requires the most time and effort. Because defect location must be completed before defect repair, it plays a crucial role in the software debugging process. However, manual defect location is time-consuming and labor-intensive. Therefore, research on how to automate defect location and improve its effectiveness to better assist debuggers and improve debugging efficiency has become a hot topic. Researchers have conducted numerous studies in the field of automated defect location and proposed various defect location techniques, including those based on spectrum, program slicing, and machine learning. These techniques typically leverage information from failed and successful test cases to output a list of "suspicious" locations—code locations that may cause defects. This allows debuggers to quickly focus on specific sections of the source code rather than examining the entire codebase, thereby improving debugger productivity.

[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 execution process to determine the ranking of program entities (statements, branches, basic blocks, etc.): test results and program spectrum. Test results refer to whether the results after executing each test case are consistent with expectations, while 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 program entities based on program spectrum information and sort them by size to determine the program entities most likely to have defects, allowing debuggers to start checking defects from program entities with high suspicion. Popular risk value assessment formulas include Tarantula, Ochiai, and D*.

[0004] In spectrum-based defect localization techniques, a program's test case set is typically used to generate an execution trace matrix. By calculating the execution results of each statement under each test case, a matrix representing the program's execution status is obtained. Spectrum-based defect localization techniques then analyze this matrix to locate defects within the program. To improve the effectiveness of this technique, a series of statement risk value metric formulas have been proposed. These formulas calculate suspicion based on statement coverage information. However, relying solely on coverage information often fails to single out defective statements from a large pool of statements. Several factors can significantly impact localization results. For example, the reliability of spectrum-based defect localization techniques is compromised when coverage information cannot adequately distinguish between failing and successful test cases. The presence of a large number of similar failing test cases or successful test cases with significantly different coverage information can lead to excessive numbers of program entities being misdiagnosed as suspicious. Some program entities containing defects may be covered by both failing and successful test cases, making them less suspicious than program entities covered only by failing test cases but not containing defects.

[0005] Therefore, the accuracy of spectrum-based defect localization technology needs to be further improved. The main reason affecting its localization accuracy is that spectrum-based defect localization technology can only assign the same risk value to program entities with the same coverage information. 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 metrics information, research on more extensive program runtime information is still lacking. 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 effectiveness 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 existing spectrum-based defect location methods such as few information sources, poor location effect and stability in actual scenarios, etc.

[0007] The first aspect of the present invention provides an auxiliary method for software defect location 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 suspicion 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 suspicion of the variable value sequence and the statement risk value; sorting the final risk value of the statement 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] 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 the labels are constructed into a training set;

[0011] The pre-built convolutional neural network model is trained using the training set until a target number of training rounds is reached to obtain the trained convolutional neural network.

[0012] Optionally, using the trained convolutional neural network to perform local interpretation on fake samples generated by all failed test cases to calculate the suspiciousness of variable value sequences 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 based on the trained linear regression model.

[0017] Optionally, the calculation formula for the variable value sequence suspicion 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 suspicion, 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 value sequence.

[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 final risk value is calculated as follows:

[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] According to a second aspect of the present invention, an embodiment provides a software defect location assistance device based on variable value sequences, comprising: an acquisition module for running multiple test cases on a target defective program to collect statement coverage information, variable value sequences, actual execution results, and variable dynamic slices of each test case; a training module for training a pre-built convolutional neural network model according to the variable value sequences and the actual execution results until a target training round is reached to obtain a trained convolutional neural network; a local interpretation module for 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 sequences; an initial positioning module for performing initial defect positioning on the target defective program according to the statement coverage information to obtain a statement risk value; a parsing module for parsing the variable dynamic slices to obtain a statement corresponding to each variable value sequence; a solution module for solving a 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; and a final positioning module for sorting the final risk values ​​of the statements corresponding to each variable value sequence to generate a sorting result, and obtaining a final defect location according to the sorting result.

[0027] An embodiment of the third aspect of the present invention provides a software defect location assistance device, including: a memory, a processor, and a computer program stored on the memory and runnable 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. When the computer program / instruction is executed by a processor, the computer program / instruction 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 assistance method and device based on variable value sequence proposed in the embodiment of the present invention calculates the suspicion of variable value sequence based on convolutional neural network and explainable artificial intelligence technology, and uses 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 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; ultimately, a complete set of software defect location assistance tools based on variable value sequence is formed. Users can use this method 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 set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may 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 readily 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 assistance method based on variable value sequences provided by an embodiment of the present invention;

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

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

[0036] Figure 4 A pseudo code diagram showing conversion of a variable value sequence provided in 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 by an embodiment of the present invention;

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

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

[0041] Figure 9 This is a structural diagram of a software defect location auxiliary device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0042] The following describes embodiments of the present invention in detail. Examples of the embodiments 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 explain the present invention, but are not to be construed as limiting the present invention.

[0043] The following describes a software defect location assistance method and apparatus based on variable value sequences 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 sequences 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 in the figure, 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. 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] Among them, the variable value sequence is:

[0049]

[0050] Among them, the set of all variables in the defective program P to be tested is recorded as V, and V 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 A sequence of values ​​(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 initial value of the i-th variable is , and the variables are arranged in lexicographic order). After m value changes, the program terminates, and 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 results until the target training rounds are 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 results 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 rounds are reached to obtain the trained convolutional neural network.

[0056] In the actual implementation process, Figure 3 As shown in , by preprocessing the variable value sequence 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. Figure 4 As shown, the value of the fixed length is: based on the slope analysis algorithm of the sliding window, 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 performed 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 used as a sample, and the execution result corresponding to the test case is used as a label (0 means pass, 1 means 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, such as 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. 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. The gradient descent algorithm is used to update the weight of each neuron, and the dynamic learning rate LR is adopted:

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

[0064] Epoch represents the number of training rounds, DropRate represents the amount of each update of the learning rate LR, 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, a 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 labels 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 generate several "fake samples" near the samples. 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 y 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 value of all variable value importance scores in the variable value sequence is summed to calculate 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 suspicion, 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, the existing spectrum-based defect location technology is combined to perform initial defect location on the target defect program based on 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 FN represents the number of failed test cases S N represents the number of failed test cases N represents the number of failed test cases CF The value after adjusting the weight of N.

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

[0088] Specifically, as shown in Figure 2 , the dynamic slice of each variable is read from the database, and the relationship between the variable obtained based on the dynamic slice of the variable and the statement, i.e. 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 suspiciousness 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 suspiciousness and the statement risk value comprises:

[0091] updating the statement risk value with the variable value sequence suspiciousness to obtain an updated statement risk value;

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

[0093] In actual execution process, as shown in Figure 2 , by 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-based defect positioning, and the final risk value of the statement corresponding to each variable value sequence is solved according to the updated statement risk value. The calculation method is characterized as:

[0094]

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

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

[0097] As Figure 2 As shown, the basic working process of the software defect location auxiliary method based on variable value sequence proposed in an embodiment of the present invention is as follows: first, there is an information collection stage, in which test cases are run on the target defect source code, and data generated during program execution is collected, including coverage information generated during the test case execution, test case execution results, program variable value sequences, and dynamic slices 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 calculating the risk value of the spectrum-based defect location technology of the statement, and converting the collected variable value sequence 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 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 sequences 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, the software defect location assistance method based on variable value sequence proposed in an embodiment of the present invention calculates the suspicion of variable value sequence based on convolutional neural network and explainable artificial intelligence technology, and uses 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 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 assistance tools based on variable value sequence is formed. 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 assisting device based on variable value sequence proposed in 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: an acquisition 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] The acquisition module 801 is used to run multiple test cases on the target defective program to collect statement coverage information, variable value sequences, actual execution results, and variable dynamic slices for each test case. The training module 802 is used to train a pre-built convolutional neural network model based on the variable value sequences and actual execution results until the target training rounds are reached, resulting in a 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 variable value sequence suspicion. The initial location module 804 is used to perform initial defect location on the target defective program based on the statement coverage information to obtain statement risk values. The parsing module 805 is used to parse the variable dynamic slices to obtain the statements corresponding to each variable value sequence. The solution module 806 is used to determine the final risk value of the statement corresponding to each variable value sequence based on the variable value sequence suspicion and statement risk value. The final location module 807 is used to sort the final risk values ​​of the statements corresponding to each variable value sequence to generate a sorted result, and then obtain the final defect location based on the sorted 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 is 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 samples and labels 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 generation unit, for generating multiple false variable value sequences in all failed test cases in multiple test cases;

[0109] A prediction unit is 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 based on the trained linear regression model.

[0112] The calculation formula for the suspiciousness of the variable value sequence 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 suspicion, 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 value sequence.

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

[0116] An updating unit, configured to update the statement risk value 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 assisting method based on variable value sequence is also applicable to the software defect localization assisting device based on variable value sequence of this embodiment, and will not be repeated here.

[0122] According to the software defect location assistance device based on variable value sequences proposed in an embodiment of the present invention, the suspicion of the variable value sequence is calculated based on convolutional neural networks 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 traditional defect location methods, 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 it with 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; ultimately, a complete set of software defect location assistance tools based on variable value sequences is formed. Users can use this method to achieve efficient and automatic defect location and use it for program debugging and positioning work in actual production.

[0123] Figure 9 A schematic diagram of the structure of a software defect location assistance device provided by an embodiment of the present invention. The software defect location assistance 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 includes:

[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 run 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, processor 902, and communication interface 903 are implemented independently, the communication interface 903, memory 901, and processor 902 can be connected to each other via a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (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 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or 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), 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. When the computer program / instructions are executed by a processor, the computer program / instructions implement the above-mentioned software defect location assistance method based on variable value sequences.

[0134] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the program implements the above-mentioned software defect location assistance method based on variable value sequence.

[0135] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" 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 expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples without contradiction.

[0136] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of technical features indicated. Thus, a feature specified as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present invention, "N" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0137] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or N executable instructions for implementing a custom logical function or step of a process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may be performed out of the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention pertain.

[0138] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or N wires (electronic devices), a portable computer disk cartridge (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and a portable compact disc 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 can be obtained electronically by optically scanning the paper or other medium and then editing, interpreting or processing it in other suitable ways as necessary, and then storing it in a computer memory.

[0139] It should be understood that various parts of the present invention can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiment, the N steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used: a discrete logic circuit having logic gate circuits for implementing logic functions on data signals, an application-specific integrated circuit having suitable combinational logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0140] Those skilled in the art will understand that all or part of the steps in the method of the above embodiment can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.

[0141] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing module, or each unit may exist physically separately, or two or more units may be integrated into a single module. The aforementioned integrated modules may be implemented in the form of hardware or in the form of software functional modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they 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 is understood that the above embodiments are exemplary and are not to be construed as limiting the present invention. Persons skilled in the art may make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.

Claims

1. A software defect location assistance 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 sequences, 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 perform local interpretation on 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 a 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; 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 the labels are constructed into a training set; The pre-built convolutional neural network model is trained using the training set until a target number of training rounds 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 based on the trained linear regression model.

4. The software defect location auxiliary method based on variable value sequence according to claim 3, characterized in that: The calculation formula for the suspiciousness of the variable value sequence is: in, For test cases Medium variables The value sequence of for The suspicion, Variables calculated during interpretation In the test case The first value in the sequence The importance score of the subvalue, A fixed length sequence of values ​​for each variable.

5. The software defect location auxiliary method based on variable value sequence according to claim 1, characterized in that: 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: in, For a statement, is the final risk value of the statement, To cover the statement The number of failed test cases, For all AND statements in the failed test case A collection of related variables, For test cases All statements in The average value of the suspiciousness of the relevant variable value series, It is the statement risk value obtained by comprehensively calculating multiple spectrum-based defect location methods.

7. A software defect location auxiliary device based on variable value sequence, characterized in that: include: The acquisition 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, configured to train 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, configured to use the trained convolutional neural network to perform local explanations on the fake samples generated by all failed test cases to calculate the suspiciousness of the variable value sequence; An initial positioning module, configured 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, configured to parse the variable dynamic slices to obtain a statement corresponding to each variable value sequence; A solution module, configured to solve a 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 a final defect location 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 according to 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 assistance method based on variable value sequence according to 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 according to 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 bug positioning method and device based on variable separation

    CN114741302A