A method for locating program defects based on statement execution path

By combining long and short-term memory neural networks and improved evidence theory, using statement execution paths and execution results for training, the problems of low accuracy of program defect positioning and high error omission rate in the prior art are solved, and more efficient and accurate defect positioning is achieved.

CN118312407BActive Publication Date: 2025-03-18CHANGCHUN INST OF OPTICS FINE MECHANICS & PHYSICS CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310477099.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-28
Publication Date
2025-03-18
Estimated Expiration
2043-04-28

AI Technical Summary

Technical Problem

In the prior art, in the positioning of program defects, there are problems such as low positioning accuracy, high error omission rate, complex learning of BP networks and slow convergence speed, making it difficult to effectively locate program defects in practical applications.

Method used

The combination of long and short-term memory (LSTM) neural network is used to train the LSTM neural network through statement execution paths and execution results, and DS evidence theory and Dempster combination rules are used to fusion and correction of evidence to improve the accuracy and reliability of defect positioning.

Benefits of technology

It improves the accuracy of program defect positioning, reduces the probability of error omission problems, and achieves more efficient defect positioning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118312407B_ABST
    Figure CN118312407B_ABST
Patent Text Reader

Abstract

The present invention provides a method for locating program defects based on statement execution paths, including: training, testing and correcting long short-term memory neural networks with statement execution paths and execution results, exploring the potential relationship between statement execution paths and execution results, and organically integrating long short-term memory neural networks with DS evidence theory, obtaining the suspiciousness value of statements according to network output, and judging the defect location according to the suspiciousness value. Compared with the existing method of training networks using program spectra, statements or functions and execution results, the statement execution path of the present invention has richer test case execution information, which can not only reflect the statement coverage, but also reflect the order in which statements are executed. The present invention obtains more judgment information, has a higher accuracy rate, and has a lower probability of error omission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of program testing, and specifically provides a method for locating program defects based on statement execution paths. Background Art

[0002] Program defect location aims to detect and find the error code that causes program failure, which is a very tedious and time-consuming activity. The traditional debugging method of manually setting breakpoints is not only difficult to choose the breakpoint location, but also time-consuming. Therefore, the automation of defect location has become a common goal pursued by the program academic and industrial circles.

[0003] In recent years, researchers have proposed a series of methods to assist in automatic defect location from different perspectives, including static defect location and dynamic defect location methods. Static defect methods focus on information such as the source code and program structure of the program, without executing the program code. However, focusing only on static defect location methods will cost a lot of money, the judgment process is extremely complex, the accuracy is low, and the possibility of errors and omissions is high, especially for comprehensive analysis of large software programs. Dynamic defect location methods require executing program code, collecting program execution information of successful and failed executions, and assisting defect location through execution information. The dynamic defect location method does not need to consider the internal structure of the program itself, and the execution overhead is small. However, in the prior art, the BP network is usually used to study the relationship between statements or functions and execution results. However, due to the complexity of the program, the BP network obtained through statement or function training usually has low positioning accuracy. Not only will a large number of suspicious prompts be obtained, which requires a lot of time for further judgment, but a large number of errors and omissions will also occur, and usually all defects cannot be located. In addition, the BP network itself has problems such as complex learning process, slow convergence speed or even no convergence. Therefore, the BP network obtained through statement or function training currently only has a certain effect in theory, but many problems make it difficult to apply in practice.

[0004] Therefore, there is an urgent need for a positioning method that can avoid errors and omissions and has high positioning accuracy. Summary of the invention

[0005] In order to solve the above problems, the present invention provides a method for locating program defects based on statement execution paths, which mainly organically integrates the Long Short-Term Memory (LSTM) neural network with the improved evidence theory, gives full play to the advantages of both, overcomes the disadvantages of both, and trains the Long Short-Term Memory neural network with the statement execution path and execution results. The defect positioning accuracy of the present invention is higher and the probability of error omission problems is reduced.

[0006] The method for locating program defects based on statement execution paths provided by the present invention includes:

[0007] S1, using the test program P = {s1, s2, ..., s M}Execute the test case set T = {t1, t2, ..., t l} in the test case t i , collect statement coverage, and generate the corresponding statement execution path Ps(t i )=(e1,e2,…,e j ,…,e z ), where M represents the number of statements that make up the test program, and s j (1≤j≤M) represents the jth statement in the test program, t i (1≤i≤l) represents the i-th test case, l represents the total number of test cases; z represents the test case t i The total number of statements covered during execution, e j (1≤j≤z) represents the test case t i The sequence number of the jth statement covered during execution;

[0008] Recording test cases i The execution result Rs(t i ), if t i If the execution is successful, then Rs(t i ) is 0, if t i If the execution fails, Rs(t i ) is 1;

[0009] S2. Training, testing and correction of long short-term memory neural networks, specifically:

[0010] S201. Based on DS evidence theory, the identification framework of the positioning result is determined as Θ={A1,A2,…,A N}, where Proposition A1 indicates that there is a defect in the current sentence to be recognized, Proposition A2 indicates that there is no defect in the current sentence to be recognized, and other propositions indicate other situations existing in the current sentence to be recognized;

[0011] S202, selecting L long short-term memory neural networks, where L is an integer not less than 3, and each long short-term memory neural network has a different activation function, expansion speed, and learning algorithm;

[0012] The topological structures of each LSTM neural network are also different, but they must meet the following constraints:

[0013] Input layer, 1 layer, the number of nodes is the same as the number of statements in the test program, the number of time steps I = max(M,Z max ), where Z maxIndicates the number of statements in the longest statement execution path in each test case;

[0014] Hidden layer, 3 layers;

[0015] Output layer, 1 layer, the number of nodes is N, N is any integer not less than 2;

[0016] Softmax layer;

[0017] S203, the characteristic data of the selected sample data is: according to the order of the elements in the statement execution path of the test case, one element is selected each time, and is sequentially input into the input layer nodes of the long short-term memory neural network, and the number of input elements is the same as the number of time steps I of the input layer. If the total number of elements in the statement execution path of the test case is less than the number of time steps I of the input layer of the long short-term memory neural network, 0 is added at the end as input;

[0018] The execution result of the test case (Rs(t i ), 1-Rs(t i )) as labeled data of sample data;

[0019] S204, completing the training of the long short-term memory neural network using the training sample set;

[0020] S205. Use the test sample set to complete the test of the long short-term memory neural network, convert the output of the long short-term memory neural network into evidence through the DS evidence theory, convert the basic probability assignment of the evidence into the Pignistic probability of each single element, and select the element with the largest value as the evaluation result; establish an indicator function to determine whether the evaluation result is consistent with the true result, and calculate the reliability factor of each evidence output by the long short-term memory neural network according to the indicator function;

[0021] S3. Defect location of the problem program, specifically:

[0022] S301, construct a virtual test case for each statement in the problem program, and set the statement coverage information of the virtual test case to Ps′(ts i )={e1,e2,…,e j ,…,e M}, where any element e at any position j The value of is the number of the corresponding statement in the program, and the rest of the values ​​are 0;

[0023] S302, inputting the data of the virtual test case into each long short-term memory neural network respectively to obtain an output result;

[0024] S303, using the DS evidence theory to generate corresponding evidence from the output result, and modifying the evidence according to the reliability factor; combining the modified evidence using the Dempster combination rule to obtain a combination result;

[0025] S304: Calculate the suspiciousness Susp(s) of each statement according to the combination result. i ), Suspiciousness Susp(s i ) has a value range of [0,1];

[0026] By sorting the suspiciousness of all statements, a defect location report of the problematic program can be obtained.

[0027] Preferably, the calculation formula of the output result of the softmax layer is as follows:

[0028]

[0029] Among them, the output result of the output layer is (S i1 ,S i2 ,...,S iN ), S ij is the output result of the jth (j=1,2,...,N) node of the output layer, and the output result of the softmax layer is (R i1 ,R i2 ,...,R iN ), R ij is the output result of the jth (j=1,2,...,N) node of the softmax layer.

[0030] Preferably, the output transformation of the LSTM neural network generates evidence as follows:

[0031] E i =(m i (A1),m i (A2),...,m i (A N ),m i (Θ));

[0032] in, m i (A j ) indicates evidence E i Zhongjiaoyuan A j The basic probability assignment of .

[0033] Preferably, the calculation process of the reliability factor of evidence is as follows:

[0034] Set the test sample set to O = {o1, o2, ..., o T},O k(k=1,2,...,T) represents any test sample in the test sample set, the long short-term memory neural network C i The reliability factor of the evidence corresponding to (i=1,2,...,L) is

[0035] Calculate the test sample O k (k=1,2,...,T) corresponding evidence E i Zhongjiaoyuan A j The Pignistic probability function value BetP{o k}(A j )for:

[0036]

[0037] Where X represents a set;

[0038] Set the indicator function to δ jk (j=1,2,...,N;k=1,2,...,T), when the evaluation result is consistent with the true result, δ jk =1; when the evaluation result is inconsistent with the actual result, δ jk =0;

[0039] Computational Long Short-Term Memory Neural Networks C i The reliability factor of the evidence corresponding to (i=1,2,...,L) as follows:

[0040]

[0041] Among them, α i is a variable, p jk =BetP{o k}(A j ).

[0042] Preferably, the evidence output by different LSTM neural networks is corrected according to the reliability factor, and the focal element A in the corrected evidence Ei is j The basic probability assignment m i '(A j )for:

[0043]

[0044] Preferably, in S3, when locating defects in the problem program, the problem program is divided into two sections, each section of the problem program can output results, and a program defect location method based on statement execution path is used to locate defects in each section of the problem program.

[0045] Compared with the prior art, the present invention can achieve the following beneficial effects:

[0046] The present invention mainly utilizes the long short-term memory neural network to fully explore the potential relationship between the program statement execution path and the execution result, and uses the program statement execution path and the execution result as the sample feature data and label data to train the long short-term memory neural network. Compared with the existing method of using program spectrum, statement or function and execution result to train the network, the statement execution path has richer test case execution information, which can reflect the statement coverage and the order in which the statements are executed. The present invention obtains more information for judgment, has higher accuracy, and has a lower probability of error omission.

[0047] The present invention adopts long short-term memory neural network and introduces the concept of time series into the network structure design, making it more adaptable in time series data analysis. At the same time, it makes up for the problems of gradient disappearance and gradient explosion, insufficient long-term memory capacity, etc., and can effectively utilize long-distance time series information. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 The flowchart of the method for locating program defects based on statement execution paths provided according to an embodiment of the present invention. DETAILED DESCRIPTION

[0049] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the following description, the same modules are represented by the same reference numerals. In the case of the same reference numerals, their names and functions are also the same. Therefore, the detailed description thereof will not be repeated.

[0050] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and do not constitute a limitation of the present invention.

[0051] It should be noted that the embodiments of the present invention involve a large number of formulas and letter expressions, which do not constitute a limitation on the protection scope of the present invention. Simple deformation of the formulas or replacement of letters should still fall within the protection scope of the present invention.

[0052] It should be noted that the superscripts of the formulas and letters involved in the embodiments of the present invention are only used for distinction or sorting and have no practical meaning.

[0053] Figure 1 A method for locating program defects based on statement execution paths provided according to an embodiment of the present invention is shown.

[0054] like Figure 1As shown, the method for locating program defects based on statement execution paths proposed in an embodiment of the present invention specifically includes the following steps:

[0055] S1. Perform basic settings:

[0056] The test procedure is: P = {s1, s2, ..., s M}, where M represents the number of statements that make up the test program, and s j (1≤j≤M) represents the jth statement in the test program.

[0057] The test case set is: T = {t1, t2, ..., t l}, where t i (1≤i≤l) represents the i-th test case, which reflects any test case in the test case set T, and l represents the total number of test cases.

[0058] The statement execution path is: Ps(t i )=(e1,e2,…,e j ,…,e z ), where z represents the test case t i The total number of statements covered during execution, e j (1≤j≤z) represents the test case t i The sequence number of the jth statement covered during execution.

[0059] During the execution of the test program, the test program P = {s1, s2, ..., s M}Execute the test case set T = {t1, t2, ..., t l}, the following is to execute the test case i (1≤i≤l) is used as an example to illustrate that after execution, it is necessary to collect statement coverage and generate the corresponding statement execution path Ps(t i )=(e1,e2,…,e j ,…,e z ), and record the test case t i The execution result Rs(t i ), the execution results are recorded as follows:

[0060] If t i If the execution is successful, then Rs(t i ) is 0;

[0061] If t i If the execution fails, Rs(t i ) is 1.

[0062] In this embodiment, taking M=6 and l=3 as an example for specific description, P={s1, s2, s3, s4, s5, s6}, T={t1, t2, t3}, the specific execution status of the test case is shown in Table 1.

[0063] Table 1 Execution of test cases

[0064]

[0065] In order to illustrate that the method of the present invention using the statement execution path and execution result to perform network training has better accuracy, the embodiment of the present invention will be compared and explained as follows:

[0066] Generate the statement spectrum and statement execution path table corresponding to the test case according to the execution status shown in Table 1:

[0067] The statement spectrum corresponding to the test case is shown in Table 2.

[0068] Table 2 Statement spectrum corresponding to test cases

[0069]

[0070]

[0071] The statement execution path corresponding to the test case is shown in Table 3.

[0072] Table 3 Statement execution path corresponding to the test case

[0073]

[0074] By comparing Table 2 and Table 3, we can see that compared with the program spectrum, the program statement execution path has richer test case execution information. In addition to reflecting the statement coverage, it can also reflect the order in which the statements are executed. That is, the statement execution path can be considered as a kind of timing information of the test case statement execution. Using the statement execution path for network training can effectively improve the accuracy of network defect location.

[0075] S2. Due to the diversity and complexity of programs, the amount of program code and data is large. If a single neural network is used to locate software defects, the network structure is complex and difficult to determine. In addition, samples for network training are difficult to obtain, and there are inevitably contradictions and randomness, resulting in poor generalization ability of neural networks. In order to solve the problem of low accuracy of a single neural network, evidence theory is introduced. Evidence theory is one of the means currently widely used in information fusion. Evidence theory does not require the conditional probability and prior probability of the judgment to be known in advance. It uses accumulated evidence to narrow the hypothesis set and has been widely used in uncertain information processing.

[0076] Since the statement execution path is sequential, the present invention combines the long short-term memory neural network with the DS evidence theory. The specific process is as follows:

[0077] S201. First, based on the DS evidence theory, the identification framework of the positioning result is determined as Θ={A1,A2,…,A N}, wherein proposition A1 indicates that there is a defect in the current sentence to be recognized, proposition A2 indicates that there is no defect in the current sentence to be recognized, and other propositions indicate other situations existing in the current sentence to be recognized. In the embodiment of the present invention, other situations are not considered in the proposition, so no other propositions are set, that is, the actual recognition framework is Θ={A1,A2}. In special cases, propositions such as uncertainty or no judgment can also be set in the recognition framework. However, in order to fully explain the calculation formulas involved, N propositions are still used in the following. In this embodiment, except for the proposition and proposition A2, other propositions can be regarded as not output.

[0078] S202, select L long short-term memory neural networks, use C i (i=1,2,...,L) represents the i-th LSTM neural network. To avoid the problem that a single network is not universal and a single network may have large errors, the total number of LSTM neural networks L should be no less than 3. At the same time, to ensure the diversity of LSTM neural networks, the activation function, expansion speed and learning algorithm of each LSTM neural network are different.

[0079] In addition, each LSTM neural network also uses a different topological structure, but must meet the following constraints:

[0080] The input layer needs to be set to 1 layer, and its number of nodes is the same as the number of statements in the test program. In this embodiment, the number of nodes is 6, and the number of time steps I = max(6, Z max ), where Z max Indicates the number of statements in the longest statement execution path in each test case;

[0081] The hidden layer needs to be set to 3 layers, and the number of nodes can be set or changed based on experience;

[0082] The output layer has 1 layer and the number of nodes is N, where N is any integer not less than 2. In this embodiment, the output layer only considers two situations: the presence of defects and the absence of defects. N is 2. The following is to clarify the formula, and N is still used in the formula.

[0083] In order to use the LSTM neural network as a source of evidence in the DS evidence theory and to generate evidence based on the output of the LSTM neural network, a softmax layer is added after the output layer of the LSTM neural network.

[0084] After the softmax layer is added, it is necessary to study the calculation formula of the output result after processing by the softmax layer. The specific process is:

[0085] Setting the long short-term memory neural network C i The result of the output layer of (i=1,2,...,L) is (S i1 ,S i2 ,...,S iN ), S ij is the output result of the jth (j=1,2,...,N) node of the output layer, and the output result of the softmax layer is (R i1 ,R i2 ,...,R iN ), R ij is the output result of the jth (j=1,2,...,N) node of the softmax layer, then:

[0086]

[0087] S203, the sample data is used for training the long short-term memory neural network. The sample data is selected according to Table 3. The characteristic data of the selected sample data is: according to the order of the elements in the statement execution path of the test case, one element is selected each time, and they are input into the nodes of the input layer of the long short-term memory neural network in sequence. The number of input elements is the same as the number of time steps I of the input layer. If the total number of elements in the statement execution path of the test case is less than the number of time steps I of the input layer of the long short-term memory neural network, 0 is added at the end as input.

[0088] The execution result of the test case (Rs(t i ), 1-Rs(t i )) is used as labeled data for sample data.

[0089] It can be seen from Table 3 that the number of time steps of the input layer of the long short-term memory neural network is 7. The execution path of the test case in Table 3 is processed according to the above method to generate the corresponding sample data as shown in Table 4.

[0090] Table 4 Sample data

[0091]

[0092] Without loss of generality, 70% of the sample data are randomly selected as the training sample set and 30% as the test sample set.

[0093] S204. Each LSTM neural network is trained separately using the training sample set. The training process of multiple LSTM neural networks can be carried out simultaneously, making full use of the computer's parallel processing capabilities to further speed up data processing until the training of all probabilistic neural networks is completed. If the network needs to be added or replaced later, only the changed network needs to be trained, tested and corrected, which greatly improves the scalability.

[0094] S205. In order to more objectively obtain the credibility distribution of evidence for different propositions, the embodiment of the present invention adopts multiple independent long short-term memory neural networks as the evidence source of the evidence theory. At the same time, the concept of evidence reliability factor is introduced to measure the reliability of evidence given by different long short-term memory neural networks. The output value of the long short-term memory neural network is corrected by the reliability factor and then used as the basic credibility of the proposition in the final recognition framework. After the reintegration of the evidence theory, the information of the evidence source can be fully utilized, the accuracy of recognition can be greatly improved, and the incompleteness and ambiguity of the information contained in a single evidence source can be eliminated. In order to achieve the reliability of evidence, firstly for the test sample O to be processed currently k (k=1,2,...,T), and input it into the long short-term memory neural network C i In (i=1,2,...,L), the output of the long short-term memory neural network (R i1 ,R i2 ,…,R iN ) Transformation generates evidence E i , then:

[0095] E i =(m i (A1),m i (A2),m i (Θ));

[0096] in, m i (A j ) indicates evidence E i Zhongjiaoyuan A j The basic probability assignment of .

[0097] It should be noted that a proposition is a set of elements under the identification framework, and a proposition represents a set with only one element, while a focal element is a set of elements under the evidence framework, and a focal element can represent a set with one or more elements.

[0098] Then set the test sample set to O = {o1, o2, ..., o T},O k (k=1,2,...,T) represents any test sample in the test sample set, the long short-term memory neural network Ci The reliability factor of the evidence corresponding to (i=1,2,...,L) is According to the Pignistic probability function, the evidence E i Make a decision and take evidence E i The basic probability assignment is converted to the Pignistic probability of each single element, and the evidence E is calculated. i Zhongjiaoyuan A j The Pignistic probability function value BetP{o k}(A j ) is as follows:

[0099]

[0100] Where X represents a set.

[0101] Evidence E i All focal elements A j The Pignistic probability function value is calculated, and the element with the largest value is selected as the evaluation result, that is: if m i (A1)≥m i (A2), test sample O k There are defective statements in the statements covered by the test cases corresponding to (k=1,2,...,T), otherwise there are no defective statements.

[0102] Set the indicator function to δ jk (j=1,2,...,N;k=1,2,...,T), and obtain the test sample O k (k=1,2,...,T) corresponding indicator function δ jk The value of indicates that the specific expression of the function is:

[0103] When the evaluation result is consistent with the true result, δ jk =1;

[0104] When the evaluation result is inconsistent with the true result, δ jk =0;

[0105] When the test sample set O = {o1,o2,...,o T After all the test samples in} are processed, the long short-term memory neural network C is calculated. i The reliability factor of the evidence corresponding to (i=1,2,...,L) as follows:

[0106]

[0107] Among them, α i is a variable, pjk =BetP{o k}(A j ).

[0108] S3. After the network is completed, it is used to locate the defect of the problematic program. The specific process is as follows:

[0109] S301, construct a virtual test case for each statement in the problem program, and the method for constructing the virtual test case is:

[0110] Setting Statements i The statement coverage information of the corresponding virtual test case is Ps′(ts i )={e1,e2,…,e j ,…,e M}, where any element e at any position j The value of is the number of the corresponding statement in the program, and the other values ​​are set to 0. Taking the data shown in Table 3 as an example, a virtual test example is constructed as shown in Table 5.

[0111] Table 5 Virtual test cases

[0112] Statements of the program being tested Corresponding virtual test cases <![CDATA[s1]]> (1,0,0,0,0,0,0) <![CDATA[s2]]> (2,0,0,0,0,0,0) <![CDATA[s3]]> (3,0,0,0,0,0,0) <![CDATA[s4]]> (4,0,0,0,0,0,0) <![CDATA[s5]]> (5,0,0,0,0,0,0) <![CDATA[s6]]> (6,0,0,0,0,0,0)

[0113] According to Table 5, the input data of each LSTM neural network corresponding to the virtual test case is constructed, as shown in Table 6.

[0114] Table 6 Input data of LSTM neural network corresponding to virtual test cases

[0115]

[0116] S302: Input the data of the virtual test case into each long short-term memory neural network to obtain output results.

[0117] S303, using DS evidence theory to generate corresponding evidence from the output results, and modifying the evidence according to the reliability factor; the modified evidence E i Zhongjiaoyuan A j The basic probability assignment m i '(A j )for:

[0118]

[0119] The modified evidence is combined using Dempster's combination rule to obtain the combination result, which is as follows:

[0120] Set the evaluation result recognition framework Θ = {A1, A2, ..., A NThe trust functions of} are BEL1 and BEL2, and m'1 and m'2 are assigned the corresponding basic probabilities after correction, B1, B2, ..., B k and C1,C2,...,C r is the corresponding focal element, then the Dempster combination rule is as follows:

[0121]

[0122] in, H is the combined data set.

[0123] Dempster combination rule satisfies the associative law. When multiple pieces of evidence are fused, pairwise fusion or other methods can be used. The combination result obtained by combining each piece of evidence using Dempster combination rule is F = (m f (A1),m f (A2),…,m f (A N ),m f (Θ)).

[0124] S304: Calculate the suspiciousness Susp(s) of each statement according to the combination result. i ), Suspiciousness Susp(s i ) has a value range of [0,1].

[0125] By sorting the suspiciousness of all statements, a defect location report of the problematic program can be obtained.

[0126] The defect location report is shown in Table 7.

[0127] Table 7 Software defect location report

[0128] <![CDATA[Statement s i > <![CDATA[Suspiciousness Susp(s i )]]> <![CDATA[s1]]> 0.71 <![CDATA[s3]]> 0.63 <![CDATA[s2]]> 0.60 <![CDATA[s4]]> 0.39 <![CDATA[s5]]> 0.27 <![CDATA[s6]]> 0.15

[0129] The defect location can be located according to the statement sequence in the defect location report.

[0130] In addition, for longer problematic programs, information duplication increases and the final output results have large deviations. The problematic program can be divided into two sections, each of which can output results. For each section of the problematic program, the program defect location method based on the statement execution path is used to locate the defect.

[0131] Although the embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. Those skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.

[0132] The above specific implementations of the present invention do not constitute a limitation on the protection scope of the present invention. Any other corresponding changes and modifications made based on the technical concept of the present invention should be included in the protection scope of the claims of the present invention.

Claims

1. A method for locating program defects based on statement execution paths, characterized in that: include: S1, using the test program P = {s1, s2, ..., s M }Execute the test case set T = {t1, t2, ..., t l } in the test case t i , collect statement coverage, and generate the corresponding statement execution path Ps(t i )=(e1,e2,…,e j ,…,e z ), where M represents the number of statements that make up the test program, and s j (1≤j≤M) represents the jth statement in the test program, t i (1≤i≤l) represents the i-th test case, l represents the total number of test cases; z represents the test case t i The total number of statements covered during execution, e j (1≤j≤z) represents the test case t i The sequence number of the jth statement covered during execution; Recording test cases i The execution result Rs(t i ), if t i If the execution is successful, then Rs(t i ) is 0, if t i If the execution fails, Rs(t i ) is 1; S2. Training, testing and correction of long short-term memory neural networks, specifically: S201. Based on DS evidence theory, the identification framework of the positioning result is determined as Θ={A1,A2,…,A N }, where Proposition A1 indicates that there is a defect in the current sentence to be recognized, Proposition A2 indicates that there is no defect in the current sentence to be recognized, and other propositions indicate other situations existing in the current sentence to be recognized; S202, selecting L long short-term memory neural networks, where L is an integer not less than 3, and each long short-term memory neural network has a different activation function, expansion speed, and learning algorithm; The topological structures of each LSTM neural network are also different, but they must meet the following constraints: Input layer, 1 layer, the number of nodes is the same as the number of statements in the test program, the number of time steps I = max(M,Z max ), where Z max Indicates the number of statements in the longest statement execution path in each test case; Hidden layer, 3 layers; Output layer, 1 layer, the number of nodes is N, N is any integer not less than 2; Softmax layer; S203, the characteristic data of the selected sample data is: according to the order of the elements in the statement execution path of the test case, one element is selected each time, and is sequentially input into the input layer nodes of the long short-term memory neural network, and the number of input elements is the same as the number of time steps I of the input layer. If the total number of elements in the statement execution path of the test case is less than the number of time steps I of the input layer of the long short-term memory neural network, 0 is added at the end as input; The execution result of the test case (Rs(t i ), 1-Rs(t i )) as labeled data of sample data; S204, completing the training of the long short-term memory neural network using the training sample set; S205. Use the test sample set to complete the test of the long short-term memory neural network, convert the output of the long short-term memory neural network into evidence through the DS evidence theory, convert the basic probability assignment of the evidence into the Pignistic probability of each single element, and select the element with the largest value as the evaluation result; establish an indicator function to determine whether the evaluation result is consistent with the true result, and calculate the reliability factor of each evidence output by the long short-term memory neural network according to the indicator function; S3. Defect location of the problem program, specifically: S301, construct a virtual test case for each statement in the problem program, and set the statement coverage information of the virtual test case to Ps′(ts i )={e1,e2,…,e j ,…,e M }, where any element e at any position j The value of is the number of the corresponding statement in the program, and the rest of the values ​​are 0; S302, inputting the data of the virtual test case into each long short-term memory neural network respectively to obtain an output result; S303, using the DS evidence theory to generate corresponding evidence from the output result, and modifying the evidence according to the reliability factor; combining the modified evidence using the Dempster combination rule to obtain a combination result; S304: Calculate the suspiciousness Susp(s) of each statement according to the combination result. i ), Suspiciousness Susp(s i ) has a value range of [0,1]; By sorting the suspiciousness of all statements, a defect location report of the problematic program can be obtained.

2. The method for locating program defects based on statement execution paths as claimed in claim 1, characterized in that: The calculation formula of the output of the softmax layer is as follows: Among them, the output result of the output layer is (S i1 ,S i2 ,...,S iN ), S ij is the output result of the jth (j=1,2,...,N) node of the output layer, and the output result of the softmax layer is (R i1 ,R i2 ,...,R iN ), R ij is the output result of the jth (j=1,2,...,N) node of the softmax layer.

3. The method for locating program defects based on statement execution paths as claimed in claim 2, characterized in that: The output transformation of the LSTM neural network generates the evidence: E i =(m i (A1),m i (A2),...,m i (A N ),m i (Θ)); in, m i (A j ) indicates evidence E i Zhongjiaoyuan A j The basic probability assignment of .

4. The method for locating program defects based on statement execution paths as claimed in claim 3, characterized in that: The calculation process of the reliability factor of evidence is as follows: Set the test sample set to O = {o1, o2, ..., o T },O k (k=1,2,...,T) represents any test sample in the test sample set, the long short-term memory neural network C i The reliability factor of the evidence corresponding to (i=1,2,...,L) is Calculate the test sample O k (k=1,2,...,T) corresponding evidence E i Zhongjiaoyuan A j The Pignistic probability function value BetP{o k }(A j )for: Where X represents a set; Set the indicator function to δ jk (j=1,2,...,N;k=1,2,...,T), when the evaluation result is consistent with the true result, δ jk =1; when the evaluation result is inconsistent with the actual result, δ jk =0; Computational Long Short-Term Memory Neural Networks C i The reliability factor of the evidence corresponding to (i=1,2,...,L) as follows: Among them, α i is a variable, p jk =BetP{o k }(A j ).

5. The method for locating program defects based on statement execution paths as claimed in claim 4, characterized in that: According to the reliability factor, the evidence output by different LSTM neural networks is modified, and the modified evidence E i Zhongjiaoyuan A j The basic probability assignment m i '(A j )for:

6. The method for locating program defects based on statement execution paths as claimed in claim 1, characterized in that: In S3, when locating defects in the problem program, the problem program is divided into two sections, each of which can output results. For each section of the problem program, a program defect location method based on statement execution path is used to locate defects.

Citation Information

Patent Citations

  • Static code defect detection method, computer device and storage medium

    CN108710568A

  • Software defect positioning method based on deep neural network

    CN110109835A