JP2024003945A - Program correction device, program correction method, and program correction program - Google Patents

Program correction device, program correction method, and program correction program Download PDF

Info

Publication number
JP2024003945A
JP2024003945A JP2022103319A JP2022103319A JP2024003945A JP 2024003945 A JP2024003945 A JP 2024003945A JP 2022103319 A JP2022103319 A JP 2022103319A JP 2022103319 A JP2022103319 A JP 2022103319A JP 2024003945 A JP2024003945 A JP 2024003945A
Authority
JP
Japan
Prior art keywords
program
defect
location
group
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2022103319A
Other languages
Japanese (ja)
Inventor
吉楠 代
Kitsunan Dai
和矢 安田
Kazuya Yasuda
信治 伊藤
Shinji Ito
正恭 加藤
Masayasu Kato
岳人 東
Takehito Azuma
知倫 中村
Tomomichi Nakamura
真雄 原田
Masao Harada
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2022103319A priority Critical patent/JP2024003945A/en
Publication of JP2024003945A publication Critical patent/JP2024003945A/en
Pending legal-status Critical Current

Links

Images

Abstract

PROBLEM TO BE SOLVED: 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
COPYRIGHT: (C)2024,JPO&INPIT

Description

本発明は、プログラム修正装置、プログラム修正方法、及びプログラム修正プログラムに関する。 The present invention relates to a program modification device, a program modification method, and a program modification program.

ソフトウェア開発において、プログラムに故障(開発者の意図と異なる動作)が発生した場合、当該故障が発生しないようにプログラムを修正する。プログラムの故障を引き起こす原因を不具合(欠陥、フォールト、又はバグ)と呼ぶ。プログラムのソースファイル中から不具合を含む箇所を特定し、当該箇所を書き換えることで不具合を取り除く作業をデバッグと呼ぶ。デバッグには、開発者の意図する動作を表したテストファイルを用いることが多い。 In software development, when a malfunction occurs in a program (an operation that differs from the developer's intention), the program is modified so that the malfunction does not occur. The causes of program failures are called defects (defects, faults, or bugs). Debugging is the process of identifying a location in a program's source file that contains a defect and rewriting the location to remove the defect. For debugging, test files that represent the behavior intended by the developer are often used.

開発者は手作業によりデバッグを行うが、これには長い時間を要するという問題がある。そこで、非特許文献1には、デバッグ作業を自動化する技術が開示されている。非特許文献1に記載された技術は、具体的には、ソースファイルから不具合を含む箇所を特定し(fault localization)、当該箇所を書き換える(patch generation)ことで、不具合を修正する技術である。この技術は、修正パターン(fix pattern)に従い、不具合を含む
箇所のコード片を、デバッグ対象のソースファイル中の別の箇所に存在する正しい素材コード片(donor)に変更するものである。
Developers manually debug, but this has the problem of taking a long time. Therefore, Non-Patent Document 1 discloses a technique for automating debugging work. Specifically, the technique described in Non-Patent Document 1 is a technique for correcting the defect by identifying a location containing a defect from a source file (fault localization) and rewriting the location (patch generation). This technique follows a fix pattern to change a code fragment containing a defect to a correct source code fragment (donor) that exists elsewhere in the source file to be debugged.

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.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.

非特許文献1に記載された技術では、複数の近似している箇所を検出し、それらを同時に書き換えることで、複数箇所の書き換えが必要な不具合を修正する。しかしながら、近似している箇所の検出をソースファイルの行単位で行うため、複数の不具合箇所がありそれらが行の一部分でのみ近似している場合、それら複数の不具合箇所を同時に検出し修正することができない。また、複数の不具合箇所のうち、不具合箇所特定処理により不具合を含む可能性が低く計算される箇所が含まれている場合、近似している他の箇所が検出対象にならないため、すべての不具合箇所を正しく書き換えることができない。さらに、近似している箇所の検出にはソースファイルの修正履歴を使用するため、修正履歴がないソフトウェアには適用できない。 The technique described in Non-Patent Document 1 detects a plurality of similar locations and rewrites them at the same time, thereby correcting a problem that requires rewriting of multiple locations. However, since the detection of similar parts is performed line by line in the source file, if there are multiple defective parts and they are approximated only in part of the line, it is difficult to detect and correct the multiple defective parts at the same time. I can't. In addition, if a location that is calculated to have a low probability of containing a defect is included among multiple defective locations, other similar locations will not be detected, so all defective locations will be detected. cannot be rewritten correctly. Furthermore, since the modification history of the source file is used to detect similar parts, it cannot be applied to software that does not have a modification history.

本発明は、このような事情に鑑みてなされたものであり、その目的は、プログラム中に存在する不具合を精度良く検出して修正することが可能なプログラム修正装置、プログラム修正方法、及びプログラム修正プログラムを提供することを目的とする。 The present invention has been made in view of the above circumstances, and its purpose is to provide a program correction device, a program correction method, and a program correction method that can accurately detect and correct defects existing in a program. The purpose is to provide programs.

上記課題を解決するための本発明の一つは、プログラムを記憶する記憶装置、及び、前記プログラムにおける不具合の箇所を特定して当該不具合を特定し、前記不具合を特定したプログラムにおける前記不具合の内容及び前記プログラムを所定のルールに従ってそれ
ぞれ汎化し、前記汎化した不具合の内容に基づき、前記プログラムにおける他の不具合の箇所を推定する処理と、前記特定した不具合及び前記プログラムに基づき、前記他の不具合の箇所を解消するための情報を作成する処理と、前記作成した情報を前記プログラムにおける前記他の不具合の箇所に適用する処理とを実行する処理装置を備えるプログラム修正装置である。
One of the present inventions for solving the above problems is a storage device for storing a program, a location of a defect in the program to identify the defect, and a content of the defect in the program in which the defect has been identified. and a process of generalizing the program according to a predetermined rule, and estimating the location of another defect in the program based on the content of the generalized defect, and determining the location of the other defect based on the identified defect and the program. The present invention is a program correction device that includes a processing device that executes a process of creating information for resolving the location of the problem, and a process of applying the created information to the other defective location in the program.

本発明によれば、プログラム中に存在する不具合を精度良く検出して修正することができる。
上記した以外の構成及び効果等は、以下の実施形態の説明により明らかにされる。
According to the present invention, defects existing in a program can be detected and corrected with high accuracy.
Structures, effects, etc. other than those described above will be made clear by the description of the embodiments below.

プログラム修正装置のハードウェアの構成の一例を示す図である。FIG. 2 is a diagram illustrating an example of a hardware configuration of a program modification device. プログラム修正装置が備える機能の一例を示す図である。FIG. 2 is a diagram illustrating an example of functions included in the program modification device. 本実施形態で説明するソースファイル群の一例を示す図である。FIG. 3 is a diagram showing an example of a source file group described in this embodiment. 本実施形態で説明するテストファイル群の一例を示す図である。FIG. 3 is a diagram showing an example of a test file group described in this embodiment. プログラム修正処理の一例を示すフローチャートである。3 is a flowchart illustrating an example of program correction processing. 不具合箇所候補の一例を示す図である。FIG. 3 is a diagram showing an example of a defective location candidate. 単一箇所修正候補群の一例を示す図である。FIG. 3 is a diagram illustrating an example of a group of single location correction candidates. 抽象化不具合箇所群の一例を示す図である。FIG. 3 is a diagram illustrating an example of an abstracted defect location group. 抽象化ソースコードの一例を示す図である。FIG. 3 is a diagram illustrating an example of abstracted source code. 追加不具合箇所群の一例を示す図である。FIG. 7 is a diagram illustrating an example of a group of additional defective locations. 追加素材コード群の一例を示す図である。It is a figure which shows an example of an additional material code group. 複数箇所修正候補群の一例を示す図である。FIG. 7 is a diagram illustrating an example of a group of multiple correction candidates. 修正結果の一例を示す図である。It is a figure which shows an example of a correction result.

以下、図面を参照しつつ、本実施形態について説明する。以下の説明において、同一の又は類似する構成について同一の符号を付して、重複した説明を省略することがある。 This embodiment will be described below with reference to the drawings. In the following description, the same or similar configurations may be denoted by the same reference numerals and redundant description may be omitted.

図1は、プログラム修正装置100のハードウェアの構成の一例を示す図である。
プログラム修正装置100は、プロセッサ110、主記憶装置120、補助記憶装置130、入力装置140、出力装置150、及び通信装置160を備える情報処理装置である。これらの装置は図示しないバス等の通信手段を介して互いに通信可能に接続されている。
FIG. 1 is a diagram showing an example of the hardware configuration of the program modification device 100.
The program modification device 100 is an information processing device including a processor 110, a main storage device 120, an auxiliary storage device 130, an input device 140, an output device 150, and a communication device 160. These devices are communicably connected to each other via a communication means such as a bus (not shown).

プロセッサ110は、例えば、CPU(Central Processing Unit)又はMPU(Micro
Processing Unit)を用いて構成されている処理装置である。プロセッサ110が、主記憶装置120に格納されているプログラムを読み出して実行することにより、後述するプログラム修正装置100の様々な機能部が実現される。
The processor 110 is, for example, a CPU (Central Processing Unit) or an MPU (Micro Processing Unit).
This is a processing device configured using a processing unit. When the processor 110 reads and executes programs stored in the main storage device 120, various functional units of the program modification device 100, which will be described later, are realized.

主記憶装置120は、プログラムやデータを記憶する装置であり、例えば、ROM(Read Only Memory)、RAM(Random Access Memory)、又は不揮発性半導体メモリ(NVRAM(Non Volatile RAM))等である。主記憶装置120は、下記に説明する各プログラムを記憶する。 The main storage device 120 is a device that stores programs and data, and is, for example, a ROM (Read Only Memory), a RAM (Random Access Memory), or a nonvolatile semiconductor memory (NVRAM (Non Volatile RAM)). The main storage device 120 stores each program described below.

補助記憶装置130は、例えば、ハードディスクドライブ、SSD(Solid State Drive)、光学式記憶装置(CD(Compact Disc)、DVD(Digital Versatile Disc)等)
、ストレージシステム、ICカード、もしくはSDメモリカードや光学式記録媒体等の記録媒体の読取及び書込装置、又はクラウドサーバの記憶領域等である。補助記憶装置13
0に格納されているプログラムやデータは主記憶装置120に随時読み込まれる。
The auxiliary storage device 130 is, for example, a hard disk drive, SSD (Solid State Drive), optical storage device (CD (Compact Disc), DVD (Digital Versatile Disc), etc.).
, a storage system, an IC card, a reading/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. Auxiliary storage device 13
Programs and data stored in 0 are read into the main storage device 120 at any time.

入力装置140は、例えば、キーボード、マウス、タッチパネル、カードリーダ、又は音声入力装置等であり、ユーザからの各種情報の入力を受け付ける。出力装置150は、ユーザに処理経過や処理結果等の各種情報を提供するユーザインタフェースであり、例えば、画面表示装置(液晶モニタ、LCD(Liquid Crystal Display)、グラフィックカード等)、音声出力装置(スピーカ等)、又は印字装置等である。 The input device 140 is, for example, a keyboard, a mouse, a touch panel, a card reader, a voice input device, or the like, 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 includes, for example, a screen display device (liquid crystal monitor, LCD (Liquid Crystal Display), graphic card, etc.), an audio output device (speaker, etc.). etc.), or a printing device, etc.

なお、入力装置140又は出力装置150の代わりに、プログラム修正装置100は、通信装置160を介して接続された他の入出力装置との間で情報の入力又は出力を行う構成としてもよい。 Note that instead of the input device 140 or the output device 150, the program modification device 100 may be configured to input or output information to or from another input/output device connected via the communication device 160.

通信装置160は、LAN(Local Area Network)又はインターネット等の通信ネットワークを介して他の装置との間の通信を実現する有線方式又は無線方式の通信インタフェースであり、例えば、NIC(Network Interface Card)、無線通信モジュール、USB(Universal Serial Interface)モジュール、又はシリアル通信モジュール等である。 The communication device 160 is a wired or wireless communication interface that realizes 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.

ここで、本実施形態で使用する用語を定義する。
「ソースコード」とは、ソフトウェア開発の対象となるプログラムであり、記述言語及びデータ形式は特に限定されない。そして、本実施形態の、(プログラム修正装置100による修正前の)ソースコードは、開発者の意図と異なる動作を引き起こす複数の不具合箇所を含んでいるものとする。
Here, terms used in this embodiment will be defined.
"Source code" is a program that is the target of software development, and the description language and data format are not particularly limited. It is assumed that the source code of this embodiment (before modification by the program modification device 100) includes a plurality of defective parts that cause an operation different from the developer's intention.

「メソッド」とは、プログラムにおけるまとまった処理の単位をいう。メソッドは、1以上の命令(Statement)を含む。命令は、0以上の関数又は式(Expression)を含む。
命令と式をあわせて「コード片」と呼ぶ。ソースコードは、このようなメソッドを1以上含む。
A "method" is a unit of processing in a program. A method includes one or more instructions (Statement). An instruction includes zero or more functions or expressions.
Instructions and expressions together are called a "code fragment." The source code includes one or more such methods.

「フィールド」とは、すべてのメソッドから参照できる変数または定数をいう。ソースコードは、0以上のフィールドを含む。 A "field" is a variable or constant that can be referenced from all methods. The source code includes zero or more fields.

「メソッド呼び出し」とは、メソッドを呼び出す呼び出し処理を行う式(関数)をいう。 A "method call" refers to an expression (function) that performs a call process to call a method.

「フィールドアクセス」とは、フィールドを参照する参照処理を行う式(関数)をいう。 "Field access" refers to an expression (function) that performs reference processing that refers to a field.

「スコープ」とは、ソースコードにおけるメソッドの呼び出し又はフィールドの参照において、メソッド又はフィールドのアクセス範囲(呼び出し範囲又は参照範囲)を指定(限定)する情報である。例えば、メソッド呼び出しは「スコープ.メソッド(パラメータ)」、フィールドアクセスは「スコープ.フィールド」という形式で表される。 "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 a 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".

「テストコード」とは、ソースコードの動作を検査するプログラムである。テストコードには、開発者が意図する動作を行うかを検証するためのプログラムが記述される。 "Test code" is a program that tests the operation of source code. The test code is a program written to verify that the program performs the operations intended by the developer.

「テストメソッド」とは、テストコードにおけるまとまった処理の単位である。例えば、テストメソッドは、1つのメソッドの動作を検査するプログラムである。なお、あるメソッドを検査するテストメソッドを、そのメソッドの「対応テストメソッド」と呼ぶ。1つのメソッドに2以上の対応テストメソッドが存在してもよい。テストコードは、このようなテストメソッドを1以上含む。 A "test method" is a unit of processing in a test code. For example, a test method is a program that tests the operation of one method. Note that a test method that tests a certain method is called a "corresponding test method" for that method. One method may have two or more corresponding test methods. The test code includes one or more such test methods.

次に、図2は、プログラム修正装置100が備える機能の一例を示す図である。本実施形態のプログラム修正装置100は、ソースコード中の複数の不具合を含む箇所のコード片を、素材コード片に書き換えることで、プログラムの修正を図る。この時、正解の素材コード片に書き換えることができれば、プログラムを修正できる。 Next, FIG. 2 is a diagram showing an example of the functions included in the program modification device 100. The program modification device 100 of this embodiment attempts to modify a program by rewriting a code fragment in a source code containing a plurality of defects into a material code fragment. At this time, if you can rewrite the correct material code piece, you can modify the program.

同図に示すように、プログラム修正装置100は、不具合箇所特定部210、単一箇所修正候補生成部220、追加不具合箇所抽出部230、追加素材コード生成部240、複数箇所修正候補生成部250、修正候補検査部260、及び情報記憶部280の各機能部を備える。 As shown in the figure, the program correction device 100 includes a defect location identification section 210, a single location correction candidate generation section 220, an additional defect location extraction section 230, an additional material code generation section 240, a multiple location correction candidate generation section 250, It includes functional units such as a correction candidate inspection unit 260 and an information storage unit 280.

不具合箇所特定部210は、ソースファイル群281及びテストファイル群282を入力として、不具合箇所候補群283を出力する(詳細は図6)。 The defective location identification unit 210 receives the source file group 281 and the test file group 282 as input, and outputs a defective location candidate group 283 (see FIG. 6 for details).

単一箇所修正候補生成部220は、ソースファイル群281及び不具合箇所候補群283を入力として、単一箇所修正候補群284を出力する(詳細は図7)。 The single location correction candidate generation unit 220 inputs the source file group 281 and the defective location candidate group 283 and outputs a single location correction candidate group 284 (see FIG. 7 for details).

追加不具合箇所抽出部230は、単一箇所修正候補群284を入力として、抽象化不具合箇所群285を出力する(詳細は図8)。 The additional defect location extracting unit 230 receives the single location correction candidate group 284 as input and outputs an abstracted defect location group 285 (see FIG. 8 for details).

また、追加不具合箇所抽出部230は、ソースファイル群281及び単一箇所修正候補群284を入力として、286を出力する(詳細は図9)。 Further, the additional defective part extracting unit 230 inputs the source file group 281 and the single part correction candidate group 284 and outputs 286 (see FIG. 9 for details).

そして、追加不具合箇所抽出部230は、抽象化不具合箇所群285及び抽象化ソースコード286を入力として、追加不具合箇所群287を出力する(詳細は図10)。 Then, the additional defective part extracting unit 230 receives the abstracted defective part group 285 and the abstracted source code 286 as input, and outputs an additional defective part group 287 (see FIG. 10 for details).

追加素材コード生成部240は、ソースファイル群281及び単一箇所修正候補群284を入力として、追加素材コード群288を出力する(詳細は図11)。 The additional material code generation unit 240 inputs the source file group 281 and the single location correction candidate group 284 and outputs the additional material code group 288 (see FIG. 11 for details).

複数箇所修正候補生成部250は、単一箇所修正候補群284と、追加不具合箇所群287と、追加素材コード群288とを入力として、複数箇所修正候補群289を出力する(詳細は図12)。 The multiple location correction candidate generation unit 250 inputs the single location correction candidate group 284, the additional defective location group 287, and the additional material code group 288, and outputs a multiple location correction candidate group 289 (see FIG. 12 for details). .

修正候補検査部260は、テストファイル群282と、単一箇所修正候補群284と、複数箇所修正候補群289とを入力として、修正結果291を出力する(詳細は図13)。 The modification candidate inspection unit 260 inputs the test file group 282, the single location modification candidate group 284, and the multiple location modification candidate group 289, and outputs a modification result 291 (see FIG. 13 for details).

情報記憶部280は、ソースファイル群281と、テストファイル群282と、不具合箇所候補群283と、単一箇所修正候補群284と、抽象化不具合箇所群285と、抽象化ソースコード286と、追加不具合箇所群287と、追加素材コード群288と、複数箇所修正候補群289と、修正結果291とを記憶している。 The information storage unit 280 includes 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, an abstracted source code 286, and additional files. A group of defective locations 287, a group of additional material codes 288, a group of multiple location correction candidates 289, and correction results 291 are stored.

ソースファイル群281は、不具合を解消する対象のソースファイルの集合である。ソースファイルは、1以上の行からなる。ソースファイルに記述されるソースコードの言語は特に限定されないが、例えば、Java(登録商標)、又はC++等である。 The source file group 281 is a collection of source files whose problems are to be resolved. A source file consists of one or more lines. The language of the source code written in the source file is not particularly limited, and may be, for example, Java (registered trademark) or C++.

テストファイル群282は、ソースファイル群281のソースファイルに不具合があるか否かを検証するための1以上のテストコードのファイル(テストファイル)を含む。テストファイルは、1以上の行からなる。 The test file group 282 includes one or more test code files (test files) for verifying whether the source files of the source file group 281 have a defect. A test file consists of one or more lines.

(ソースファイル群)
ここで、図3は、本実施形態で説明するソースファイル群281の一例を示す図である。このソースファイル群281は、ファイル名がFile1のソースファイル310と、ファ
イル名がFile2のソースファイル320とを含む。
(source files)
Here, FIG. 3 is a diagram showing an example of the source file group 281 described in this embodiment. This source file group 281 includes a source file 310 with the file name File1 and a source file 320 with the file name File2.

ファイル名がFile1のソースファイル310は9行のソースコードを含み、1行目~9
行目にはcheckCubeAndCalcVolumeという名前のメソッドの内容が記述されている。
The source file 310 with the file name File1 contains nine lines of source code, and lines 1 to 9
The contents of the method named checkCubeAndCalcVolume are described in the first line.

このソースファイル310のソースコードは、3行目と5行目に不具合を含んでいるものとする。具体的には、この不具合を解消するためには、3行目の「String[ ] keys={SHAPES.REC, SHAPES.TRI, SHAPES.HEX} ;」における「SHAPES.REC」(符号311)を「SHAPES.CUBE」に書き換え、5行目の「if(shape.is(SHAPES.REC)){」における「SHAPES.REC
」(符号312)を「SHAPES.CUBE」に書き換えなければならないものとする。
It is assumed that the source code of this source file 310 includes defects in the third and fifth lines. Specifically, in order to resolve this problem, change "SHAPES.REC" (code 311) in "String[ ] keys={SHAPES.REC, SHAPES.TRI, SHAPES.HEX};" in the third line. Rewrite it to "SHAPES.CUBE" and "SHAPES.REC" in "if(shape.is(SHAPES.REC)){" on the 5th line.
” (code 312) must be rewritten to “SHAPES.CUBE”.

(テストファイル群)
次に、図4は、本実施形態で説明するテストファイル群282の一例を示す図である。テストファイル群282は、ファイル名がFile1Testであるテストファイル410を含む
(Test file group)
Next, FIG. 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 whose file name is File1Test.

このテストファイル410は、11行のテストコードを有する。テストファイル410は、1行目~5行目にtestVolumeCube1という名前のテストメソッドを有し、7行目~1
1行目にtestVolumeCube2という名前のテストメソッドを有する。テストメソッドtestVolumeCube1とtestVolumeCube2は共に、ソースファイル310内のメソッドcheckCubeAndcalcVolumeの対応テストメソッドである。
This test file 410 has 11 lines of test code. The test file 410 has a test method named testVolumeCube1 in lines 1 to 5, and a test method named testVolumeCube1 in lines 7 to 1.
The first line has a test method named testVolumeCube2. Test methods testVolumeCube1 and testVolumeCube2 are both corresponding test methods of method checkCubeAndcalcVolume in source file 310.

なお、プログラムの開発者は、テストファイル410のテストコードの2行目~4行目及び8行目~10行目について、ソースファイル310内のメソッドcheckCubeAndCalcVolumeが、0が入力されると辺長が2の立方体の体積8を出力し、2が入力されると立方体ではないことを示す「-1」を出力するといった動作を行うように設計するという意図を
有している。
Note that the program developer can change the side length by using the method checkCubeAndCalcVolume in the source file 310 for lines 2 to 4 and lines 8 to 10 of the test code in the test file 410 when 0 is input. The intention is to output the volume 8 of the cube of 2, and when 2 is input, output "-1" indicating that it is not a cube.

次に、図2に示す不具合箇所候補群283は、ソースコードの不具合箇所の位置(本実施形態では行)を特定する情報である。 Next, the defect location candidate group 283 shown in FIG. 2 is information that specifies the position (line in this embodiment) of a defect location in the source code.

単一箇所修正候補群284は、ソースコードのうち、不具合のある箇所(コード片)を一か所書き換えたソースファイル(以下、第1修正候補という)の集合である。 The single location correction candidate group 284 is a set of source files (hereinafter referred to as first correction candidates) in which one defective location (code fragment) in the source code is rewritten.

抽象化不具合箇所群285は、単一箇所修正候補群284において書き換えられた、不具合を有していたコード片(以下、修正コード片という)を抽象化(汎化)したコード片(以下、抽象化修正コード片という)の集合である。 The abstract defect location group 285 is a code fragment (hereinafter referred to as an abstraction) that is an abstraction (generalization) of a code fragment having a defect (hereinafter referred to as a corrected code fragment) that was rewritten in the single location correction candidate group 284. This is a collection of modified code fragments).

抽象化ソースコード286は、ソースファイルの一部(コード片)を所定の記号(プレースホルダ)に書き換えることでソースコードを抽象化(汎化)したソースコードの集合である。なお、本実施形態ではプレースホルダは「$ID」であるものとするが、それ以外
の文字列を用いてもよい。
The abstracted source code 286 is a collection of source codes obtained by abstracting (generalizing) the source code by rewriting part of the source file (code fragment) with a predetermined symbol (placeholder). In this embodiment, the placeholder is assumed to be "$ID", but other character strings may be used.

追加不具合箇所群287は、ソースコードにおける、修正コード片以外の不具合の箇所(以下、追加修正コード片という)を含む行を特定するための情報の集合である。 The additional defective portion group 287 is a collection of information for identifying lines in the source code that include defective portions other than corrected code fragments (hereinafter referred to as additional corrected code fragments).

追加素材コード群288は、単一箇所修正候補群284における各不具合箇所の修正(
書き換え)に用いるコード片の集合である。なお、以下では、追加素材コード群288における各コード片を素材コード片という。
The additional material code group 288 corrects each defective part in the single part correction candidate group 284 (
This is a collection of code fragments used for (rewriting). Note that, hereinafter, each code piece in the additional material code group 288 will be referred to as a material code piece.

複数箇所修正候補群289は、不具合のある箇所(コード片)を追加素材コード群288の各素材コード片を用いて書き換えたソースコード(以下、第2修正候補という)の情報の集合である。 The multiple location correction candidate group 289 is a collection of information on source codes (hereinafter referred to as second correction candidates) in which defective locations (code pieces) have been rewritten using each material code piece of the additional material code group 288.

修正結果291は、不具合が解消されたソースコードの情報である。 The correction result 291 is information on the source code in which the problem has been resolved.

以上に説明したプログラム修正装置100の各機能部の機能は、プロセッサ110が、主記憶装置120又は補助記憶装置130から、各機能部に対応して作成されたプログラムを読み出すことにより実現される。これらのプログラムは、例えば、可搬性の又は固定された記録媒体に記録して配布することができる。なお、プログラム修正装置100の各機能は、その全部または一部が、例えば、クラウドシステムによって提供される仮想サーバのように、仮想化技術やプロセス空間分離技術等を用いて提供される仮想的な情報処理資源を用いて実現されるものであってもよい。また、プログラム修正装置100の各機能部の全部又は一部は、例えば、クラウドシステムがAPI (Application Programming Interface)等を介して提供するサービスによって実現してもよい。
次に、プログラム修正装置100で行われる処理について説明する。
The functions of each functional unit of the program modification device 100 described above are realized by the processor 110 reading a program created corresponding to each functional unit from the main storage device 120 or the auxiliary storage device 130. These programs can be distributed by being recorded on, for example, a portable or fixed recording medium. It should be noted that each function of the program modification device 100 may be implemented in whole or in part by a virtual server provided using virtualization technology, process space separation technology, etc., such as a virtual server provided by a cloud system. It may also be realized using information processing resources. Further, 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 modification device 100 will be explained.

<プログラム修正処理>
図5は、プログラム修正装置100が行うプログラム修正処理の一例を示すフローチャートである。プログラム修正処理は、例えば、プログラム修正装置100がユーザから指示入力を受け付けた場合、又は、スケジュールされたタイミングで実行するように設定されたバッチ処理等により開始される。なお、以下において、符号の前に付している文字「S」は処理ステップを意味する。
<Program correction process>
FIG. 5 is a flowchart illustrating an example of a 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 batch processing that is set to be executed at a scheduled timing. In addition, in the following, the letter "S" added before the reference numeral means a processing step.

まず、不具合箇所特定部210は、情報記憶部280に記憶されているソースファイル群281及びテストファイル群282を読み込んでテストファイルを実行し、その結果特定したソースファイル群281の不具合箇所の情報を不具合箇所候補群283に格納する(S111)。 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 file, and obtains information on the identified defect location in the source file group 281. It is stored in the defect location candidate group 283 (S111).

不具合箇所は、例えば、スコープを有するメソッドに対するメソッド呼び出し、スコープを有するフィールドへのフィールドアクセスである。不具合箇所は、例えば静的解析を用いて特定してもよいし、欠陥限局(fault localization)を用いて特定してもよい。なお、不具合箇所特定部210は、S111で特定した不具合を確定的なものとして解消しておいてもよい。 The problem is, for example, a method call to a scoped method or a field access to a scoped field. The defect location may be identified using, for example, static analysis or fault localization. Note that the defect location specifying unit 210 may definitively resolve the defect identified in S111.

(不具合箇所候補)
ここで、図6は、不具合箇所候補群283の一例を示す図である。
(Problem location candidates)
Here, FIG. 6 is a diagram showing an example of the defect location candidate group 283.

不具合箇所候補群283は、1以上のエントリを含む。不具合箇所候補群283のエントリは、ファイル名2831、行番号2832、及び疑わしさ2833のカラムを含む。ファイル名2831には、不具合を含む可能性のあるソースファイルのファイル名が格納され、行番号2832にはそのソースファイル中の不具合箇所の行番号が格納される。疑わしさ2833には、その不具合箇所が不具合を含んでいる可能性の高さが格納される。同図の例では、不具合箇所候補群283のエントリ2834に、ソースコードの3行目の記述に不具合箇所がある可能性が高い(1.0)ことが記録されている。 The defect location candidate group 283 includes one or more entries. The entry of the problem location candidate group 283 includes columns of file name 2831, line number 2832, and suspicion 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 defective location in the source file. Suspicion 2833 stores the probability that the defective location contains a defect. In the example shown in the figure, the entry 2834 of the defect location candidate group 283 records that there is a high possibility (1.0) that the description in the third line of the source code has a defect location.

なお、不具合を含む箇所が一意に特定できる場合、エントリには、必ずしもファイル名
2831、行番号2832、及び疑わしさ2833の全てに情報が設定されている必要はない。
Note that if the location containing the defect can be uniquely identified, the entry does not necessarily need to have information set in all of the file name 2831, line number 2832, and suspicion level 2833.

次に、図5に示すように、単一箇所修正候補生成部220は、情報記憶部280に記憶されているソースファイル群281及び不具合箇所候補群283を読み込んでこれらを解析することで、第1修正候補を含む単一箇所修正候補群284を生成する(S112)。 Next, as shown in FIG. 5, the single location correction candidate generation unit 220 reads the source file group 281 and defective location candidate group 283 stored in the information storage unit 280 and analyzes them. A single location correction candidate group 284 including one correction candidate is generated (S112).

具体的には、単一箇所修正候補生成部220は、不具合箇所候補群283に登録されている不具合箇所のうち一箇所を選択し、選択した箇所を、正しい他の記述に書き換えることで、単一箇所修正候補群284を生成する。単一箇所修正候補群284は、例えば修正テンプレートを用いて生成してもよいし、総当たりにより生成してもよい(Brute-force)
し、開発者等が手動で作成してもよい。
Specifically, the single location correction candidate generation unit 220 selects one location from among the defect locations registered in the defect location candidate group 283, and rewrites the selected location with another correct description. A group of one-place correction candidates 284 is generated. The single location correction candidate group 284 may be generated using a correction template, for example, or may be generated by brute force (Brute-force).
However, it may also be created manually by a developer or the like.

(単一箇所修正候補群)
図7は、単一箇所修正候補群284の一例を示す図である。この単一箇所修正候補群284は、1以上の単一箇所修正候補2841(第1修正候補)を含む。単一箇所修正候補2841には、不具合箇所候補群283に登録されている不具合箇所のうち一箇所を書き換えた、ソースファイル群281のソースコード310が格納される。
(Single location correction candidates)
FIG. 7 is a diagram showing an example of the single location correction candidate group 284. This single location modification candidate group 284 includes one or more single location modification candidates 2841 (first modification candidates). The single location correction candidate 2841 stores the source code 310 of the source file group 281 in which one of the defect locations registered in the defect location candidate group 283 has been rewritten.

同図の例では、単一箇所修正候補2841のソースコードは、ソースファイル310(File1)の3行目に存在している不具合箇所であるフィールドアクセス311「SHAPES.REC」を、フィールドアクセス2842「SHAPES.CUBE」に書き換えたソースコードである。 In the example shown in the figure, the source code of the single location correction candidate 2841 is to change the field access 311 "SHAPES.REC", which is the defective location on the third line of the source file 310 (File 1), to the field access 2842 "SHAPES.REC". This is the source code rewritten to “SHAPES.CUBE”.

次に、図5に示すように、追加不具合箇所抽出部230は、情報記憶部280に記憶されているソースファイル群281と、単一箇所修正候補群284とに基づき、以下の処理P1~P3に従って追加不具合箇所群287を出力する(S113)。 Next, as shown in FIG. 5, the additional defect location extraction unit 230 performs the following processes P1 to P3 based on the source file group 281 and the single location correction candidate group 284 stored in the information storage unit 280. Accordingly, the additional failure location group 287 is output (S113).

処理P1:追加不具合箇所抽出部230は、単一箇所修正候補群284におけるコード片を抽象化して、抽象化不具合箇所群285に出力する。 Process P1: The additional defect location extracting unit 230 abstracts the code fragments in the single location correction candidate group 284 and outputs it to the abstracted defect location group 285.

具体的には、追加不具合箇所抽出部230は、単一箇所修正候補群284における、スコープ(呼び出し範囲)が明示されたメソッド呼び出しにおけるメソッドの指定部分、及び、スコープ(参照範囲)が明示されたフィールドアクセスにおけるフィールドの参照部分の夫々を、プレースホルダ「$ID」に置き換えることにより抽象化し、これを抽象化不
具合箇所群285に出力する。一方、追加不具合箇所抽出部230は、単一箇所修正候補群284におけるコード片がメソッド呼び出しでもフィールドアクセスでもない場合は、それらをプレースホルダに置き換えずにそのまま、抽象化不具合箇所群285に出力する。なお、メソッド呼び出しの中に別のメソッド呼び出し又はフィールドアクセスがパラメータとして出現する場合、追加不具合箇所抽出部230は、一番内側のメソッド呼び出し又はフィールドアクセスのみをプレースホルダ「$ID」に置き換えてもよい。
Specifically, the additional defect extraction unit 230 extracts the specified part of a method in a method call whose scope (calling range) is specified and the scope (reference range) specified in the single-location correction candidate group 284. Each reference part of a field in field access is abstracted by replacing it with a placeholder "$ID", and this is output to the abstraction defect location group 285. On the other hand, if the code fragments in the single location correction candidate group 284 are neither method calls nor field accesses, the additional defect location extraction unit 230 outputs them as is to the abstracted defect location group 285 without replacing them with placeholders. . Note that if another method call or field access appears as a parameter in a method call, the additional defect extraction unit 230 may replace only the innermost method call or field access with the placeholder "$ID". good.

また、追加不具合箇所抽出部230は、スコープが明示されていないメソッド呼び出しにおけるメソッドの指定部分及び、スコープが明示されていないフィールドアクセスにおけるフィールドの参照部分については、プレースホルダに置き換えなくてもよい。これにより、抽象化されるコード片の数を減らすことで、後述の処理P3において不要な追加不具合箇所が出力されることを抑制できる。 Further, the additional defect 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. Thereby, by reducing the number of abstracted code fragments, it is possible to suppress output of unnecessary additional defect points in process P3, which will be described later.

(抽象化不具合箇所群)
図8は、抽象化不具合箇所群285の一例を示す図である。
(Abstract defect location group)
FIG. 8 is a diagram showing an example of the abstracted defect location group 285.

抽象化不具合箇所群285は、1以上の抽象化不具合箇所2851を含む。抽象化不具合箇所2851は、単一箇所修正候補群284でその記述が書き換えられたコード片(修正コード片)を抽象化したコード片、すなわち抽象化修正コード片を含んだ情報である。 The abstracted defective location group 285 includes one or more abstracted defective locations 2851. The abstract defective location 2851 is a code fragment that is an abstraction of a code fragment (corrected code fragment) whose description has been rewritten in the single location correction candidate group 284, that is, information that includes an abstracted corrected code fragment.

例えば、前記のS112の処理により書き換えられた単一箇所修正候補群284のコード片であるソースファイル310のフィールドアクセス311「SHAPES.REC」は、スコープが明示されたコード片であり、具体的には、スコープ「SHAPES」及びフィールド「REC
」を含む。したがって、追加不具合箇所抽出部230は、フィールドアクセス311「SHAPES.REC」のうちフィールド「REC」の部分をプレースホルダ「$ID」に書き換える抽象化を行うことで、抽象化された修正コード片2852「SHAPES.$ID」を抽象化不具合箇所群285に出力している。
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 in the process of S112, is a code fragment with a clear scope, and is specifically has scope “SHAPES” and field “REC
"including. Therefore, the additional defect extraction unit 230 abstracts the modified code fragment 2852 by rewriting the field "REC" part of the field access 311 "SHAPES.REC" to the placeholder "$ID". “SHAPES.$ID” is output to the abstract defect location group 285.

処理P2:次に、追加不具合箇所抽出部230は、ソースファイル群281に含まれるソースコード全体を(そこに不具合があるか否かに関係なく)抽象化して、抽象化ソースコード286に出力する。抽象化の方法は処理P1と同様である。ただし、追加不具合箇所抽出部230は、単一箇所修正候補群284で書き換えられた行は抽象化しない。 Process P2: Next, the additional defect extraction unit 230 abstracts the entire source code included in the source file group 281 (regardless of whether there is a defect there) and outputs it to the abstracted source code 286. . The method of abstraction is the same as the process P1. However, the additional defect location extracting unit 230 does not abstract lines that have been rewritten using the single location correction candidate group 284.

(抽象化ソースコード)
図9は、抽象化ソースコード286の一例を示す図である。
(abstraction source code)
FIG. 9 is a diagram showing an example of the abstract source code 286.

この抽象化ソースコード286は、ソースファイル群281におけるソースファイル310に含まれるソースコードの一部をプレースホルダ「$ID」に書き換えることで抽象化
されたソースコードの情報である。
This abstracted source code 286 is source code information that is abstracted by rewriting a part of the source code included in the source file 310 in the source file group 281 to a placeholder "$ID".

同図では、追加不具合箇所抽出部230は、ソースファイル群281に含まれるソースコードのうち、S112の処理により単一箇所修正候補群284に出力された(書き換えられた)前記のソースファイル310「File1」の3行目2861以外の、抽象化可能な
すべてのコードを抽象化することで、抽象化ソースコード286を出力している。
In the figure, the additional defect extraction unit 230 selects the source file 310, which has been output (rewritten) to the single location correction candidate group 284 through the process of S112, out of the source code included in the source file group 281. By abstracting all abstractable codes other than the third line 2861 of "File 1", an abstracted source code 286 is output.

例えば、ソースファイル310「File1」の5行目のメソッド呼び出し313「shape.is(SHAPES.REC)」は、パラメータにフィールドアクセス312「SHAPES.REC」(これは単
一箇所修正候補群284で書き換えられている)を含んでいたため、追加不具合箇所抽出部230は、これを抽象化せずにそのまま抽象化ソースコード286に出力している。また、ソースファイル310「File1」の6行目のメソッド呼び出し314「Math.power(shape.length1,3)」はパラメータにスコープが明示されたフィールドアクセス315「shape.length1」を含むため、追加不具合箇所抽出部230は、これを抽象化して抽象化ソー
スコード286に出力している(符号2862)。
For example, the method call 313 "shape.is(SHAPES.REC)" on the fifth line of the source file 310 "File1" has a field access 312 "SHAPES.REC" for the parameter (this is rewritten with the single location correction candidate group 284). ), the additional defect extraction unit 230 outputs this as it is to the abstracted source code 286 without abstracting it. Additionally, the method call 314 "Math.power(shape.length1,3)" on the 6th line of the source file 310 "File1" includes a field access 315 "shape.length1" whose scope is clearly specified in the parameter, so there is an additional problem. The location extraction unit 230 abstracts this and outputs it to the abstracted source code 286 (reference numeral 2862).

処理P3:次に、追加不具合箇所抽出部230は、抽象化ソースコード286の各行のうち、抽象化不具合箇所群285に登録されている抽象化修正コード片を含んでいる行であって、かつ、S112の処理で単一箇所修正候補群284によりコード片を書き換えた行とは異なる行(すなわち追加の不具合を含む行)を全て特定し、特定した各行の情報を、追加不具合箇所群287に出力する。 Process P3: Next, the additional defect extraction unit 230 selects a line that includes an abstracted correction code piece registered in the abstracted defect group 285 from among each line of the abstracted source code 286, and , in the process of S112, all lines that are different from the line for which the code fragment was rewritten (that is, lines containing additional defects) are identified by the single location correction candidate group 284, and the information of each identified line is added to the additional defect location group 287. Output.

(追加不具合箇所群)
図10は、追加不具合箇所群287の一例を示す図である。
(Additional defective locations)
FIG. 10 is a diagram showing an example of the additional defect location group 287.

追加不具合箇所群287は、0以上のエントリを含む。追加不具合箇所群287のエントリは、ファイル名2871、及び行番号2872のカラムを含む。ファイル名2871には、追加の不具合を含むソースファイル310、320のファイル名が格納され、行番
号2872には、追加の不具合を含む行の行番号が格納される。
The additional failure location group 287 includes zero or more entries. The entry of the additional defect location group 287 includes columns of file name 2871 and line number 2872. The file name 2871 stores the file names of the source files 310 and 320 that include the additional defect, and the line number 2872 stores the line number of the line that includes the additional defect.

同図の例では、追加不具合箇所抽出部230は、抽象化ソースコード286の各行のうち、抽象化不具合箇所群285に登録されているコード片であってソースファイル310(File1)から抽象化されたコード片2852「SHAPES.$ID」を含んでいる5行目286
3を、ソースファイル310(File1)に対応づけて、追加不具合箇所群287の行番号
2872に出力する。
In the example shown in the figure, the additional defect extraction unit 230 extracts code fragments registered in the abstracted defect group 285 from among each line of the abstracted source code 286 that are abstracted from the source file 310 (File 1). The fifth line 286 contains the code fragment 2852 “SHAPES.$ID”.
3 is associated with the source file 310 (File 1) and output to line number 2872 of the additional defect location group 287.

次に、追加素材コード生成部240は、単一箇所修正候補群284に基づき、追加素材コード群288を生成する(S114)。 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).

具体的には、例えば、追加素材コード生成部240は、単一箇所修正候補群284において書き換えられたコード片(修正コード片)がフィールドアクセスの場合、ソースファイル群281から、そのコード片と同じスコープに含まれるフィールドを参照する他のフィールドアクセスの式を抽出し、そのフィールドの部分を追加素材コード群288に出力する。また、例えば、追加素材コード生成部240は、修正コード片がメソッド呼び出しの場合、ソースファイル群281から、そのコード片と同じスコープに含まれるメソッドを呼び出す他のメソッド呼び出しの式を抽出する。そして、追加素材コード生成部240は、抽出したメソッド呼び出しの式から、前記コード片とパラメータの数又はタイプが異なるメソッド呼び出しの式を除外し、そのメソッド呼び出しの部分を追加素材コード群288に出力する。 Specifically, for example, if the 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 generates the same code fragment from the source file group 281. Other field access expressions that refer to fields included in the scope are extracted, and the field portion is output to the additional material code group 288. Further, for example, when the modified code fragment is a method call, the additional material code generation unit 240 extracts from the source file group 281 an expression for another method call that calls a method included in the same scope as the code fragment. Then, the additional material code generation unit 240 excludes method invocation expressions having a different number or type of parameters from the code fragment from the extracted method invocation expressions, and outputs the method invocation part to the additional material code group 288. do.

なお、単一箇所修正候補群284の生成にコード片が使われていない場合、追加素材コード生成部240は0の追加素材コードを出力する。 Note that if no code piece is used to generate the single location correction candidate group 284, the additional material code generation unit 240 outputs an additional material code of 0.

(追加素材コード群)
図11は、追加素材コード群288の一例を示す図である。追加素材コード群288は、0以上の追加素材コード2881を含む。
(Additional material code group)
FIG. 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.

追加素材コード2881は、例えば、単一箇所修正候補群284において書き換えに使用されたコード片、そのコード片と同じスコープに含まれる他のフィールドを参照するフィールドアクセスの式、又は、そのコード片と同じスコープに含まれる他のメソッドを呼び出すメソッド呼び出しの式等である。同図に示した追加素材コード2881は、フィールドアクセス2881a「SAHPES.CUBE」と、そのコード片と同じスコープに含まれる他
のフィールドを参照する他のコード片であるフィールドアクセス2881b、c(「SHAPES.TRI」、「SHAPES.HEX」)とを含む。
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 code fragment that is used for rewriting the single location correction candidate group 284. This is a method call expression that calls another method included in the same scope. The additional material code 2881 shown in the figure includes a field access 2881a "SAHPES.CUBE" and field access 2881b, c ("SHAPES.CUBE") which are other code fragments that refer to other fields included in the same scope as that code fragment. .TRI”, “SHAPES.HEX”).

なお、追加素材コード群288には、単一箇所修正候補群284で書き換えられたコード片(修正コード片)は設定されなくてもよい。例えば、同図に示した追加素材コード群288では、単一箇所修正候補群284で書き換えられたコード片「SHAPES.REC」は設定されていない。 Note that the additional material code group 288 does not need to be set with the code pieces (corrected code pieces) rewritten in the single-location correction candidate group 284 . For example, in the additional material code group 288 shown in the figure, the code piece "SHAPES.REC" that was rewritten in the single location correction candidate group 284 is not set.

次に、図5に示すように、複数箇所修正候補生成部250は、単一箇所修正候補群284と、追加不具合箇所群287と、追加素材コード群288とに基づき、第2修正候補の情報である複数箇所修正候補群289を出力する(S115)。 Next, as shown in FIG. 5, the multiple location correction candidate generation unit 250 generates 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. A group of multiple correction candidates 289 is output (S115).

具体的には、複数箇所修正候補生成部250は、単一箇所修正候補群284のソースコードから、追加不具合箇所群287が示す箇所(行)の各コード片を抽象化ソースコード286を参照しつつ特定し、特定した各コード片の不具合箇所を、追加素材コード群288に登録されている各素材コード片で書き換えることで、複数箇所修正候補群289を出
力する。なお、複数箇所修正候補生成部250は、例えば、単一箇所修正候補群284の生成と同じ方法により書き換えを実行することができるが、書き換えの方法は特に限定されない。
Specifically, the multiple location correction candidate generation unit 250 refers to the abstract source code 286 for each code piece of the location (line) indicated by the additional defect location group 287 from the source code of the single location correction candidate group 284. By rewriting the defective parts of each identified code piece with each material code piece registered in the additional material code group 288, a plurality of correction candidate group 289 is output. Note that the multiple location correction candidate generation unit 250 can perform rewriting using the same method as for generating the single location correction candidate group 284, for example, but the rewriting method is not particularly limited.

(複数箇所修正候補群)
図12は、複数箇所修正候補群289の一例を示す図である。複数箇所修正候補群289は、0以上の複数箇所修正候補510(510a,510b,510c,・・・)を含む(第2修正候補)。複数箇所修正候補510は、単一箇所修正候補群284のソースコードにおける、追加不具合箇所群287に登録されている各行において、その不具合箇所を、追加素材コード群288の各素材コード片を用いて書き換えたソースコードを有する。
(Group of multiple correction candidates)
FIG. 12 is a diagram showing an example of a group of multiple correction candidates 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 correct defective locations in each line registered in the additional defective location group 287 in the source code of the single location correction candidate group 284 using each material code piece of the additional material code group 288. Contains rewritten source code.

同図に示す複数箇所修正候補510aは、追加不具合箇所群287の行番号2872により示されている箇所(File1の5行目)のフィールドアクセス「SHAPES.REC」を、追加
素材コード群288の追加素材コード2881に登録されているフィールドアクセス2881a「SHAPES.CUBE」で書き換えたソースコードである。また、複数箇所修正候補51
0bは、追加不具合箇所群287の行番号2872により示されている箇所(File1の5
行目)のフィールドアクセス「SHAPES.REC」を、追加素材コード群288の追加素材コード2881に登録されている他のフィールドアクセス2881b「SHAPES.TRI」で書き換えたソースコードである。また、複数箇所修正候補510cは、追加不具合箇所群287の行番号2872により示されている箇所(File1の5行目)のフィールドアクセス「SHAPES.REC」を、追加素材コード群288の追加素材コード2881に登録されているさら
に他のフィールドアクセス2881c「SHAPES.HEX」で書き換えたソースコードである。
The multiple location correction candidate 510a shown in the figure includes the field access “SHAPES.REC” at the location indicated by line number 2872 of the additional defective location group 287 (line 5 of File 1), and the addition of the additional material code group 288. This is the source code rewritten using the field access 2881a "SHAPES.CUBE" registered in the material code 2881. In addition, multiple correction candidates 51
0b is the location indicated by line number 2872 of the additional defect location group 287 (5 of File 1).
This is a source code in which the field access “SHAPES.REC” in line 288 is rewritten with another field access 2881b “SHAPES.TRI” registered in the additional material code 2881 of the additional material code group 288. In addition, the multiple location correction candidate 510c uses the field access "SHAPES.REC" of the location indicated by line number 2872 of the additional defect location group 287 (fifth line of File 1) to the additional material code of the additional material code group 288. This is the source code rewritten with yet another field access 2881c "SHAPES.HEX" registered in 2881.

次に、図5に示すように、修正候補検査部260は、情報記憶部280に記憶されているテストファイル群282と、単一箇所修正候補群284と、複数箇所修正候補群289とに基づき、修正結果291を出力する(S116)。 Next, as shown in FIG. 5, the modification candidate inspection unit 260 uses the test file group 282, the single location modification candidate group 284, and the multiple location modification candidate group 289 stored in the information storage unit 280. , outputs the correction result 291 (S116).

具体的には、修正候補検査部260は、単一箇所修正候補群284及び複数箇所修正候補群289の各ソースコードに含まれる修正候補(第1修正候補、第2修正候補)のそれぞれをテストファイル群282の各テストファイルに入力することで、各テストファイルの出力データを取得する。修正候補検査部260は、テストファイルの出力データが、不具合箇所を含む行が正しく書き換えられたことを示している場合は、その修正候補を修正結果291に出力する。なお、不具合箇所を含む行が正しく書き換えられたか否かの検査には、例えば静的解析を用いてもよいし、テストコードを用いてもよい。 Specifically, the modification candidate inspection unit 260 tests each of the modification candidates (first modification candidate, second modification candidate) included in each source code of the single location modification candidate group 284 and the multiple location modification candidate group 289. By inputting data to each test file of the file group 282, output data of each test file is obtained. If the output data of the test file indicates that the line including the defective part has been correctly rewritten, the modification candidate inspection unit 260 outputs the modification candidate as the modification result 291. Note that static analysis may be used, for example, or a test code may be used to check whether the line including the defective part has been correctly rewritten.

その後、プログラム修正装置100は、新たな単一箇所修正候補群284を作成すべく、S112の処理を繰り返してもよい(S117)。この際、プログラム修正装置100は、追加不具合箇所抽出部230、追加素材コード生成部240、複数箇所修正候補生成部250、抽象化不具合箇所群285、抽象化ソースコード286、追加不具合箇所群287、及び追加素材コード群288等を初期化してもよい。これにより、複数の第1修正候補に対し、夫々独立した第1修正候補を生成することができ、互いに影響を及ぼすことなく、より多くの不具合を取り除くことができる。 Thereafter, the program modification device 100 may repeat the process of S112 to create a new single location modification candidate group 284 (S117). At this time, the program correction device 100 includes an additional defect location extraction unit 230, an additional material code generation unit 240, a multiple location correction candidate generation unit 250, an abstracted defect location group 285, an abstracted source code 286, an additional defect location group 287, The additional material code group 288 and the like may also be initialized. As a result, independent first correction candidates can be generated for a plurality of first correction candidates, and more defects can be removed without affecting each other.

その際、さらに、プログラム修正装置100の単一箇所修正候補生成部220は、不具合箇所候補群283の他のエントリを選択してもよい。これにより、ある行におけるコード片の変更では不具合を解消できなかった場合に、他の行におけるコード片の変更も試し、より高い確率で不具合を解消することができる。 At this time, the single location modification candidate generation unit 220 of the program modification device 100 may further select other entries in the defective location candidate group 283. As a result, if a problem cannot be solved by changing the code piece in a certain line, it is possible to try changing the code piece in another line and solve the problem with a higher probability.

(修正結果)
ここで、図13は、修正結果291の一例を示す図である。同図に示す修正結果291には、ソースファイル310のソースコードの3行目のフィールドアクセス311「SHAPES.REC」をフィールドアクセス2911「SHAPES.CUBE」に(第1修正候補)、5行目の
フィールドアクセス312「SHAPES.REC」をフィールドアクセス2912「SHAPES.CUBE
」に(第2修正候補)それぞれ書き換えることで不具合が解消されたソースコードが記憶されている。
(Result of correction)
Here, FIG. 13 is a diagram showing an example of the correction result 291. The modification result 291 shown in the same figure includes field access 311 "SHAPES.REC" in the third line of the source code of the source file 310 to field access 2911 "SHAPES.CUBE" (first modification candidate), and Field access 312 "SHAPES.REC" Field access 2912 "SHAPES.CUBE"
” (second correction candidate), the source code in which the problem was resolved by rewriting each is stored.

以上のように、本実施形態のプログラム修正装置100は、ソースコードの指定された箇所の不具合を解消して単一箇所修正候補群284を生成し、不具合を解消したソースコード(単一箇所修正候補群284)における不具合の内容及びソースコードを所定のルールに従ってそれぞれ汎化し(抽象化不具合箇所群285、抽象化ソースコード286)、汎化した不具合の内容に基づき、ソースコードにおける他の不具合の箇所を推定し(追加不具合箇所群287)、上記単一箇所修正候補群284及びソースコードに基づき、他の不具合の箇所を解消するための情報を作成し(追加素材コード群288)、作成した情報をソースコードにおける他の不具合の箇所に適用する。 As described above, the program correction apparatus 100 of the present embodiment eliminates defects at specified locations in the source code, generates the single location correction candidate group 284, and generates the source code (single location correction The content of defects in the candidate group 284) and the source code are generalized according to predetermined rules (abstracted defect location group 285, abstracted source code 286), and based on the generalized content of defects, other defects in the source code are generalized. The location was estimated (additional defect location group 287), and based on the single location correction candidate group 284 and the source code, information for resolving other defect locations was created (additional material code group 288). Apply the information to other defective locations in the source code.

すなわち、プログラム修正装置100は、最初に特定した不具合箇所及びソースコードをそれぞれ抽象化して両者を参照することで、ソースコードの他の不具合箇所を幅広く推定すると共に修正候補を作成することができ、作成した修正候補でソースコードの他の不具合を修正することができる。 That is, the program correction device 100 can broadly estimate other defective parts of the source code and create correction candidates by abstracting the initially identified defective part and the source code and referring to both. Other defects in the source code can be corrected using the created correction candidates.

このように、本実施形態のプログラム修正装置100によれば、プログラム中に存在する不具合を精度良く検出して修正することができる。そして、これにより、開発者のデバッグ作業を効率化することができる。 In this way, according to the program correction apparatus 100 of the present embodiment, it is possible to accurately detect and correct defects existing in a program. This makes it possible to make the developer's debugging work more efficient.

また、本実施形態のプログラム修正装置100は、メソッド呼び出しのメソッド、及び、スコープが明示されたフィールドアクセスのフィールドをそれぞれプレースホルダに置換することで、ソースコードを汎化する。 Furthermore, the program modification apparatus 100 of this embodiment generalizes the source code by replacing each of the method call method and field access field whose scope is specified with a placeholder.

これにより、ソースコードでバグが一般的な発生し易い箇所を特定し、ソースコードを効率良く修正することができる。 This makes it possible to identify locations in the source code where bugs commonly occur, and to efficiently modify the source code.

また、本実施形態のプログラム修正装置100は、スコープが明示されていないフィールドアクセス及びメソッド呼び出しにおけるフィールド及びメソッドの部分はそのまま汎化したソースコードの一部とする。 Furthermore, the program modification apparatus 100 of this embodiment treats field and method portions in field accesses and method calls whose scopes are not explicitly specified as part of the generalized source code as they are.

このように、抽象化が不要な場合は抽象化処理を行わないことで、不具合箇所の特定及び解消の処理をより高速に行うことができる。 In this way, by not performing abstraction processing when abstraction is not necessary, it is possible to perform processing for identifying and resolving defective locations at higher speed.

また、本実施形態のプログラム修正装置100は、スコープを有するメソッド呼び出しの部分、又はスコープを有するフィールドのフィールドアクセスの部分の不具合を解消し(単一箇所修正候補群284)、抽象化不具合箇所群285として、同じスコープ内の他のメソッド呼び出しの部分、又は同じスコープ内のフィールドアクセスを生成する。 In addition, the program correction device 100 of this embodiment eliminates defects in the scoped method call portion or the field access portion of the scoped field (single location correction candidate group 284), and abstracts the defect location group. 285 to generate part of another method call within the same scope, or a field access within the same scope.

これにより、同じスコープ内のメソッド又はフィールドを呼び出し又は産所ぷするメソッド呼び出し又はフィールドアクセスを、他の不具合を修正するための素材として用いることができ、不具合のある可能性が高い箇所を効率良く修正することができる。 As a result, method calls or field accesses that call or produce methods or fields within the same scope can be used as material for fixing other defects, and points that are likely to have defects can be efficiently fixed. Can be fixed.

本発明は、上記実施形態に限定されるものではなく、その要旨を逸脱しない範囲内で、任意の構成要素を用いて実施可能である。以上説明した実施形態や変形例はあくまで一例
であり、発明の特徴が損なわれない限り、本発明はこれらの内容に限定されるものではない。また、上記では種々の実施形態や変形例を説明したが、本発明はこれらの内容に限定されるものではない。本発明の技術的思想の範囲内で考えられるその他の態様も本発明の範囲内に含まれる。
The present invention is not limited to the embodiments described above, and can be implemented using arbitrary components without departing from the spirit thereof. The embodiments and modifications described above are merely examples, and the present invention is not limited to these contents as long as the characteristics of the invention are not impaired. Furthermore, although various embodiments and modifications have been described above, the present invention is not limited to these. Other embodiments considered within the technical spirit of the present invention are also included within the scope of the present invention.

例えば、本実施形態の各装置が備えるハードウェアの一部は、他の装置に設けてもよい。 For example, some of the hardware included in each device of this embodiment may be provided in another device.

また、プログラム修正装置100の各プログラムは他の装置に設けてもよいし、あるプログラムを複数のプログラムからなるものとしてもよいし、複数のプログラムを一つのプログラムに統合してもよい。 Further, each program of the program modification device 100 may be provided in another device, a certain program may be made up of a plurality of programs, or a plurality of programs may be integrated into one program.

100 プログラム修正装置
210 不具合箇所特定部
220 単一箇所修正候補生成部
230 追加不具合箇所抽出部
240 追加素材コード生成部
250 複数箇所修正候補生成部
260 修正候補検査部
100 Program correction device 210 Defect location identification unit 220 Single location correction candidate generation unit 230 Additional defect location extraction unit 240 Additional material code generation unit 250 Multiple location correction candidate generation unit 260 Correction candidate inspection unit

Claims (6)

プログラムを記憶する記憶装置、及び、
前記プログラムにおける不具合の箇所を特定し、前記不具合を特定したプログラムにおける前記不具合の内容及び前記プログラムを所定のルールに従ってそれぞれ汎化し、前記汎化した不具合の内容に基づき、前記プログラムにおける他の不具合の箇所を推定する処理と、
前記特定した不具合及び前記プログラムに基づき、前記他の不具合の箇所を解消するための情報を作成する処理と、
前記作成した情報を前記プログラムにおける前記他の不具合の箇所に適用する処理とを実行する処理装置
を備えるプログラム修正装置。
a storage device that stores the program; and
The location of the defect in the program is identified, the contents of the defect in the program in which the defect has been identified and the program are generalized according to predetermined rules, and based on the contents of the generalized defect, other defects in the program are determined. A process of estimating the location,
A process of creating information for eliminating the other defective parts based on the identified defect and the program;
A program correction device comprising: a processing device that executes a process of applying the created information to the other defective location in the program.
前記処理装置は、
呼び出し範囲が指定されている他の処理を呼び出す処理の部分における当該他の処理の指定部分、又は、参照範囲が指定されている定数若しくは変数を参照する処理の部分における当該定数若しくは変数の参照部分を、前記所定の記号に置換することで、前記プログラムを汎化する、
請求項1に記載のプログラム修正装置。
The processing device includes:
A specified part of a process that calls another process for which a call range is specified, or a part that refers to a constant or variable in a process that refers to a constant or variable for which a reference range is specified. generalizing the program by replacing with the predetermined symbol;
A program modification device according to claim 1.
前記処理装置は、呼び出し範囲が指定されていない他の処理を呼び出す処理の部分における当該他の処理の指定部分、又は、参照範囲が指定されていない定数若しくは変数を参照する処理の部分における当該定数若しくは変数の参照部分は、そのまま前記汎化したプログラムの一部とする、請求項2に記載のプログラム修正装置。 The processing device is a specified part of a process that calls another process for which a call range is not specified, or a constant in a process part that refers to a constant or variable for which a reference range is not specified. 3. The program modification device according to claim 2, wherein the reference portion of the variable is made a part of the generalized program as it is. 前記処理装置は、
呼び出し範囲が指定されている他の処理を呼び出す呼び出し処理の部分、又は、参照範囲が指定されている定数若しくは変数を参照する参照処理の部分における不具合を特定し、
前記他の不具合の箇所を解消するための情報として、前記呼び出し範囲内の他の処理を呼び出す呼び出し処理の部分、又は、前記参照範囲内の他の定数若しくは変数を参照する参照処理の部分を、前記他の不具合の箇所を解消するための情報を作成する、
請求項1に記載のプログラム修正装置。
The processing device includes:
Identifying defects in the part of the call process that calls other processes for which the call range is specified, or the part of the reference process that refers to constants or variables for which the reference range is specified,
As information for resolving the other problems, a part of the calling process that calls other processes within the calling range, or a part of the reference process that refers to other constants or variables within the reference range, Create information to resolve the other problems mentioned above;
A program modification device according to claim 1.
情報処理装置が、
プログラムを記憶し、
前記プログラムにおける不具合の箇所を特定し、前記不具合を特定したプログラムにおける前記不具合の内容及び前記プログラムを所定のルールに従ってそれぞれ汎化し、前記汎化した不具合の内容に基づき、前記プログラムにおける他の不具合の箇所を推定する処理と、
前記特定した不具合及び前記プログラムに基づき、前記他の不具合の箇所を解消するための情報を作成する処理と、
前記作成した情報を前記プログラムにおける前記他の不具合の箇所に適用する処理とを実行する、
プログラム修正方法。
The information processing device
memorize the program,
The location of the defect in the program is identified, the contents of the defect in the program in which the defect has been identified and the program are generalized according to predetermined rules, and based on the contents of the generalized defect, other defects in the program are determined. A process of estimating the location,
A process of creating information for eliminating the other defective parts based on the identified defect and the program;
applying the created information to the other defective location in the program;
How to modify the program.
情報処理装置に、
プログラムを記憶させ、
前記プログラムにおける不具合の箇所を特定し、前記不具合を特定したプログラムにおける前記不具合の内容及び前記プログラムを所定のルールに従ってそれぞれ汎化し、前記
汎化した不具合の内容に基づき、前記プログラムにおける他の不具合の箇所を推定する処理と、
前記特定した不具合及び前記プログラムに基づき、前記他の不具合の箇所を解消するための情報を作成する処理と、
前記作成した情報を前記プログラムにおける前記他の不具合の箇所に適用する処理とを実行させる、
プログラム修正プログラム。




In the information processing device,
memorize the program,
The location of the defect in the program is identified, the contents of the defect in the program in which the defect has been identified and the program are generalized according to predetermined rules, and based on the contents of the generalized defect, other defects in the program are determined. A process of estimating the location,
A process of creating information for eliminating the other defective parts based on the identified defect and the program;
executing a process of applying the created information to the other defective location in the program;
Program fix.




JP2022103319A 2022-06-28 2022-06-28 Program correction device, program correction method, and program correction program Pending JP2024003945A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2022103319A JP2024003945A (en) 2022-06-28 2022-06-28 Program correction device, program correction method, and program correction program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2022103319A JP2024003945A (en) 2022-06-28 2022-06-28 Program correction device, program correction method, and program correction program

Publications (1)

Publication Number Publication Date
JP2024003945A true JP2024003945A (en) 2024-01-16

Family

ID=89538084

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2022103319A Pending JP2024003945A (en) 2022-06-28 2022-06-28 Program correction device, program correction method, and program correction program

Country Status (1)

Country Link
JP (1) JP2024003945A (en)

Similar Documents

Publication Publication Date Title
US8930884B2 (en) Efficient extraction of software dependencies from program code
US8966449B2 (en) Test case pattern matching
US9983984B2 (en) Automated modularization of graphical user interface test cases
US20060143596A1 (en) Program analyzing apparatus and testing apparatus, and analyzing method and program therefor
US10049031B2 (en) Correlation of violating change sets in regression testing of computer software
US9208451B2 (en) Automatic identification of information useful for generation-based functional verification
US8209658B2 (en) Method of creating signatures for classifying program failures
US20120185669A1 (en) Program inspection method and non-transitory, computer readable storage medium storing inspection program
US20150089296A1 (en) Derivation of generalized test cases
JP7409197B2 (en) Elaboration of repair patterns for static analysis violations in software programs
JP6440895B2 (en) Software analysis apparatus and software analysis method
CN107957939B (en) Webpage interaction interface testing method and system
US10380313B1 (en) Implementation and evaluation of designs for heterogeneous computing platforms with hardware acceleration
CN112988578A (en) Automatic testing method and device
Heelan et al. Augmenting vulnerability analysis of binary code
Peng et al. {GLeeFuzz}: Fuzzing {WebGL} Through Error Message Guided Mutation
US9734458B2 (en) Predicting outcome based on input
Wang et al. Fast reproducing web application errors
Wang et al. JSTrace: Fast reproducing web application errors
JP2024003945A (en) Program correction device, program correction method, and program correction program
JP7380851B2 (en) Test script generation device, test script generation method and program
US11200126B2 (en) Utilizing translation tables for testing processors
JP5578625B2 (en) Program analysis apparatus, program analysis method, and program
JP7456843B2 (en) Program modification device, program modification method, and program modification program
JP2023003882A (en) Failure place specification support device and failure place specification support method