Program correction device, program correction method, and program correction program

The program correction device efficiently identifies and corrects multiple defect locations in programs by generalizing defects and applying correction candidates, enhancing debugging accuracy and speed.

JP7811522B2Active Publication Date: 2026-02-05HITACHI LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
JP2022103319
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Filing Date
2022-06-28
Publication Date
2026-02-05
Estimated Expiration
2042-06-28

AI Technical Summary

Technical Problem

Existing debugging technologies struggle to accurately detect and correct multiple defect locations in a program, especially when they are similar only in part of a line, and cannot be applied to software without a revision history.

Method used

A program correction device and method that identifies defect locations, generalizes defects, estimates other defect locations, and applies correction candidates using placeholder abstraction and material code fragments to efficiently rewrite code fragments.

Benefits of technology

Accurately detects and corrects defects in programs with high efficiency, improving debugging speed and accuracy by utilizing placeholder abstraction and material code fragments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007811522000001
    Figure 0007811522000001
  • Figure 0007811522000002
    Figure 0007811522000002
  • Figure 0007811522000003
    Figure 0007811522000003
Patent Text Reader

Abstract

To provide a method and program for detecting and correcting a failure existing in a program with high accuracy.SOLUTION: A program correction device 100 generates a single point correction candidate group 284 by eliminating a failure of a designated point of a source code of a program to be an object of software development, respectively generalizes (an abstraction failure point group 285, an abstraction source code 286) contents of the failure of the source code (the single point correction candidate group 284) in which the failure has been eliminated and the source code according to a prescribed rule, estimates another failure point (an additional failure point group 287) in the source code on the basis of the generalized contents of the failure, and applies processing for creating information (an additional material code group 288) for eliminating the other failure point and the created information to the other failure point in the source code on the basis of the failure of the designated point and the source code.SELECTED DRAWING: Figure 2
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present invention relates to a program correction device, a program correction method, and a program correction program. [Background technology]

[0002] In software development, if a program malfunctions (behavior that differs from what the developer intended), the program must be modified to prevent that malfunction from occurring. The cause of a program malfunction is called a defect (defect, fault, or bug). Debugging is the process of identifying the part of the program source file that contains the malfunction and rewriting that part to remove the malfunction. Debugging often uses test files that represent the behavior intended by the developer.

[0003] Developers perform debugging manually, but this has the problem of taking a long time. Therefore, Non-Patent Document 1 discloses a technology for automating debugging work. Specifically, the technology described in Non-Patent Document 1 is a technology for fixing a fault by identifying a part containing a fault from a source file (fault localization) and rewriting that part (patch generation). This technology fixes the fault by following a fix pattern (fix pattern). The code fragment at the location is changed to the correct source code fragment (donor) that exists at another location in the source file to be debugged. [Prior art documents] [Non-patent literature]

[0004] [Non-Patent Document 1] Seemanta Saha, Ripon K Saha, and Mukul R Prasad. Harnessing evolution for multi-hunk program repair. In Proceedings of the 41st International Conference on Software Engineering, pages 13-24. IEEE Press, 2019. Summary of the Invention [Problem to be solved by the invention]

[0005] The technology described in Non-Patent Document 1 detects multiple similar locations and rewrites them simultaneously to correct defects that require multiple rewrites. However, because the detection of similar locations is performed line by line in the source file, if there are multiple defect locations and they are similar only in part of a line, it is not possible to simultaneously detect and correct these multiple defect locations. Furthermore, if the defect location identification process calculates that one of the multiple defect locations is unlikely to contain a defect, other similar locations will not be detected, making it impossible to correctly rewrite all defect locations. Furthermore, because the source file's revision history is used to detect similar locations, it cannot be applied to software that does not have a revision history.

[0006] The present invention has been made in consideration of these circumstances, and its purpose is to provide a program correction device, a program correction method, and a program correction program that are capable of accurately detecting and correcting defects that exist in a program. [Means for solving the problem]

[0007] One aspect of the present invention for solving the above problem is a storage device for storing a program, and a program control device for specifying a location of a defect in the program, identifying the defect, and executing the program in accordance with a predetermined rule to identify the content of the defect in the program. The program correction device is equipped with a processing device that executes the following processes: generalizing each of the identified defects and estimating the locations of other defects in the program based on the content of the generalized defect; creating information to eliminate the locations of the other defects based on the identified defects and the program; and applying the created information to the locations of the other defects in the program. [Effects of the Invention]

[0008] According to the present invention, defects present in a program can be detected and corrected with high accuracy. Configurations and effects other than those described above will become apparent from the following description of the embodiments. [Brief explanation of the drawings]

[0009] [Figure 1] FIG. 2 illustrates an example of a hardware configuration of a program modification device. [Figure 2] FIG. 2 is a diagram illustrating an example of functions provided in a program correction device. [Figure 3] FIG. 2 is a diagram illustrating an example of a source file group described in the present embodiment. [Figure 4] FIG. 2 is a diagram illustrating an example of a test file group described in the present embodiment. [Figure 5] 10 is a flowchart illustrating an example of a program correction process. [Figure 6] FIG. 10 is a diagram illustrating an example of a defect location candidate. [Figure 7] FIG. 10 is a diagram illustrating an example of a group of single-location correction candidates. [Figure 8] FIG. 10 is a diagram illustrating an example of an abstracted defect portion group. [Figure 9] FIG. 10 is a diagram illustrating an example of abstracted source code. [Figure 10]FIG. 10 is a diagram illustrating an example of an additional defect location group. [Figure 11] FIG. 10 is a diagram showing an example of an additional material code group. [Figure 12] FIG. 10 is a diagram illustrating an example of a group of multiple-location correction candidates. [Figure 13] FIG. 10 is a diagram illustrating an example of a correction result. DETAILED DESCRIPTION OF THE INVENTION

[0010] Hereinafter, the present embodiment will be described with reference to the drawings. In the following description, the same or similar components will be denoted by the same reference numerals, and redundant description may be omitted.

[0011] FIG. 1 is a diagram illustrating an example of the hardware configuration of a program modifying device 100. As shown in FIG. The program modification device 100 is an information processing device that includes a processor 110, a main memory device 120, an auxiliary memory device 130, an input device 140, an output device 150, and a communication device 160. These devices are connected to each other so that they can communicate with each other via communication means such as a bus (not shown).

[0012] The processor 110 is, for example, a CPU (Central Processing Unit) or an MPU (Microprocessor Unit). The processor 110 reads and executes a program stored in the main memory 120, thereby realizing various functional units of the program modification device 100, which will be described later.

[0013] The main memory device 120 is a device that stores programs and data, and is, for example, a read-only memory (ROM), a random access memory (RAM), or a non-volatile semiconductor memory (NVRAM (Non Volatile RAM)). The main memory device 120 stores the programs described below.

[0014] The auxiliary storage device 130 may be, for example, a hard disk drive, a solid state drive (SSD), an optical storage device (a compact disc (CD), a digital versatile disc (DVD), etc.), , a storage system, an IC card, a reading and writing device for a recording medium such as an SD memory card or an optical recording medium, or a storage area of ​​a cloud server. The programs and data stored in the memory 120 are read into the main memory 120 as needed.

[0015] The input device 140 is, for example, a keyboard, a mouse, a touch panel, a card reader, or an audio input device, and receives input of various information from the user. The output device 150 is a user interface that provides the user with various information such as processing progress and processing results, and is, for example, a screen display device (liquid crystal monitor, LCD (Liquid Crystal Display), graphic card, etc.), an audio output device (speaker, etc.), or a printer, etc.

[0016] Instead of the input device 140 or the output device 150, the program modifying device 100 may be configured to input or output information to or from another input / output device connected via a communication device 160.

[0017] The communication device 160 is a wired or wireless communication interface that enables communication with other devices via a communication network such as a LAN (Local Area Network) or the Internet, and is, for example, a NIC (Network Interface Card), a wireless communication module, a USB (Universal Serial Interface) module, or a serial communication module.

[0018] Here, terms used in this embodiment will be defined. The "source code" refers to a program that is the subject of software development, and the description language and data format are not particularly limited. In this embodiment, the source code (before being modified by the program modification device 100) contains multiple defects that cause behavior different from that intended by the developer.

[0019] A "method" is a unit of processing in a program. A method contains one or more statements. A statement contains zero or more functions or expressions. Instructions and expressions together are called "code fragments." A source code contains one or more such methods.

[0020] A "field" is a variable or constant that can be referenced by all methods. A source code contains zero or more fields.

[0021] A "method call" refers to an expression (function) that performs a call process to call a method.

[0022] "Field access" refers to an expression (function) that performs a reference process that references a field.

[0023] "Scope" is information that specifies (limits) the access range (call range or reference range) of a method or field when calling a method or referencing a field in source code. For example, a method call is expressed in the format "scope.method(parameter)", and a field access is expressed in the format "scope.field".

[0024] "Test code" is a program that checks the behavior of source code. Test code contains programs that verify whether the code performs the intended function.

[0025] A "test method" is a unit of processing in test code. For example, a test method is a program that checks the behavior of a single method. A test method that checks a particular method is called the "corresponding test method" of that method. A single method may have two or more corresponding test methods. Test code contains one or more such test methods.

[0026] 2 is a diagram showing an example of the functions of the program correction device 100. The program correction device 100 of this embodiment attempts to correct a program by rewriting code fragments at locations in the source code that contain multiple defects with raw code fragments. At this time, if the source code fragments can be rewritten to the correct answer, the program can be corrected.

[0027] As shown in the figure, the program modification device 100 includes the following functional units: a defect location identification unit 210, a single location modification candidate generation unit 220, an additional defect location extraction unit 230, an additional material code generation unit 240, a multiple location modification candidate generation unit 250, a modification candidate inspection unit 260, and an information storage unit 280.

[0028] The defect location identifying unit 210 receives a source file group 281 and a test file group 282 as input, and outputs a defect location candidate group 283 (see FIG. 6 for details).

[0029] The single location correction candidate generation unit 220 receives a source file group 281 and a defect location candidate group 283 as input, and outputs a single location correction candidate group 284 (see FIG. 7 for details).

[0030] The additional defect part extraction unit 230 receives the single part correction candidate group 284 as input and outputs an abstracted defect part group 285 (see FIG. 8 for details).

[0031] The additional defect part extraction unit 230 receives the source file group 281 and the single part correction candidate group 284 as input, and outputs 286 (see FIG. 9 for details).

[0032] The additional defect location extraction unit 230 receives the abstracted defect location group 285 and the abstracted source code 286 as input, and outputs an additional defect location group 287 (see FIG. 10 for details).

[0033] The additional material code generation unit 240 receives the source file group 281 and the single-location correction candidate group 284 as input, and outputs the additional material code group 288 (see FIG. 11 for details).

[0034] The multiple location correction candidate generation unit 250 receives the single location correction candidate group 284, the additional defective location group 287, and the additional material code group 288 as input, and outputs the multiple location correction candidate group 289 (see FIG. 12 for details).

[0035] The correction candidate inspector 260 receives the test file group 282, the single-location correction candidate group 284, and the multiple-location correction candidate group 289 as input, and outputs the correction result 291 (see FIG. 13 for details).

[0036] The information storage unit 280 stores a source file group 281, a test file group 282, a defect location candidate group 283, a single location correction candidate group 284, an abstracted defect location group 285, abstracted source code 286, an additional defect location group 287, an additional material code group 288, a multiple location correction candidate group 289, and correction results 291.

[0037] The source file group 281 is a collection of source files for which defects are to be resolved. A source file consists of one or more lines. The language of the source code written in the source files is not particularly limited, but may be, for example, Java (registered trademark) or C++.

[0038] The test file group 282 includes one or more test code files (test files) for verifying whether or not there is a defect in the source files of the source file group 281. A test file consists of one or more lines.

[0039] (Source files) 3 is a diagram showing an example of the source file group 281 described in this embodiment. The source file group 281 includes a source file 310 with the file name File1 and The source file 320 has the file name File2.

[0040] The source file 310 with the file name File1 contains 9 lines of source code. The content of a method named checkCubeAndCalcVolume is written in the 3rd line.

[0041] The source code of this source file 310 contains defects on lines 3 and 5. Specifically, to resolve this defect, "SHAPES.REC" (reference numeral 311) in "String[ ] keys={SHAPES.REC, SHAPES.TRI, SHAPES.HEX} ;" on line 3 is rewritten to "SHAPES.CUBE", and "SHAPES.REC" in "if(shape.is(SHAPES.REC)){" on line 5 is rewritten to "SHAPES.REC" " (code 312) must be rewritten as "SHAPES.CUBE".

[0042] (test files) 4 is a diagram showing an example of the test file group 282 described in this embodiment. The test file group 282 includes a test file 410 with the file name File1Test. .

[0043] This test file 410 has 11 lines of test code. The test file 410 has a test method named testVolumeCube1 on lines 1 to 5, and a test method named testVolumeCube2 on lines 7 to 11. The first line contains a test method named testVolumeCube2. Both test methods testVolumeCube1 and testVolumeCube2 are corresponding test methods for the method checkCubeAndcalcVolume in source file 310.

[0044] The developer of the program intended to design the test code in lines 2 to 4 and lines 8 to 10 of the test file 410 so that the method checkCubeAndCalcVolume in the source file 310 would output the volume 8 of a cube with a side length of 2 when 0 was input, and would output "-1" indicating that the cube is not a cube when 2 was input. It has.

[0045] Next, the defect location candidate group 283 shown in FIG. 2 is information that identifies the location (line in this embodiment) of the defect location in the source code.

[0046] The single-location correction candidate group 284 is a collection of source files (hereinafter referred to as first correction candidates) in which a defective location (code fragment) in the source code has been rewritten at one location.

[0047] The abstracted defect location group 285 is a collection of code fragments (hereinafter referred to as abstracted modified code fragments) that have been abstracted (generalized) from the code fragments (hereinafter referred to as modified code fragments) that had defects and were rewritten in the single location modification candidate group 284.

[0048] The abstracted source code 286 is a set of source code that has been abstracted (generalized) by replacing a part (code fragment) of a source file with a predetermined symbol (placeholder). In this embodiment, the placeholder is "$ID", but other symbols may be used. The following string may also be used:

[0049] The additional defect location group 287 is a collection of information for identifying lines in the source code that include defect locations other than modified code fragments (hereinafter referred to as additional modified code fragments).

[0050] The additional material code group 288 includes corrections ( It should be noted that, hereinafter, each code fragment in the additional material code group 288 will be referred to as a material code fragment.

[0051] The multiple location correction candidate group 289 is a collection of information on source code (hereinafter referred to as second correction candidate) in which defective locations (code fragments) are rewritten using each material code fragment in the additional material code group 288.

[0052] The correction result 291 is information about the source code in which the defect has been resolved.

[0053] The functions of each functional unit of the program modification device 100 described above are realized by the processor 110 reading out a program created corresponding to each functional unit from the main storage device 120 or the auxiliary storage device 130. These programs can be recorded on, for example, a portable or fixed recording medium and distributed. Note that all or part of each function of the program modification device 100 may be realized using virtual information processing resources provided using virtualization technology, process space separation technology, or the like, such as a virtual server provided by a cloud system. Furthermore, all or part of each functional unit of the program modification device 100 may be realized by, for example, a service provided by a cloud system via an API (Application Programming Interface), or the like. Next, the processing performed by the program modifying device 100 will be described.

[0054] <Program correction process> 5 is a flowchart showing an example of the program modification process performed by the program modification device 100. The program modification process is started, for example, when the program modification device 100 receives an instruction input from a user, or by a batch process set to be executed at a scheduled timing. Note that in the following, the letter "S" before the reference numeral indicates a processing step.

[0055] First, the defect location identification unit 210 reads the source file group 281 and the test file group 282 stored in the information storage unit 280, executes the test files, and stores information on the defect locations in the source file group 281 identified as a result in the defect location candidate group 283 (S111).

[0056] The fault location may be, for example, a method call to a method having a scope or a field access to a field having a scope. The fault location may be identified using, for example, static analysis or fault localization. Note that the fault location identifying unit 210 may resolve the fault identified in S111 as a definitive one.

[0057] (Possible defect location) FIG. 6 is a diagram showing an example of the defect part candidate group 283. As shown in FIG.

[0058] The defect location candidate group 283 includes one or more entries. An entry of the defect location candidate group 283 includes columns of a file name 2831, a line number 2832, and a suspiciousness 2833. The file name 2831 stores the file name of a source file that may contain a defect, and the line number 2832 stores the line number of the defect location in that source file. The suspiciousness 2833 stores the degree of likelihood that the defect location contains a defect. In the example of the same figure, entry 2834 of the defect location candidate group 283 records that there is a high probability (1.0) that the description on the third line of the source code contains a defect location.

[0059] If the part containing the defect can be uniquely identified, the entry does not necessarily include the file name. It is not necessary that information be set in all of 2831, line number 2832, and suspiciousness 2833.

[0060] Next, as shown in FIG. 5, the single-location correction candidate generation unit 220 reads and analyzes the source file group 281 and the defect location candidate group 283 stored in the information storage unit 280, thereby generating a single-location correction candidate group 284 including the first correction candidate (S112).

[0061] Specifically, the single-location correction candidate generation unit 220 selects one of the defect locations registered in the defect location candidate group 283, and rewrites the selected location with another correct description to generate the single-location correction candidate group 284. The single-location correction candidate group 284 may be generated using, for example, a correction template, or may be generated by brute-force. Alternatively, a developer may create it manually.

[0062] (Single-location correction suggestions) 7 is a diagram showing an example of the single location correction candidate group 284. This single location correction candidate group 284 includes one or more single location correction candidates 2841 (first correction candidates). The single location correction candidate 2841 stores the source code 310 of the source file group 281 obtained by rewriting one of the defect locations registered in the defect location candidate group 283.

[0063] In the example shown in the figure, the source code for the single-location correction candidate 2841 is source code in which the field access 311 “SHAPES.REC”, which is the defective part located on the third line of the source file 310 (File1), has been rewritten to the field access 2842 “SHAPES.CUBE”.

[0064] Next, as shown in FIG. 5, the additional defect part extraction unit 230 outputs an additional defect part group 287 based on the source file group 281 stored in the information storage unit 280 and the single-part correction candidate group 284 in accordance with the following processes P1 to P3 (S113).

[0065] Process P1: The additional defect location extraction unit 230 abstracts the code fragments in the single location correction candidate group 284 and outputs them to the abstracted defect location group 285.

[0066] Specifically, the additional defect location extraction unit 230 abstracts the method specification part in the method call whose scope (call range) is specified and the field reference part in the field access whose scope (reference range) is specified in the single location correction candidate group 284 by replacing them with the placeholder "$ID", and then extracts them as abstracted parts. On the other hand, if the code fragment in the single-location correction candidate group 284 is neither a method call nor a field access, the additional defect location extraction unit 230 outputs it as is to the abstracted defect location group 285 without replacing it with a placeholder. Note that if another method call or field access appears as a parameter in a method call, the additional defect location extraction unit 230 may replace only the innermost method call or field access with the placeholder "$ID".

[0067] Furthermore, the additional defect part extraction unit 230 does not need to replace with placeholders the method specification part in a method call whose scope is not specified and the field reference part in a field access whose scope is not specified. This reduces the number of code fragments to be abstracted, thereby preventing unnecessary additional defect parts from being output in process P3 described below.

[0068] (Abstraction defect group) FIG. 8 is a diagram showing an example of the abstracted defect part group 285. As shown in FIG.

[0069] The abstracted defect location group 285 includes one or more abstracted defect locations 2851. The abstracted defect location 2851 is information including a code fragment obtained by abstracting a code fragment (corrected code fragment) whose description has been rewritten in the single location correction candidate group 284, that is, an abstracted corrected code fragment.

[0070] For example, the field access 311 "SHAPES.REC" of the source file 310, which is a code fragment of the single-location correction candidate group 284 rewritten by the process of S112, is a code fragment with a specified scope. Specifically, the scope "SHAPES" and the field "REC Therefore, the additional defect part extraction unit 230 performs abstraction by rewriting the field “REC” part of the field access 311 “SHAPES.REC” to the placeholder “$ID”, and outputs the abstracted correction code fragment 2852 “SHAPES.$ID” to the abstract defect part group 285.

[0071] Process P2: Next, the additional defect location extraction unit 230 abstracts the entire source code included in the source file group 281 (regardless of whether there is a defect therein) and outputs it to the abstracted source code 286. The abstraction method is the same as in process P1. However, the additional defect location extraction unit 230 does not abstract the lines rewritten in the single location correction candidate group 284.

[0072] (abstract source code) FIG. 9 is a diagram showing an example of the abstracted source code 286.

[0073] This abstracted source code 286 is abstracted by rewriting part of the source code included in the source file 310 in the source file group 281 into the placeholder "$ID". This is the source code information.

[0074] In the figure, the additional defect location extraction unit 230 extracts the abstractable source code included in the source file group 281, other than the third line 2861 of the source file 310 “File1” that has been output (rewritten) to the single location correction candidate group 284 by the process of S112. By abstracting all the code, abstracted source code 286 is output.

[0075] For example, the method call 313 "shape.is(SHAPES.REC)" on line 5 of the source file 310 "File1" uses the field access 312 "SHAPES.REC" (which is simply Since the source file 310 "File1" contains a method call 314 "Math.power(shape.length1,3)" on the sixth line of the source file 310 "File1" which contains a field access 315 "shape.length1" whose parameter is specified as a scope, the additional defect extraction unit 230 abstracts this and outputs it as it is to the abstract source code 286. The output is to code 286 (code 2862).

[0076] Process P3: Next, the additional defect location extraction unit 230 identifies all lines of the abstracted source code 286 that contain abstraction correction code fragments registered in the abstraction defect location group 285 and that are different from the lines whose code fragments have been rewritten by the single-location correction candidate group 284 in the process of S112 (i.e., lines that contain additional defects), and outputs information about each identified line to the additional defect location group 287.

[0077] (Additional defect areas) FIG. 10 is a diagram showing an example of the additional defect location group 287. As shown in FIG.

[0078] The added defect location group 287 includes zero or more entries. The entries of the added defect location group 287 include columns of a file name 2871 and a line number 2872. The file name 2871 stores the file names of the source files 310 and 320 containing the added defect, and the line number 2872 stores the file names of the source files 310 and 320 containing the added defect. Number 2872 stores the line number of the line containing the additional defect.

[0079] In the example shown in the figure, the additional defect part extraction unit 230 extracts the code fragment 2852 "SHAPES.$ID" from the fifth line 286 of the abstracted source code 286, which is registered in the abstracted defect part group 285 and is abstracted from the source file 310 (File1). 3 corresponds to the source file 310 (File1), and the line number of the additional defect group 287 Output to 2872.

[0080] Next, the additional material code generation unit 240 generates an additional material code group 288 based on the single-location correction candidate group 284 (S114).

[0081] Specifically, for example, if a code fragment (modified code fragment) rewritten in the single-location modification candidate group 284 is a field access, the additional material code generation unit 240 extracts, from the source file group 281, other field access expressions that reference a field included in the same scope as the code fragment, and outputs the field portion to the additional material code group 288. Also, for example, if the modified code fragment is a method call, the additional material code generation unit 240 extracts, from the source file group 281, other method call expressions that call methods included in the same scope as the code fragment. Then, the additional material code generation unit 240 excludes, from the extracted method call expressions, method call expressions that have a different number or type of parameters from those of the code fragment, and outputs the method call portion to the additional material code group 288.

[0082] If the code fragment is not used to generate the single-location correction candidate group 284, the additional material code generation unit 240 outputs an additional material code of 0.

[0083] (Additional material code group) 11 is a diagram showing an example of the additional material code group 288. The additional material code group 288 includes zero or more additional material codes 2881.

[0084] The additional material code 2881 is, for example, a code fragment used for rewriting in the single-location correction candidate group 284, a field access expression that refers to another field included in the same scope as the code fragment, or a method call expression that calls another method included in the same scope as the code fragment. The additional material code 2881 shown in the figure is a field access 2881a "SAHPES.CUBE" and other methods included in the same scope as the code fragment. The other code fragments referencing the fields include field accesses 2881b, c ("SHAPES.TRI", "SHAPES.HEX").

[0085] It should be noted that the code fragment (modified code fragment) rewritten in the single-location correction candidate group 284 does not have to be set in the additional material code group 288. For example, the code fragment "SHAPES.REC" rewritten in the single-location correction candidate group 284 is not set in the additional material code group 288 shown in the same figure.

[0086] Next, as shown in FIG. 5, the multiple-location correction candidate generation unit 250 outputs a multiple-location correction candidate group 289, which is information on the second correction candidate, based on the single-location correction candidate group 284, the additional defective location group 287, and the additional material code group 288 (S115).

[0087] Specifically, the multiple location correction candidate generation unit 250 identifies each code fragment of the location (line) indicated by the additional defect location group 287 from the source code of the single location correction candidate group 284 while referring to the abstracted source code 286, and rewrites the defect location of each identified code fragment with each material code fragment registered in the additional material code group 288, thereby outputting the multiple location correction candidate group 289. The multiple-location correction candidate generator 250 can execute the rewriting using the same method as that used to generate the single-location correction candidate group 284, but the rewriting method is not particularly limited.

[0088] (Multiple correction suggestions) 12 is a diagram showing an example of the multiple location correction candidate group 289. The multiple location correction candidate group 289 includes zero or more multiple location correction candidates 510 (510a, 510b, 510c, ...) (second correction candidates). The multiple location correction candidates 510 have source code in which the defect locations in each line registered in the additional defect location group 287 in the source code of the single location correction candidate group 284 are rewritten using each material code fragment in the additional material code group 288.

[0089] The multiple location correction candidate 510a shown in the figure is the field access "SHAPES.REC" at the location indicated by line number 2872 of the additional defect location group 287 (the fifth line of File1). This is the source code rewritten using the field access 2881a "SHAPES.CUBE" registered in the additional material code 2881 of the material code group 288. Also, there are multiple correction candidates 51 0b is the part indicated by line number 2872 of the additional defect part group 287 (5 of File1 The multiple location correction candidate 510c is a source code in which the field access "SHAPES.REC" at the location indicated by line number 2872 of the additional defect location group 287 (the fifth line of File1) is rewritten with another field access 2881b "SHAPES.TRI" registered in the additional material code 2881 of the additional material code group 288. This is the source code rewritten with other field access 2881c "SHAPES.HEX".

[0090] Next, as shown in FIG. 5, the correction candidate inspection unit 260 outputs a correction result 291 based on the test file group 282, the single-location correction candidate group 284, and the multiple-location correction candidate group 289 stored in the information storage unit 280 (S116).

[0091] Specifically, the correction candidate inspection unit 260 acquires output data for each test file by inputting each of the correction candidates (first correction candidate, second correction candidate) included in each source code of the single-location correction candidate group 284 and the multiple-location correction candidate group 289 into each test file of the test file group 282. If the output data of the test file indicates that the line including the defective part has been correctly rewritten, the correction candidate inspection unit 260 outputs the correction candidate to the correction result 291. Note that, for example, static analysis or test code may be used to inspect whether the line including the defective part has been correctly rewritten.

[0092] Thereafter, the program modification device 100 may repeat the process of S112 (S117) to generate a new single-location modification candidate group 284. At this time, the program modification device 100 may initialize the additional defect location extraction unit 230, the additional material code generation unit 240, the multiple-location modification candidate generation unit 250, the abstracted defect location group 285, the abstracted source code 286, the additional defect location group 287, and the additional material code group 288. This makes it possible to generate independent first modification candidates for multiple first modification candidates, and to remove more defects without affecting each other.

[0093] At this time, the single location modification candidate generation unit 220 of the program modification device 100 may also select another entry from the defect location candidate group 283. In this way, if a defect cannot be resolved by modifying a code fragment in a certain line, modifications to code fragments in other lines can also be tried, thereby making it possible to resolve the defect with a higher probability.

[0094] (Result of correction) 13 is a diagram showing an example of a correction result 291. The correction result 291 shown in the figure includes a first correction candidate for changing the field access 311 "SHAPES.REC" on the third line of the source code of the source file 310 to a field access 2911 "SHAPES.CUBE" on the fifth line. Change field access 312 "SHAPES.REC" to field access 2912 "SHAPES.CUBE" " (Second modification candidate) The source code that fixed the problem by rewriting each is stored.

[0095] As described above, the program correction device 100 of this embodiment generates a group of single-location correction candidates 284 by eliminating defects at specified locations in the source code, generalizes the content of the defect and the source code in the source code from which the defect has been eliminated (single-location correction candidate group 284) according to predetermined rules (abstracted defect location group 285, abstracted source code 286), estimates other defect locations in the source code based on the generalized content of the defect (additional defect location group 287), creates information for eliminating the other defect locations based on the single-location correction candidate group 284 and the source code (additional material code group 288), and applies the created information to the other defect locations in the source code.

[0096] In other words, by abstracting the initially identified defect location and source code and referencing both, the program correction device 100 can make a wide range of estimates of other defect locations in the source code and create correction candidates, and can correct other defects in the source code using the created correction candidates.

[0097] In this way, the program correction device 100 of this embodiment can accurately detect and correct defects in a program, thereby improving the efficiency of the developer's debugging work.

[0098] Furthermore, the program modifying apparatus 100 of this embodiment generalizes the source code by replacing the method of a method call and the field of a field access whose scope is specified with a placeholder.

[0099] This allows you to identify locations in the source code where bugs are likely to occur and efficiently correct the source code.

[0100] Furthermore, the program modifying device 100 of this embodiment treats the field and method portions in the field access and method call where the scope is not clearly specified as part of the generalized source code.

[0101] In this way, by not performing abstraction processing when abstraction is not necessary, it is possible to identify and resolve the defect location more quickly.

[0102] Furthermore, the program correction device 100 of this embodiment eliminates defects in the part of a method call having a scope or the part of a field access of a field having a scope (single-location correction candidate group 284), and generates other part of a method call within the same scope or field access within the same scope as an abstraction defect location group 285.

[0103] This allows method calls or field accesses that call or produce methods or fields within the same scope to be used as material for correcting other defects, making it possible to efficiently correct areas where defects are likely to exist.

[0104] The present invention is not limited to the above-described embodiment, and can be implemented using any components without departing from the spirit of the present invention. The above-described embodiment and modifications are merely examples. The present invention is not limited to these details as long as the features of the invention are not impaired. Furthermore, although various embodiments and modifications have been described above, the present invention is not limited to these details. Other aspects that can be considered within the scope of the technical idea of ​​the present invention are also included within the scope of the present invention.

[0105] For example, part of the hardware provided in each device of this embodiment may be provided in another device.

[0106] Furthermore, each program of the program modification device 100 may be provided in another device, a program may consist of multiple programs, or multiple programs may be integrated into one program. [Explanation of symbols]

[0107] 100 Program correction device 210 Defective part identification section 220 Single-location correction candidate generation unit 230 Additional defect extraction section 240 Additional Material Code Generation Unit 250 Multiple location correction candidate generation unit 260 Correction Suggestion Inspection Unit

Claims

1. a storage device for storing a program; and a process of identifying a location of a defect in the program, generalizing the content of the defect in the program in which the defect has been identified and the program in accordance with a predetermined rule, and estimating the location of other defects in the program based on the content of the generalized defect; A process of creating information for resolving the other defects based on the identified defects and the program; and a processing device that applies the created information to the other defective parts of the program. Equipped with The processing device includes: generalizing the program by substituting the predetermined symbol for a portion of a process that calls another process having a specified call range, or a portion of a process that references a constant or variable having a specified reference range, with the predetermined symbol; generalizing the program by substituting, with the predetermined symbol, a portion of a process that calls another process for which the calling range is specified, or a portion of a process that references a constant or variable for which the reference range is specified, with the predetermined symbol; Program correction device.

2. The processing device includes: Identify defects in the part of the call process that calls other processes with a specified call range, or in the part of the reference process that references a constant or variable with a specified reference range, As information for resolving the other defect, information on a part of a calling process that calls another process within the calling range, or information on a part of a referencing process that refers to another constant or variable within the referencing range is created. The program correction device according to claim 1 .

3. The information processing device Store the program a process of identifying a location of a defect in the program, generalizing the content of the defect in the program in which the defect has been identified and the program in accordance with a predetermined rule, and estimating the location of other defects in the program based on the content of the generalized defect; A process of creating information for resolving the other defects based on the identified defects and the program; and applying the created information to the other defect location in the program. generalizing the program by substituting the predetermined symbol for a portion of a process that calls another process having a specified call range, or a portion of a process that references a constant or variable having a specified reference range, with the predetermined symbol; generalizing the program by substituting, with the predetermined symbol, a portion of a process that calls another process for which the calling range is specified, or a portion of a process that references a constant or variable for which the reference range is specified, with the predetermined symbol; How to fix the program.

4. In the information processing device, Store the program Identifying a location of a defect in the program, generalizing the content of the defect in the program in which the defect is identified and the program in accordance with a predetermined rule, A process of estimating locations of other defects in the program based on the generalized defect content; A process of creating information for resolving the other defects based on the identified defects and the program; and applying the created information to the other defect location in the program, generalizing the program by substituting the predetermined symbol for a portion of a process that calls another process having a specified call range, or a portion of a process that references a constant or variable having a specified reference range, generalizing the program by replacing, with the predetermined symbol, a portion of a process that calls another process for which the call range is specified, or a portion of a process that references a constant or variable for which the reference range is specified, with the predetermined symbol; Program fixes.

Citation Information

Patent Citations

  • Similar source code extraction program, similar source code extraction device and similar source code extraction method

    JP2006018693A

  • Automatic candidate correction patch generation

    JP2020126603A

  • Automatic identification of posts related to software patches

    JP2022029423A