JP2024003945A - Program correction device, program correction method, and program correction program - Google Patents
Program correction device, program correction method, and program correction program Download PDFInfo
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 96
- 238000012545 processing Methods 0.000 claims abstract description 21
- 230000007547 defect Effects 0.000 claims description 120
- 230000004048 modification Effects 0.000 claims description 56
- 230000002950 deficient Effects 0.000 claims description 48
- 230000008569 process Effects 0.000 claims description 39
- 230000010365 information processing Effects 0.000 claims description 4
- 238000012937 correction Methods 0.000 abstract description 89
- 239000000463 material Substances 0.000 abstract description 47
- 239000012634 fragment Substances 0.000 description 38
- 238000012360 testing method Methods 0.000 description 33
- 238000012986 modification Methods 0.000 description 29
- 238000010586 diagram Methods 0.000 description 22
- 238000000605 extraction Methods 0.000 description 15
- 238000010998 test method Methods 0.000 description 11
- 230000014509 gene expression Effects 0.000 description 10
- 238000004891 communication Methods 0.000 description 9
- 230000006870 function Effects 0.000 description 7
- 238000007689 inspection Methods 0.000 description 6
- 230000008859 change Effects 0.000 description 4
- 239000000284 extract Substances 0.000 description 3
- 238000004458 analytical method Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 239000004973 liquid crystal related substance Substances 0.000 description 2
- 230000004807 localization Effects 0.000 description 2
- 230000007257 malfunction Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 238000001514 detection method Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000001771 impaired effect Effects 0.000 description 1
- 238000007639 printing Methods 0.000 description 1
- 230000008439 repair process Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000000926 separation method Methods 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Images
Abstract
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
非特許文献1に記載された技術では、複数の近似している箇所を検出し、それらを同時に書き換えることで、複数箇所の書き換えが必要な不具合を修正する。しかしながら、近似している箇所の検出をソースファイルの行単位で行うため、複数の不具合箇所がありそれらが行の一部分でのみ近似している場合、それら複数の不具合箇所を同時に検出し修正することができない。また、複数の不具合箇所のうち、不具合箇所特定処理により不具合を含む可能性が低く計算される箇所が含まれている場合、近似している他の箇所が検出対象にならないため、すべての不具合箇所を正しく書き換えることができない。さらに、近似している箇所の検出にはソースファイルの修正履歴を使用するため、修正履歴がないソフトウェアには適用できない。
The technique described in Non-Patent
本発明は、このような事情に鑑みてなされたものであり、その目的は、プログラム中に存在する不具合を精度良く検出して修正することが可能なプログラム修正装置、プログラム修正方法、及びプログラム修正プログラムを提供することを目的とする。 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.
以下、図面を参照しつつ、本実施形態について説明する。以下の説明において、同一の又は類似する構成について同一の符号を付して、重複した説明を省略することがある。 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
The
プロセッサ110は、例えば、CPU(Central Processing Unit)又はMPU(Micro
Processing Unit)を用いて構成されている処理装置である。プロセッサ110が、主記憶装置120に格納されているプログラムを読み出して実行することにより、後述するプログラム修正装置100の様々な機能部が実現される。
The
This is a processing device configured using a processing unit. When the
主記憶装置120は、プログラムやデータを記憶する装置であり、例えば、ROM(Read Only Memory)、RAM(Random Access Memory)、又は不揮発性半導体メモリ(NVRAM(Non Volatile RAM))等である。主記憶装置120は、下記に説明する各プログラムを記憶する。
The
補助記憶装置130は、例えば、ハードディスクドライブ、SSD(Solid State Drive)、光学式記憶装置(CD(Compact Disc)、DVD(Digital Versatile Disc)等)
、ストレージシステム、ICカード、もしくはSDメモリカードや光学式記録媒体等の記録媒体の読取及び書込装置、又はクラウドサーバの記憶領域等である。補助記憶装置13
0に格納されているプログラムやデータは主記憶装置120に随時読み込まれる。
The
, 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
入力装置140は、例えば、キーボード、マウス、タッチパネル、カードリーダ、又は音声入力装置等であり、ユーザからの各種情報の入力を受け付ける。出力装置150は、ユーザに処理経過や処理結果等の各種情報を提供するユーザインタフェースであり、例えば、画面表示装置(液晶モニタ、LCD(Liquid Crystal Display)、グラフィックカード等)、音声出力装置(スピーカ等)、又は印字装置等である。
The
なお、入力装置140又は出力装置150の代わりに、プログラム修正装置100は、通信装置160を介して接続された他の入出力装置との間で情報の入力又は出力を行う構成としてもよい。
Note that instead of the
通信装置160は、LAN(Local Area Network)又はインターネット等の通信ネットワークを介して他の装置との間の通信を実現する有線方式又は無線方式の通信インタフェースであり、例えば、NIC(Network Interface Card)、無線通信モジュール、USB(Universal Serial Interface)モジュール、又はシリアル通信モジュール等である。
The
ここで、本実施形態で使用する用語を定義する。
「ソースコード」とは、ソフトウェア開発の対象となるプログラムであり、記述言語及びデータ形式は特に限定されない。そして、本実施形態の、(プログラム修正装置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
同図に示すように、プログラム修正装置100は、不具合箇所特定部210、単一箇所修正候補生成部220、追加不具合箇所抽出部230、追加素材コード生成部240、複数箇所修正候補生成部250、修正候補検査部260、及び情報記憶部280の各機能部を備える。
As shown in the figure, the
不具合箇所特定部210は、ソースファイル群281及びテストファイル群282を入力として、不具合箇所候補群283を出力する(詳細は図6)。
The defective
単一箇所修正候補生成部220は、ソースファイル群281及び不具合箇所候補群283を入力として、単一箇所修正候補群284を出力する(詳細は図7)。
The single location correction
追加不具合箇所抽出部230は、単一箇所修正候補群284を入力として、抽象化不具合箇所群285を出力する(詳細は図8)。
The additional defect
また、追加不具合箇所抽出部230は、ソースファイル群281及び単一箇所修正候補群284を入力として、286を出力する(詳細は図9)。
Further, the additional defective
そして、追加不具合箇所抽出部230は、抽象化不具合箇所群285及び抽象化ソースコード286を入力として、追加不具合箇所群287を出力する(詳細は図10)。
Then, the additional defective
追加素材コード生成部240は、ソースファイル群281及び単一箇所修正候補群284を入力として、追加素材コード群288を出力する(詳細は図11)。
The additional material
複数箇所修正候補生成部250は、単一箇所修正候補群284と、追加不具合箇所群287と、追加素材コード群288とを入力として、複数箇所修正候補群289を出力する(詳細は図12)。
The multiple location correction
修正候補検査部260は、テストファイル群282と、単一箇所修正候補群284と、複数箇所修正候補群289とを入力として、修正結果291を出力する(詳細は図13)。
The modification
情報記憶部280は、ソースファイル群281と、テストファイル群282と、不具合箇所候補群283と、単一箇所修正候補群284と、抽象化不具合箇所群285と、抽象化ソースコード286と、追加不具合箇所群287と、追加素材コード群288と、複数箇所修正候補群289と、修正結果291とを記憶している。
The
ソースファイル群281は、不具合を解消する対象のソースファイルの集合である。ソースファイルは、1以上の行からなる。ソースファイルに記述されるソースコードの言語は特に限定されないが、例えば、Java(登録商標)、又はC++等である。
The
テストファイル群282は、ソースファイル群281のソースファイルに不具合があるか否かを検証するための1以上のテストコードのファイル(テストファイル)を含む。テストファイルは、1以上の行からなる。
The
(ソースファイル群)
ここで、図3は、本実施形態で説明するソースファイル群281の一例を示す図である。このソースファイル群281は、ファイル名がFile1のソースファイル310と、ファ
イル名がFile2のソースファイル320とを含む。
(source files)
Here, FIG. 3 is a diagram showing an example of the
ファイル名がFile1のソースファイル310は9行のソースコードを含み、1行目~9
行目にはcheckCubeAndCalcVolumeという名前のメソッドの内容が記述されている。
The
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
このテストファイル410は、11行のテストコードを有する。テストファイル410は、1行目~5行目にtestVolumeCube1という名前のテストメソッドを有し、7行目~1
1行目にtestVolumeCube2という名前のテストメソッドを有する。テストメソッドtestVolumeCube1とtestVolumeCube2は共に、ソースファイル310内のメソッドcheckCubeAndcalcVolumeの対応テストメソッドである。
This
The first line has a test method named testVolumeCube2. Test methods testVolumeCube1 and testVolumeCube2 are both corresponding test methods of method checkCubeAndcalcVolume in
なお、プログラムの開発者は、テストファイル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
次に、図2に示す不具合箇所候補群283は、ソースコードの不具合箇所の位置(本実施形態では行)を特定する情報である。
Next, the defect
単一箇所修正候補群284は、ソースコードのうち、不具合のある箇所(コード片)を一か所書き換えたソースファイル(以下、第1修正候補という)の集合である。
The single location
抽象化不具合箇所群285は、単一箇所修正候補群284において書き換えられた、不具合を有していたコード片(以下、修正コード片という)を抽象化(汎化)したコード片(以下、抽象化修正コード片という)の集合である。
The abstract
抽象化ソースコード286は、ソースファイルの一部(コード片)を所定の記号(プレースホルダ)に書き換えることでソースコードを抽象化(汎化)したソースコードの集合である。なお、本実施形態ではプレースホルダは「$ID」であるものとするが、それ以外
の文字列を用いてもよい。
The
追加不具合箇所群287は、ソースコードにおける、修正コード片以外の不具合の箇所(以下、追加修正コード片という)を含む行を特定するための情報の集合である。
The additional
追加素材コード群288は、単一箇所修正候補群284における各不具合箇所の修正(
書き換え)に用いるコード片の集合である。なお、以下では、追加素材コード群288における各コード片を素材コード片という。
The additional
This is a collection of code fragments used for (rewriting). Note that, hereinafter, each code piece in the additional
複数箇所修正候補群289は、不具合のある箇所(コード片)を追加素材コード群288の各素材コード片を用いて書き換えたソースコード(以下、第2修正候補という)の情報の集合である。
The multiple location
修正結果291は、不具合が解消されたソースコードの情報である。
The
以上に説明したプログラム修正装置100の各機能部の機能は、プロセッサ110が、主記憶装置120又は補助記憶装置130から、各機能部に対応して作成されたプログラムを読み出すことにより実現される。これらのプログラムは、例えば、可搬性の又は固定された記録媒体に記録して配布することができる。なお、プログラム修正装置100の各機能は、その全部または一部が、例えば、クラウドシステムによって提供される仮想サーバのように、仮想化技術やプロセス空間分離技術等を用いて提供される仮想的な情報処理資源を用いて実現されるものであってもよい。また、プログラム修正装置100の各機能部の全部又は一部は、例えば、クラウドシステムがAPI (Application Programming Interface)等を介して提供するサービスによって実現してもよい。
次に、プログラム修正装置100で行われる処理について説明する。
The functions of each functional unit of the
Next, the processing performed by the
<プログラム修正処理>
図5は、プログラム修正装置100が行うプログラム修正処理の一例を示すフローチャートである。プログラム修正処理は、例えば、プログラム修正装置100がユーザから指示入力を受け付けた場合、又は、スケジュールされたタイミングで実行するように設定されたバッチ処理等により開始される。なお、以下において、符号の前に付している文字「S」は処理ステップを意味する。
<Program correction process>
FIG. 5 is a flowchart illustrating an example of a program modification process performed by the
まず、不具合箇所特定部210は、情報記憶部280に記憶されているソースファイル群281及びテストファイル群282を読み込んでテストファイルを実行し、その結果特定したソースファイル群281の不具合箇所の情報を不具合箇所候補群283に格納する(S111)。
First, the defect
不具合箇所は、例えば、スコープを有するメソッドに対するメソッド呼び出し、スコープを有するフィールドへのフィールドアクセスである。不具合箇所は、例えば静的解析を用いて特定してもよいし、欠陥限局(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
(不具合箇所候補)
ここで、図6は、不具合箇所候補群283の一例を示す図である。
(Problem location candidates)
Here, FIG. 6 is a diagram showing an example of the defect
不具合箇所候補群283は、1以上のエントリを含む。不具合箇所候補群283のエントリは、ファイル名2831、行番号2832、及び疑わしさ2833のカラムを含む。ファイル名2831には、不具合を含む可能性のあるソースファイルのファイル名が格納され、行番号2832にはそのソースファイル中の不具合箇所の行番号が格納される。疑わしさ2833には、その不具合箇所が不具合を含んでいる可能性の高さが格納される。同図の例では、不具合箇所候補群283のエントリ2834に、ソースコードの3行目の記述に不具合箇所がある可能性が高い(1.0)ことが記録されている。
The defect
なお、不具合を含む箇所が一意に特定できる場合、エントリには、必ずしもファイル名
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
次に、図5に示すように、単一箇所修正候補生成部220は、情報記憶部280に記憶されているソースファイル群281及び不具合箇所候補群283を読み込んでこれらを解析することで、第1修正候補を含む単一箇所修正候補群284を生成する(S112)。
Next, as shown in FIG. 5, the single location correction
具体的には、単一箇所修正候補生成部220は、不具合箇所候補群283に登録されている不具合箇所のうち一箇所を選択し、選択した箇所を、正しい他の記述に書き換えることで、単一箇所修正候補群284を生成する。単一箇所修正候補群284は、例えば修正テンプレートを用いて生成してもよいし、総当たりにより生成してもよい(Brute-force)
し、開発者等が手動で作成してもよい。
Specifically, the single location correction
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
同図の例では、単一箇所修正候補2841のソースコードは、ソースファイル310(File1)の3行目に存在している不具合箇所であるフィールドアクセス311「SHAPES.REC」を、フィールドアクセス2842「SHAPES.CUBE」に書き換えたソースコードである。
In the example shown in the figure, the source code of the single
次に、図5に示すように、追加不具合箇所抽出部230は、情報記憶部280に記憶されているソースファイル群281と、単一箇所修正候補群284とに基づき、以下の処理P1~P3に従って追加不具合箇所群287を出力する(S113)。
Next, as shown in FIG. 5, the additional defect
処理P1:追加不具合箇所抽出部230は、単一箇所修正候補群284におけるコード片を抽象化して、抽象化不具合箇所群285に出力する。
Process P1: The additional defect
具体的には、追加不具合箇所抽出部230は、単一箇所修正候補群284における、スコープ(呼び出し範囲)が明示されたメソッド呼び出しにおけるメソッドの指定部分、及び、スコープ(参照範囲)が明示されたフィールドアクセスにおけるフィールドの参照部分の夫々を、プレースホルダ「$ID」に置き換えることにより抽象化し、これを抽象化不
具合箇所群285に出力する。一方、追加不具合箇所抽出部230は、単一箇所修正候補群284におけるコード片がメソッド呼び出しでもフィールドアクセスでもない場合は、それらをプレースホルダに置き換えずにそのまま、抽象化不具合箇所群285に出力する。なお、メソッド呼び出しの中に別のメソッド呼び出し又はフィールドアクセスがパラメータとして出現する場合、追加不具合箇所抽出部230は、一番内側のメソッド呼び出し又はフィールドアクセスのみをプレースホルダ「$ID」に置き換えてもよい。
Specifically, the additional
また、追加不具合箇所抽出部230は、スコープが明示されていないメソッド呼び出しにおけるメソッドの指定部分及び、スコープが明示されていないフィールドアクセスにおけるフィールドの参照部分については、プレースホルダに置き換えなくてもよい。これにより、抽象化されるコード片の数を減らすことで、後述の処理P3において不要な追加不具合箇所が出力されることを抑制できる。
Further, the additional
(抽象化不具合箇所群)
図8は、抽象化不具合箇所群285の一例を示す図である。
(Abstract defect location group)
FIG. 8 is a diagram showing an example of the abstracted
抽象化不具合箇所群285は、1以上の抽象化不具合箇所2851を含む。抽象化不具合箇所2851は、単一箇所修正候補群284でその記述が書き換えられたコード片(修正コード片)を抽象化したコード片、すなわち抽象化修正コード片を含んだ情報である。
The abstracted
例えば、前記のS112の処理により書き換えられた単一箇所修正候補群284のコード片であるソースファイル310のフィールドアクセス311「SHAPES.REC」は、スコープが明示されたコード片であり、具体的には、スコープ「SHAPES」及びフィールド「REC
」を含む。したがって、追加不具合箇所抽出部230は、フィールドアクセス311「SHAPES.REC」のうちフィールド「REC」の部分をプレースホルダ「$ID」に書き換える抽象化を行うことで、抽象化された修正コード片2852「SHAPES.$ID」を抽象化不具合箇所群285に出力している。
For example, the
"including. Therefore, the additional
処理P2:次に、追加不具合箇所抽出部230は、ソースファイル群281に含まれるソースコード全体を(そこに不具合があるか否かに関係なく)抽象化して、抽象化ソースコード286に出力する。抽象化の方法は処理P1と同様である。ただし、追加不具合箇所抽出部230は、単一箇所修正候補群284で書き換えられた行は抽象化しない。
Process P2: Next, the additional
(抽象化ソースコード)
図9は、抽象化ソースコード286の一例を示す図である。
(abstraction source code)
FIG. 9 is a diagram showing an example of the
この抽象化ソースコード286は、ソースファイル群281におけるソースファイル310に含まれるソースコードの一部をプレースホルダ「$ID」に書き換えることで抽象化
されたソースコードの情報である。
This
同図では、追加不具合箇所抽出部230は、ソースファイル群281に含まれるソースコードのうち、S112の処理により単一箇所修正候補群284に出力された(書き換えられた)前記のソースファイル310「File1」の3行目2861以外の、抽象化可能な
すべてのコードを抽象化することで、抽象化ソースコード286を出力している。
In the figure, the additional
例えば、ソースファイル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
処理P3:次に、追加不具合箇所抽出部230は、抽象化ソースコード286の各行のうち、抽象化不具合箇所群285に登録されている抽象化修正コード片を含んでいる行であって、かつ、S112の処理で単一箇所修正候補群284によりコード片を書き換えた行とは異なる行(すなわち追加の不具合を含む行)を全て特定し、特定した各行の情報を、追加不具合箇所群287に出力する。
Process P3: Next, the additional
(追加不具合箇所群)
図10は、追加不具合箇所群287の一例を示す図である。
(Additional defective locations)
FIG. 10 is a diagram showing an example of the additional
追加不具合箇所群287は、0以上のエントリを含む。追加不具合箇所群287のエントリは、ファイル名2871、及び行番号2872のカラムを含む。ファイル名2871には、追加の不具合を含むソースファイル310、320のファイル名が格納され、行番
号2872には、追加の不具合を含む行の行番号が格納される。
The additional
同図の例では、追加不具合箇所抽出部230は、抽象化ソースコード286の各行のうち、抽象化不具合箇所群285に登録されているコード片であってソースファイル310(File1)から抽象化されたコード片2852「SHAPES.$ID」を含んでいる5行目286
3を、ソースファイル310(File1)に対応づけて、追加不具合箇所群287の行番号
2872に出力する。
In the example shown in the figure, the additional
3 is associated with the source file 310 (File 1) and output to
次に、追加素材コード生成部240は、単一箇所修正候補群284に基づき、追加素材コード群288を生成する(S114)。
Next, the additional material
具体的には、例えば、追加素材コード生成部240は、単一箇所修正候補群284において書き換えられたコード片(修正コード片)がフィールドアクセスの場合、ソースファイル群281から、そのコード片と同じスコープに含まれるフィールドを参照する他のフィールドアクセスの式を抽出し、そのフィールドの部分を追加素材コード群288に出力する。また、例えば、追加素材コード生成部240は、修正コード片がメソッド呼び出しの場合、ソースファイル群281から、そのコード片と同じスコープに含まれるメソッドを呼び出す他のメソッド呼び出しの式を抽出する。そして、追加素材コード生成部240は、抽出したメソッド呼び出しの式から、前記コード片とパラメータの数又はタイプが異なるメソッド呼び出しの式を除外し、そのメソッド呼び出しの部分を追加素材コード群288に出力する。
Specifically, for example, if the code fragment (modified code fragment) rewritten in the single location
なお、単一箇所修正候補群284の生成にコード片が使われていない場合、追加素材コード生成部240は0の追加素材コードを出力する。
Note that if no code piece is used to generate the single location
(追加素材コード群)
図11は、追加素材コード群288の一例を示す図である。追加素材コード群288は、0以上の追加素材コード2881を含む。
(Additional material code group)
FIG. 11 is a diagram showing an example of the additional
追加素材コード2881は、例えば、単一箇所修正候補群284において書き換えに使用されたコード片、そのコード片と同じスコープに含まれる他のフィールドを参照するフィールドアクセスの式、又は、そのコード片と同じスコープに含まれる他のメソッドを呼び出すメソッド呼び出しの式等である。同図に示した追加素材コード2881は、フィールドアクセス2881a「SAHPES.CUBE」と、そのコード片と同じスコープに含まれる他
のフィールドを参照する他のコード片であるフィールドアクセス2881b、c(「SHAPES.TRI」、「SHAPES.HEX」)とを含む。
The
なお、追加素材コード群288には、単一箇所修正候補群284で書き換えられたコード片(修正コード片)は設定されなくてもよい。例えば、同図に示した追加素材コード群288では、単一箇所修正候補群284で書き換えられたコード片「SHAPES.REC」は設定されていない。
Note that the additional
次に、図5に示すように、複数箇所修正候補生成部250は、単一箇所修正候補群284と、追加不具合箇所群287と、追加素材コード群288とに基づき、第2修正候補の情報である複数箇所修正候補群289を出力する(S115)。
Next, as shown in FIG. 5, the multiple location correction
具体的には、複数箇所修正候補生成部250は、単一箇所修正候補群284のソースコードから、追加不具合箇所群287が示す箇所(行)の各コード片を抽象化ソースコード286を参照しつつ特定し、特定した各コード片の不具合箇所を、追加素材コード群288に登録されている各素材コード片で書き換えることで、複数箇所修正候補群289を出
力する。なお、複数箇所修正候補生成部250は、例えば、単一箇所修正候補群284の生成と同じ方法により書き換えを実行することができるが、書き換えの方法は特に限定されない。
Specifically, the multiple location correction
(複数箇所修正候補群)
図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
同図に示す複数箇所修正候補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
0b is the location indicated by
This is a source code in which the field access “SHAPES.REC” in
次に、図5に示すように、修正候補検査部260は、情報記憶部280に記憶されているテストファイル群282と、単一箇所修正候補群284と、複数箇所修正候補群289とに基づき、修正結果291を出力する(S116)。
Next, as shown in FIG. 5, the modification
具体的には、修正候補検査部260は、単一箇所修正候補群284及び複数箇所修正候補群289の各ソースコードに含まれる修正候補(第1修正候補、第2修正候補)のそれぞれをテストファイル群282の各テストファイルに入力することで、各テストファイルの出力データを取得する。修正候補検査部260は、テストファイルの出力データが、不具合箇所を含む行が正しく書き換えられたことを示している場合は、その修正候補を修正結果291に出力する。なお、不具合箇所を含む行が正しく書き換えられたか否かの検査には、例えば静的解析を用いてもよいし、テストコードを用いてもよい。
Specifically, the modification
その後、プログラム修正装置100は、新たな単一箇所修正候補群284を作成すべく、S112の処理を繰り返してもよい(S117)。この際、プログラム修正装置100は、追加不具合箇所抽出部230、追加素材コード生成部240、複数箇所修正候補生成部250、抽象化不具合箇所群285、抽象化ソースコード286、追加不具合箇所群287、及び追加素材コード群288等を初期化してもよい。これにより、複数の第1修正候補に対し、夫々独立した第1修正候補を生成することができ、互いに影響を及ぼすことなく、より多くの不具合を取り除くことができる。
Thereafter, the
その際、さらに、プログラム修正装置100の単一箇所修正候補生成部220は、不具合箇所候補群283の他のエントリを選択してもよい。これにより、ある行におけるコード片の変更では不具合を解消できなかった場合に、他の行におけるコード片の変更も試し、より高い確率で不具合を解消することができる。
At this time, the single location modification
(修正結果)
ここで、図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
” (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
すなわち、プログラム修正装置100は、最初に特定した不具合箇所及びソースコードをそれぞれ抽象化して両者を参照することで、ソースコードの他の不具合箇所を幅広く推定すると共に修正候補を作成することができ、作成した修正候補でソースコードの他の不具合を修正することができる。
That is, the
このように、本実施形態のプログラム修正装置100によれば、プログラム中に存在する不具合を精度良く検出して修正することができる。そして、これにより、開発者のデバッグ作業を効率化することができる。
In this way, according to the
また、本実施形態のプログラム修正装置100は、メソッド呼び出しのメソッド、及び、スコープが明示されたフィールドアクセスのフィールドをそれぞれプレースホルダに置換することで、ソースコードを汎化する。
Furthermore, the
これにより、ソースコードでバグが一般的な発生し易い箇所を特定し、ソースコードを効率良く修正することができる。 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
このように、抽象化が不要な場合は抽象化処理を行わないことで、不具合箇所の特定及び解消の処理をより高速に行うことができる。 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
これにより、同じスコープ内のメソッド又はフィールドを呼び出し又は産所ぷするメソッド呼び出し又はフィールドアクセスを、他の不具合を修正するための素材として用いることができ、不具合のある可能性が高い箇所を効率良く修正することができる。 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
100 プログラム修正装置
210 不具合箇所特定部
220 単一箇所修正候補生成部
230 追加不具合箇所抽出部
240 追加素材コード生成部
250 複数箇所修正候補生成部
260 修正候補検査部
100
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.
呼び出し範囲が指定されている他の処理を呼び出す呼び出し処理の部分、又は、参照範囲が指定されている定数若しくは変数を参照する参照処理の部分における不具合を特定し、
前記他の不具合の箇所を解消するための情報として、前記呼び出し範囲内の他の処理を呼び出す呼び出し処理の部分、又は、前記参照範囲内の他の定数若しくは変数を参照する参照処理の部分を、前記他の不具合の箇所を解消するための情報を作成する、
請求項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.
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) |
-
2022
- 2022-06-28 JP JP2022103319A patent/JP2024003945A/en active Pending
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 |