Fine-grained software-based defect location assistance method and apparatus

By using convolutional neural networks and explainable artificial intelligence technology to calculate the suspiciousness of variable value sequences and combining them with spectral information for defect location, the problem of lack of variable-level information in existing technologies is solved, achieving more accurate defect location and an efficient debugging process.

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

Patent Information

Application Number
CN202411363096.8
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 defect localization methods lack information on the variable level during program runtime, resulting in insufficient localization accuracy, especially when the coverage information is not obvious and the credibility is reduced.

Method used

Using convolutional neural networks and explainable artificial intelligence technology, the suspiciousness of variable value sequences is calculated through training models, and then aggregated with statement coverage information to provide a final suspiciousness ranking for each variable to improve the accuracy of defect location.

Benefits of technology

It provides more fine-grained defect location, helping debuggers find defects starting from the variables most likely to cause errors, improving location accuracy and efficiency, and meeting actual debugging needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357030B_ABST
    Figure CN119357030B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of computer, particularly relates to a kind of based on fine-grained software's defect positioning auxiliary method and device, wherein, method includes: the variable value sequence and actual execution result of test case etc. are collected to train convolution neural network model, and the suspicious degree of variable value sequence is calculated by using the local interpretation of the generated false sample of all failure test cases to the trained model;Variable suspicious degree is obtained based on the aggregation of variable value sequence based on variable value sequence;According to statement coverage information, initial defect positioning is carried out on defect program, to obtain statement risk value;According to variable value sequence suspicious degree, statement risk value, variable suspicious degree based on variable value sequence and variable suspicious degree based on coverage, the final suspicious degree of each variable is solved, and is sorted, to obtain final defect positioning according to the sorting result. Therefore, the problems, such as the lack of program runtime variable level information in the existing defect positioning method based on spectrum, 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 fine-grained software-based defect location auxiliary method and device. Background Art

[0002] Software debugging is a critical step in ensuring software quality. It is generally divided into three phases: defect location, defect understanding, and defect repair. Defect location is the most time-consuming and costly phase and must be completed before defect repair. Therefore, defect location is crucial in software debugging. However, manual defect location is difficult and slow. Therefore, research is focused on automating defect location and improving its effectiveness to help debuggers increase debugging speed. Researchers have conducted extensive research in the field of automated defect location and have proposed numerous defect location techniques, including spectrum-based, program slicing-based, and machine learning-based techniques. 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 reviewing the entire codebase, thereby improving debugger efficiency.

[0003] Spectrum-based defect localization technology is a mainstream technique in the field of automated defect localization. This technique uses two types of information to rank program entities: test results and program spectra. Test results indicate whether each test case performs as expected after execution, while program spectra refer to the coverage status of the program entity under investigation, typically in binary form. Spectrum-based defect localization technology typically uses a metric formula to calculate the suspicion of program entities based on program spectrum information and sorts them by suspicion to identify those most likely to contain defects, allowing debuggers to begin their search for defects with highly suspicious program entities. However, spectrum-based defect localization technology has significant limitations. Research has shown that existing defect localization methods are based on the assumption that examining defective statements alone is sufficient for debuggers to understand and fix the corresponding defects. Furthermore, manual debugging often focuses on information related to variable values.

[0004] Given this, it's necessary to provide debuggers with more fine-grained and accurate suspicion information. Providing debuggers with more fine-grained (i.e., variable-level) suspicion is more consistent with their debugging habits than providing only suspicious statements. Statement-level defect localization reports only provide unrelated statements ranked by suspicion, without context. Using variable-level defect localization reports allows developers to inspect at a finer granularity, pinpointing the location of defects and fixing them. Researchers have enhanced the accuracy of defect localization results by incorporating method call information, the frequency of program entity execution, program control flow graph information, statement execution context, and code metrics. However, research on more extensive information at the program runtime variable level remains scarce. Therefore, incorporating variable value information into spectrum-based defect localization is a worthy approach to improving the effectiveness of spectrum-based defect localization techniques. Designing fine-grained software-based defect localization tools is a critical issue. Summary of the Invention

[0005] The present invention provides a fine-grained software-based defect localization auxiliary method and device to solve the problems that the existing spectrum-based defect localization method lacks research on the variable level information during program runtime, and the spectrum-based defect localization technology relies on coverage information to distinguish between failed test cases and successful test cases. If the coverage information is not obvious enough, the credibility will be reduced.

[0006] The first aspect of the present invention provides an auxiliary method for defect location based on fine-grained software, comprising the following steps: running multiple test cases on a target defect program to collect statement coverage information, variable value sequence and actual execution results of each test case; training a pre-built convolutional neural network model according to the variable value sequence and the actual execution results 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 variable value sequence suspicion; aggregating the variable value sequence suspicion to obtain variable suspicion based on the variable value sequence; performing initial defect location on the target defect program according to the statement coverage information to obtain a statement risk value; aggregating the variable value sequence suspicion and the statement risk value to obtain a coverage-based variable suspicion; solving the final suspicion of each variable according to the variable value sequence-based variable suspicion and the coverage-based variable suspicion; sorting the final suspicion of each variable to generate a sorting result, and obtaining a final defect location according to the sorting result.

[0007] Optionally, the training of a pre-built convolutional neural network model according to the variable value sequence and the actual execution result until a target training round is reached to obtain a trained convolutional neural network includes:

[0008] The variable value sequence is preprocessed to obtain a variable information matrix; the variable information matrix corresponding to each test case is used as a sample, and the actual execution result corresponding to each test case is used as a label to construct a training set; the pre-constructed convolutional neural network model is trained using the training set until a target training round is reached, thereby obtaining the trained convolutional neural network.

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

[0010] A plurality of dummy variable value sequences are generated in all failed test cases in the plurality of test cases; the plurality of dummy variable value sequences are predicted using the trained convolutional neural network to obtain a label corresponding to each dummy variable value sequence; a pre-built linear regression model is trained based on the plurality of dummy variable value sequences and the label corresponding to each dummy variable value sequence to obtain a trained linear regression model; and the suspicion degree of the variable value sequence is calculated based on the trained linear regression model.

[0011] Optionally, performing initial defect location on the target defective program according to the statement coverage information to obtain a statement risk value includes:

[0012] The forward slicing algorithm is improved using the suspiciousness of the variable value sequence to obtain an improved backward slicing algorithm; the statement coverage information is processed using the improved backward slicing algorithm to obtain a statement spectrum set; and the target defect program is initially defectively located based on the statement spectrum set to obtain the statement risk value.

[0013] Optionally, the calculation formula for the variable suspicion based on the variable value sequence is:

[0014]

[0015] in, is the variable suspicion based on the variable value sequence, For test cases Medium variables The suspiciousness of the value sequence of A sequence of values.

[0016] The second embodiment of the present invention provides a defect location auxiliary device based on fine-grained software, including: an acquisition module for running multiple test cases on a target defect program to collect statement coverage information, variable value sequence and actual execution results of each test case; a training module for training a pre-built convolutional neural network model according to the variable value sequence and the actual execution results until the target training round is reached to obtain a trained convolutional neural network; a local interpretation module for using 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; a first aggregation module for The variable value sequence suspicions are aggregated to obtain variable suspicions based on variable value sequences; an initial positioning module is used to perform initial defect positioning on the target defect program according to the statement coverage information to obtain statement risk values; a second aggregation module is used to aggregate the variable value sequence suspicions and the statement risk values ​​to obtain variable suspicions based on coverage; a solution module is used to solve the final suspicion of each variable according to the variable suspicions based on the variable value sequence and the variable suspicions based on coverage; a final positioning module is used to sort the final suspicions of each variable to generate a sorting result, and obtain a final defect positioning according to the sorting result.

[0017] The third aspect of the present invention provides a fine-grained 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 fine-grained software-based defect location assistance method as described in the above embodiment.

[0018] A fourth aspect of the present invention provides a computer program product. When the computer program / instructions are executed by a processor, the computer program / instructions implement the above-mentioned fine-grained software-based defect localization assistance method.

[0019] A fifth aspect of the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-mentioned fine-grained software-based defect localization assistance method.

[0020] The fine-grained software-based defect localization assistance method and device proposed in an embodiment of the present invention calculates the suspicion of variable value sequences based on convolutional neural networks and explainable artificial intelligence technology, and uses the suspicion of variable value sequences in combination with spectrum-based defect localization to perform defect localization at the variable level. Compared with traditional defect localization methods, this method provides the suspicion of defects for each variable, which can help debuggers start looking for defects from the variables most likely to cause errors. This is more suitable for debuggers' actual debugging methods than providing only suspicious statements. Spectrum-based defect localization technology relies on coverage information to distinguish between failed test cases and successful test cases. If the coverage information is not clear enough, the credibility will be reduced. The present invention uses variable value sequences to improve the accuracy of defect localization and introduces more coverage information during program runtime to assist in localization. Compared with the suspicion at the statement level, the more detailed information improves the accuracy of localization. Ultimately, a complete set of fine-grained software defect localization assistance tools is formed. Users can use this method to achieve efficient and automated defect localization and apply it to program debugging and localization work in actual production.

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

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

[0023] Figure 1 A flowchart of a fine-grained software-based defect location assistance method provided by an embodiment of the present invention;

[0024] Figure 2 A schematic diagram of a detailed implementation of a fine-grained software-based defect location assistance method provided by an embodiment of the present invention;

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

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

[0027] Figure 5 A pseudo code diagram of a backward slicing algorithm based on variable value suspicion provided by an embodiment of the present invention;

[0028] Figure 6 A block diagram of a defect location assisting device based on fine-grained software provided by an embodiment of the present invention;

[0029] Figure 7 This is a structural diagram of a fine-grained software defect location auxiliary device provided by an embodiment of the present invention. DETAILED DESCRIPTION

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

[0031] The following describes a fine-grained software defect location assisting method and apparatus according to an embodiment of the present invention with reference to the accompanying drawings.

[0032] Figure 1 A flowchart of a fine-grained software defect location assistance method provided by an embodiment of the present invention.

[0033] like Figure 1 As shown, the fine-grained software defect location auxiliary method includes the following steps:

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

[0035] In the actual implementation process, Figure 2 As shown, when multiple test cases are run on the target defective program, coverage information, variable value sequences and actual execution results are collected, and variable tracking is performed to obtain the value sequence of each variable.

[0036] Among them, the variable value sequence is:

[0037]

[0038] Among them, the defective program to be tested The set of all variables in is denoted as , Contains variables , For one of the variables, For a test case set, Contains Test cases , For one of the test cases. To run the test case When the defective program to be tested A variable in A sequence of values ​​(if the value of the variable does not change, there is only one value in the sequence), let the variable The initial value is (Execute test case Time The initial values ​​of the variables are arranged in lexicographical order), after After the program terminates after the value changes, the variable The last value of the sequence of values ​​is ,sequence To execute the test case Time variable A sequence of values.

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

[0040] In some embodiments, a pre-built convolutional neural network model is trained according to a sequence of variable values ​​and actual execution results until a target number of training rounds is reached to obtain a trained convolutional neural network, including:

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

[0042] The variable information matrix corresponding to each test case is used as a sample, and the actual execution result corresponding to each test case is used as a label to construct a training set;

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

[0044] In the actual implementation process, Figure 3 As shown in the figure, the variable value sequence is preprocessed 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. The variable value sequence matrix can be generated by normalizing the non-numeric variable value sequence, where the variable information matrix is:

[0045]

[0046] in, To run the test case When the program A variable in A sequence of values.

[0047] 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 pre-built convolutional neural network model is trained using the training set.

[0048] 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 ,in, is the number of variables, The fixed length of each variable value sequence is used 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 is used in the excitation layer. As the activation function; 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: .

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

[0050]

[0051] in, represents the number of training rounds, Indicates the amount of learning rate LR updated at each time, It 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. Set to 0.9.

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

[0053] In some embodiments, the trained convolutional neural network is used to perform local interpretation on the fake samples generated by all failed test cases to calculate the suspiciousness of the variable value sequence, including:

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

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

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

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

[0058] In the actual implementation process, Figure 2 and 4 As shown in the figure, LIME technology is used to interpret all failed test cases and generate several “fake samples” near the samples. The variable value sequence information of a failed test case is ,exist The "fake sample" dataset generated nearby is:

[0059]

[0060] Where, For The generated nearby fake samples, a total of A fake sample, To predict fake samples using convolutional neural network models Tags from and Local explanations can be extracted from

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

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

[0063]

[0064] Where, and Represents two different sequences of variable values ​​of the same length.

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

[0066]

[0067] 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 variable value. The larger the absolute value, the greater the influence of the variable value on the model prediction result.

[0068] In step S104, the variable value sequence suspicions are aggregated to obtain variable suspicions based on the variable value sequence.

[0069] The calculation formula of variable suspicion based on variable value sequence is:

[0070]

[0071] Where, is the variable suspicion based on the variable value sequence, For test cases Medium variables The suspiciousness of the value sequence of A sequence of values.

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

[0073] In some embodiments, performing initial defect location on a target defective program based on statement coverage information to obtain a statement risk value includes:

[0074] The forward slicing algorithm is improved by using the suspicious degree of the variable value sequence to obtain the improved backward slicing algorithm;

[0075] The sentence coverage information is processed using the improved backward slicing algorithm to obtain a sentence spectrum set;

[0076] Initial defect location is performed on the target defect program based on the statement spectrum set to obtain the statement risk value.

[0077] In the actual implementation process, Figure 2 and 5 As shown, the forward slicing algorithm is improved by using the suspicious degree of the variable value sequence to obtain an improved backward slicing algorithm, wherein the improved backward slicing algorithm is expressed as:

[0078]

[0079] Where, For variables Improved backward slicing, The statements contained in the backward slice.

[0080] Furthermore, the improved backward slicing algorithm is used to process the statement coverage information to obtain a set of related statements, that is, a set of statement spectra related to suspicious variables. Combined with the existing spectrum-based defect location technology, the target defect program is initially located according to the statement spectrum set to obtain a statement risk value.

[0081] In step S106 , the variable value sequence suspicion and the statement risk value are aggregated to obtain the coverage-based variable suspicion.

[0082] In step S107 , the final suspicion of each variable is calculated based on the variable value sequence-based suspicion and the coverage-based suspicion.

[0083] During the actual execution process, the variable value sequence suspicion will also be used in the dynamic slicing of variables, and the statement risk values ​​of the spectrum-based defect location technology of the variable slices will be aggregated and normalized to obtain the coverage-based variable suspicion. Finally, the two suspicions are weighted and summed to obtain the final suspicion of each variable, and the variables are ranked according to the size of the suspicion.

[0084] The calculation formula for the final suspiciousness of each variable is:

[0085]

[0086] Where, For variables Based on the suspiciousness of the covered variables, For variables The suspiciousness of a variable based on its value sequence, The weight parameter controls the weight of the two. Since the positioning accuracy of the existing defect positioning based on spectrum and the defect positioning based on variable value sequence accounts for the final variable suspicion when the ratio is 10 / 7, the weight parameter can be set to 0.7, that is, α = 0.7.

[0087] In step S108 , the final suspiciousness of each variable is sorted to generate a sorting result, and the final defect location is obtained according to the sorting result.

[0088] like Figure 2As shown, the basic working process of the fine-grained software defect localization auxiliary method proposed in the embodiment of the present invention is as follows: first, run the test case on the target defect source code and collect coverage information, test case execution results and each variable value sequence. The coverage information is used to calculate the spectrum of each statement, the test case execution results are used to determine whether the test case fails, and the variable value sequence is used to record the value changes of each variable in each test case; read the statement coverage information and variable information matrix of each test case from the database, pre-process the collected information to train the pre-built convolutional neural network model, and use LIME to train the pre-built convolutional neural network model. The technology interprets all failed test cases to obtain the importance score of each variable value and the suspicion of the variable value sequence; uses the suspicion of the variable value sequence to improve the backward slicing algorithm to obtain a set of related statements, that is, a set of statements related to suspicious variables. Initial defect location is performed on the target defect program based on the related statement set to obtain the statement risk value, and then calculate the coverage-based variable suspicion; finally, the suspicion of the variable value sequence is aggregated and weighted to obtain the variable suspicion based on the variable value sequence, and the variable suspicion based on the variable value sequence and the coverage-based variable suspicion are weighted summed and sorted, and the variable most likely to have a defect is found from the sorting results.

[0089] In summary, the fine-grained software defect localization assistance method proposed in an embodiment of the present invention calculates the suspicion of variable value sequences based on convolutional neural networks and explainable artificial intelligence technology, and uses the suspicion of variable value sequences combined with spectrum-based defect localization to perform defect localization at the variable level. Compared with traditional defect localization methods, it provides the suspicion of defects for each variable, which can help debuggers start looking for defects from the variables most likely to cause errors, which is more suitable for debuggers' actual debugging methods than providing only suspicious statements. The spectrum-based defect localization technology relies on coverage information to distinguish between failed test cases and successful test cases. If the coverage information is not obvious enough, the credibility will be reduced. The present invention uses variable value sequences to improve the accuracy of defect localization and introduces more coverage information during program runtime to assist in localization. Compared with the suspicion at the statement level, the more detailed information improves the accuracy of localization. Finally, a complete set of fine-grained software defect localization assistance tools is formed. Users can use this method to achieve efficient and automated defect localization and use it for program debugging and localization work in actual production.

[0090] Next, a fine-grained software-based defect localization assisting device proposed in an embodiment of the present invention will be described with reference to the accompanying drawings.

[0091] Figure 6 4 is a block diagram of a fine-grained software-based defect location assisting device according to an embodiment of the present invention.

[0092] like Figure 6As shown, the fine-grained software-based defect location auxiliary device 60 includes: an acquisition module 601, a training module 602, a local interpretation module 603, a first aggregation module 604, an initial positioning module 605, a second aggregation module 606, a solution module 607 and a final positioning module 608.

[0093] The acquisition module 601 is used to run multiple test cases on the target defective program to collect statement coverage information, variable value sequences, and actual execution results for each test case. The training module 602 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, thereby obtaining a trained convolutional neural network. The local interpretation module 603 is used to use the trained convolutional neural network to perform local interpretation on the false samples generated by all failed test cases to calculate the variable value sequence suspicion. The first aggregation module 604 is used to aggregate the variable value sequence suspicions to obtain variable suspicions based on the variable value sequence. The initial location module 605 is used to perform initial defect location on the target defective program based on statement coverage information to obtain statement risk values. The second aggregation module 606 is used to aggregate the variable value sequence suspicions and statement risk values ​​to obtain coverage-based variable suspicions. The solution module 607 is used to determine the final suspicion of each variable based on the variable value sequence-based and coverage-based variable suspicions. The final location module 608 is used to sort the final suspiciousness of each variable to generate a sorting result, and obtain the final defect location according to the sorting result.

[0094] In some embodiments, the training module 602 includes:

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

[0096] A construction unit is used to use the variable information matrix corresponding to each test case as a sample and the actual execution result corresponding to each test case as a label to construct a training set;

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

[0098] In some embodiments, the local interpretation module 603 includes:

[0099] A generation unit, for generating multiple false variable value sequences in all failed test cases in multiple test cases;

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

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

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

[0103] In some embodiments, the initial positioning module 605 includes:

[0104] An improvement unit, used for improving the forward slicing algorithm by utilizing the suspiciousness of the variable value sequence to obtain an improved backward slicing algorithm;

[0105] a processing unit, configured to process the sentence coverage information using an improved backward slicing algorithm to obtain a sentence spectrum set;

[0106] The initial positioning unit is used to perform initial defect positioning on the target defect program according to the statement spectrum set to obtain a statement risk value.

[0107] In some embodiments, the calculation formula for the variable suspicion based on the variable value sequence is:

[0108]

[0109] in, is the variable suspicion based on the variable value sequence, For test cases Medium variables The suspiciousness of the value sequence of A sequence of values.

[0110] It should be noted that the aforementioned explanation of the embodiment of the defect localization assisting method based on fine-grained software is also applicable to the defect localization assisting device based on fine-grained software of this embodiment, and will not be repeated here.

[0111] The fine-grained software-based defect localization assistance device proposed in an embodiment of the present invention calculates the suspicion of variable value sequences based on convolutional neural networks and explainable artificial intelligence technology, and uses the suspicion of variable value sequences in combination with spectrum-based defect localization to perform defect localization at the variable level. Compared with traditional defect localization methods, it provides the suspicion of defects for each variable, which can help debuggers start looking for defects from the variables most likely to cause errors. This is more suitable for debuggers' actual debugging methods than simply providing suspicious statements. Spectrum-based defect localization technology relies on coverage information to distinguish between failed test cases and successful test cases. If the coverage information is not clear enough, the credibility will be reduced. The present invention uses variable value sequences to improve the accuracy of defect localization and introduces more coverage information during program runtime to assist in localization. Compared with the suspicion level at the statement level, the more detailed information improves the accuracy of localization. Ultimately, a complete set of fine-grained software defect localization assistance tools is formed. Users can use this method to achieve efficient and automated defect localization and apply it to program debugging and localization work in actual production.

[0112] Figure 7 A schematic diagram of the structure of a fine-grained software defect localization auxiliary device provided by an embodiment of the present invention. The fine-grained software defect localization auxiliary device may include:

[0113] Memory 701 , processor 702 , and computer programs stored in the memory 701 and executable on the processor 702 .

[0114] When the processor 702 executes the program, the fine-grained software defect localization assistance method provided in the above embodiment is implemented.

[0115] Furthermore, the fine-grained software defect location auxiliary equipment also includes:

[0116] The communication interface 703 is used for communication between the memory 701 and the processor 702 .

[0117] The memory 701 is used to store computer programs that can be run on the processor 702 .

[0118] The memory 701 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0119] If the memory 701, processor 702, and communication interface 703 are implemented independently, the communication interface 703, memory 701, and processor 702 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. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.

[0120] Optionally, in a specific implementation, if the memory 701, the processor 702 and the communication interface 703 are integrated on a chip, the memory 701, the processor 702 and the communication interface 703 can communicate with each other through an internal interface.

[0121] The processor 702 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.

[0122] An embodiment of the present invention further provides a computer program product, which implements the above-mentioned fine-grained software defect localization assistance method when the computer program / instructions are executed by a processor.

[0123] 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 above-mentioned fine-grained software defect location assistance method is implemented.

[0124] In the description of this specification, the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean 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 features of different embodiments or examples without contradiction.

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

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

[0127] The logic and / or steps represented in a flowchart or otherwise described herein, for example, can be considered 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" is 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 (not exhaustive) of computer-readable media include: an electrical connection with one or more 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.

[0128] It should be understood that various components 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 of the following technologies known in the art or a combination thereof can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application-specific integrated circuits having suitable combinational logic gate circuits, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

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

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

[0131] 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 defect location auxiliary method based on fine-grained software, characterized in that: The following steps are involved: Run multiple test cases on the target defective program to collect statement coverage information, variable value sequences, and actual execution results of each test case; Training a pre-built convolutional neural network model according to the variable value sequence and the actual execution result until a target training round is reached to obtain a trained convolutional neural network; Using the trained convolutional neural network to perform local interpretation on the fake samples generated by all failed test cases to calculate the suspiciousness of the variable value sequence; Aggregating the variable value sequence suspicions to obtain variable suspicions based on the variable value sequence; Performing initial defect location on the target defective program according to the statement coverage information to obtain a statement risk value; Aggregating the variable value sequence suspicion and the statement risk value to obtain a coverage-based variable suspicion; Calculating a final suspicious degree of each variable according to the variable suspicious degree based on the variable value sequence and the variable suspicious degree based on coverage; The final suspiciousness of each variable is sorted to generate a sorting result, and a final defect location is obtained according to the sorting result.

2. The fine-grained software-based defect location assistance method 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, and the actual execution result corresponding to each test case is used as a label to construct 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 fine-grained software-based defect location assistance method 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 fine-grained software-based defect location assistance method according to claim 1, characterized in that: The performing initial defect location on the target defective program according to the statement coverage information to obtain a statement risk value includes: The forward slicing algorithm is improved by using the suspicious degree of the variable value sequence to obtain an improved backward slicing algorithm; Processing the sentence coverage information using the improved backward slicing algorithm to obtain a sentence spectrum set; Initial defect location is performed on the target defective program according to the statement spectrum set to obtain the statement risk value.

5. The fine-grained software-based defect location assistance method according to claim 1, characterized in that: The calculation formula of the variable suspicion based on the variable value sequence is: in, is the variable suspicion based on the variable value sequence, For test cases Medium variables The suspiciousness of the value sequence of A sequence of values.

6. A defect location auxiliary device based on fine-grained software, characterized in that: include: The acquisition module is used to run multiple test cases on the target defective program to collect the statement coverage information, variable value sequence and actual execution results of each test case; 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; A first aggregation module is configured to aggregate the variable value sequence suspicions to obtain a variable suspicion based on 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 second aggregation module is configured to aggregate the variable value sequence suspicion and the statement risk value to obtain a coverage-based variable suspicion; A solving module, configured to solve a final suspicious degree of each variable according to the variable suspicious degree based on the variable value sequence and the variable suspicious degree based on coverage; The final positioning module is used to sort the final suspiciousness of each variable to generate a sorting result, and obtain the final defect positioning according to the sorting result.

7. A fine-grained software defect location auxiliary device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the fine-grained software-based defect localization assisting method according to any one of claims 1 to 5.

8. A computer program product, characterized in that When the computer program / instruction is executed by a processor, the fine-grained software-based defect localization auxiliary method according to any one of claims 1 to 5 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the fine-grained software-based defect location assistance method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Software defect positioning method and device based on convolutional neural network, and medium

    CN110232023A

  • Local interpretation method of time sequence regression model based on Lime algorithm

    CN117909682A