A defect location method based on spectrum technology and assertion switching technology

By combining spectrum technology and assertion switching technology in software defect location, the slices are acquired and the doubt is recalculated, the problem of insufficient accuracy and efficiency of missed defect positioning in large projects is solved, and more efficient and accurate defect positioning is achieved.

CN114153735BActive Publication Date: 2025-04-29HANGZHOU DIANZI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111480144.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-06
Publication Date
2025-04-29
Estimated Expiration
2041-12-06

AI Technical Summary

Technical Problem

The accuracy and efficiency of the prior art for missed defect positioning in large projects need to be improved, especially the combination of spectrum technology and dynamic slicing technology is insufficient in identifying entities that really affect the output of the program.

Method used

The software defect positioning method based on spectrum technology and assertion switching technology is adopted. Slices are obtained through assertion switching technology, and suspicious lists are obtained in combination. Finally, the suspiciousness is recalculated through combined calculations to improve the accuracy of defect positioning.

Benefits of technology

It improves the accuracy of high-ranking statements in suspicious lists, achieves faster and more accurate defect positioning, and improves the efficiency and accuracy of dynamic slicing and spectrum combination technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114153735B_ABST
    Figure CN114153735B_ABST
Patent Text Reader

Abstract

The present invention relates to a defect location method based on spectrum technology and assertion switching technology. The present invention mainly considers how to obtain more accurate slices and how to combine slices with suspicious lists. First, the assertion switching technology is used to find all key assertions in the failed test of the program; then the failed test is sliced ​​to obtain the slices; then, the spectrum technology is used to analyze the program, that is, all test cases of the program are executed to collect spectrum information, and the spectrum information is used to calculate all suspicious elements and corresponding suspicion scores; finally, based on the obtained slices and suspicion scores, a new suspicious list is recalculated to locate the defects. The present invention enhances the location of some missed defects by the combination of slicing and spectrum technology, and further improves the location accuracy and efficiency after combining slicing with spectrum technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of software defect location, and relates to a software defect location method based on spectrum technology and assertion switching technology. Background Art

[0002] In the process of software development and maintenance, software debugging usually takes up a lot of resources in a project. Software debugging is to find errors in the code. For software development and maintenance, finding code snippets that need to be repaired is an inevitable process. The use of defect location technology can not only improve the efficiency of finding defects, but also improve the accuracy of defect repair.

[0003] In recent decades, many defect location technologies have been proposed to improve the efficiency and productivity of debugging projects. Spectral technology collects coverage information of test case execution to calculate the suspicion score of program entities to explore the relationship between program entities and failed cases, and finally obtains the suspicion ranking of program entities for location. However, this technology relies too much on coverage information and cannot identify which entities actually affect the program output, so some high-ranking entities may be irrelevant to defects. Program slicing tracks statements in the code using data and control dependencies to find a program slice whose execution affects the program output or a given point of interest. Among them, dynamic slicing technology occupies an important position due to its advantages such as less time consumption and higher accuracy. Through slicing, those entities that really affect the program output among the high-ranking entities can be identified to further exclude irrelevant suspicious entities. Therefore, the combination of dynamic slicing technology and spectral technology has become an important development direction. Although the combination of the two effectively solves the problems of spectral technology, it is still difficult to locate missed defects in large projects in reality. The accuracy and efficiency of this combined technology need to be improved. Summary of the invention

[0004] In view of the deficiencies of the prior art, the present invention proposes a software defect location method based on spectrum technology and assertion switching technology to further improve the efficiency and accuracy of dynamic slicing and spectrum combination technology, and provide a basis for defect location.

[0005] The software defect location method based on spectrum technology and assertion switching technology specifically includes the following steps:

[0006] Step 1: Slice acquisition based on assertion switching technology;

[0007] 1-1. Counting failed test cases

[0008] Among the provided test cases, all failed test cases are counted and filtered out;

[0009] 1-2. Find key assertions

[0010] For an assertion in a program, if the result of an assertion changes and causes the output of the entire program to change to the expected output, then this assertion is the key assertion of the program. The assertion switching technology is to find the key assertion by dynamically switching the result of the assertion. This technology first tracks the execution of the failed test to find all the branch assertions, then forces the switch of an assertion result in turn and re-executes the test case. If the output result of the program execution is the expected result, then the assertion is judged to be a key assertion;

[0011] Narrow down the assertions to be switched, and use the multi-assertions simultaneous switching strategy to switch in order to find more key assertions;

[0012] The assertion reduction is specifically as follows: first, all assertions are recorded by tracing the execution process of the program, then all statements controlled by the assertions are calculated, and it is determined whether there are executed statements in the controlled statements. If there are, the assertion is removed and the assertion is no longer switched;

[0013] The strategy of switching multiple assertions at the same time is as follows: after finding all the assertions that need to be switched, they are sorted and ranked according to the distance between the assertions and the output errors. The closer the distance is, the higher the ranking is. After all the rankings are obtained, the switching is performed. The entire ranking list is switched from high to low for single assertion switching, double assertion switching, and triple assertion switching. The double assertion switching fixes the assertion ranked first, and the triple assertion switching needs to fix the assertions ranked first and second.

[0014] 1-3. Get slices

[0015] Determine whether the program has key assertions, and slice the previously filtered failed test cases. If yes, put all key assertions into the slices during the slicing process, otherwise, slice directly;

[0016] 1-4. Fusion of slices

[0017] After obtaining the slices of the failed test cases of all programs, further processing is performed. If a program has multiple failed test cases, there are multiple slices, and these slices need to be processed by taking the union, while only the individual slices do not need to be processed.

[0018] Step 2: Obtain a suspicious list based on spectrum technology;

[0019] 2-1. Obtain spectrum information

[0020] 2-1-1. First, ensure that the program has at least one failed test case;

[0021] 2-1-2. Then execute all the test cases of the program and record the execution process to collect the corresponding data. The collected data includes: test cases, executed statements, and execution results. These data are coverage information and output information.

[0022] 2-1-3. A spectrum matrix is ​​formed through the interpreter: the row corresponds to each test case, the column corresponds to each statement, and a separate column vector is used to represent the execution result information;

[0023] 2-2. Calculate intermediate variables

[0024] 2-2-1. Input the spectrum information collected in the previous step into the analyzer and calculate the four intermediate variables. The formula is as follows:

[0025] a pq (j) = |{i|x ij = pΛe i =q}|

[0026] a 00 (j) represents the number of statements j that are not in the successful test cases, a 01 (j) indicates whether statement j is in the failed test case, a 10 (j) represents the number of statement j in the successful test cases, a 11 (j) represents the number of statement j in the failed test cases, x ij is the coverage result of statement j in test case i, e i is the execution result of test case i;

[0027] 2-3. Obtaining the Suspicious List

[0028] 2-3-1. After calculating the intermediate variables of each statement, the suspicion of the statement is calculated using the formula. The formula used here is:

[0029]

[0030] After obtaining the suspicion level of each statement, the statements are ranked according to the suspicion level to obtain a list of suspicious statements.

[0031] Step 3: Combine and calculate a new suspicious list;

[0032] 3-1. Confirmation statement

[0033] 3-1-1. Check whether the statements in the suspicion list are in the slice of the program. If they are, the slice score of the statement is 1, otherwise it is 0;

[0034] 3-2. Recalculate the suspicion level

[0035] 3-2-1. Recalculate the suspicion degree based on the suspicion degree score of the statement and the obtained slice score. The formula is as follows:

[0036] newsocre=α*oriscore+β*sliscore

[0037] Among them, oriscore is the ochiai score, sliscore is the slice score, α and β are coefficients, α+β=1;

[0038] Obtained a list of suspects for recalculating suspicion levels;

[0039] 3-2-1. Further locate defects based on the suspect list with recalculated suspicion.

[0040] Preferably, the parameters α and β are both set to 0.5 to keep the ochiai score and sliscore at the same priority, that is, to ensure that the proportion of the slice and the original suspicious list is the same, so that one side is not too heavy, resulting in the suspicious statements obtained by the slice or spectrum technology occupying too high a ranking.

[0041] Preferably, the further defect location is specifically as follows: first check the first 5 suspicious statements, then check the first 10 suspicious statements, and finally check the remaining statements in sequence.

[0042] Compared with the prior art, the present invention has the following effects: the accuracy of high-ranking sentences in the suspicious list is further improved, so that defect location can be performed faster and more accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 It is a finishing flow chart of the present invention;

[0044] Figure 2 is a flowchart of the assertion reduction algorithm;

[0045] Figure 3 This is a diagram illustrating the multi-assertion switching strategy. DETAILED DESCRIPTION

[0046] like Figure 1 As shown, the present invention mainly includes three parts: slice acquisition based on assertion switching technology, suspicious list acquisition based on spectrum technology, and combined calculation of new suspicious list.

[0047] Step 1: Slice acquisition based on assertion switching technology;

[0048] Slice acquisition based on assertion switching technology includes four steps: failed test statistics, key assertion search, slice acquisition, and slice fusion;

[0049] Step 1-1: Statistics of failed test cases

[0050] Among the test cases provided, there are both successful test cases and failed test cases, and some faulty programs have more than one failed test case, so all failed test cases should be counted and screened out for subsequent steps;

[0051] Step 1-2: Find the key assertion

[0052] The assertion switching technology is to find key assertions by dynamically switching the results of assertions. The assertion switching technology used in the present invention first needs to narrow down the assertions to be switched, and then use the multi-assertions simultaneous switching strategy to switch in order to find more key assertions;

[0053] Step 1-2-1: Narrow down assertions

[0054] like Figure 2 As shown, firstly, all assertions are recorded by tracing the execution process of the program, then all statements controlled by the assertions are calculated, and then it is determined whether there are executed statements in the controlled statements. If so, the assertion is removed and the assertion is no longer switched;

[0055] Step 1-2-2: Multiple assertion switching

[0056] After finding all the assertions that need to be switched, sort them and rank them according to the distance between the assertions and the output errors. The closer the distance, the higher the ranking. After all the rankings are obtained, switch them. For example, Figure 3 As shown, the entire ranking list is switched from high to low for single assertion, double assertion, and triple assertion, respectively. Double assertion switching and triple assertion switching require fixing the first-ranked assertion and the first and second-ranked assertions, respectively.

[0057] Steps 1-3: Get the slice

[0058] After finding all the key assertions, obtain the slices. Slice the execution process of the previously filtered failed test cases. Before slicing, it is necessary to determine whether the program has key assertions. If so, put all the key assertions into the unformed slices during the slicing process, otherwise, directly slice;

[0059] Steps 1-4: Fusing the slices

[0060] After obtaining the failed test slices of all programs, further processing is performed. If the program has multiple failed tests and therefore multiple slices, these slices need to be unioned. If the program has only a single slice, no processing is required.

[0061] Step 2: Obtain a suspicious list based on spectrum technology;

[0062] The acquisition of suspicious lists based on spectrum technology is divided into three steps: spectrum acquisition, intermediate variable calculation, and suspicious list acquisition;

[0063] Step 2-1: Obtain spectrum information

[0064] First, we need to ensure that the program has at least one failed test case. Then we execute all the test cases of the program and record the execution process to collect the corresponding data. The collected data includes: test cases, executed statements, and execution results. These data are coverage information and output information. Finally, we use the interpreter to form a spectrum matrix: rows correspond to each test case, columns correspond to each statement, and use a separate column vector to represent the execution result information.

[0065] Step 2-2: Calculate intermediate variables

[0066] Input the spectrum information collected in the previous step into the analyzer to calculate four intermediate variables. The formula is:

[0067] a pq (j) = |{i|x ij = pΛe i =q}|

[0068] a 00 (j) represents the number of statements j that are not in the successful test cases; a 01 (j) indicates the number of test cases where statement j is not in the failed test case; a 10 (j) represents the number of statement j in the successful test cases; a 11 (j) represents the number of statement j in the failed test cases, x ij is the coverage result of statement j in test case i, e i is the execution result of test case i;

[0069] Step 2-3: Get the suspect list

[0070] After calculating the intermediate variables of each statement, the suspicion score of the statement can be calculated using the formula, which is:

[0071]

[0072] After obtaining the suspicion level of each statement, a list of suspicious statements is obtained by ranking them according to the suspicion level.

[0073] Step 3: Combine and calculate the new suspect list

[0074] The suspicious list obtained by the spectrum technique is recalculated using the slices obtained by the assertion switching technique. This combined calculation is divided into two steps: confirming the statement and calculating the score;

[0075] Step 3-1: Confirmation statement

[0076] According to the statements in the suspicion list obtained by the spectrum technology, confirm whether they are in the slice of the program. If they are, the slice score of the statement is 1, otherwise it is 0;

[0077] Step 3-2: Recalculate suspicion

[0078] Based on the obtained ochiai score and the slice score sliscore, the suspicion is recalculated using the following formula:

[0079] newsocre=α*oriscore+β*sliscore

[0080] The parameters α and β are both set to 0.5 to keep the ochiai score and sliscore at the same priority, that is, to ensure that the proportion of the slice and the original suspicious list is the same, so that one side is not too heavy, so that the suspicious statements obtained by the slice or spectrum technology occupy too high a ranking. Finally, a suspicious list with a recalculated score is obtained, based on which defects can be further located, first checking the top 5 suspicious statements, then checking the top 10 suspicious statements, and finally checking the remaining statements in turn.

Claims

1. A defect location method based on spectrum technology and assertion switching technology, characterized in that it includes the following steps: Step 1: Slice acquisition based on assertion switching technology; 1-1. Counting failed test cases 1-1-1. Among the test cases provided, count and filter out all failed test cases; 1-2. Find key assertions Narrow down the assertions to be switched, and use the multi-assertions simultaneous switching strategy to switch in order to find more key assertions; The assertion reduction is as follows: first, all assertions are recorded by tracing the execution process of the program, then all statements controlled by the assertions are calculated, and it is determined whether there are executed statements in the controlled statements. If there are, the assertion is removed and the assertion is no longer switched; The strategy of switching multiple assertions at the same time is as follows: after finding all the assertions that need to be switched, they are sorted and ranked according to the distance between the assertions and the output errors. The closer the distance is, the higher the ranking is. After all the rankings are obtained, the switching is performed. From the entire ranking list, single assertion switching, double assertion switching, and triple assertion switching are performed from high to low. For double assertion switching, the assertion ranked first is fixed, and for triple assertion switching, the assertions ranked first and second are fixed. 1-3. Get slices Determine whether the program has key assertions, and slice the previously filtered failed test cases. If yes, put all key assertions into the slices during the slicing process, otherwise, slice directly; 1-4. Fusion of slices After obtaining the slices of all failed test cases of the program, further processing is performed. If a program has multiple failed test cases, there are multiple slices, and these slices need to be processed by taking the union, while only the individual slices do not need to be processed; Step 2: Obtain a suspicious list based on spectrum technology; 2-1. Obtain spectrum information 2-1-1. First, ensure that the program has at least one failed test case; 2-1-2. Then execute all the test cases of the program and record the execution process to collect the corresponding data. The collected data includes: test cases, executed statements, and execution results. These data are coverage information and output information. 2-1-3. A spectrum matrix is ​​formed through the interpreter: the row corresponds to each test case, the column corresponds to each statement, and a separate column vector is used to represent the execution result information; 2-2. Intermediate variable calculation 2-2-1. Input the spectrum information collected in the previous step into the analyzer and calculate the four intermediate variables. The formula is as follows: a pq (j)=|{i|x ij =pΛe i =q}| a 00 (j) represents the number of statements j that are not in the successful test cases; a 01 (j) indicates the number of test cases where statement j is not in the failed test case; a 10 (j) represents the number of statement j in the successful test cases; a 11 (j) represents the number of statement j in the failed test cases, x ij is the coverage result of statement j in test case i, e i is the execution result of test case i; 2-3. Obtaining the Suspicious List 2-3-1. After calculating the intermediate variables of each statement, the suspicion of the statement is calculated using the formula. The formula used here is: After obtaining the suspicion level of each statement, the statements are ranked according to the suspicion level to obtain a list of suspicious statements; Step 3: Combine and calculate a new suspicious list; 3-1. Confirmation statement 3-1-1. Check whether the statements in the suspicion list are in the slice of the program. If they are, the slice score of the statement is 1, otherwise it is 0; 3-2. Recalculate the suspicion level 3-2-1. Recalculate the suspicion degree based on the suspicion degree score of the statement and the obtained slice score. The formula is as follows: newsocre=α*oriscore+β*sliscore Among them, oriscore is ochiai score, sliscore is slice score, α and β are coefficients, α+β=1; the suspicious list of recalculated suspicion is obtained; 3-2-1. Further locate defects based on the suspect list with recalculated suspicion.

2. According to claim 1, a defect location method based on spectrum technology and assertion switching technology is characterized in that: The parameters α and β are both set to 0.5 to keep the ochiai score and sliscore at the same priority, that is, to ensure that the proportion of the slice and the original suspicious list is the same, so that one side is not too heavy, resulting in the suspicious statements obtained by the slice or spectrum technology occupying too high a ranking.

3. The defect location method based on spectrum technology and assertion switching technology according to claim 1 is characterized in that: The further defect location is specifically as follows: first check the first 5 suspicious statements, then check the first 10 suspicious statements, and finally check the remaining statements in sequence.

Citation Information

Patent Citations

  • Method for positioning software defects by redundancy removing and optimizing of frequency spectrum information

    CN104008051A

  • Incremental defect positioning method based on frequency spectrum

    CN105975388A