JP5761056B2 - Generating device, generating program, and generating method - Google Patents
Generating device, generating program, and generating method Download PDFInfo
- Publication number
- JP5761056B2 JP5761056B2 JP2012019285A JP2012019285A JP5761056B2 JP 5761056 B2 JP5761056 B2 JP 5761056B2 JP 2012019285 A JP2012019285 A JP 2012019285A JP 2012019285 A JP2012019285 A JP 2012019285A JP 5761056 B2 JP5761056 B2 JP 5761056B2
- Authority
- JP
- Japan
- Prior art keywords
- node
- branch
- execution
- executed
- program
- 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.)
- Expired - Fee Related
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
- Devices For Executing Special Programs (AREA)
- Stored Programmes (AREA)
Description
本発明は、生成装置、生成プログラム、および生成方法に関する。 The present invention relates to a generation device, a generation program, and a generation method.
従来、テストデータをプログラムに与えた場合に、プログラムの実行経路を示す2分木をトレースして到達する葉ノードを特定し、2分木の葉ノードの中で特定された葉ノードの割合を、プログラムに対するテストデータの網羅性として算出する技術がある(例えば、下記特許文献1参照)。
Conventionally, when test data is given to a program, a leaf tree that traces a binary tree indicating the execution path of the program is traced and a leaf node that is reached is identified. There is a technique for calculating the completeness of test data for (see, for example,
しかしながら、上述した従来技術では、2分木の生成過程において、プログラムの分岐命令ごとに2分木の末端ノードが枝分かれするため、ノードの個数が増大していく。また、プログラムの実行経路を示す2分木のトレースによりプログラムに対するテストデータの網羅性が算出されるため、2分木を記憶装置に保持し続けると、記憶領域を圧迫するといった問題がある。また、記憶領域が圧迫されるとプログラムの実行効率が低下し、テストデータの網羅性の算出が長期化することになる。また、記憶領域に2分木を保持しきれなくなった場合、プログラムの実行が中断される。これにより、2分木が完成せず、テストデータの網羅性の算出ができない場合がある。 However, in the above-described conventional technique, the end node of the binary tree branches for each branch instruction of the program in the generation process of the binary tree, so the number of nodes increases. Further, since the completeness of the test data for the program is calculated by tracing the binary tree indicating the execution path of the program, there is a problem that if the binary tree is kept in the storage device, the storage area is compressed. In addition, if the storage area is compressed, the execution efficiency of the program is reduced, and the calculation of the completeness of the test data is prolonged. When the binary tree cannot be held in the storage area, the program execution is interrupted. As a result, the binary tree may not be completed, and the completeness of test data may not be calculated.
本発明は、上述した従来技術による問題点を解消するため、記憶領域の使用量増加を抑制することができる生成装置、生成プログラム、および生成方法を提供することを目的とする。 An object of the present invention is to provide a generation device, a generation program, and a generation method that can suppress an increase in the amount of use of a storage area in order to solve the above-described problems caused by the conventional technology.
上述した課題を解決し、目的を達成するため、本発明の一側面によれば、プログラムの実行中に到達した分岐命令において未実行の分岐条件が実行された場合、分岐命令と、実行された分岐条件と、プログラムの実行開始から分岐命令の分岐元の分岐命令までに実行された一連の分岐条件と、を関連付けたノードを生成し、生成されたノードを記憶装置に格納し、プログラムの実行が終了した場合、プログラムが終了するまでの実行経路上の末尾ノードが示す一連の分岐条件に基づいて、プログラムが終了するまでに実行された一連の分岐条件を生成し、生成された一連の分岐条件を記憶装置に格納し、プログラムの実行が終了した場合、プログラムが終了するまでの実行経路を当該実行経路上の末尾ノードから前記実行経路の逆順に探索して未実行の分岐条件が最初に出現するノードを、記憶装置の中から特定し、特定されたノードが示す分岐命令からプログラムが再開され、未実行の分岐条件が実行された場合、当該分岐条件を特定されたノードが示す分岐命令に関連付けることにより、特定されたノードを記憶装置内において更新し、未実行の分岐条件がなくなったノードを記憶装置から削除する生成装置、生成プログラム、および生成方法が提案される。 In order to solve the above-described problems and achieve the object, according to one aspect of the present invention, when an unexecuted branch condition is executed in a branch instruction reached during program execution, the branch instruction is executed. Generates a node that associates the branch condition with a series of branch conditions executed from the start of program execution to the branch instruction that is the branch source of the branch instruction, stores the generated node in the storage device, and executes the program When is completed, a series of branch conditions executed until the program ends is generated based on a series of branch conditions indicated by the end node on the execution path until the program ends, and the generated series of branches When the condition is stored in the storage device and the execution of the program ends, the execution path until the program ends is searched from the last node on the execution path in the reverse order of the execution path. The node in which the unexecuted branch condition first appears is identified from the storage device, and when the program is restarted from the branch instruction indicated by the identified node and the unexecuted branch condition is executed, the branch condition is A generation device, a generation program, and a generation method for updating a specified node in a storage device by associating it with a branch instruction indicated by the specified node and deleting a node that has no unexecuted branch condition from the storage device Proposed.
本発明の一側面によれば、記憶領域の使用量増加を抑制することができるという効果を奏する。 According to one aspect of the present invention, there is an effect that an increase in the usage amount of a storage area can be suppressed.
以下に添付図面を参照して、この発明にかかる生成装置、生成プログラム、および生成方法の実施の形態を詳細に説明する。 Exemplary embodiments of a generating device, a generating program, and a generating method according to the present invention will be explained below in detail with reference to the accompanying drawings.
(生成装置によるパス条件の生成の内容)
図1は、生成装置によるパス条件の生成の内容を示す説明図である。図1において、生成装置100は、パス条件の生成対象になる対象プログラムTPをシンボリック実行するコンピュータである。パス条件とは、或る実行経路で対象プログラムTPを実行する場合に対象プログラムTPの入力になるデータが満たすべき条件であり、対象プログラムTPの実行が終了するまでの実行経路上において実行された一連の分岐条件である。
(Contents of path condition generation by the generator)
FIG. 1 is an explanatory diagram showing details of generation of a path condition by the generation device. In FIG. 1, the
シンボリック実行とは、対象プログラムTPの変数に具体的な値を入力する代わりに、シンボル値(記号値)を入力し、シンボル値のまま対象プログラムTPを模擬的に実行することである。以降、シンボル値が入力される変数を「シンボル変数」と称す。生成装置100は、対象プログラムTPのシンボリック実行中において、シンボル変数に関する分岐命令を実行するごとに、当該分岐命令に対応するノードNを生成する。
Symbolic execution is to input a symbol value (symbol value) instead of inputting a specific value to a variable of the target program TP, and execute the target program TP in a simulated manner with the symbol value. Hereinafter, a variable to which a symbol value is input is referred to as a “symbol variable”. The
(A)は、生成されたノードNのデータ構造を示す。分岐命令に対応するノードNには、例えば、分岐命令に応じたプログラムカウンタ、および分岐命令までの実行経路上において実行された一連の分岐条件、実行された分岐条件が含まれる。プログラムカウンタとは、命令の番地(アドレス)である。 (A) shows the data structure of the generated node N. The node N corresponding to the branch instruction includes, for example, a program counter corresponding to the branch instruction, a series of branch conditions executed on the execution path to the branch instruction, and an executed branch condition. The program counter is an instruction address (address).
ここで、一般的なシンボリック実行の場合とは異なり、ノードNには、実行された分岐条件が含まれる。これにより、生成装置100は、ノードNが示す分岐命令に、未実行の分岐条件があるか否かを判別できる。また、一般的なシンボリック実行の場合とは異なり、ノードNには、分岐命令までの実行経路上において実行された一連の分岐条件が含まれる。これにより、生成装置100は、ノードNが示す一連の分岐条件を引き継ぐことにより、ノードNが示す分岐命令から対象プログラムTPの実行を再開して、未実行の実行経路を途中から実行することができる。
Here, unlike the case of general symbolic execution, the executed branch condition is included in the node N. Thereby, the
また、生成装置100は、対象プログラムTPの実行を終了した場合、対象プログラムTPの実行の終了に対応するノードNを生成する。この場合、対象プログラムTPの実行の終了に対応するノードNには、例えば、対象プログラムTPの実行の終了に応じたプログラムカウンタ、および対象プログラムTPの実行の終了までの実行経路上において実行された一連の分岐条件が含まれる。
Further, when the execution of the target program TP is ended, the
また、各ノードNは、実行経路上の親ノードNへのリンクとして、親ノードのアドレスを含んでもよい。また、各ノードNは、実行経路上の子ノードNへのリンクとして、子ノードのアドレスを含んでもよい。ノードNの子ノードとは、当該ノードNから分岐したノードである。ノードNの親ノードとは、当該ノードNの直前の分岐元のノードNである。 Each node N may include the address of the parent node as a link to the parent node N on the execution path. Each node N may include the address of the child node as a link to the child node N on the execution path. The child node of the node N is a node branched from the node N. The parent node of the node N is the branching node N immediately before the node N.
(B)は、対象プログラムTPの記述内容の一例を示す。対象プログラムTPは、シンボル変数「a」に関する分岐命令を3番地に含み、シンボル変数「b」に関する分岐命令を4番地に含む。(C)〜(E)は、生成されたノード群により構成される木構造データの一例を示している。以下、(B)〜(E)を参照して、生成装置100による対象プログラムTPのパス条件の生成の内容について説明する。
(B) shows an example of the description content of the target program TP. The target program TP includes a branch instruction related to the symbol variable “a” at the third address, and includes a branch instruction related to the symbol variable “b” at the fourth address. (C)-(E) have shown an example of the tree structure data comprised by the produced | generated node group. Hereinafter, with reference to (B) to (E), the contents of the generation of the path condition of the target program TP by the
(B)において、(1)まず、生成装置100は、対象プログラムTPの1番地からシンボリック実行を開始し、対象プログラムTPの3番地に到達する。そして、(C)において、(2)生成装置100は、対象プログラムTPの3番地において、シンボル変数「a」に関する分岐命令「if(a>0)」が真になる分岐条件「a>0」を実行すると、当該分岐命令に対応するノードN1を生成する。
In (B), (1) First, the
ノードN1は、例えば、当該分岐命令の番地を示すプログラムカウンタ「3」と、3番地までに実行された一連の分岐条件と、当該分岐命令が真になる分岐条件を実行したことを示す「真」と、を含む。ここで、3番地までに実行された分岐条件がないため、ノードN1は、3番地までに実行された分岐条件がないことを示す情報「True」を含む。 The node N1, for example, indicates that the program counter “3” indicating the address of the branch instruction, a series of branch conditions executed up to the third address, and “true” indicating execution of the branch condition that makes the branch instruction true. ”. Here, since there is no branch condition executed up to the third address, the node N1 includes information “True” indicating that there is no branch condition executed up to the third address.
次に、(B)において、(3)生成装置100は、対象プログラムTPを3番地から再開し、対象プログラムTPの4番地に到達する。そして、(C)において、(4)生成装置100は、対象プログラムTPの4番地において、シンボル変数「b」に関する分岐命令「if(b>0)」が真になる分岐条件「b>0」を実行すると、当該分岐命令に対応するノードN2を生成する。
Next, in (B), (3) the
ノードN2は、例えば、当該分岐命令の番地を示すプログラムカウンタ「4」と、4番地までに実行された一連の分岐条件「a>0」と、当該分岐命令が真になる分岐条件を実行したことを示す「真」と、を含む。4番地までに実行された一連の分岐条件「a>0」は、ノードN1が示す一連の分岐条件「True」と、3番地において実行された分岐条件「a>0」を参照して生成される。 For example, the node N2 executes a program counter “4” indicating the address of the branch instruction, a series of branch conditions “a> 0” executed up to the fourth address, and a branch condition that makes the branch instruction true. "True" indicating that. A series of branch conditions “a> 0” executed up to the fourth address are generated with reference to a series of branch conditions “True” indicated by the node N1 and a branch condition “a> 0” executed at the third address. The
次に、(B)において、(5)生成装置100は、対象プログラムTPを4番地から再開し、対象プログラムTPの8番地まで到達する。そして、(C)において、(6)生成装置100は、対象プログラムTPの8番地で、対象プログラムTPの実行の終了を検出すると、対象プログラムTPの実行の終了に対応するノードN3を生成する。
Next, in (B), (5) the
ノードN3は、例えば、対象プログラムTPが終了した番地を示すプログラムカウンタ「8」と、8番地までに実行された一連の分岐条件「(a>0)&&(b>0)」と、を含む。8番地までに実行された一連の分岐条件「(a>0)&&(b>0)」は、ノードN2が示す一連の分岐条件「a>0」と、4番地において実行された分岐条件「b>0」を参照して生成される。「&&」は論理積を示す。ここで、生成装置100は、生成したノードN3が示す一連の分岐条件「a>0&&b>0」をパス条件PC1として記憶装置に保持しておく。
The node N3 includes, for example, a program counter “8” indicating the address at which the target program TP has ended, and a series of branch conditions “(a> 0) && (b> 0)” executed up to the
また、(B)において、(7)生成装置100は、対象プログラムTPの実行の終了を検出すると、ノードN3の親になるノードN2が示す分岐命令の番地「4」まで戻る。そして、(D)において、(8)生成装置100は、ノードN2が示す分岐命令の番地「4」に戻ると、他のパス条件の生成に用いない不要なノードN3を削除する。これにより、生成装置100は、記憶領域の使用量増加を抑制することができる。(9)そして、生成装置100は、番地「4」の分岐命令に、未実行の分岐条件があるか否かを判定する。
In (B), (7) when the
次に、(B)において、(10)生成装置100は、ノードN2に分岐命令が偽になる分岐条件を実行したことを示す「偽」が含まれていないため、未実行の分岐条件があると判断する。
Next, in (B), (10) since the
そのため、生成装置100は、4番地の分岐命令「if(b>0)」が偽になる未実行の分岐条件「!b>0」を実行し、対象プログラムTPを4番地から再開し、対象プログラムTPの8番地まで到達する。「!」は否定を示す。ここで、生成装置100は、分岐命令が偽になる分岐条件を実行したことを示す「偽」を、ノードN2に追加する。(11)そして、生成装置100は、対象プログラムTPの8番地において、対象プログラムTPの実行の終了を検出すると、対象プログラムTPの実行の終了に対応するノードN4を生成する。
Therefore, the
ノードN4は、例えば、対象プログラムTPの実行の終了の番地を示すプログラムカウンタ「8」と、8番地までに実行された一連の分岐条件「a>0&&!b>0」と、を含む。8番地までに実行された一連の分岐条件「a>0&&!b>0」は、ノードN2が示す一連の分岐条件「a>0」と、4番地において実行された分岐条件「b≦0」を参照して生成される。ここで、生成装置100は、生成したノードN4が示す一連の分岐条件「a>0&&!b>0」をパス条件PC2として保持しておく。
The node N4 includes, for example, a program counter “8” indicating an end address of execution of the target program TP and a series of branch conditions “a> 0 &&! B> 0” executed up to the eighth address. A series of branch conditions “a> 0 &&! B> 0” executed up to the 8th address are a series of branch conditions “a> 0” indicated by the node N2 and a branch condition “b ≦ 0” executed at the 4th address. Generated with reference to Here, the
また、(B)において、(12)生成装置100は、対象プログラムTPが終了すると、ノードN4の親になるノードN2が示す分岐命令の番地「4」まで戻る。そして、(E)において、(13)生成装置100は、ノードN2が示す分岐命令の番地「4」に戻ると、ノードN4を削除する。(14)そして、生成装置100は、番地「4」の分岐命令に、未実行の分岐条件があるか否かを判定する。
In (B), (12) when the target program TP ends, the generating
次に、(B)において、(15)ノードN2に「真」と「偽」が含まれているため、生成装置100は、未実行の分岐条件がないと判断する。そのため、生成装置100は、さらに、ノードN2の親になるノードN1が示す分岐命令の番地「3」まで戻る。そして、(E)において、(16)生成装置100は、ノードN1が示す分岐命令の番地「3」に戻ると、未実行の分岐条件がないノードN2を、他のパス条件の生成に用いない不要なノードNとして削除する。これにより、生成装置100は、記憶領域の使用量増加を抑制することができる。(17)そして、生成装置100は、番地「3」の分岐命令に、未実行の分岐条件があるか否かを判定する。
Next, in (B), (15) since the node N2 includes “true” and “false”, the generating
次に、(B)において、(18)ノードN1に分岐命令が偽になる分岐条件を実行したことを示す「偽」が含まれていないため、生成装置100は、未実行の分岐条件があると判断する。そのため、生成装置100は、3番地の分岐命令「if(a>0)」が「偽」になる未実行の分岐条件「!a>0」を実行し、対象プログラムTPを3番地から再開し、対象プログラムTPの8番地まで到達する。
Next, in (B), (18) because the node N1 does not include “false” indicating that the branch condition that makes the branch instruction false is included, the
そして、(E)において、(19)生成装置100は、対象プログラムTPの8番地で、対象プログラムTPの実行の終了を検出すると、対象プログラムTPの実行の終了に対応するノードN5を生成する。ノードN5は、対象プログラムTPの実行の終了の番地を示すプログラムカウンタ「8」と、1番地から8番地までに実行された分岐条件「!a>0」と、を含む。8番地までに実行された一連の分岐条件「!a>0」は、ノードN1が示す一連の分岐条件「True」と、3番地において実行された分岐条件「!a>0」を参照して生成される。ここで、生成装置100は、生成したノードN5が示す分岐条件「!a>0」をパス条件PC3として保持しておく。
In (E), (19) when the
これにより、生成装置100は、対象プログラムTPの各々の実行経路に対応するパス条件PC1〜PC3を生成することができる。この際、生成装置100は、パス条件の生成に伴って、パス条件の生成を終えた実行経路上のノードNを、パス条件の生成に用いない不要なノードNとして削除していくことにより、記憶領域の使用量増加を抑制することができる。
Thereby, the generating
このように、生成装置100は、記憶領域に保持されるノードNの個数増加を抑制し、ノードNの保持によるワークエリアになる記憶領域の圧迫を抑制する。そして、生成装置100は、ワークエリアの圧迫によるプログラムの実行効率の低下を抑制することができる。生成装置100は、例えば、テストデータの対象プログラムTPに対する網羅性の算出効率の低下を抑制することができる。また、生成装置100は、記憶領域にノードNが保持しきれずに、ワークエリアとして使用可能な領域がなくなることを防止することができる。そして、生成装置100は、ワークエリアとして使用可能な領域がなくなり、パス条件の生成が中断することを防止することができる。
In this way, the
また、生成装置100は、生成したパス条件PC1〜PC3から、対象プログラムTPの動作確認に用いられるテストデータが、各々の実行経路をどの程度網羅しているかを示す網羅性を算出することができる。ここで、テストデータは、例えば、生成装置100の利用者によって生成される。例えば、テストデータが「(a,b)=(1,1),(1,−1)」であれば、上述した3つのパス条件PC1〜PC3のうち、2つのパス条件PC1,PC2を満たすため、当該テストデータの網羅性は「66%」である。
Further, the
これにより、生成装置100の利用者は、テストデータの対象プログラムTPに対する網羅性が100%に満たない場合、対象プログラムTPの実行経路の各々を100%網羅して動作確認ができるように、テストデータを追加することができる。生成装置100の利用者は、例えば、上記テストデータ「(a,b)=(1,1),(1,−1)」に、パス条件PC3を満たす「(a,b)=(−1,−1)」を追加して、網羅性を100%にする。
As a result, when the user of the
また、生成装置100の利用者は、テストデータの対象プログラムTPに対する網羅性が100%である場合、テストデータから不要なデータを削除し、対象プログラムTPの動作確認の効率化を図ってもよい。生成装置100の利用者は、例えば、テストデータ「(a,b)=(1,1),(2,1),(−1,−1),(1,−1)」から、「(a,b)=(2,1)」を削除しても網羅性が100%のままであるため、「(a,b)=(2,1)」を削除する。
In addition, when the coverage of the test data with respect to the target program TP is 100%, the user of the
また、生成装置100は、生成したパス条件の各々を満たすテストデータを生成してもよい。生成装置100は、例えば、パス条件「(a>0)&&(b>0)」を満たすテストデータとして、「(a,b)=(1,1)」を生成する。
Further, the
(生成装置100のハードウェア構成例)
図2は、実施の形態にかかる生成装置100のハードウェア構成例を示すブロック図である。図2において、生成装置100は、CPU(Central Processing Unit)201と、ROM(Read‐Only Memory)202と、RAM(Random Access Memory)203と、磁気ディスクドライブ204と、磁気ディスク205と、光ディスクドライブ206と、光ディスク207と、ディスプレイ208と、I/F(Interface)209と、キーボード210と、マウス211と、スキャナ212と、プリンタ213と、を備えている。また、各構成部はバス220によってそれぞれ接続されている。
(Hardware configuration example of generation device 100)
FIG. 2 is a block diagram illustrating a hardware configuration example of the
ここで、CPU201は、生成装置100の全体の制御を司る。ROM202は、ブートプログラムなどのプログラムを記憶している。RAM203は、CPU201のワークエリアとして使用される。磁気ディスクドライブ204は、CPU201の制御にしたがって磁気ディスク205に対するデータのリード/ライトを制御する。磁気ディスク205は、磁気ディスクドライブ204の制御で書き込まれたデータを記憶する。
Here, the
光ディスクドライブ206は、CPU201の制御にしたがって光ディスク207に対するデータのリード/ライトを制御する。光ディスク207は、光ディスクドライブ206の制御で書き込まれたデータを記憶したり、光ディスク207に記憶されたデータをコンピュータに読み取らせたりする。
The
ディスプレイ208は、カーソル、アイコンあるいはツールボックスをはじめ、文書、画像、機能情報などのデータを表示する。このディスプレイ208は、例えば、液晶ディスプレイ、プラズマディスプレイなどを採用することができる。
The
インターフェース(以下、「I/F」と略する。)209は、通信回線を通じてLAN(Local Area Network)、WAN(Wide Area Network)、インターネットなどのネットワーク214に接続され、このネットワーク214を介して他の装置に接続される。そして、I/F209は、ネットワーク214と内部のインターフェースを司り、外部装置からのデータの入出力を制御する。I/F209には、例えばモデムやLANアダプタなどを採用することができる。
An interface (hereinafter abbreviated as “I / F”) 209 is connected to a
キーボード210は、文字、数字、各種指示などの入力のためのキーを備え、データの入力をおこなう。また、タッチパネル式の入力パッドやテンキーなどであってもよい。マウス211は、カーソルの移動や範囲選択、あるいはウィンドウの移動やサイズの変更などをおこなう。ポインティングデバイスとして同様に機能を有するものであれば、トラックボールやジョイスティックなどであってもよい。
The
スキャナ212は、画像を光学的に読み取り、生成装置100内に画像データを取り込む。なお、スキャナ212は、OCR(Optical Character Reader)機能を持たせてもよい。また、プリンタ213は、画像データや文書データを印刷する。プリンタ213には、例えば、レーザプリンタやインクジェットプリンタを採用することができる。
The
(生成装置100の機能的構成例)
図3は、生成装置100の機能的構成例を示すブロック図である。生成装置100は、入力部301と、実行部302と、第1の生成部303と、第1の格納部304と、第2の生成部305と、第2の格納部306と、特定部307と、更新部308と、削除部309と、追加部310と、判定部311と、出力部312と、判断部313と、算出部314と、を含む構成である。
(Functional configuration example of the generation device 100)
FIG. 3 is a block diagram illustrating a functional configuration example of the
入力部301、実行部302、第1の生成部303、第1の格納部304、第2の生成部305、第2の格納部306、特定部307、更新部308、削除部309、追加部310、判定部311、出力部312、判断部313、および、算出部314は、具体的には、例えば、図2に示したROM202、RAM203、磁気ディスク205、光ディスク207などの記憶装置300に記憶されたプログラムをCPU201に実行させることにより、または、I/F209により、その機能を実現する。
ここで、生成装置100は、対象プログラムTPについて実行可能な各々の実行経路に対応するパス条件を生成する機能を有する。ここで、実行経路とは、対象プログラムTPの実行に伴って生成されたノードNの集合における先頭ノードNから末尾ノードNまでの経路である。また、生成装置100は、或る分岐命令の実行回数が閾値以上になったことを検出する機能を有する。また、生成装置100は、生成したパス条件の集合から、テストデータの網羅性を算出する機能を有する。
Here, the
まず、パス条件を生成する機能について説明する。パス条件を生成する機能は、入力部301〜削除部309によって実現される。パス条件を生成する具体例については、図5〜図11を用いて後述する。
First, a function for generating a path condition will be described. The function of generating the path condition is realized by the
入力部301は、プログラムの入力を受け付ける。ここで、プログラムとは、パス条件の生成対象になるプログラムであり、例えば、上述した対象プログラムTPである。これにより、入力部301は、対象プログラムTPのシンボリック実行を実行部302に開始させるトリガを発生することができる。ここで、図4を用いて、入力部301によって入力される対象プログラムTPについて説明する。
The
図4は、対象プログラムTPの一例を示す説明図である。図4に示すように、対象プログラムTPは、3番地に、変数「a」にシンボル値を入力する命令「klee_make_symbolic(&a);」を含む。また、対象プログラムTPは、4番地に、変数「b」にシンボル値を入力する命令「klee_make_symbolic(&b);」を含む。ここで、シンボル値を入力された変数を、シンボル変数という。 FIG. 4 is an explanatory diagram showing an example of the target program TP. As shown in FIG. 4, the target program TP includes an instruction “klee_make_symbolic (&a);” for inputting a symbol value to the variable “a” at the third address. The target program TP includes an instruction “klee_make_symbolic (&b);” for inputting a symbol value to the variable “b” at the fourth address. Here, a variable to which a symbol value is input is referred to as a symbol variable.
また、対象プログラムTPは、17番地に、シンボル変数に関する分岐命令であるif文「if(b<10) n++;」を含む。if文「if(b<10) n++;」は、シンボル変数「b」が10より小さいか否かにより分岐する。また、対象プログラムTPは、22番地に、シンボル変数に関する分岐命令になるif文「if(x<0) return −x;」を含む。if文「if(x<0) return −x;」は、変数「x」の引数になるシンボル変数「a」が0より小さいか否かにより分岐する。 Further, the target program TP includes an if statement “if (b <10) n ++;” which is a branch instruction related to the symbol variable at the 17th address. The if statement “if (b <10) n ++;” branches depending on whether the symbol variable “b” is smaller than 10. Further, the target program TP includes an if statement “if (x <0) return -x;” that becomes a branch instruction related to a symbol variable at the 22nd address. The if statement “if (x <0) return -x;” branches depending on whether or not the symbol variable “a” that is an argument of the variable “x” is smaller than zero.
図3に戻り、実行部302は、入力部301によって入力されたプログラムをシンボリック実行する。ここで、シンボリック実行とは、上述したように、対象プログラムTPの変数に具体的な値を入力する代わりに、シンボル値(記号値)を入力し、シンボル値のまま対象プログラムTPを模擬的に実行することである。実行部302は、具体的には、例えば、プログラムカウンタが示す対象プログラムTPの番地から命令を読み出し、読み出した命令を実行する。
Returning to FIG. 3, the
また、実行部302は、シンボル変数に関する分岐命令を読み出した場合、未実行の分岐条件を実行し、第1の生成部303に未実行の分岐命令を実行したことを通知する。実行部302は、具体的には、例えば、図4の17番地のif文「if(b<10) n++;」を読み出した場合、当該if文が真になる未実行である分岐条件「b<10」を実行する。これにより、実行部302は、第1の生成部303にノードNの生成を開始させることができる。
Further, when the
また、実行部302は、具体的には、例えば、図4の17番地のif文「if(b<10) n++;」を読み出した場合、分岐条件「b<10」を実行済みであれば、当該if文が偽になる未実行である分岐条件「b≧10」を実行してもよい。これにより、実行部302は、第1の生成部303にノードNの生成を開始させることができる。
Further, for example, when the
また、実行部302は、プログラムの終了命令を読み出した場合、第2の生成部305にプログラムの終了を通知する。ここで、プログラムの終了命令とは、例えば、関数「main()」の終了を示す、図4の8番地の閉じ括弧である。これにより、実行部302は、第2の生成部305にパス条件の生成を開始させることができる。
Further, when the
第1の生成部303は、プログラムの実行中に到達した分岐命令において未実行の分岐条件が実行された場合、分岐命令と、実行された分岐条件と、プログラムの実行開始から分岐命令の分岐元の分岐命令までに実行された一連の分岐条件と、を関連付けたノードNを生成する。
When an unexecuted branch condition is executed in a branch instruction reached during program execution, the
ここで、実行部302によって図4の22番地のif文が真になる分岐条件「a<0」が実行された場合を例に挙げる。この場合、第1の生成部303は、具体的には、例えば、実行された分岐命令を示す番地「22」と、実行された分岐条件「a<0」と、22番地までに実行された一連の分岐条件「True」と、を関連付けたノードNを生成する。ここで、一連の分岐条件「True」とは、22番地までに実行された分岐条件がないことを示す情報である。
Here, a case will be described as an example in which the
また、実行部302によって図4の22番地のif文の分岐条件「x<0」が実行された後に、17番地のif文の分岐条件「b<10」が実行された場合を例に挙げる。この場合、第1の生成部303は、具体的には、例えば、実行された分岐命令を示す番地「17」と、実行された分岐条件「b<10」と、17番地までに実行された一連の分岐条件「a<0」と、を関連付けたノードNを生成する。17番地までに実行された一連の分岐条件「a<0」は、22番地の分岐命令に対応する親ノードNが示す一連の分岐条件「True」と実行された分岐条件「a<0」から生成される。
In addition, a case where the branch condition “b <10” of the if statement at the
また、ノードNは、親ノードNへのリンクになる記憶装置300における親ノードNのアドレスを含んでもよい。また、親ノードNは、ノードNへのリンクになる記憶装置300におけるノードNのアドレスを含んでもよい。また、第1の生成部303は、ノードNに、「a<0」の代わりに、分岐命令が真になる分岐条件が実行されたことを示す「真」を関連付けてもよい。また、第1の生成部303は、ノードNに、分岐命令に到達した場合の変数の値を関連付けてもよい。
Further, the node N may include the address of the parent node N in the
これにより、特定部307は、第1の生成部303により生成されたノードNが示す実行済みの分岐条件を参照して、ノードNが示す分岐命令に未実行の分岐条件があるか否かを判別することができる。また、実行部302は、第1の生成部303により生成されたノードNが示す一連の分岐条件と変数の値とを参照して、対象プログラムTPの実行を再開することができる。
Thereby, the specifying
第1の格納部304は、第1の生成部303によって生成されたノードNを記憶装置300に格納する。ここで、記憶装置300は、図2に示したRAM203、磁気ディスク205、光ディスク207などである。これにより、特定部307は、第1の格納部304により格納されたノードNが示す実行済みの分岐条件を、記憶装置300から取得することができる。また、実行部302は、第1の格納部304により格納されたノードNが示す一連の分岐条件と変数の値とを、記憶装置300から取得することができる。
The
第2の生成部305は、プログラムの実行が終了した場合、プログラムが終了するまでの実行経路上の末尾ノードNが示す一連の分岐条件に基づいて、プログラムが終了するまでに実行された一連の分岐条件を生成する。プログラムが終了するまでに実行された一連の分岐条件をパス条件という。パス条件は、当該実行経路(パス)でプログラムを実行する場合に各シンボル変数が満たすべき条件である。
When the execution of the program ends, the
ここで、分岐命令を示す番地「17」と、実行された分岐条件「b<10」と、17番地までに実行された一連の分岐条件「a<0」と、を関連付けたノードNが末尾ノードNである場合を例に挙げる。この場合、第2の生成部305は、具体的には、例えば、プログラムが終了するまでに実行された一連の分岐条件として、末尾ノードNが示す17番地において実行された分岐条件「b<10」と、17番地までに実行された一連の分岐条件「a<0」と、の論理積「(b<10)&&(a<0)」を生成する。これにより、算出部314は、第2の生成部305により生成されたパス条件を参照して、対象プログラムTPの動作確認に用いられるテストデータの網羅性を算出することができる。
Here, the node N that associates the address “17” indicating the branch instruction, the executed branch condition “b <10”, and the series of branch conditions “a <0” executed up to the
第2の格納部306は、第2の生成部305によって生成された一連の分岐条件を記憶装置300に格納する。ここで、記憶装置300は、図2に示したRAM203、磁気ディスク205、光ディスク207などである。これにより、削除部309は、第2の格納部306により記憶装置300に格納済みのパス条件に対応する実行経路上のノードNを、パス条件の生成に用いない不要なノードNとして削除することができる。また、算出部314は、第2の格納部306により格納されたパス条件を、記憶装置300から取得することができる。
The
特定部307は、プログラムの実行が終了した場合、プログラムが終了するまでの実行経路を当該実行経路上の末尾ノードNから実行経路の逆順に探索して、未実行の分岐条件が最初に存在するノードNを記憶装置300の中から特定する。ここで、逆順とは、ノードNの生成された順序の逆の順序であり、実行経路上の各ノードNが示す分岐命令が実行された順序の逆の順序である。実行経路を当該実行経路上の末尾ノードNから実行経路の逆順に探索することを、バックトラックという。
When the execution of the program ends, the specifying
特定部307は、具体的には、例えば、末尾ノードNを始点にし、プログラムが終了するまでの実行経路上の各々のノードNが示す親のノードNのアドレスを参照して、親のノードNに戻る。特定部307は、親のノードNに戻ると、さらに、その親のノードに戻る。このようにして、特定部307は、プログラムが終了するまでの実行経路をその逆順に探索していくことになる。次に、特定部307は、プログラムが終了するまでの実行経路を探索する過程において、当該実行経路内のノードNが示す実行済み分岐条件を取得する。そして、特定部307は、取得された分岐条件が1つ以下である場合に、未実行の分岐条件が存在すると判定し、分岐条件を取得したノードNを、未実行の分岐条件が存在するノードNとして特定する。
Specifically, for example, the specifying
特定部307は、より具体的には、図4の17番地の分岐命令に応じた末尾ノードNから、実行された分岐条件「b<10」を取得する。特定部307は、分岐条件「b<10」が1つ以下であり、未実行の分岐条件「b≧10」が存在すると判定する。そして、特定部307は、17番地の分岐命令に応じた末尾ノードNを、未実行の分岐条件が存在するノードNとして特定する。
More specifically, the specifying
これにより、実行部302は、特定部307により特定されたノードNが示す分岐命令を起点にして、対象プログラムTPの実行を再開することができる。また、実行部302は、対象プログラムTPの実行を再開し、分岐命令が真になる分岐条件と、偽になる分岐条件と、を実行することができる。
Thereby, the
この場合、実行部302は、特定されたノードNが示す変数の値を各変数に設定し、特定されたノードNが示す番地から対象プログラムTPを実行する。これにより、実行部302は、対象プログラムTPを最初から実行しなくても、途中から再開することができ、未実行の実行経路の実行を開始することができる。そのため、実行部302は、対象プログラムTPの実行可能な実行経路の各々を、効率的に実行していくことができる。
In this case, the
また、実行部302は、対象プログラムTPの実行を再開し、分岐命令が真になる分岐条件と、偽になる分岐条件と、を実行することができる。そのため、削除部309は、実行部302により実行され、未実行の分岐条件がなくなったノードNを、パス条件の生成に用いないノードNとして削除することができる。
Further, the
更新部308は、特定部307によって特定されたノードNが示す分岐命令からプログラムが再開され、未実行の分岐条件が実行された場合、当該分岐条件を特定されたノードNが示す分岐命令に関連付けることにより、特定されたノードNを記憶装置300内において更新する。
When the program is restarted from the branch instruction indicated by the node N specified by the specifying
更新部308は、具体的には、例えば、実行部302により17番地の分岐命令が偽になる分岐条件「b≧10」が実行され、対象プログラムTPが再開された場合、17番地の分岐命令に応じた末尾ノードNに、さらに「b≧10」を関連付けて更新する。また、更新部308は、末尾ノードNに、「b≧10」の代わりに、分岐命令が偽になる分岐条件が実行されたことを示す「偽」を関連付けて更新してもよい。これにより、削除部309は、更新部308により更新された実行された分岐条件を参照して、未実行の分岐条件がなくなったノードNを特定することができる。
Specifically, for example, when the
削除部309は、未実行の分岐条件がなくなったノードNを記憶装置300から削除する。削除部309は、具体的には、例えば、実行された分岐条件として2つの分岐条件が関連付けられたノードNを、パス条件の生成に用いない不要なノードNと判断して削除する。これにより、削除部309は、メモリ使用量の増加を抑制することができる。
The
次に、分岐命令の実行回数が閾値以上になったことを検出する機能について説明する。分岐命令の実行回数が閾値以上になったことを検出する機能は、追加部310〜出力部312によって実現される。分岐命令の実行回数が閾値以上になったことを検出する具体例については、図12を用いて後述する。
Next, a function for detecting that the number of executions of the branch instruction has exceeded the threshold will be described. The function of detecting that the number of executions of the branch instruction has exceeded the threshold value is realized by the adding
追加部310は、生成されたノードNに、生成されたノードNが示す分岐命令を呼び出した関数の履歴を追加する。関数の履歴とは、対象プログラムTPの実行により呼び出された一連の関数と当該関数の呼び出し順序とを示す情報である。関数の履歴は、例えば、LIFO(Last In First Out)の記憶方式であり、呼び出された関数の履歴が、当該関数の終了に伴って消去されるコールスタックの内容である。また、関数の履歴は、呼び出された関数の履歴が、当該関数の終了に伴って消去されない履歴であってもよい。
The adding
追加部310は、具体的には、例えば、図4の22番地に応じたノードNに、22番地の分岐命令におけるコールスタックを関連付ける。22番地の分岐命令におけるコールスタックは、関数「int abs(int x)」と関数「int funcA(int a)」と関数「int main()」とを含む。これにより、判定部311は、追加部310により追加されたノードNと同一の実行経路において、追加されたノードNと、同一の関数の履歴を示し、かつ、同一の分岐命令を示すノードNが何個あるかを特定することができる。
Specifically, the adding
判定部311は、追加部310によって関数の履歴が追加された追加後のノード列を当該ノード列の末尾ノードから追加後のノード列の逆順に探索することにより、追加後のノード列の末尾ノードNと同一内容の関数の履歴を示すノードNが閾値以上連続して出現するか否かを判定する。ここで、追加後のノード列とは、各々のノードが示す分岐命令が実行された場合のコールスタックの内容を含むノードNの集合であり、コールスタックが追加された最新のノードNまでの実行経路である。追加後のノード列の末尾ノードNとは、コールスタックが追加された最新のノードNである。
The
判定部311は、具体的には、例えば、追加後のノード列の末尾ノードNを始点にし、追加後のノード列の各々のノードNが示す親のノードNのアドレスを参照して、親のノードNに戻る。判定部311は、親のノードNに戻ると、さらに、その親のノードに戻る。このようにして、判定部311は、追加後のノード列をその逆順に探索していくことになる。次に、判定部311は、追加後のノード列を探索する過程において、追加後のノード列の末尾ノードNを始点にして、同一の分岐命令を示し、かつ、同一のコールスタックの内容を示すノードNが何個あるかを計数する。
Specifically, for example, the
そして、判定部311は、計数結果が閾値以上であるか否かを判定する。判定結果は、例えば、RAM203、磁気ディスク205、光ディスク207などの記憶装置300に記憶される。これにより、判定部311は、同一の実行経路上における実行回数が閾値以上である分岐命令を特定することができる。
And the
出力部312は、判定部311によって出現すると判定された場合、追加後のノード列の末尾ノードNが示す分岐命令が閾値以上連続して実行された旨を示す情報を出力する。出力部312は、具体的には、例えば、追加後のノード列の末尾ノードNが示すコールスタックの内容から分岐命令を呼び出した関数と分岐命令の番地とを特定し、特定した関数と番地とを出力する。
When it is determined by the
出力形式としては、例えば、ディスプレイ208への表示、プリンタ213への印刷出力、I/F209による外部装置への送信がある。また、RAM203、磁気ディスク205、光ディスク207などの記憶領域に記憶することとしてもよい。これにより、出力部312は、生成装置100の利用者に、閾値以上連続して実行された分岐命令の対象プログラムTPにおける番地を通知することができる。
Examples of the output format include display on the
そのため、生成装置100の利用者は、通知された番地を参照して、閾値以上連続して実行された分岐命令を特定することができる。そして、生成装置100の利用者は、通知された番地の分岐命令をシンボル変数ではない通常の変数に関する分岐命令に変更したり、シンボル変数の取り得る値の範囲を狭めたりすることができる。ここで、生成装置100の利用者は、番地が通知されているため、当該分岐命令を対象プログラムTPの中から特定する手間を省くことができる。これにより、生成装置100の利用者は、対象プログラムTPのパス条件に不要なパス条件が入らないように対象プログラムTPに変更を加え、対象プログラムTPのパス条件の生成の効率化を図ることができる。
Therefore, the user of the
また、判定部311によって出現すると判定された場合、第2の格納部306は、追加後のノード列の末尾ノードNが示す一連の分岐条件を記憶装置300に格納してもよい。これにより、算出部314は、記憶装置300を参照して、第2の格納部306により格納された対象プログラムTPのパス条件の各々を取得することができる。
Further, when it is determined by the
また、判定部311によって出現すると判定された場合、特定部307は、追加後のノード列を追加後のノード列の末尾ノードNから探索して未実行の分岐条件が最初に出現するノードNを記憶装置300の中から特定してもよい。この場合、特定部307は、具体的には、例えば、追加後のノード列の末尾ノードNを始点にし、当該ノード列の各々のノードNが示す親のノードNのアドレスを参照することにより、追加後のノード列を探索していく。次に、特定部307は、追加後のノード列を探索する過程において、追加後のノード列内のノードNが示す実行済み分岐条件を取得する。そして、特定部307は、取得された分岐条件が1つ以下である場合に、未実行の分岐条件が存在すると判定し、分岐条件を取得したノードNを、未実行の分岐条件が存在するノードNとして特定することになる。
If the
これにより、実行部302は、特定部307により、特定されたノードNが示す分岐命令から、対象プログラムTPの実行を再開することができ、分岐命令の実行回数が閾値以上になった実行経路以外の実行経路を実行することができる。そのため、実行部302は、分岐命令の実行回数が閾値以上になった実行経路の実行を停止し、対象プログラムTPのシンボリック実行にかかる処理量を低減することができる。
As a result, the
また、判定部311によって出現すると判定された場合、実行部302は、対象プログラムTPの実行を停止してもよい。これにより、実行部302は、分岐命令の実行回数が閾値以上になった対象プログラムTPの実行を停止し、対象プログラムTPのシンボリック実行にかかる処理量を低減することができる。
Further, when it is determined by the
次に、テストデータの網羅性を算出する機能について説明する。テストデータの網羅性を算出する機能は、入力部301と、判断部313と、算出部314と、出力部312と、によって実現される。
Next, a function for calculating the completeness of the test data will be described. The function of calculating the completeness of the test data is realized by the
入力部301は、対象プログラムTPの入力になるデータを受け付ける。対象プログラムTPの入力になるデータとは、プログラムの動作確認のために入力されるテストデータである。これにより、入力部301は、算出部314にテストデータの対象プログラムTPに対する網羅性を算出させることができる。
The
判断部313は、対象プログラムTPの入力になるデータが、第2の格納部306によって記憶装置300に格納された一連の分岐条件に該当するか否かを判断する。判断結果は、例えば、RAM203、磁気ディスク205、光ディスク207などの記憶領域に記憶される。これにより、判断部313は、テストデータがパス条件の集合のうち、いくつのパス条件を満たしているかを判断することができる。
The
算出部314は、記憶装置300に記憶された一連の分岐条件の集合において、判断部313によって該当すると判断される一連の分岐条件が占める割合を算出する。算出部314は、パス条件の集合のうちで、テストデータがパス条件を満たしている割合を、テストデータの対象プログラムTPに対する網羅性として算出する。算出結果は、例えば、RAM203、磁気ディスク205、光ディスク207などの記憶領域に記憶される。これにより、出力部312は、算出部314により算出されたテストデータの網羅性を出力することができる。
The
出力部312は、算出部314による算出結果を出力する。出力形式としては、例えば、ディスプレイ208への表示、プリンタ213への印刷出力、I/F209による外部装置への送信がある。また、RAM203、磁気ディスク205、光ディスク207などの記憶領域に記憶することとしてもよい。これにより、出力部312は、生成装置100の利用者に、テストデータの対象プログラムTPに対する網羅性を通知することができる。そして、生成装置100の利用者は、テストデータの対象プログラムTPに対する網羅性から、テストデータを調整することができる。
The
生成装置100の利用者は、例えば、テストデータの対象プログラムTPに対する網羅性が100%に満たない場合、対象プログラムTPの実行経路の各々を100%網羅して動作確認ができるように、テストデータを追加することができる。また、生成装置100の利用者は、テストデータの対象プログラムTPに対する網羅性が100%である場合、テストデータから不要なデータを削除し、対象プログラムTPの動作確認の効率化を図ってもよい。
For example, when the coverage of the target program TP of the test data is less than 100%, the user of the
(パス条件を生成する具体例)
次に、図5〜図11を用いて、図4に示した対象プログラムTPを例に挙げて、パス条件を生成する具体例について説明する。
(Specific example of generating a path condition)
Next, a specific example of generating a path condition will be described using FIGS. 5 to 11 and taking the target program TP shown in FIG. 4 as an example.
図5〜図11は、パス条件を生成する具体例を示す説明図である。図5に示す生成装置100は、対象プログラムTPの実行中において、シンボル変数に関する分岐命令を実行するごとに、当該分岐命令に対応するノードNを生成する。ノードNには、例えば、分岐命令に応じたプログラムカウンタ、分岐命令に到達した場合のコールスタック、分岐命令に到達した場合の変数の値、分岐命令までの実行経路上において実行された一連の分岐条件、分岐命令において実行された分岐条件、および実行カウンタが含まれる。実行カウンタは、同一の分岐命令が、同一の関数から連続して呼び出された回数を、分岐命令の実行回数として保持する。
5 to 11 are explanatory diagrams illustrating specific examples of generating the path condition. The
実行カウンタには、ノードN22とノードN22の親になるノードN21とが示すスタックとプログラムカウンタが一致する場合、ノードN21が示す回数に1を加算した加算後の回数が採用される。また、実行カウンタには、ノードN22とノードN22の親になるノードN21とが示すスタックまたはプログラムカウンタのいずれかが一致しない場合、1が採用される。 When the stack indicated by the node N22 and the node N21 that is the parent of the node N22 matches the program counter, the number of times after addition obtained by adding 1 to the number indicated by the node N21 is adopted as the execution counter. The execution counter is 1 when either the stack or the program counter indicated by the node N22 and the node N21 that is the parent of the node N22 does not match.
そして、生成装置100は、実行カウンタが閾値以上になった場合、分岐命令の実行回数が閾値以上であると判断し、分岐命令の実行回数が閾値以上である旨を示す情報を出力する。これにより、生成装置100は、生成装置100の利用者に、閾値以上連続して実行された分岐命令の対象プログラムTPにおける番地を通知することができる。
Then, when the execution counter reaches or exceeds the threshold, the
図5において、(21)まず、生成装置100は、対象プログラムTPの1番地〜8番地が示す関数「int main()」の実行を開始する。ここで、生成装置100は、コールスタックに、実行された関数「int main()」を格納する。そのため、コールスタックは、関数「int main()」が格納された状態になる。
In FIG. 5, (21) First, the generating
そして、生成装置100は、関数「int main()」を1番地から実行し、5番地に到達する。生成装置100は、5番地において、9番地〜14番地が示す関数「int funcA(int a)」を呼び出す。ここで、生成装置100は、コールスタックに、呼び出した関数「int funcA(int a)」を格納する。コールスタックへの格納方法は、「後入れ先出し」である。そのため、コールスタックは、先頭から順に、関数「int funcA(int a)」、関数「int main()」が格納された状態になる。
Then, the
(22)次に、生成装置100は、呼び出された関数「int funcA(int a)」の9番地から実行を開始し、11番地に到達する。生成装置100は、11番地において、21番地〜24番地が示す関数「int abs(int x)」を呼び出す。ここで、生成装置100は、コールスタックに、呼び出した関数「int abs(int x)」を格納する。そのため、コールスタックは、先頭から順に、関数「int abs(int x)」、関数「int funcA(int a)」、および関数「int main()」が格納された状態になる。
(22) Next, the
(23)そして、生成装置100は、呼び出された関数「int abs(int x)」の21番地から実行を開始し、22番地に到達する。(24)生成装置100は、22番地において、シンボル変数「a」に関する分岐命令「if(x<0)」が真になる未実行の分岐条件「x<0」を実行すると、当該分岐命令に対応するノードN11を生成する。
(23) Then, the
ノードN11は、当該分岐命令の番地を示すプログラムカウンタ「22」、当該分岐命令に到達した場合の変数の値「x=*」、22番地までに実行された一連の分岐条件「True」、および、当該分岐命令が真になる分岐条件を実行したことを示す「真」を含む。また、ノードN11は、当該分岐命令の実行回数を示す実行カウンタ「1」、および、当該分岐命令に到達するまでに呼び出された関数の履歴を示すスタック(stack)1を含む。
The node N11 includes a program counter “22” indicating the address of the branch instruction, a variable value “x = *” when the branch instruction is reached, a series of branch conditions “True” executed up to the
スタック1は、当該分岐命令に到達した場合のコールスタックの内容である。スタック1は、例えば、関数「int abs(int x)」と、関数「int funcA(int a)」と、関数「int main()」と、を含む。
(25)次に、生成装置100は、対象プログラムTPを23番地から再開し、24番地に到達する。生成装置100は、24番地において、関数「int abs(int x)」が終了したことを検出する。そして、生成装置100は、関数「int abs(int x)」が終了すると、呼び出し元の関数「int funcA(int a)」に戻る。ここで、生成装置100は、コールスタックの先頭に格納された関数「int abs(int x)」を削除する。そのため、コールスタックは、先頭から順に、関数「int funcA(int a)」、関数「int main()」が格納された状態になる。
(25) Next, the generating
(26)次に、生成装置100は、呼び出し元の関数「int funcA(int a)」に戻ると、11番地から実行を開始し、14番地に到達する。生成装置100は、14番地において、関数「int funcA(int a)」が終了したことを検出する。そして、生成装置100は、関数「int funcA(int a)」が終了すると、呼び出し元の関数「int main()」に戻る。ここで、生成装置100は、コールスタックの先頭に格納された関数「int funcA(int a)」を削除する。そのため、コールスタックは、関数「int main()」が格納された状態になる。
(26) Next, when the generating
(27)次に、生成装置100は、呼び出し元の関数「int main()」に戻ると、6番地から実行を開始する。生成装置100は、6番地において、15番地〜20番地が示す関数「int funcB(int b)」を呼び出す。ここで、生成装置100は、コールスタックに、呼び出した関数「int funcB(int b)」を格納する。そのため、コールスタックは、先頭から順に、関数「int funcB(int b)」、および関数「int main()」が格納された状態になる。
(27) Next, when the generating
(28)そして、生成装置100は、呼び出された関数「int funcB(int b)」の15番地から実行を開始し、17番地に到達する。(29)生成装置100は、17番地において、シンボル変数「b」に関する分岐命令「if(b<10)」が真になる未実行の分岐条件「b<10」を実行すると、当該分岐命令に対応するノードN12を生成する。
(28) Then, the
ノードN12は、当該分岐命令の番地を示すプログラムカウンタ「17」、当該分岐命令に到達した場合の変数の値「b=*,n=*」、17番地までに実行された一連の分岐条件「a<0」、および、当該分岐命令が真になる分岐条件を実行したことを示す「真」を含む。また、ノードN12は、実行カウンタ「1」、および、当該分岐命令に到達するまでに呼び出された関数の履歴を示すスタック2を含む。
The node N12 has a program counter “17” indicating the address of the branch instruction, variable values “b = *, n = *” when the branch instruction is reached, and a series of branch conditions “ a <0 ”and“ true ”indicating that the branch condition that makes the branch instruction true is executed. Further, the node N12 includes an execution counter “1” and a
17番地までに実行された一連の分岐条件「a<0」は、ノードN11が示す一連の分岐条件「True」と、実行された分岐条件が「真」であることと、を参照して生成される。スタック2は、当該分岐命令に到達した場合のコールスタックの内容である。スタック2は、例えば、関数「int funcB(int b)」と、関数「int main()」と、を含む。次に、生成装置100は、図6の(30)に移行する。
A series of branch conditions “a <0” executed up to address 17 are generated with reference to a series of branch conditions “True” indicated by node N11 and the executed branch condition is “true”. Is done. The
図6において、(30)生成装置100は、対象プログラムTPを18番地から再開し、20番地に到達する。生成装置100は、20番地において、関数「int funcB(int b)」が終了したことを検出する。そして、生成装置100は、関数「int funcB(int b)」が終了すると、呼び出し元の関数「int main()」に戻る。ここで、生成装置100は、コールスタックの先頭に格納された関数「int funcB(int b)」を削除する。そのため、コールスタックは、関数「int main()」が格納された状態になる。
In FIG. 6, (30) the
(31)次に、生成装置100は、呼び出し元の関数「int main()」に戻ると、7番地から実行を開始し、8番地に到達する。(32)そして、生成装置100は、対象プログラムTPの8番地において、対象プログラムTPの実行の終了を検出すると、対象プログラムTPの実行の終了に対応するノードN13を生成する。
(31) Next, when the
ノードN13は、対象プログラムTPが終了した番地を示すプログラムカウンタ「8」、当該分岐命令に到達した場合の変数の値「a=*,b=*,n=1」、8番地までに実行された一連の分岐条件「(a<0)&&(b<10)」を含む。また、ノードN13は、実行カウンタ「1」、および、当該分岐命令に到達するまでに呼び出された関数の履歴を示すスタック3を含む。
The node N13 is executed by the program counter “8” indicating the address at which the target program TP ends, the variable values “a = *, b = *, n = 1” when the branch instruction is reached, and the eighth address. A series of branch conditions “(a <0) && (b <10)” are included. The node N13 includes an execution counter “1” and a
8番地までに実行された一連の分岐条件「(a<0)&&(b<10)」は、ノードN12が示す一連の分岐条件「a<0」と、実行された分岐条件が「真」であることと、を参照して生成される。スタック3は、対象プログラムTPが終了した場合のコールスタックの内容である。スタック3は、例えば、関数「int main()」を含む。ここで、生成装置100は、生成したノードN13が示す一連の分岐条件「(a<0)&&(b<10)」をパス条件PC11として保持しておく。次に、生成装置100は、図7の(33)に移行する。
A series of branch conditions “(a <0) && (b <10)” executed up to the 8th address are a series of branch conditions “a <0” indicated by the node N12, and the executed branch condition is “true”. It is generated with reference to. The
図7において、(33)生成装置100は、対象プログラムTPが終了すると、ノードN13の親になるノードN12が示す分岐命令の番地「17」まで戻る。(34)生成装置100は、ノードN12が示す分岐命令の番地「17」に戻ると、他のパス条件の生成に用いない不要なノードN13を削除する。
In FIG. 7, (33) when the target program TP ends, the generating
(35)次に、生成装置100は、番地「17」の分岐命令に、未実行の分岐条件があるか否かを判定する。(36)ここで、生成装置100は、ノードN12に分岐命令が偽になる分岐条件を実行したことを示す「偽」が含まれていないため、未実行の分岐条件があると判断する。そのため、生成装置100は、シンボル変数「b」に関する分岐命令「if(b<10)」が偽になる未実行の分岐条件「b≧10」を実行して、対象プログラムTPを18番地から再開する。ここで、生成装置100は、分岐命令が偽になる分岐条件を実行したことを示す「偽」を、ノードN12に追加する。
(35) Next, the generating
次に、生成装置100は、20番地まで到達する。生成装置100は、20番地において、関数「int funcB(int b)」が終了したことを検出する。そして、生成装置100は、関数「int funcB(int b)」が終了すると、呼び出し元の関数「int main()」に戻る。ここで、生成装置100は、コールスタックの先頭に格納された関数「int funcB(int b)」を削除する。そのため、コールスタックは、関数「int main()」が格納された状態になる。
Next, the generating
(37)次に、生成装置100は、呼び出し元の関数「int main()」に戻ると、7番地から実行を開始し、8番地に到達する。(38)そして、生成装置100は、対象プログラムTPの8番地において、対象プログラムTPの実行の終了を検出すると、対象プログラムTPの実行の終了に対応するノードN14を生成する。
(37) Next, when the
ノードN14は、対象プログラムTPが終了した番地を示すプログラムカウンタ「8」、当該分岐命令に到達した場合の変数の値「a=*,b=*,n=0」、8番地までに実行された一連の分岐条件「(a<0)&&!(b<10)」を含む。また、ノードN14は、実行カウンタ「1」、および、当該分岐命令に到達するまでに呼び出された関数の履歴を示すスタック3を含む。
The node N14 is executed by the program counter “8” indicating the address at which the target program TP ends, the variable values “a = *, b = *, n = 0” when the branch instruction is reached, and the eight addresses. A series of branch conditions “(a <0) &&! (B <10)” are included. The node N14 includes an execution counter “1” and a
8番地までに実行された一連の分岐条件「(a<0)&&(b<10)」は、ノードN12が示す一連の分岐条件「a<0」と、実行された分岐条件が「偽」であることと、を参照して生成される。ここで、生成装置100は、生成したノードN14が示す一連の分岐条件「(a<0)&&!(b<10)」をパス条件PC12として保持しておく。次に、生成装置100は、図8の(39)に移行する。
A series of branch conditions “(a <0) && (b <10)” executed up to the 8th address is a series of branch conditions “a <0” indicated by the node N12, and the executed branch condition is “false”. It is generated with reference to. Here, the
図8において、(39)生成装置100は、対象プログラムTPが終了すると、ノードN14の親になるノードN12が示す分岐命令の番地「17」まで戻る。(40)生成装置100は、ノードN12が示す分岐命令の番地「17」に戻ると、他のパス条件の生成に用いない不要なノードN14を削除する。
8, (39) when the target program TP ends, the generating
(41)そして、生成装置100は、番地「17」の分岐命令に、未実行の分岐条件があるか否かを判定する。(42)ここで、生成装置100は、ノードN12に「真」と「偽」が含まれているため、未実行の分岐条件がないと判断する。そのため、生成装置100は、さらに、ノードN12の親になるノードN11が示す分岐命令の番地「22」まで戻る。(43)生成装置100は、ノードN11が示す分岐命令の番地「22」に戻ると、他のパス条件の生成に用いない不要なノードN12を削除する。次に、生成装置100は、図9の(44)に移行する。
(41) Then, the
図9において、(44)生成装置100は、番地「22」の分岐命令に、未実行の分岐条件があるか否かを判定する。(45)ここで、生成装置100は、ノードN11に分岐命令が偽になる分岐条件を実行したことを示す「偽」が含まれていないため、未実行の分岐条件があると判断する。そのため、生成装置100は、シンボル変数「a」に関する分岐命令「if(x<0)」が偽になる未実行の分岐条件「x≧0」を実行して、対象プログラムTPを23番地から再開する。
In FIG. 9, (44) the
生成装置100は、24番地に到達する。生成装置100は、24番地において、関数「int abs(int x)」が終了したことを検出する。そして、生成装置100は、関数「int abs(int x)」が終了すると、呼び出し元の関数「int funcA(int a)」に戻る。ここで、生成装置100は、コールスタックの先頭に格納された関数「int abs(int x)」を削除する。そのため、コールスタックは、先頭から順に、関数「int funcA(int a)」、関数「int main()」が格納された状態になる。
The
(46)次に、生成装置100は、呼び出し元の関数「int funcA(int a)」に戻ると、11番地から実行を開始し、14番地に到達する。生成装置100は、14番地において、関数「int funcA(int a)」が終了したことを検出する。そして、生成装置100は、関数「int funcA(int a)」が終了すると、呼び出し元の関数「int main()」に戻る。ここで、生成装置100は、コールスタックの先頭に格納された関数「int funcA(int a)」を削除する。そのため、コールスタックは、関数「int main()」が格納された状態になる。
(46) Next, when returning to the caller function “int funcA (int a)”, the
(47)次に、生成装置100は、呼び出し元の関数「int main()」に戻ると、6番地から実行を開始する。生成装置100は、6番地において、15番地〜20番地が示す関数「int funcB(int b)」を呼び出す。ここで、生成装置100は、コールスタックに、呼び出した関数「int funcB(int b)」を格納する。そのため、コールスタックは、先頭から順に、関数「int funcB(int b)」、および関数「int main()」が格納された状態になる。
(47) Next, when returning to the caller function “int main ()”, the generating
(48)そして、生成装置100は、呼び出された関数「int funcB(int b)」の15番地から実行を開始し、17番地に到達する。(49)生成装置100は、17番地において、シンボル変数「b」に関する分岐命令「if(b<10)」が真になる未実行の分岐条件「b<10」を実行すると、当該分岐命令に対応するノードN15を生成する。
(48) Then, the
ノードN15は、当該分岐命令の番地を示すプログラムカウンタ「17」、当該分岐命令に到達した場合の変数の値「b=*,n=0」、17番地までに実行された一連の分岐条件「!(a<0)」、および、当該分岐命令が真になる分岐条件を実行したことを示す「真」を含む。また、ノードN15は、実行カウンタ「1」、および、当該分岐命令に到達するまでに呼び出された関数の履歴を示すスタック2を含む。
The node N15 has a program counter “17” indicating the address of the branch instruction, variable values “b = *, n = 0” when the branch instruction is reached, and a series of branch conditions “ (A <0) ”and“ true ”indicating that the branch condition for which the branch instruction is true has been executed. Further, the node N15 includes an execution counter “1” and a
17番地までに実行された一連の分岐条件「!(a<0)&&(b<10)」は、ノードN11が示す一連の分岐条件「True」と、実行された分岐条件が「偽」であることと、を参照して生成される。スタック2は、当該分岐命令に到達した場合のコールスタックの内容である。スタック2は、例えば、関数「int funcB(int b)」と、関数「int main()」と、を含む。次に、生成装置100は、図10の(50)に移行する。
A series of branch conditions “! (A <0) && (b <10)” executed up to the 17th address are a series of branch conditions “True” indicated by the node N11 and the executed branch condition is “false”. It is generated with reference to what. The
図10において、(50)生成装置100は、対象プログラムTPを18番地から再開し、20番地に到達する。生成装置100は、20番地において、関数「int funcB(int b)」が終了したことを検出する。そして、生成装置100は、関数「int funcB(int b)」が終了すると、呼び出し元の関数「int main()」に戻る。ここで、生成装置100は、コールスタックの先頭に格納された関数「int funcB(int b)」を削除する。そのため、コールスタックは、関数「int main()」が格納された状態になる。
In FIG. 10, (50) the
(51)次に、生成装置100は、呼び出し元の関数「int main()」に戻ると、7番地から実行を開始し、8番地に到達する。(52)そして、生成装置100は、対象プログラムTPの8番地において、対象プログラムTPの実行の終了を検出すると、対象プログラムTPの実行の終了に対応するノードN16を生成する。
(51) Next, when returning to the caller function “int main ()”, the
ノードN16は、対象プログラムTPが終了した番地を示すプログラムカウンタ「8」、当該分岐命令に到達した場合の変数の値「a=*,b=*,n=1」、8番地までに実行された一連の分岐条件「!(a<0)&&(b<10)」、および、当該分岐命令が真になる分岐条件を実行したことを示す「真」を含む。また、ノードN16は、実行カウンタ「1」、および、当該分岐命令に到達するまでに呼び出された関数の履歴を示すスタック3を含む。
The node N16 is executed by the program counter “8” indicating the address at which the target program TP ends, the variable values “a = *, b = *, n = 1” when the branch instruction is reached, and the eighth address. And a series of branch conditions “! (A <0) && (b <10)” and “true” indicating that the branch condition for which the branch instruction is true has been executed. The node N16 includes an execution counter “1” and a
8番地までに実行された一連の分岐条件「!(a<0)&&(b<10)」は、ノードN15が示す一連の分岐条件「!(a<0)」と、実行された分岐条件が「真」であることと、を参照して生成される。スタック3は、対象プログラムTPが終了した場合のコールスタックの内容である。スタック3は、例えば、関数「int main()」を含む。ここで、生成装置100は、生成したノードN16が示す一連の分岐条件「!(a<0)&&(b<10)」をパス条件PC13として保持しておく。次に、生成装置100は、図11の(53)に移行する。
A series of branch conditions “! (A <0) && (b <10)” executed up to address 8 are a series of branch conditions “! (A <0)” indicated by the node N15 and executed branch conditions. Is generated with reference to “true”. The
図11において、(53)生成装置100は、対象プログラムTPが終了すると、ノードN16の親になるノードN15が示す分岐命令の番地「17」まで戻る。(54)生成装置100は、ノードN15が示す分岐命令の番地「17」に戻ると、他のパス条件の生成に用いない不要なノードN16を削除する。
In FIG. 11, (53) when the target program TP ends, the generating
(55)次に、生成装置100は、番地「17」の分岐命令に、未実行の分岐条件があるか否かを判定する。(56)ここで、生成装置100は、ノードN15に分岐命令が偽になる分岐条件を実行したことを示す「偽」が含まれていないため、未実行の分岐条件があると判断する。そのため、生成装置100は、シンボル変数「b」に関する分岐命令「if(b<10)」が偽になる未実行の分岐条件「b≧10」を実行して、対象プログラムTPを18番地から再開する。ここで、生成装置100は、分岐命令が偽になる分岐条件を実行したことを示す「偽」を、ノードN15に追加する。
(55) Next, the
次に、生成装置100は、20番地まで到達する。生成装置100は、20番地において、関数「int funcB(int b)」が終了したことを検出する。そして、生成装置100は、関数「int funcB(int b)」が終了すると、呼び出し元の関数「int main()」に戻る。ここで、生成装置100は、コールスタックの先頭に格納された関数「int funcB(int b)」を削除する。そのため、コールスタックは、関数「int main()」が格納された状態になる。
Next, the generating
(57)次に、生成装置100は、呼び出し元の関数「int main()」に戻ると、7番地から実行を開始し、8番地に到達する。(58)そして、生成装置100は、対象プログラムTPの8番地において、対象プログラムTPの実行の終了を検出すると、対象プログラムTPの実行の終了に対応するノードN17を生成する。
(57) Next, when returning to the caller function “int main ()”, the
ノードN17は、対象プログラムTPが終了した番地を示すプログラムカウンタ「8」、当該分岐命令に到達した場合の変数の値「a=*,b=*,n=0」、8番地までに実行された一連の分岐条件「!(a<0)&&!(b<10)」、および、当該分岐命令が真になる分岐条件を実行したことを示す「真」を含む。また、ノードN17は、実行カウンタ「1」、および、当該分岐命令に到達するまでに呼び出された関数の履歴を示すスタック3を含む。
The node N17 is executed by the program counter “8” indicating the address at which the target program TP ends, the variable values “a = *, b = *, n = 0” when the branch instruction is reached, and the eighth address. And a series of branch conditions “! (A <0) &&! (B <10)” and “true” indicating that a branch condition for which the branch instruction is true has been executed. The node N17 includes an execution counter “1” and a
8番地までに実行された一連の分岐条件「!(a<0)&&!(b<10)」は、ノードN15が示す一連の分岐条件「!(a<0)」と、実行された分岐条件が「偽」であることと、を参照して生成される。ここで、生成装置100は、生成したノードN17が示す分岐条件「!(a<0)&&!(b<10)」をパス条件PC14として保持しておく。
A series of branch conditions “! (A <0) &&! (B <10)” executed up to address 8 are a series of branch conditions “! (A <0)” indicated by the node N15 and executed branches. The condition is generated with reference to “false”. Here, the
これにより、生成装置100は、記憶領域の使用量増加を抑制した上で、対象プログラムTPの各々の実行経路に対応するパス条件PC11〜PC14を生成することができる。例えば、2分木のノードNのすべてを保持する場合の記憶領域の使用量に比べて、記憶領域の使用量をn/(2^n−1)に減少させることができる。nは2分木の分岐の数を示す。^は累乗を示す。
Thereby, the
また、生成装置100は、生成されたパス条件PC11〜PC14から、対象プログラムTPの動作確認のためのテストデータの対象プログラムTPに対する網羅性を算出し、算出結果を出力してもよい。網羅性とは、テストデータが、対象プログラムTPについて実行可能な実行経路をどの程度網羅しているかを示す割合である。
The
これにより、生成装置100の利用者は、テストデータの対象プログラムTPに対する網羅性が100%に満たない場合、対象プログラムTPの実行経路の各々を100%網羅して動作確認ができるように、テストデータを追加することができる。また、生成装置100の利用者は、テストデータの対象プログラムTPに対する網羅性が100%である場合、テストデータから不要なデータを削除し、対象プログラムTPの動作確認の効率化を図ってもよい。
As a result, when the user of the
(実行回数が閾値以上になったことを検出する具体例)
次に、図12を用いて、実行回数が閾値以上になったことを検出する具体例について説明する。
(Specific example of detecting that the number of executions has exceeded the threshold)
Next, a specific example of detecting that the number of executions is equal to or greater than a threshold will be described with reference to FIG.
図12は、実行回数が閾値以上になったことを検出する具体例を示す説明図である。閾値は、例えば、予め、生成装置100の利用者によって設定されている。図12の例では、閾値は「8」とする。図12において、(61)まず、生成装置100は、対象プログラムTPの1番地〜8番地が示す関数「int main()」の実行を開始する。ここで、生成装置100は、コールスタックに、実行された関数「int main()」を格納する。そのため、コールスタックは、関数「int main()」が格納された状態になる。
FIG. 12 is an explanatory diagram illustrating a specific example of detecting that the number of executions is equal to or greater than a threshold value. The threshold is set in advance by the user of the
そして、生成装置100は、関数「int main()」を1番地から実行し、4番地に到達する。生成装置100は、4番地において、6番地〜13番地が示す関数「int CountBit(x)」を呼び出す。ここで、生成装置100は、コールスタックに、呼び出した関数「int CountBit(x)」を格納する。そのため、コールスタックは、先頭から順に、関数「int CountBit(x)」、関数「int main()」が格納された状態になる。
Then, the
(62)次に、生成装置100は、呼び出された関数「int CountBit(x)」の6番地から実行を開始し、8番地においてfor文のループの条件が真であるため、for文の中の命令を実行し、9番地に到達する。
(62) Next, the
(63)生成装置100は、9番地において、シンボル変数「x」に関する分岐命令「if(((x>>1)&1)!=0)」が真になる分岐条件「(x>>1)&1)!=0」を実行すると、当該分岐命令に対応するノードN21を生成する。ノードN21は、当該分岐命令の番地を示すプログラムカウンタ「9」、当該分岐命令に到達した場合の変数の値「x=*」、9番地までに実行された一連の分岐条件「True」、当該分岐命令が真になる分岐条件を実行したことを示す「真」を含む。また、ノードN21は、当該分岐命令に到達するまでに呼び出された関数の履歴を示すスタック1、当該分岐命令が呼び出された回数を示す実行カウンタ「1」を含む。スタック1は、呼び出された関数の履歴であり、関数「int CountBit(x)」と、関数「int main()」と、を含む。
(63) The
(64)次に、生成装置100は、対象プログラムTPを10番地から再開し、11番地に到達する。生成装置100は、11番地において、for文が終了したため、8番地に戻る。(65)次に、生成装置100は、8番地においてfor文のループの条件が真であるため、for文の中の命令を実行し、9番地に到達する。(66)生成装置100は、9番地において、シンボル変数「x」に関する分岐命令「if(((x>>2)&1)!=0)」が真になる分岐条件「((x>>2)&1)!=0)」を実行すると、当該分岐命令に対応するノードN22を生成する。
(64) Next, the generating
ノードN22は、当該分岐命令の番地を示すプログラムカウンタ「9」、当該分岐命令に到達した場合の変数の値「x=*」、9番地までに実行された一連の分岐条件「(x>>1)&1)!=0」、当該分岐命令が真になる分岐条件を実行したことを示す「真」を含む。また、ノードN22は、当該分岐命令に到達するまでに呼び出された関数の履歴を示すスタック1、当該分岐命令が呼び出された回数を示す実行カウンタ「2」を含む。9番地までに実行された一連の分岐条件「(x>>1)&1)!=0」は、ノードN21が示す一連の分岐条件「True」と、実行された分岐条件が「真」であることと、を参照して生成される。
The node N22 has a program counter “9” indicating the address of the branch instruction, a variable value “x = *” when the branch instruction is reached, and a series of branch conditions “(x >>) executed up to the ninth address. 1) & 1)! = 0 ”, including“ true ”indicating that the branch condition for which the branch instruction is true has been executed. The node N22 includes a
実行カウンタには、ノードN22とノードN22の親になるノードN21とが示すスタックとプログラムカウンタが一致する場合、ノードN21が示す回数に1を加算した加算後の回数が採用される。また、実行カウンタには、ノードN22とノードN22の親になるノードN21とが示すスタックまたはプログラムカウンタのいずれかが一致しない場合、1が採用される。そのため、ノードN22が示す実行カウンタは、ノードN21が示す実行カウンタに1を加算した加算後の回数「2」になっている。 When the stack indicated by the node N22 and the node N21 that is the parent of the node N22 matches the program counter, the number of times after addition obtained by adding 1 to the number indicated by the node N21 is adopted as the execution counter. The execution counter is 1 when either the stack or the program counter indicated by the node N22 and the node N21 that is the parent of the node N22 does not match. Therefore, the execution counter indicated by the node N22 is “2” after the addition of adding 1 to the execution counter indicated by the node N21.
以降において、生成装置100は、(64)〜(66)と同様にして、9番地の分岐命令を実行するごとに、ノードNを生成する。ここで、生成装置100は、7回目の分岐命令を実行し、ノードNを生成したとする。
Thereafter, the
(67)生成装置100は、対象プログラムTPを10番地から再開し、11番地に到達する。生成装置100は、11番地において、for文が終了したため、8番地に戻る。(68)次に、生成装置100は、8番地においてfor文のループの条件が真であるため、for文の中の命令を実行し、9番地に到達する。(69)生成装置100は、9番地において、シンボル変数「x」に関する分岐命令「if(((x>>8)&1)!=0)」が真になる分岐条件「((x>>8)&1)!=0)」を実行すると、当該分岐命令に対応するノードN28を生成する。
(67) The
ノードN28は、当該分岐命令の番地を示すプログラムカウンタ「9」、当該分岐命令に到達した場合の変数の値「x=*」、9番地までに実行された一連の分岐条件「((x>>1)&1)!=0)&&((x>>2)&1)!=0)&&・・・&&((x>>7)&1)!=0)」、当該分岐命令が真になる分岐条件を実行したことを示す「真」を含む。また、ノードN28は、当該分岐命令に到達するまでに呼び出された関数の履歴を示すスタック1と、実行カウンタ「8」を含む。
The node N28 has a program counter “9” indicating the address of the branch instruction, a variable value “x = *” when the branch instruction is reached, and a series of branch conditions “((x> > 1) & 1)! = 0) && ((x >> 2) & 1)! = 0) && ... && ((x >> 7) & 1)! = 0) ", the branch instruction becomes true Contains "true" indicating that the branch condition has been executed. Further, the node N28 includes a
9番地までに実行された一連の分岐条件「((x>>1)&1)!=0)&&((x>>2)&1)!=0)&&・・・&&((x>>7)&1)!=0)」は、ノード28の親になるノードN27(不図示)が示す一連の分岐条件と、実行された分岐条件が真であることと、を参照して生成される。また、ノードN28が示す実行カウンタは、ノードN27(不図示)が示す実行カウンタに1を加算した加算後の回数「8」になっている。
A series of branch conditions executed up to address 9 "((x >> 1) & 1)! = 0) && ((x >> 2) & 1)! = 0) && ... && ((x >> 7 ) & 1)! = 0) ”is generated with reference to a series of branch conditions indicated by the node N27 (not shown) that is the parent of the
(70)ここで、生成装置100は、実行カウンタ「8」が閾値以上であるため、9番地の分岐命令の実行回数が閾値以上になったと判断する。そして、生成装置100は、9番地の分岐命令の実行回数が閾値以上である旨を示す情報を出力する。
(70) Here, since the execution counter “8” is equal to or greater than the threshold, the
これにより、生成装置100は、生成装置100の利用者に、閾値以上連続して実行された分岐命令の対象プログラムTPにおける番地を通知することができる。生成装置100の利用者は、対象プログラムTPに、シンボル変数に関する分岐命令が連続して実行されている部分があると判断できる。例えば、分岐命令が連続して実行されている部分とは、for文の中に分岐命令が含まれる場合である。
Thereby, the
そして、生成装置100の利用者は、通知された番地の分岐命令をシンボル変数ではない通常の変数に関する分岐命令に変更したり、シンボル変数の取り得る値の範囲を狭めたりすることができる。ここで、生成装置100の利用者は、番地が通知されているため、当該分岐命令を対象プログラムTPの中から特定する手間を省くことができる。これにより、生成装置100の利用者は、対象プログラムTPのパス条件に不要なパス条件が入らないように対象プログラムTPに変更を加え、対象プログラムTPのパス条件の生成の効率化を図ることができる。
The user of the
また、生成装置100は、9番地の分岐命令の実行回数が閾値以上である旨を示す情報を出力済みであることを示す警告済み判定フラグを保持していてもよい。そして、生成装置100は、実行カウンタが「8」の場合に実行回数が閾値以上である旨を示す情報を出力した後、警告済み判定フラグを真に設定する。
The
その後、生成装置100は、9番地の分岐命令に関する実行カウンタが「9」の場合でも、警告済み判定フラグが真のため、実行回数が閾値以上である旨を示す情報を出力しない。また、生成装置100は、別の実行経路において、9番地の分岐命令に関する実行カウンタが閾値以上の場合でも、警告済み判定フラグが真のため、実行回数が閾値以上である旨を示す情報を出力しない。
Thereafter, even when the execution counter for the branch instruction at
そのため、生成装置100は、同一の分岐命令について、実行回数が閾値以上である旨を示す情報を1回出力した後、2回目以降は出力しない。これにより、生成装置100の利用者は、出力された数から、直感的に何ヶ所の分岐命令の実行回数が閾値以上であるかを把握することができる。
Therefore, after generating information indicating that the number of executions is equal to or greater than the threshold value for the same branch instruction once, the
(パス条件生成処理)
図13および図14は、パス条件生成処理の詳細な処理手順を示すフローチャートである。まず、生成装置100は、対象プログラムTPと、分岐命令の実行回数の上限を規定する閾値と、の入力があったか否かを判定する(ステップS1301)。ここで、入力がない場合(ステップS1301:No)、生成装置100は、ステップS1301に戻り、入力を待つ。
(Path condition generation process)
13 and 14 are flowcharts showing the detailed processing procedure of the path condition generation processing. First, the generating
一方、入力があった場合(ステップS1301:Yes)、生成装置100は、入力された対象プログラムTPから1命令を読み出す(ステップS1302)。次に、生成装置100は、読み出した命令がシンボル変数に関する命令か否かを判定する(ステップS1303)。ここで、シンボル変数に関する命令である場合(ステップS1303:Yes)、生成装置100は、図14のステップS1401に移行する。
On the other hand, when there is an input (step S1301: Yes), the
一方、シンボル変数に関する命令ではない場合(ステップS1303:No)、生成装置100は、対象プログラムTPの次の命令を読み出し対象に設定する(ステップS1304)。次に、生成装置100は、対象プログラムTPが終了したか否かを判定する(ステップS1305)。ここで、終了していない場合(ステップS1305:No)、生成装置100は、ステップS1302に戻る。
On the other hand, if the instruction is not related to a symbol variable (step S1303: No), the generating
一方、対象プログラムTPが終了した場合(ステップS1305:Yes)、生成装置100は、パス条件を記憶する(ステップS1306)。次に、生成装置100は、親のノードNが存在するか否かを判定する(ステップS1307)。ここで、親のノードNが存在しない場合(ステップS1307:No)、生成装置100は、パス条件生成処理を終了する。
On the other hand, when the target program TP ends (step S1305: Yes), the
一方、親のノードNが存在する場合(ステップS1307:Yes)、生成装置100は、親のノードNまで戻る(ステップS1308)。次に、生成装置100は、偽のパスが実行済みか否かを判定する(ステップS1309)。ここで、偽の実行条件が実行済みである場合(ステップS1309:Yes)、生成装置100は、ステップS1307に戻る。一方、偽の実行条件が実行済みではない場合(ステップS1309:No)、生成装置100は、偽の実行条件を実行し、対象プログラムTPの実行を再開する(ステップS1310)。次に、生成装置100は、ステップS1305に戻る。
On the other hand, when the parent node N exists (step S1307: Yes), the generating
図14において、生成装置100は、親のノードNのコールスタックと一致するか否かを判定する(ステップS1401)。一致しない場合(ステップS1401:No)、生成装置100は、ステップS1403に移行する。一方、一致する場合(ステップS1401:Yes)、生成装置100は、実行カウンタを「0」に設定する(ステップS1402)。次に、生成装置100は、ステップS1403に移行する。
In FIG. 14, the generating
そして、生成装置100は、ノードNにおける実行カウンタをインクリメントする(ステップS1403)。次に、生成装置100は、実行カウンタが閾値以上であるか否かを判定する(ステップS1404)。ここで、実行カウンタが閾値以上ではない場合(ステップS1404:No)、生成装置100は、ステップS1408に移行する。
Then, the
一方、実行カウンタが閾値以上である場合(ステップS1404:Yes)、生成装置100は、警告済み判定フラグが偽か否かを判定する(ステップS1405)。ここで、警告済み判定フラグが偽ではない場合(ステップS1405:No)、生成装置100は、ステップS1408に移行する。
On the other hand, when the execution counter is greater than or equal to the threshold (step S1404: Yes), the generating
一方、警告済み判定フラグが偽である場合(ステップS1405:Yes)、生成装置100は、ノードNが示す分岐命令の実行回数が閾値以上である旨を示す警告を出力する(ステップS1406)。次に、生成装置100は、警告済み判定フラグを真にする(ステップS1407)。
On the other hand, if the warning completion determination flag is false (step S1405: Yes), the
そして、生成装置100は、親のノードNの実行カウンタを、各々の子のノードNの実行カウンタに複製する(ステップS1408)。次に、生成装置100は、子のノードNに、コールスタックと、パス条件と、親のノードNへのリンクを記憶する(ステップS1409)。
The
そして、生成装置100は、真の実行条件を実行し、対象プログラムTPの実行を再開する(ステップS1410)。次に、生成装置100は、図13のステップS1305に移行する。これにより、生成装置100は、記憶領域の使用量増加を抑制しつつ、対象プログラムTPの各々の実行経路に対応するパス条件を生成することができる。
Then, the
以上説明したように、生成装置100は、対象プログラムTPの実行経路上の分岐命令ごとに、分岐命令において実行された分岐条件と、分岐命令までに実行された一連の分岐条件と、を関連付けたノードNを生成していく。次に、生成装置100は、実行経路上の末尾ノードNから、当該実行経路で対象プログラムTPを実行する場合に、対象プログラムTPの入力になるデータが満たすべきパス条件を生成する。そして、生成装置100は、実行経路上の未実行の分岐条件が存在する分岐命令から対象プログラムTPの実行を再開し、他の実行経路についても同様にパス条件を生成する。また、生成装置100は、パス条件の生成に伴って、未実行の分岐条件がなくなったノードNがあれば、当該ノードNを削除する。
As described above, the generating
これにより、生成装置100は、記憶領域の使用量増加を抑制した上で、対象プログラムTPの各々の実行経路に対応するパス条件を生成することができる。例えば、2分木のノードNのすべてを保持する場合の記憶領域の使用量に比べて、記憶領域の使用量をn/(2^n−1)に減少させることができる。
Thereby, the
このように、生成装置100は、記憶領域に保持されるノードNの個数増加を抑制し、ワークエリアになる記憶領域の圧迫を抑制する。したがって、生成装置100は、ワークエリアの圧迫によるプログラムの実行効率の低下を抑制することができる。これにより、生成装置100は、例えば、テストデータの対象プログラムTPに対する網羅性の算出効率の低下を抑制することができる。また、生成装置100は、記憶領域にノードNが保持しきれずに、ワークエリアとして使用可能な領域がなくなることを防止することができ、パス条件の生成が中断することを防止することができる。したがって、利用者は、2分木のメモリ使用量を気にせずにシンボリック実行をおこなうことができる。
As described above, the
また、生成装置100は、分岐命令を実行した場合のコールスタックの内容を、ノードNに関連付けておく。次に、生成装置100は、生成したノードNを始点にして、生成したノードNと同一の実行経路上に、生成したノードNと同一の分岐命令を示し、かつ、同一のコールスタックの内容を示すノードNが閾値以上連続して出現するか否かを判断する。そして、生成装置100は、閾値以上連続して出現する場合、生成したノードNが示す分岐命令が閾値以上連続して実行された旨を示す情報と、当該分岐命令の番地と、を出力する。
The
これにより、生成装置100は、生成装置100の利用者に、同一の実行経路上、かつ、同一のコールスタックの状態において、閾値以上連続して実行された分岐命令の対象プログラムTPにおける番地を通知することができる。生成装置100の利用者は、対象プログラムTPに、シンボル変数に関する分岐命令が連続して実行されている部分があると判断できる。例えば、分岐命令が連続して実行されている部分とは、for文の中に分岐命令が含まれる場合である。
As a result, the
そして、生成装置100の利用者は、通知された番地の分岐命令をシンボル変数ではない通常の変数に関する分岐命令に変更したり、シンボル変数の取り得る値の範囲を狭めたりすることができる。ここで、生成装置100の利用者は、番地が通知されているため、当該分岐命令を対象プログラムTPの中から特定する手間を省くことができる。これにより、生成装置100の利用者は、対象プログラムTPのパス条件に不要なパス条件が入らないように対象プログラムTPに変更を加え、対象プログラムTPのパス条件の生成の効率化を図ることができる。
The user of the
また、これにより、生成装置100は、生成装置100の利用者に、複数の実行経路における同一の分岐命令の実行回数の和が閾値以上になっても、分岐命令が閾値以上連続して実行されたと誤って通知することがない。また、生成装置100は、対象プログラムTPの複数箇所から或る関数が呼び出され、当該関数内の分岐命令の実行回数が閾値以上になっても、分岐命令が閾値以上連続して実行されたと誤って通知することがない。
Accordingly, the
また、生成装置100は、生成されたパス条件の集合から、対象プログラムTPの動作確認のためのテストデータの対象プログラムTPに対する網羅性を算出し、算出結果を出力する。これにより、生成装置100の利用者は、テストデータの対象プログラムTPに対する網羅性が100%に満たない場合、対象プログラムTPの実行経路の各々を100%網羅して動作確認ができるように、テストデータを追加することができる。また、生成装置100の利用者は、テストデータの対象プログラムTPに対する網羅性が100%である場合、テストデータから不要なデータを削除し、対象プログラムTPの動作確認の効率化を図ってもよい。
Further, the
なお、本実施の形態で説明した生成方法は、予め用意されたプログラムをパーソナル・コンピュータやワークステーション等のコンピュータで実行することにより実現することができる。本生成プログラムは、ハードディスク、フレキシブルディスク、CD−ROM、MO、DVD等のコンピュータで読み取り可能な記録媒体に記録され、コンピュータによって記録媒体から読み出されることによって実行される。また本生成プログラムは、インターネット等のネットワークを介して配布してもよい。 Note that the generation method described in this embodiment can be realized by executing a program prepared in advance on a computer such as a personal computer or a workstation. The generation program is recorded on a computer-readable recording medium such as a hard disk, a flexible disk, a CD-ROM, an MO, and a DVD, and is executed by being read from the recording medium by the computer. The generation program may be distributed via a network such as the Internet.
また、本実施の形態で説明した生成装置100は、スタンダードセルやストラクチャードASIC(Application Specific Integrated Circuit)などの特定用途向けIC(以下、単に「ASIC」と称す。)やFPGAなどのPLD(Programmable Logic Device)によっても実現することができる。具体的には、例えば、上述した生成装置100の機能(入力部301〜算出部314)をHDL記述によって機能定義し、そのHDL記述を論理合成してASICやPLDに与えることにより、生成装置100を製造することができる。
In addition, the
上述した実施の形態に関し、さらに以下の付記を開示する。 The following additional notes are disclosed with respect to the embodiment described above.
(付記1)プログラムの実行中に到達した分岐命令において未実行の分岐条件が実行された場合、前記分岐命令と、実行された分岐条件と、前記プログラムの実行開始から前記分岐命令の分岐元の分岐命令までに実行された一連の分岐条件と、を関連付けたノードを生成する第1の生成部と、
前記第1の生成部によって生成されたノードを記憶装置に格納する第1の格納部と、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路上の末尾ノードが示す一連の分岐条件に基づいて、前記プログラムが終了するまでに実行された一連の分岐条件を生成する第2の生成部と、
前記第2の生成部によって生成された一連の分岐条件を前記記憶装置に格納する第2の格納部と、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路を当該実行経路上の末尾ノードから前記実行経路の逆順に探索して未実行の分岐条件が最初に出現するノードを、前記記憶装置の中から特定する特定部と、
前記特定部によって特定されたノードが示す分岐命令から前記プログラムが再開され、未実行の分岐条件が実行された場合、当該分岐条件を前記特定されたノードが示す分岐命令に関連付けることにより、前記特定されたノードを前記記憶装置内において更新する更新部と、
未実行の分岐条件がなくなったノードを前記記憶装置から削除する削除部と、
を有することを特徴とする生成装置。
(Supplementary Note 1) When an unexecuted branch condition is executed in a branch instruction reached during program execution, the branch instruction, the executed branch condition, and the branch source of the branch instruction from the start of execution of the program A first generation unit that generates a node that associates a series of branch conditions executed up to the branch instruction;
A first storage unit that stores the node generated by the first generation unit in a storage device;
When the execution of the program ends, a series of branch conditions that are executed until the program ends are generated based on a series of branch conditions indicated by the end node on the execution path until the program ends. Two generators;
A second storage unit that stores a series of branch conditions generated by the second generation unit in the storage device;
When the execution of the program ends, the execution path until the program ends is searched from the end node on the execution path in the reverse order of the execution path, and the node where the unexecuted branch condition first appears is A specific unit that identifies the storage device;
When the program is restarted from the branch instruction indicated by the node specified by the specifying unit and an unexecuted branch condition is executed, the specification is performed by associating the branch condition with the branch instruction indicated by the specified node. An updating unit for updating the generated node in the storage device;
A deletion unit that deletes a node that has no unexecuted branch condition from the storage device; and
A generation apparatus comprising:
(付記2)前記生成されたノードに、前記生成されたノードが示す分岐命令を呼び出した関数の履歴を追加する追加部と、
前記追加部によって関数の履歴が追加された追加後のノード列を当該追加後のノード列の末尾ノードから前記追加後のノード列の逆順に探索することにより、前記追加後のノード列の末尾ノードと同一の分岐命令を示し、かつ、同一内容の関数の履歴を示すノードが閾値以上連続して出現するか否かを判定する判定部と、
前記判定部によって出現すると判定された場合、前記追加後のノード列の末尾ノードが示す分岐命令が閾値以上連続して実行された旨を示す情報を出力する出力部と、
を有することを特徴とする付記1に記載の生成装置。
(Additional remark 2) The addition part which adds the log | history of the function which called the branch instruction which the said produced | generated node shows to the said produced | generated node,
By searching the node sequence after the addition of which the function history has been added by the adding unit in the reverse order of the node sequence after the addition from the end node of the node sequence after the addition, the end node of the node sequence after the addition A determination unit that determines whether or not a node indicating the same branch instruction and a history of a function history having the same content appears continuously over a threshold value;
An output unit that outputs information indicating that the branch instruction indicated by the end node of the node sequence after the addition is continuously executed for a threshold value or more when determined to appear by the determination unit;
The generating apparatus according to
(付記3)前記第2の格納部は、
前記判定部によって出現すると判定された場合、前記追加後のノード列の末尾ノードが示す一連の分岐条件を前記記憶装置に格納し、
前記特定部は、
前記判定部によって出現すると判定された場合、前記追加後のノード列を前記追加後のノード列の末尾ノードから前記追加後のノード列の逆順に探索して未実行の分岐条件が最初に出現するノードを、前記記憶装置の中から特定することを特徴とする付記2に記載の生成装置。
(Appendix 3) The second storage unit is
If it is determined by the determination unit to appear, a series of branch conditions indicated by the end node of the node sequence after the addition is stored in the storage device,
The specific part is:
When it is determined by the determination unit that the node sequence after the addition is added, the node sequence after the addition is searched in the reverse order of the node sequence after the addition from the end node of the node sequence after the addition, and the unexecuted branch condition appears first. The generation apparatus according to
(付記4)前記判定部によって出現すると判定された場合、前記プログラムの実行を停止する停止部を有することを特徴とする付記2に記載の生成装置。
(Additional remark 4) When it determines with appearing by the said determination part, it has a stop part which stops execution of the said program, The production | generation apparatus of
(付記5)前記プログラムの入力になるデータが、前記第2の格納部によって前記記憶装置に格納された一連の分岐条件に該当するか否かを判断する判断部と、
前記記憶装置に記憶された一連の分岐条件の集合において、前記判断部によって該当すると判断される一連の分岐条件が占める割合を算出する算出部と、
を有することを特徴とする付記1乃至4のいずれか一つに記載の生成装置。
(Additional remark 5) The judgment part which judges whether the data used as the input of the said program correspond to a series of branch conditions stored in the said memory | storage device by the said 2nd storage part,
A calculation unit that calculates a ratio of a series of branch conditions determined to be applicable by the determination unit in the set of branch conditions stored in the storage device;
The generating apparatus according to any one of
(付記6)コンピュータに、
プログラムの実行中に到達した分岐命令において未実行の分岐条件が実行された場合、前記分岐命令と、実行された分岐条件と、前記プログラムの実行開始から前記分岐命令の分岐元の分岐命令までに実行された一連の分岐条件と、を関連付けたノードを生成し、
生成されたノードを記憶装置に格納し、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路上の末尾ノードが示す一連の分岐条件に基づいて、前記プログラムが終了するまでに実行された一連の分岐条件を生成し、
生成された一連の分岐条件を前記記憶装置に格納し、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路を当該実行経路上の末尾ノードから前記実行経路の逆順に探索して未実行の分岐条件が最初に出現するノードを、前記記憶装置の中から特定し、
特定されたノードが示す分岐命令から前記プログラムが再開され、未実行の分岐条件が実行された場合、当該分岐条件を前記特定されたノードが示す分岐命令に関連付けることにより、前記特定されたノードを前記記憶装置内において更新し、
未実行の分岐条件がなくなったノードを前記記憶装置から削除する、
処理を実行させることを特徴とする生成プログラム。
(Appendix 6)
When an unexecuted branch condition is executed in a branch instruction that is reached during execution of the program, the branch instruction, the executed branch condition, and from the start of execution of the program to the branch instruction that is the branch source of the branch instruction Generate a node that associates a series of executed branch conditions with
Store the generated node in the storage device,
When the execution of the program ends, based on a series of branch conditions indicated by the end node on the execution path until the program ends, a series of branch conditions executed until the program ends,
Storing the generated series of branch conditions in the storage device;
When the execution of the program ends, the execution path until the program ends is searched from the end node on the execution path in the reverse order of the execution path, and the node where the unexecuted branch condition first appears is Identify the storage device,
When the program is resumed from the branch instruction indicated by the identified node and an unexecuted branch condition is executed, the identified node is associated with the branch instruction indicated by the identified node. Updating in the storage device;
Deleting a node that has no unexecuted branch condition from the storage device;
A generation program characterized by causing processing to be executed.
(付記7)コンピュータが、
プログラムの実行中に到達した分岐命令において未実行の分岐条件が実行された場合、前記分岐命令と、実行された分岐条件と、前記プログラムの実行開始から前記分岐命令の分岐元の分岐命令までに実行された一連の分岐条件と、を関連付けたノードを生成し、
生成されたノードを記憶装置に格納し、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路上の末尾ノードが示す一連の分岐条件に基づいて、前記プログラムが終了するまでに実行された一連の分岐条件を生成し、
生成された一連の分岐条件を前記記憶装置に格納し、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路を当該実行経路上の末尾ノードから前記実行経路の逆順に探索して未実行の分岐条件が最初に出現するノードを、前記記憶装置の中から特定し、
特定されたノードが示す分岐命令から前記プログラムが再開され、未実行の分岐条件が実行された場合、当該分岐条件を前記特定されたノードが示す分岐命令に関連付けることにより、前記特定されたノードを前記記憶装置内において更新し、
未実行の分岐条件がなくなったノードを前記記憶装置から削除する、
処理を実行することを特徴とする生成方法。
(Appendix 7) The computer
When an unexecuted branch condition is executed in a branch instruction that is reached during execution of the program, the branch instruction, the executed branch condition, and from the start of execution of the program to the branch instruction that is the branch source of the branch instruction Generate a node that associates a series of executed branch conditions with
Store the generated node in the storage device,
When the execution of the program ends, based on a series of branch conditions indicated by the end node on the execution path until the program ends, a series of branch conditions executed until the program ends,
Storing the generated series of branch conditions in the storage device;
When the execution of the program ends, the execution path until the program ends is searched from the end node on the execution path in the reverse order of the execution path, and the node where the unexecuted branch condition first appears is Identify the storage device,
When the program is resumed from the branch instruction indicated by the identified node and an unexecuted branch condition is executed, the identified node is associated with the branch instruction indicated by the identified node. Updating in the storage device;
Deleting a node that has no unexecuted branch condition from the storage device;
A generation method characterized by executing processing.
100 生成装置
TP 対象プログラム
N,N1〜N5,N11〜N17,N21,N22,N28 ノード
301 入力部
302 実行部
303 第1の生成部
304 第1の格納部
305 第2の生成部
306 第2の格納部
307 特定部
308 更新部
309 削除部
310 追加部
311 判定部
312 出力部
313 判断部
314 算出部
100 generator TP target program N, N1 to N5, N11 to N17, N21, N22,
Claims (6)
前記第1の生成部によって生成されたノードを記憶装置に格納する第1の格納部と、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路上の末尾ノードが示す一連の分岐条件に基づいて、前記プログラムが終了するまでに実行された一連の分岐条件を生成する第2の生成部と、
前記第2の生成部によって生成された一連の分岐条件を前記記憶装置に格納する第2の格納部と、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路を当該実行経路上の末尾ノードから前記実行経路の逆順に探索して未実行の分岐条件が最初に出現するノードを、前記記憶装置の中から特定する特定部と、
前記特定部によって特定されたノードが示す分岐命令から前記プログラムが再開され、未実行の分岐条件が実行された場合、当該分岐条件を前記特定されたノードが示す分岐命令に関連付けることにより、前記特定されたノードを前記記憶装置内において更新する更新部と、
未実行の分岐条件がなくなったノードを前記記憶装置から削除する削除部と、
を有することを特徴とする生成装置。 When an unexecuted branch condition is executed in a branch instruction that is reached during execution of the program, the branch instruction, the executed branch condition, and from the start of execution of the program to the branch instruction that is the branch source of the branch instruction A first generation unit that generates a node that associates a series of executed branch conditions with each other;
A first storage unit that stores the node generated by the first generation unit in a storage device;
When the execution of the program ends, a series of branch conditions that are executed until the program ends are generated based on a series of branch conditions indicated by the end node on the execution path until the program ends. Two generators;
A second storage unit that stores a series of branch conditions generated by the second generation unit in the storage device;
When the execution of the program ends, the execution path until the program ends is searched from the end node on the execution path in the reverse order of the execution path, and the node where the unexecuted branch condition first appears is A specific unit that identifies the storage device;
When the program is restarted from the branch instruction indicated by the node specified by the specifying unit and an unexecuted branch condition is executed, the specification is performed by associating the branch condition with the branch instruction indicated by the specified node. An updating unit for updating the generated node in the storage device;
A deletion unit that deletes a node that has no unexecuted branch condition from the storage device; and
A generation apparatus comprising:
前記追加部によって関数の履歴が追加された追加後のノード列を当該追加後のノード列の末尾ノードから前記追加後のノード列の逆順に探索することにより、前記追加後のノード列の末尾ノードと同一の分岐命令を示し、かつ、同一内容の関数の履歴を示すノードが閾値以上連続して出現するか否かを判定する判定部と、
前記判定部によって出現すると判定された場合、前記追加後のノード列の末尾ノードが示す分岐命令が閾値以上連続して実行された旨を示す情報を出力する出力部と、
を有することを特徴とする請求項1に記載の生成装置。 An adding unit that adds a history of a function that called a branch instruction indicated by the generated node to the generated node;
By searching the node sequence after the addition of which the function history has been added by the adding unit in the reverse order of the node sequence after the addition from the end node of the node sequence after the addition, the end node of the node sequence after the addition A determination unit that determines whether or not a node indicating the same branch instruction and a history of a function history having the same content appears continuously over a threshold value;
An output unit that outputs information indicating that the branch instruction indicated by the end node of the node sequence after the addition is continuously executed for a threshold value or more when determined to appear by the determination unit;
The generating apparatus according to claim 1, wherein:
前記判定部によって出現すると判定された場合、前記追加後のノード列の末尾ノードが示す一連の分岐条件を前記記憶装置に格納し、
前記特定部は、
前記判定部によって出現すると判定された場合、前記追加後のノード列を前記追加後のノード列の末尾ノードから前記追加後のノード列の逆順に探索して未実行の分岐条件が最初に出現するノードを、前記記憶装置の中から特定することを特徴とする請求項2に記載の生成装置。 The second storage unit
If it is determined by the determination unit to appear, a series of branch conditions indicated by the end node of the node sequence after the addition is stored in the storage device,
The specific part is:
When it is determined by the determination unit that the node sequence after the addition is added, the node sequence after the addition is searched in the reverse order of the node sequence after the addition from the end node of the node sequence after the addition, and the unexecuted branch condition appears first. The generation apparatus according to claim 2, wherein a node is specified from the storage device.
前記記憶装置に記憶された一連の分岐条件の集合において、前記判断部によって該当すると判断される一連の分岐条件が占める割合を算出する算出部と、
を有することを特徴とする請求項1乃至3のいずれか一項に記載の生成装置。 A determination unit that determines whether data to be input to the program satisfies a series of branch conditions stored in the storage device by the second storage unit;
A calculation unit that calculates a ratio of a series of branch conditions determined to be applicable by the determination unit in the set of branch conditions stored in the storage device;
The generating apparatus according to claim 1, wherein the generating apparatus includes:
プログラムの実行中に到達した分岐命令において未実行の分岐条件が実行された場合、前記分岐命令と、実行された分岐条件と、前記プログラムの実行開始から前記分岐命令の分岐元の分岐命令までに実行された一連の分岐条件と、を関連付けたノードを生成し、
生成されたノードを記憶装置に格納し、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路上の末尾ノードが示す一連の分岐条件に基づいて、前記プログラムが終了するまでに実行された一連の分岐条件を生成し、
生成された一連の分岐条件を前記記憶装置に格納し、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路を当該実行経路上の末尾ノードから前記実行経路の逆順に探索して未実行の分岐条件が最初に出現するノードを、前記記憶装置の中から特定し、
特定されたノードが示す分岐命令から前記プログラムが再開され、未実行の分岐条件が実行された場合、当該分岐条件を前記特定されたノードが示す分岐命令に関連付けることにより、前記特定されたノードを前記記憶装置内において更新し、
未実行の分岐条件がなくなったノードを前記記憶装置から削除する、
処理を実行させることを特徴とする生成プログラム。 On the computer,
When an unexecuted branch condition is executed in a branch instruction that is reached during execution of the program, the branch instruction, the executed branch condition, and from the start of execution of the program to the branch instruction that is the branch source of the branch instruction Generate a node that associates a series of executed branch conditions with
Store the generated node in the storage device,
When the execution of the program ends, based on a series of branch conditions indicated by the end node on the execution path until the program ends, a series of branch conditions executed until the program ends,
Storing the generated series of branch conditions in the storage device;
When the execution of the program ends, the execution path until the program ends is searched from the end node on the execution path in the reverse order of the execution path, and the node where the unexecuted branch condition first appears is Identify the storage device,
When the program is resumed from the branch instruction indicated by the identified node and an unexecuted branch condition is executed, the identified node is associated with the branch instruction indicated by the identified node. Updating in the storage device;
Deleting a node that has no unexecuted branch condition from the storage device;
A generation program characterized by causing processing to be executed.
プログラムの実行中に到達した分岐命令において未実行の分岐条件が実行された場合、前記分岐命令と、実行された分岐条件と、前記プログラムの実行開始から前記分岐命令の分岐元の分岐命令までに実行された一連の分岐条件と、を関連付けたノードを生成し、
生成されたノードを記憶装置に格納し、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路上の末尾ノードが示す一連の分岐条件に基づいて、前記プログラムが終了するまでに実行された一連の分岐条件を生成し、
生成された一連の分岐条件を前記記憶装置に格納し、
前記プログラムの実行が終了した場合、前記プログラムが終了するまでの実行経路を当該実行経路上の末尾ノードから前記実行経路の逆順に探索して未実行の分岐条件が最初に出現するノードを、前記記憶装置の中から特定し、
特定されたノードが示す分岐命令から前記プログラムが再開され、未実行の分岐条件が実行された場合、当該分岐条件を前記特定されたノードが示す分岐命令に関連付けることにより、前記特定されたノードを前記記憶装置内において更新し、
未実行の分岐条件がなくなったノードを前記記憶装置から削除する、
処理を実行することを特徴とする生成方法。 Computer
When an unexecuted branch condition is executed in a branch instruction that is reached during execution of the program, the branch instruction, the executed branch condition, and from the start of execution of the program to the branch instruction that is the branch source of the branch instruction Generate a node that associates a series of executed branch conditions with
Store the generated node in the storage device,
When the execution of the program ends, based on a series of branch conditions indicated by the end node on the execution path until the program ends, a series of branch conditions executed until the program ends,
Storing the generated series of branch conditions in the storage device;
When the execution of the program ends, the execution path until the program ends is searched from the end node on the execution path in the reverse order of the execution path, and the node where the unexecuted branch condition first appears is Identify the storage device,
When the program is resumed from the branch instruction indicated by the identified node and an unexecuted branch condition is executed, the identified node is associated with the branch instruction indicated by the identified node. Updating in the storage device;
Deleting a node that has no unexecuted branch condition from the storage device;
A generation method characterized by executing processing.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2012019285A JP5761056B2 (en) | 2012-01-31 | 2012-01-31 | Generating device, generating program, and generating method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2012019285A JP5761056B2 (en) | 2012-01-31 | 2012-01-31 | Generating device, generating program, and generating method |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2013156961A JP2013156961A (en) | 2013-08-15 |
JP5761056B2 true JP5761056B2 (en) | 2015-08-12 |
Family
ID=49052045
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2012019285A Expired - Fee Related JP5761056B2 (en) | 2012-01-31 | 2012-01-31 | Generating device, generating program, and generating method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP5761056B2 (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP6201567B2 (en) * | 2013-09-24 | 2017-09-27 | 富士通株式会社 | Symbolic execution method, symbolic execution device, and symbolic execution program |
JP6882892B2 (en) * | 2013-12-18 | 2021-06-02 | アビニシオ テクノロジー エルエルシー | Data generation |
US20150331786A1 (en) * | 2014-05-15 | 2015-11-19 | Fujitsu Limited | Path execution reduction in software program verification |
JP6331756B2 (en) * | 2014-06-25 | 2018-05-30 | 富士通株式会社 | Test case generation program, test case generation method, and test case generation apparatus |
JP6559600B2 (en) * | 2016-03-17 | 2019-08-14 | 株式会社東芝 | Information processing apparatus, information processing program, and inspection system |
-
2012
- 2012-01-31 JP JP2012019285A patent/JP5761056B2/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
JP2013156961A (en) | 2013-08-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP5761056B2 (en) | Generating device, generating program, and generating method | |
US8375007B2 (en) | Status tool to expose metadata read and write queues | |
US8719797B2 (en) | System and method for debugging dynamically generated code of an application | |
JP6122448B2 (en) | Extension activation for related documents | |
US20130080720A1 (en) | Information processing apparatus and method | |
JP6003699B2 (en) | Test data generation program, method and apparatus | |
USRE44722E1 (en) | Efficient use of exceptions in text segmentation | |
CN111143205B (en) | Android platform-oriented test case automatic generation method and generation system | |
CN111460235A (en) | Atlas data processing method, device, equipment and storage medium | |
KR101683448B1 (en) | Method for undoing multiple command | |
US8458110B2 (en) | Verification support apparatus, verification support method, and computer product | |
CN114356299A (en) | Event arrangement method and device in page building process | |
CN108304367A (en) | Segmenting method and device | |
JP2018147106A (en) | Program analyzer, program analysis method and program analysis program | |
CN102411534A (en) | Breakpoint debugging method and debugger | |
JP4893811B2 (en) | Verification support program and verification support device | |
JP6260234B2 (en) | Document analysis apparatus, document analysis method, and document analysis program | |
JP6556091B2 (en) | System specification verification support apparatus and system specification verification support method | |
US9910647B2 (en) | Field size calculation and color coding display options usable in an emulated integrated development environment (IDE) | |
KR101550652B1 (en) | Method and apparatus for providing program development environment | |
JP2014067109A (en) | Data transition trace device, data transition trace method, and data transition trace program | |
JP2012160101A (en) | Information processing unit, software testing method and software testing program | |
US20230385314A1 (en) | Method and apparatus for searching contents | |
JP2009042951A (en) | Data extraction method and device from program | |
JP6960270B2 (en) | Design document learning device and design document learning method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20141007 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20150422 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20150512 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20150525 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 5761056 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
LAPS | Cancellation because of no payment of annual fees |