JP2017204164A - Program analysis method, program analysis device and analysis program - Google Patents

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

Info

Publication number
JP2017204164A
JP2017204164A JP2016095882A JP2016095882A JP2017204164A JP 2017204164 A JP2017204164 A JP 2017204164A JP 2016095882 A JP2016095882 A JP 2016095882A JP 2016095882 A JP2016095882 A JP 2016095882A JP 2017204164 A JP2017204164 A JP 2017204164A
Authority
JP
Japan
Prior art keywords
variable
module
execution
logic
symbol
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.)
Granted
Application number
JP2016095882A
Other languages
Japanese (ja)
Other versions
JP6659955B2 (en
Inventor
前田 芳晴
Yoshiharu Maeda
芳晴 前田
昭彦 松尾
Akihiko Matsuo
昭彦 松尾
健一 平井
Kenichi Hirai
健一 平井
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2016095882A priority Critical patent/JP6659955B2/en
Publication of JP2017204164A publication Critical patent/JP2017204164A/en
Application granted granted Critical
Publication of JP6659955B2 publication Critical patent/JP6659955B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

PROBLEM TO BE SOLVED: To efficiently analyze an execution path of a program.SOLUTION: A symbol c1 is allocated to input of a module 21 to generate first information 24 which represents a previous processing result of a call instruction 22 using the symbol c1, and a symbol c2 is allocated to a call result to generate second information 25 which represents a processing result of first execution paths 23a, 23b using the symbol c2. Further, a symbol c3 is allocated to input of a module 26 to generate third information 28 which represents a processing result of second execution paths 27a, 27b using the symbol c3. A processing result of the first information 24 and the symbol c3 are made to correspond to each other, and a processing result of the third information 28 and the symbol c2 are made to correspond to each other to generate path information 32 which represents a processing result of composite execution paths 31a, 31b, 31c, and 31d using the symbol c1.SELECTED DRAWING: Figure 1

Description

本発明はプログラム分析方法、プログラム分析装置および分析プログラムに関する。   The present invention relates to a program analysis method, a program analysis apparatus, and an analysis program.

プログラムに条件分岐文が含まれている場合、実行される命令の列(実行パス)はプログラムに対する入力に応じて変化する。そこで、作成されたプログラムを分析して、プログラムから実行パスを抽出することがある。例えば、既存の情報処理システムの改変や交換を行う際、その情報処理システムの開発当初に作成された設計資料が十分に残っていない場合がある。その場合、実装物としてのプログラムから実行パスを抽出し、実行パス毎の入力と出力の関係を判定することで、その情報処理システムの仕様を理解することがある。また、例えば、作成されたプログラムをテストする際、そのプログラムから実行パスを抽出し、抽出された実行パスについてテスト計画を作成することがある。   When a conditional branch statement is included in the program, the sequence of instructions to be executed (execution path) changes according to the input to the program. Therefore, the created program may be analyzed to extract an execution path from the program. For example, when modifying or exchanging an existing information processing system, there may be a case where sufficient design data created at the beginning of the development of the information processing system does not remain. In that case, the execution path is extracted from the program as the implementation, and the relationship between the input and output for each execution path is determined to understand the specifications of the information processing system. Further, for example, when testing a created program, an execution path may be extracted from the program, and a test plan may be created for the extracted execution path.

プログラムの分析方法の1つのとして、シンボリック実行(記号実行)がある。シンボリック実行では、プログラムへの入力値を格納する変数に、具体的な数値や具体的な文字に代えて定数を示すシンボル(記号値)を割り当てる。プログラムにおいて更新される変数の値は、シンボルを含む式として表されることがある。シンボルを用いてプログラムの命令を擬似的に実行することで、具体的な値を次々に入力してプログラムを繰り返し実行する場合よりも、プログラムの実行パスを効率的に抽出できる。   One of the program analysis methods is symbolic execution (symbol execution). In symbolic execution, a symbol (symbol value) indicating a constant is assigned instead of a specific numerical value or a specific character to a variable for storing an input value to the program. The value of a variable that is updated in a program may be expressed as an expression that includes a symbol. By executing the program instructions in a pseudo manner using symbols, the execution path of the program can be extracted more efficiently than when the program is repeatedly executed by inputting specific values one after another.

プログラムに条件分岐文が含まれている場合、シンボルは任意の定数を表すため、分岐方向を1つに絞り込めないことがある。具体的な値によって分岐条件の判定がYESになることもNOになることもある場合、その条件分岐文を分割点として実行パスを分割する。すなわち、その分岐条件の判定がYESになる場合の実行パスと、その分岐条件の判定がNOになる場合の実行パスの両方が存在するものとして取り扱う。条件分岐文が増えると、プログラムから抽出される実行パスは指数関数的に増加することが多い。   If a conditional branch statement is included in the program, the symbol represents an arbitrary constant, so the branch direction may not be narrowed down to one. When the branch condition is determined to be YES or NO depending on a specific value, the execution path is divided using the conditional branch statement as a division point. That is, it is treated that both an execution path when the determination of the branch condition is YES and an execution path when the determination of the branch condition is NO exist. When the number of conditional branch statements increases, the execution paths extracted from the program often increase exponentially.

なお、シンボリック実行を利用してプログラムから実行パスを抽出し、抽出した実行パスをカバーするテストデータを生成するテストデータ生成装置が提案されている。提案のテストデータ生成装置は、シンボリック実行の計算量を削減するため、複数の変数のうち一部の変数のみにシンボルを割り当て、他の変数にはシンボルではない具体的な値を割り当てる。シンボルと具体的な値の組み合わせによってシンボリック実行を行うと、プログラムに含まれる複数の実行パスのうち一部の実行パスが抽出される。テストデータ生成装置は、シンボルを割り当てる変数を切り替えながらシンボリック実行を繰り返すことで、テストすべき実行パスの全てをプログラムから抽出する。   In addition, a test data generation device that extracts an execution path from a program using symbolic execution and generates test data that covers the extracted execution path has been proposed. The proposed test data generation apparatus assigns symbols only to some of a plurality of variables and assigns specific values that are not symbols to other variables in order to reduce the amount of calculation for symbolic execution. When symbolic execution is performed using a combination of symbols and specific values, some execution paths are extracted from among a plurality of execution paths included in the program. The test data generation apparatus extracts all execution paths to be tested from the program by repeating symbolic execution while switching variables to which symbols are assigned.

また、シンボリック実行を利用して関数内部の実行パスを探索するソフトウェアテスト方法が提案されている。提案のソフトウェアテスト方法では、関数の戻り値にシンボルを割り当て、シンボルが取り得る値の範囲を示す制約を導出し、制約を満たすように関数についてシンボル実行を行うことで探索する実行パスを制限する。   In addition, a software test method for searching for an execution path inside a function using symbolic execution has been proposed. In the proposed software test method, a symbol is assigned to the return value of the function, a constraint indicating the range of values that the symbol can take is derived, and the execution path to be searched is limited by performing symbol execution on the function so as to satisfy the constraint. .

特開2014−153908号公報JP 2014-153908 A 特開2016−12343号公報JP 2006-12343 A

プログラムでは、あるモジュールが他のモジュールを呼び出すことがある。モジュールは、関数・手続き・メソッド・セクションなど、プログラムに含まれる部分プログラムであって他のモジュールから呼び出されることがあるものであればよい。この場合、プログラムをどのように分析して実行パスを抽出すればよいかが問題となる。   In a program, one module may call another module. The module may be a partial program included in the program, such as a function, procedure, method, or section, and may be called from another module. In this case, the question is how to analyze the program and extract the execution path.

呼び出し元モジュールと呼び出し先モジュールの両方に跨がる実行パスを直接抽出しようとすると、探索する実行パスが膨大になるというパス爆発の問題が生じる。例えば、呼び出し元モジュールに、1回ずつ実行されるN個の直列の条件分岐文が含まれ、呼び出し先モジュールに、1回ずつ実行されるM個の直列の条件分岐文が含まれているとする(N,Mは2以上の整数)。その場合、2つのモジュールからは最大で2M+N個の実行パスが抽出される。2M+N個の実行パスを直接探索しようとすると、各モジュールの条件分岐文の数(NやM)の増加に伴って計算量が大きく増加してしまう。 If an attempt is made to directly extract an execution path that extends over both the caller module and the callee module, a problem of path explosion occurs in which an execution path to be searched becomes enormous. For example, if the caller module includes N serial conditional branch statements that are executed once, and the callee module includes M serial conditional branch statements that are executed once. (N and M are integers of 2 or more). In that case, a maximum of 2 M + N execution paths are extracted from the two modules. If an attempt is made to directly search for 2 M + N execution paths, the amount of calculation greatly increases as the number of conditional branch statements (N and M) in each module increases.

一方、モジュール毎に独立に実行パスを抽出するだけでは、呼び出し元モジュールを正しく分析したことにはならない。他のモジュールを呼び出した後に呼び出し元モジュールで実行される命令は、呼び出し先モジュールの実行結果に依存するためである。   On the other hand, simply extracting the execution path independently for each module does not correctly analyze the calling module. This is because an instruction executed in the caller module after calling another module depends on the execution result of the callee module.

1つの側面では、本発明は、プログラムの実行パスを効率的に分析できるプログラム分析方法、プログラム分析装置および分析プログラムを提供することを目的とする。   In one aspect, an object of the present invention is to provide a program analysis method, a program analysis apparatus, and an analysis program that can efficiently analyze an execution path of a program.

1つの態様では、コンピュータが実行するプログラム分析方法が提供される。第1のモジュールと第2のモジュールとを含み、第1のモジュールは第2のモジュールを呼び出す呼び出し命令を含むプログラムを取得する。第1のモジュールの入力に第1のシンボルを割り当て、呼び出し命令の前における第1の処理結果を第1のシンボルを用いて表した第1の情報を生成し、呼び出し命令の呼び出し結果に第2のシンボルを割り当て、第1のモジュールに含まれる複数の第1の実行パスそれぞれの呼び出し命令の後における第2の処理結果を第2のシンボルを用いて表した第2の情報を生成する。第2のモジュールの入力に第3のシンボルを割り当て、第2のモジュールに含まれる複数の第2の実行パスそれぞれの第3の処理結果を第3のシンボルを用いて表した第3の情報を生成する。第1の情報が示す第1の処理結果と第3の情報に用いられた第3のシンボルとを対応付け、また、第3の情報が示す第3の処理結果と第2の情報に用いられた第2のシンボルとを対応付けることで、複数の第1の実行パスと複数の第2の実行パスとを合成した複数の合成実行パスそれぞれの処理結果を第1のシンボルを用いて表したパス情報を生成する。   In one aspect, a program analysis method executed by a computer is provided. The first module includes a first module and a second module, and the first module obtains a program including a call instruction for calling the second module. The first symbol is assigned to the input of the first module, the first information representing the first processing result before the call instruction using the first symbol is generated, and the call result of the call instruction is the second Are generated, and second information in which the second processing result after the call instruction of each of the plurality of first execution paths included in the first module is expressed using the second symbol is generated. The third symbol is assigned to the input of the second module, and the third information representing the third processing result of each of the plurality of second execution paths included in the second module using the third symbol is provided. Generate. The first processing result indicated by the first information is associated with the third symbol used for the third information, and the third processing result indicated by the third information is used for the second information. Paths in which processing results of a plurality of combined execution paths obtained by combining a plurality of first execution paths and a plurality of second execution paths are represented using the first symbols by associating with the second symbols. Generate information.

また、1つの態様では、記憶部と演算部とを有するプログラム分析装置が提供される。また、1つの態様では、コンピュータに実行させる分析プログラムが提供される。   In one aspect, a program analysis device having a storage unit and a calculation unit is provided. In one aspect, an analysis program to be executed by a computer is provided.

1つの側面では、プログラムの実行パスを効率的に分析できる。   In one aspect, the execution path of the program can be analyzed efficiently.

第1の実施の形態のプログラム分析装置の例を示す図である。It is a figure which shows the example of the program analysis apparatus of 1st Embodiment. プログラム分析装置のハードウェア例を示すブロック図である。It is a block diagram which shows the hardware example of a program analyzer. プログラムの第1の例を示す図である。It is a figure which shows the 1st example of a program. ロジックテーブルの第1の例を示す図である。It is a figure which shows the 1st example of a logic table. プログラムの第2の例を示す図である。It is a figure which shows the 2nd example of a program. ロジックテーブルの第2の例を示す図である。It is a figure which shows the 2nd example of a logic table. シンボリック実行の分割と部分ロジックの結合の例を示す図である。It is a figure which shows the example of the division | segmentation of symbolic execution, and the coupling | bonding of a partial logic. 更新変数テーブルとシンボル割り当てテーブルの例を示す図である。It is a figure which shows the example of an update variable table and a symbol allocation table. 階層的な更新変数の抽出例を示す図である。It is a figure which shows the example of extraction of a hierarchical update variable. 途中点と呼び出し先と終点のロジックテーブルの例を示す図である。It is a figure which shows the example of the logic table of a halfway point, a call destination, and an end point. 部分ロジックの簡約化例を示す図である。It is a figure which shows the simplification example of a partial logic. 部分ロジックの結合例を示す図である。It is a figure which shows the example of a coupling | bonding of a partial logic. 部分ロジックの結合例を示す図(続き)である。It is a figure (example) which shows the example of a combination of a partial logic. プログラムの第3の例を示す図である。It is a figure which shows the 3rd example of a program. プログラム分析装置の機能例を示すブロック図である。It is a block diagram which shows the function example of a program analyzer. プログラム分析の手順例を示すフローチャートである。It is a flowchart which shows the example of a procedure of a program analysis. 更新変数抽出の手順例を示すフローチャートである。It is a flowchart which shows the example of a procedure of update variable extraction. シンボリック実行の手順例を示すフローチャートである。It is a flowchart which shows the example of a procedure of symbolic execution. シンボリック実行の手順例を示すフローチャート(続き)である。It is a flowchart (continuation) which shows the example of a procedure of symbolic execution. ロジック簡約化の手順例を示すフローチャートである。It is a flowchart which shows the example of a procedure of logic simplification. ロジック結合の手順例を示すフローチャートである。It is a flowchart which shows the example of a procedure of logic coupling | bonding.

以下、本実施の形態を図面を参照して説明する。
[第1の実施の形態]
第1の実施の形態を説明する。
Hereinafter, the present embodiment will be described with reference to the drawings.
[First Embodiment]
A first embodiment will be described.

図1は、第1の実施の形態のプログラム分析装置の例を示す図である。
第1の実施の形態のプログラム分析装置10は、シンボリック実行によってプログラムを分析し、プログラムから実行パスを抽出する。分析対象のプログラムは、プログラミング言語で記述されたソースコードでもよいし、実行可能なオブジェクトコードなどソースコード以外のものでもよい。例えば、プログラム分析装置10は、既存の情報処理システムの仕様を理解することを目的として、過去に作成されたプログラムから実行パスを抽出するときに用いることができる。また、例えば、プログラム分析装置10は、新たに構築する情報処理システムをテストすることを目的として、新たに作成されたプログラムからテスト対象の実行パスを抽出するときに用いることができる。
FIG. 1 is a diagram illustrating an example of a program analysis apparatus according to the first embodiment.
The program analysis apparatus 10 according to the first embodiment analyzes a program by symbolic execution and extracts an execution path from the program. The analysis target program may be a source code described in a programming language, or may be a non-source code such as an executable object code. For example, the program analysis apparatus 10 can be used when extracting an execution path from a program created in the past for the purpose of understanding the specifications of an existing information processing system. Further, for example, the program analysis apparatus 10 can be used when extracting an execution path to be tested from a newly created program for the purpose of testing a newly constructed information processing system.

プログラム分析装置10は、クライアントコンピュータでもよいしサーバコンピュータでもよい。プログラム分析装置10は、記憶部11および演算部12を有する。
記憶部11は、分析対象のプログラム20を記憶する。記憶部11は、RAM(Random Access Memory)などの揮発性の半導体メモリでもよいし、HDD(Hard Disk Drive)やフラッシュメモリなどの不揮発性の記憶装置でもよい。
The program analysis apparatus 10 may be a client computer or a server computer. The program analysis device 10 includes a storage unit 11 and a calculation unit 12.
The storage unit 11 stores the analysis target program 20. The storage unit 11 may be a volatile semiconductor memory such as a RAM (Random Access Memory) or a non-volatile storage device such as an HDD (Hard Disk Drive) or a flash memory.

演算部12は、記憶部11に記憶されたプログラム20に含まれる実行パスを分析する。演算部12は、CPU(Central Processing Unit)やDSP(Digital Signal Processor)などのプロセッサでもよい。また、演算部12は、ASIC(Application Specific Integrated Circuit)やFPGA(Field Programmable Gate Array)などの特定用途の電子回路を含んでもよい。プロセッサは、RAMなどのメモリ(記憶部11でもよい)に記憶されたプログラムを実行する。プロセッサが実行するプログラムには、以下に説明する処理を記載した分析プログラムが含まれる。複数のプロセッサの集合を、「マルチプロセッサ」または単に「プロセッサ」と言うこともある。   The calculation unit 12 analyzes the execution path included in the program 20 stored in the storage unit 11. The arithmetic unit 12 may be a processor such as a CPU (Central Processing Unit) or a DSP (Digital Signal Processor). The arithmetic unit 12 may include an electronic circuit for a specific purpose such as an application specific integrated circuit (ASIC) or a field programmable gate array (FPGA). The processor executes a program stored in a memory such as a RAM (or the storage unit 11). The program executed by the processor includes an analysis program describing the processing described below. A set of processors may be referred to as “multiprocessor” or simply “processor”.

プログラム20は、モジュール21(第1のモジュール)とモジュール26(第2のモジュール)を含む。モジュール21,26はそれぞれ、プログラム20に含まれる部分プログラムであって他のモジュールから呼び出されることがあるものであればよい。例えば、モジュール21,26として関数・手続き・メソッド・セクションなどが挙げられる。モジュール単位の名称はプログラミング言語に依存する。   The program 20 includes a module 21 (first module) and a module 26 (second module). Each of the modules 21 and 26 may be a partial program included in the program 20 and may be called from another module. For example, the modules 21, 26 include functions, procedures, methods, sections, and the like. The name of the module unit depends on the programming language.

モジュール21は、モジュール26を呼び出す呼び出し命令22を含む。モジュール21が呼び出し元モジュールであり、モジュール26が呼び出し先モジュールである。呼び出し命令22の一例として、他のセクションを呼び出すPERFORM文が挙げられる。   Module 21 includes a call instruction 22 that calls module 26. Module 21 is a caller module, and module 26 is a callee module. An example of the call instruction 22 is a PERFORM statement that calls another section.

演算部12は、モジュール21についてシンボリック実行を行う。このとき、演算部12は、モジュール21の入力にシンボルc1(第1のシンボル)を割り当てる。例えば、演算部12は、モジュール21で使用される変数のうちモジュール21の外部から提供される値を格納する変数に、シンボルc1を割り当てる。   The calculation unit 12 performs symbolic execution on the module 21. At this time, the arithmetic unit 12 assigns the symbol c1 (first symbol) to the input of the module 21. For example, the arithmetic unit 12 assigns the symbol c <b> 1 to a variable that stores a value provided from outside the module 21 among variables used in the module 21.

演算部12は、呼び出し命令22の前における処理結果(第1の処理結果)をシンボルc1を用いて表した第1の情報24を生成する。第1の情報24は、例えば、モジュール21で使用される変数のうち呼び出し命令22の前までに更新された変数の値を、シンボルc1を含む式で表したものである。第1の情報24は、例えば、シンボリック実行によって、呼び出し命令22の前までの命令をシンボルc1を用いて擬似的に実行することで生成できる。一例として、第1の情報24は、呼び出し命令22の直前における変数xの値がc1+1であるという処理結果を示す。   The computing unit 12 generates first information 24 that represents the processing result (first processing result) before the call instruction 22 by using the symbol c1. The first information 24 is, for example, a value of a variable updated before the call instruction 22 among variables used in the module 21 is expressed by an expression including the symbol c1. The first information 24 can be generated, for example, by executing the instructions up to the calling instruction 22 in a pseudo manner using the symbol c1 by symbolic execution. As an example, the first information 24 indicates a processing result that the value of the variable x immediately before the call instruction 22 is c1 + 1.

演算部12は、呼び出し命令22の呼び出し結果に、シンボルc1とは独立なシンボルc2(第2のシンボル)を割り当てる。これにより、モジュール26がスタブ化され、モジュール21をモジュール26とは独立にシンボリック実行することができる。例えば、演算部12は、モジュール21で使用される変数のうちモジュール26によって更新される可能性がある変数に、シンボルc2を割り当てる。一例として、演算部12は、モジュール21によって更新される変数yに、シンボルc2を割り当てる。   The arithmetic unit 12 assigns a symbol c2 (second symbol) independent of the symbol c1 to the call result of the call instruction 22. Thereby, the module 26 is stubbed, and the module 21 can be symbolically executed independently of the module 26. For example, the arithmetic unit 12 assigns the symbol c <b> 2 to a variable that may be updated by the module 26 among the variables used in the module 21. As an example, the arithmetic unit 12 assigns the symbol c2 to the variable y updated by the module 21.

呼び出し命令22は、モジュール26の作用を明示しない形式で記述されていてもよい。例えば、モジュール26がグローバル変数を更新する場合など、モジュール26によって更新される値を格納する変数がモジュール21に明記されていない場合であってもよい。その場合、例えば、演算部12は、モジュール21で使用される変数のうちモジュール26によって更新される可能性のある更新変数を、モジュール26から検索しておく。   The call instruction 22 may be described in a format that does not clearly indicate the operation of the module 26. For example, when the module 26 updates a global variable, the variable for storing the value updated by the module 26 may not be specified in the module 21. In this case, for example, the arithmetic unit 12 searches the module 26 for an update variable that may be updated by the module 26 among the variables used in the module 21.

演算部12は、第1の実行パス23a,23bを含む複数の第1の実行パスを、モジュール21から検出する。モジュール21に含まれる1以上の条件分岐命令によって、これら複数の第1の実行パスが分岐する。条件分岐命令は、呼び出し命令22の前に存在してもよいし、呼び出し命令22の後に存在してもよい。   The computing unit 12 detects a plurality of first execution paths including the first execution paths 23 a and 23 b from the module 21. The plurality of first execution paths are branched by one or more conditional branch instructions included in the module 21. The conditional branch instruction may exist before the call instruction 22 or may exist after the call instruction 22.

演算部12は、複数の第1の実行パスそれぞれの呼び出し命令22の後における処理結果(第2の処理結果)をシンボルc2を用いて表した第2の情報25を生成する。第2の情報25は、例えば、モジュール21で使用される変数のうち呼び出し命令22の後に更新された変数の値を、シンボルc2を含む式で表したものである。当該式に更にシンボルc1が含まれていてもよい。第2の情報25は、例えば、シンボリック実行によって、呼び出し命令22の後の命令をシンボルc2を用いて擬似的に実行することで生成できる。   The computing unit 12 generates second information 25 that represents the processing result (second processing result) after the call instruction 22 of each of the plurality of first execution paths using the symbol c2. The second information 25 represents, for example, a value of a variable updated after the call instruction 22 among variables used in the module 21 by an expression including the symbol c2. The expression may further include a symbol c1. The second information 25 can be generated by, for example, executing the instruction after the call instruction 22 in a pseudo manner using the symbol c2 by symbolic execution.

第2の情報25が示す処理結果は、第1の実行パスによって異なる可能性がある。一例として、第2の情報25は、第1の実行パス23aの終了点における変数zの値がc2+3であるという処理結果を示す。また、第2の情報25は、第1の実行パス23bの終了点における変数zの値がc2−3であるという処理結果を示す。なお、呼び出し命令22の前に条件分岐命令が存在する場合、第1の情報24が示す処理結果も、第2の情報25と同様に第1の実行パスによって異なる可能性がある。   The processing result indicated by the second information 25 may vary depending on the first execution path. As an example, the second information 25 indicates a processing result that the value of the variable z at the end point of the first execution path 23a is c2 + 3. The second information 25 indicates a processing result that the value of the variable z at the end point of the first execution path 23b is c2-3. When a conditional branch instruction is present before the call instruction 22, the processing result indicated by the first information 24 may be different depending on the first execution path, similarly to the second information 25.

また、演算部12は、モジュール21とは独立にモジュール26についてシンボリック実行を行う。モジュール26のシンボリック実行は、モジュール21のシンボリック実行よりも前に行ってもよいし、モジュール21のシンボリック実行の後に行ってもよい。また、モジュール26のシンボリック実行は、呼び出し命令22の前までのシンボリック実行と呼び出し命令22の後のシンボリック実行との間に行ってもよい。   In addition, the arithmetic unit 12 performs symbolic execution on the module 26 independently of the module 21. The symbolic execution of the module 26 may be performed before the symbolic execution of the module 21, or may be performed after the symbolic execution of the module 21. The symbolic execution of the module 26 may be performed between the symbolic execution before the call instruction 22 and the symbolic execution after the call instruction 22.

このとき、演算部12は、モジュール26の入力に、シンボルc1,c2とは独立なシンボルc3(第3のシンボル)を割り当てる。例えば、演算部12は、モジュール26で使用される変数のうちモジュール26の外部から提供される値を格納する変数に、シンボルc3を割り当てる。演算部12は、第2の実行パス27a,27bを含む複数の第2の実行パスを、モジュール26から検出する。モジュール26に含まれる1以上の条件分岐命令によって、これら複数の第2の実行パスが分岐する。   At this time, the arithmetic unit 12 assigns a symbol c3 (third symbol) independent of the symbols c1 and c2 to the input of the module 26. For example, the computing unit 12 assigns the symbol c3 to a variable that stores a value provided from outside the module 26 among variables used in the module 26. The computing unit 12 detects a plurality of second execution paths including the second execution paths 27 a and 27 b from the module 26. The plurality of second execution paths are branched by one or more conditional branch instructions included in the module 26.

演算部12は、複数の第2の実行パスそれぞれの処理結果(第3の処理結果)をシンボルc3を用いて表した第3の情報28を生成する。第3の情報28は、例えば、モジュール26で使用される変数のうちモジュール26の中で更新された変数の値を、シンボルc3を含む式で表したものである。第3の情報28は、例えば、シンボリック実行によって、モジュール26の命令をシンボルc3を用いて擬似的に実行することで生成できる。   The computing unit 12 generates third information 28 that represents the processing results (third processing results) of the plurality of second execution paths using the symbol c3. The third information 28 is, for example, a value of a variable updated in the module 26 among variables used in the module 26 expressed by an expression including the symbol c3. The third information 28 can be generated, for example, by executing the instruction of the module 26 in a pseudo manner using the symbol c3 by symbolic execution.

第3の情報28が示す処理結果は、第2の実行パスによって異なる可能性がある。一例として、第3の情報28は、第2の実行パス27aの終了点における変数yの値がc3+2であるという処理結果を示す。また、第3の情報28は、第2の実行パス27bの終了点における変数yの値がc3−2であるという処理結果を示す。なお、図1では変数x,y,zを使用しているが、これらの変数の一部または全部が同一でもよい。   The processing result indicated by the third information 28 may vary depending on the second execution path. As an example, the third information 28 indicates a processing result that the value of the variable y at the end point of the second execution path 27a is c3 + 2. The third information 28 indicates the processing result that the value of the variable y at the end point of the second execution path 27b is c3-2. In FIG. 1, variables x, y, and z are used, but some or all of these variables may be the same.

そして、演算部12は、複数の第1の実行パスと複数の第2の実行パスとを合成し、合成実行パス31a,31b,31c,31dを含む複数の合成実行パスを生成する。合成実行パスは、モジュール21,26に跨がる実行パスであり、呼び出し命令22の前の命令に続けてモジュール26の中の命令も実行した場合に得られる実行パスと同等である。   Then, the arithmetic unit 12 combines the plurality of first execution paths and the plurality of second execution paths to generate a plurality of combined execution paths including the combined execution paths 31a, 31b, 31c, and 31d. The synthesis execution path is an execution path that extends over the modules 21 and 26, and is equivalent to an execution path that is obtained when an instruction in the module 26 is executed following the instruction preceding the call instruction 22.

このとき、演算部12は、第1の情報24、第2の情報25および第3の情報28を取得する。演算部12は、第1の情報24が示す処理結果と第3の情報28に用いられたシンボルc3とを対応付ける。これは、呼び出し命令22の前の処理結果は、モジュール26に対する入力として用いられるためである。例えば、変数xの値を示す式とシンボルc3とが対応付けられる。また、演算部12は、第3の情報28が示す処理結果と第2の情報25に用いられたシンボルc2とを対応付ける。これは、モジュール26の処理結果は、呼び出し命令22の後の命令の入力として用いられるためである。例えば、変数yの値を示す式とシンボルc2とが対応付けられる。   At this time, the calculation unit 12 acquires the first information 24, the second information 25, and the third information 28. The computing unit 12 associates the processing result indicated by the first information 24 with the symbol c3 used for the third information 28. This is because the processing result before the call instruction 22 is used as an input to the module 26. For example, an expression indicating the value of the variable x is associated with the symbol c3. In addition, the arithmetic unit 12 associates the processing result indicated by the third information 28 with the symbol c <b> 2 used for the second information 25. This is because the processing result of the module 26 is used as an input of an instruction after the call instruction 22. For example, an expression indicating the value of the variable y is associated with the symbol c2.

演算部12は、第1の情報24、第2の情報25および第3の情報28と、上記の対応付けとによって、複数の合成実行パスそれぞれの処理結果をシンボルc1を用いて表したパス情報32を生成する。パス情報32は、呼び出し命令22も考慮して、モジュール21の入力と出力の関係を合成実行パス毎に表したものである。   The calculation unit 12 uses the first information 24, the second information 25, the third information 28, and the association described above to express the processing results of each of the plurality of synthesis execution paths using the symbol c1. 32 is generated. The path information 32 represents the relationship between the input and output of the module 21 for each synthesis execution path in consideration of the call instruction 22.

一例として、演算部12は、第1の情報24が示すx=c1+1を、第3の情報28のシンボルc3に代入する。これにより、第2の実行パス27aの処理結果はy=c1+3と表され、第2の実行パス27bの処理結果はy=c1−1と表される。   As an example, the arithmetic unit 12 substitutes x = c1 + 1 indicated by the first information 24 for the symbol c3 of the third information 28. As a result, the processing result of the second execution path 27a is expressed as y = c1 + 3, and the processing result of the second execution path 27b is expressed as y = c1-1.

更に、演算部12は、第2の実行パス27a,27bの処理結果を、第2の情報25のシンボルc2に代入する。このとき、演算部12は、任意の第1の実行パスと任意の第2の実行パスとの組み合わせを検討する。ここでは、第1の実行パス23aと第2の実行パス27aとを合成して合成実行パス31aが生成される。第1の実行パス23aと第2の実行パス27bとを合成して合成実行パス31bが生成される。第1の実行パス23bと第2の実行パス27aとを合成して合成実行パス31cが生成される。第1の実行パス23bと第2の実行パス27bとを合成して合成実行パス31dが生成される。   Further, the arithmetic unit 12 substitutes the processing results of the second execution paths 27a and 27b into the symbol c2 of the second information 25. At this time, the arithmetic unit 12 considers a combination of an arbitrary first execution path and an arbitrary second execution path. Here, the first execution path 23a and the second execution path 27a are combined to generate a combined execution path 31a. The synthesis execution path 31b is generated by synthesizing the first execution path 23a and the second execution path 27b. The synthesis execution path 31c is generated by synthesizing the first execution path 23b and the second execution path 27a. The first execution path 23b and the second execution path 27b are combined to generate a combined execution path 31d.

演算部12は、第2の実行パス27aのy=c1+3を、第1の実行パス23aのz=c2+3のシンボルc2に代入する。これにより、合成実行パス31aの処理結果はz=c1+6と表される。また、演算部12は、第2の実行パス27bのy=c1−1を、第1の実行パス23aのz=c2+3のシンボルc2に代入する。これにより、合成実行パス31bの処理結果はz=c1+2と表される。演算部12は、第2の実行パス27aのy=c1+3を、第1の実行パス23bのz=c2−3のシンボルc2に代入する。これにより、合成実行パス31cの処理結果はz=c1と表される。演算部12は、第2の実行パス27bのy=c1−1を、第1の実行パス23bのz=c2−3のシンボルc2に代入する。これにより、合成実行パス31dの処理結果はz=c1−4と表される。   The arithmetic unit 12 substitutes y = c1 + 3 of the second execution path 27a into the symbol c2 of z = c2 + 3 of the first execution path 23a. As a result, the processing result of the synthesis execution path 31a is expressed as z = c1 + 6. In addition, the calculation unit 12 substitutes y = c1-1 of the second execution path 27b into the symbol c2 of z = c2 + 3 of the first execution path 23a. As a result, the processing result of the synthesis execution path 31b is expressed as z = c1 + 2. The computing unit 12 substitutes y = c1 + 3 of the second execution path 27a into the symbol c2 of z = c2-3 of the first execution path 23b. As a result, the processing result of the synthesis execution path 31c is expressed as z = c1. The arithmetic unit 12 substitutes y = c1-1 of the second execution path 27b into the symbol c2 of z = c2-3 of the first execution path 23b. As a result, the processing result of the synthesis execution path 31d is expressed as z = c1-4.

ただし、任意の第1の実行パスと任意の第2の実行パスとを合成した合成実行パスの全てが、プログラム20において実際に実行される有効な実行パスではないこともある。その場合、演算部12は、複数の第1の実行パスと複数の第2の実行パスとの間の全ての組み合わせの中から、有効な組み合わせのみを選択するようにしてもよい。   However, all of the combined execution paths obtained by combining the arbitrary first execution path and the arbitrary second execution path may not be effective execution paths that are actually executed in the program 20. In that case, the calculation unit 12 may select only effective combinations from all combinations between the plurality of first execution paths and the plurality of second execution paths.

例えば、第2の情報25は、各第1の実行パスの実行条件(第1の実行条件)を、シンボルc1,c2の少なくとも一方を用いて表していてもよい。第1の実行パスの実行条件は、モジュール21に含まれる条件分岐命令の分岐条件から判定することができる。また、第3の情報28は、各第2の実行パスの実行条件(第2の実行条件)を、シンボルc3を用いて表していてもよい。第2の実行パスの実行条件は、モジュール26に含まれる条件分岐命令の分岐条件から判定することができる。   For example, the second information 25 may represent the execution condition (first execution condition) of each first execution path using at least one of the symbols c1 and c2. The execution condition of the first execution path can be determined from the branch condition of the conditional branch instruction included in the module 21. Further, the third information 28 may represent the execution condition (second execution condition) of each second execution path using the symbol c3. The execution condition of the second execution path can be determined from the branch condition of the conditional branch instruction included in the module 26.

この場合、例えば、演算部12は、ある第1の実行パスの実行条件とある第2の実行パスの実行条件とが矛盾しないとき、当該第1の実行パスと当該第2の実行パスとを合成した合成実行パスを有効と判定することができる。一方、演算部12は、ある第1の実行パスの実行条件とある第2の実行パスの実行条件とが矛盾するとき、当該第1の実行パスと当該第2の実行パスとを合成した合成実行パスを無効と判定することができる。   In this case, for example, when the execution condition of a certain first execution path and the execution condition of a certain second execution path do not contradict each other, the arithmetic unit 12 determines the first execution path and the second execution path. It is possible to determine that the combined execution path is valid. On the other hand, when the execution condition of a certain first execution path and the execution condition of a certain second execution path contradict each other, the arithmetic unit 12 combines the first execution path and the second execution path. It is possible to determine that the execution path is invalid.

第1の実施の形態のプログラム分析装置10によれば、モジュール21のシンボリック実行とモジュール26のシンボリック実行とが独立に実行される。モジュール21のシンボリック実行によって、呼び出し命令22の前についての第1の情報24と、呼び出し命令22の後についての第2の情報25とが収集される。また、モジュール26のシンボリック実行によって、第3の情報28が収集される。そして、第1の情報24、第2の情報25および第3の情報28に基づいて、モジュール21から検出された複数の第1の実行パスとモジュール26から検出された複数の第2の実行パスとが合成される。   According to the program analysis apparatus 10 of the first embodiment, the symbolic execution of the module 21 and the symbolic execution of the module 26 are executed independently. By the symbolic execution of the module 21, first information 24 before the call instruction 22 and second information 25 after the call instruction 22 are collected. Further, the third information 28 is collected by the symbolic execution of the module 26. Then, based on the first information 24, the second information 25, and the third information 28, a plurality of first execution paths detected from the module 21 and a plurality of second execution paths detected from the module 26. And are synthesized.

これにより、モジュール21,26に跨がる実行パスを分析する際のパス爆発を抑制し、プログラム20の実行パスを効率的に分析することができる。例えば、モジュール21にN個の直列の条件分岐命令が含まれ、モジュール26にM個の直列の条件分岐命令が含まれているとする。モジュール21,26に跨がる実行パスをシンボリック実行によって直接検出する場合、最大で2M+N個の実行パスが検出される。一方、第1の実施の形態によれば、シンボリック実行によって検出すべき実行パスは最大で2M+2N個となる。このため、シンボリック実行の計算量を削減することができる。 Thereby, the path explosion at the time of analyzing the execution path over the modules 21 and 26 can be suppressed, and the execution path of the program 20 can be analyzed efficiently. For example, it is assumed that the module 21 includes N serial conditional branch instructions, and the module 26 includes M serial conditional branch instructions. When an execution path straddling the modules 21 and 26 is directly detected by symbolic execution, a maximum of 2 M + N execution paths are detected. On the other hand, according to the first embodiment, the maximum number of execution paths to be detected by symbolic execution is 2 M +2 N. For this reason, the calculation amount of symbolic execution can be reduced.

また、第1の実施の形態では、モジュール21から呼び出されるモジュール26の処理を無視しているわけではなく、モジュール26から検出された第2の実行パスがモジュール21から検出された第1の実行パスと合成される。よって、生成されるパス情報32は、モジュール21の入力と出力との関係を正しく表すことができる。   Further, in the first embodiment, the process of the module 26 called from the module 21 is not ignored, and the second execution path detected from the module 26 is detected from the module 21. Synthesized with path. Therefore, the generated path information 32 can correctly represent the relationship between the input and output of the module 21.

[第2の実施の形態]
次に、第2の実施の形態を説明する。
第2の実施の形態のプログラム分析装置は、シンボリック実行によってプログラムから実行パスを抽出し、入力と出力の関係を示すロジック情報を生成する。
[Second Embodiment]
Next, a second embodiment will be described.
The program analysis apparatus according to the second embodiment extracts an execution path from a program by symbolic execution, and generates logic information indicating a relationship between input and output.

図2は、プログラム分析装置のハードウェア例を示すブロック図である。
プログラム分析装置100は、プロセッサ101、RAM102、HDD103、画像信号処理部104、入力信号処理部105、媒体リーダ106および通信インタフェース107を有する。プログラム分析装置100の上記ユニットは、バス108に接続されている。なお、プログラム分析装置100は、第1の実施の形態のプログラム分析装置10に対応する。プロセッサ101は、第1の実施の形態の演算部12に対応する。RAM102またはHDD103は、第1の実施の形態の記憶部11に対応する。
FIG. 2 is a block diagram illustrating a hardware example of the program analysis apparatus.
The program analysis apparatus 100 includes a processor 101, a RAM 102, an HDD 103, an image signal processing unit 104, an input signal processing unit 105, a medium reader 106, and a communication interface 107. The unit of the program analysis apparatus 100 is connected to the bus 108. The program analysis device 100 corresponds to the program analysis device 10 of the first embodiment. The processor 101 corresponds to the calculation unit 12 of the first embodiment. The RAM 102 or the HDD 103 corresponds to the storage unit 11 of the first embodiment.

プロセッサ101は、プログラムの命令を実行する演算回路を含むプロセッサである。プロセッサ101は、例えば、CPUである。プロセッサ101は、HDD103に記憶されたプログラムおよびデータの少なくとも一部をRAM102にロードし、ロードされたプログラムを実行する。なお、プロセッサ101が複数のプロセッサコアを備えてもよいし、プログラム分析装置100が複数のプロセッサを備えてもよい。以下で説明する処理を、複数のプロセッサまたはプロセッサコアを用いて並列に実行してもよい。   The processor 101 is a processor including an arithmetic circuit that executes program instructions. The processor 101 is a CPU, for example. The processor 101 loads at least a part of the program and data stored in the HDD 103 into the RAM 102 and executes the loaded program. The processor 101 may include a plurality of processor cores, and the program analysis apparatus 100 may include a plurality of processors. The processes described below may be executed in parallel using a plurality of processors or processor cores.

RAM102は、プロセッサ101が実行するプログラムや演算に用いるデータを一時的に記憶する揮発性の半導体メモリである。なお、プログラム分析装置100は、RAM以外の種類のメモリを備えてもよいし、複数個のメモリを備えてもよい。   The RAM 102 is a volatile semiconductor memory that temporarily stores programs executed by the processor 101 and data used for calculations. Note that the program analysis apparatus 100 may include a type of memory other than the RAM, or may include a plurality of memories.

HDD103は、OS(Operating System)やミドルウェアやアプリケーションソフトウェアなどのソフトウェアのプログラム、および、データを記憶する不揮発性の記憶装置である。プログラムには、分析プログラムが含まれる。なお、プログラム分析装置100は、フラッシュメモリやSSD(Solid State Drive)などの他の種類の記憶装置を備えてもよいし、複数の不揮発性の記憶装置を備えてもよい。   The HDD 103 is a non-volatile storage device that stores an OS (Operating System), software programs such as middleware and application software, and data. The program includes an analysis program. Note that the program analysis device 100 may include other types of storage devices such as a flash memory and an SSD (Solid State Drive), or may include a plurality of nonvolatile storage devices.

画像信号処理部104は、プロセッサ101からの命令に従って、プログラム分析装置100に接続されたディスプレイ111に画像を出力する。ディスプレイ111としては、CRT(Cathode Ray Tube)ディスプレイ、液晶ディスプレイ(LCD:Liquid Crystal Display)、プラズマディスプレイ、有機EL(OEL:Organic Electro-Luminescence)ディスプレイなど、任意の種類のディスプレイを用いることができる。   The image signal processing unit 104 outputs an image to the display 111 connected to the program analysis apparatus 100 in accordance with an instruction from the processor 101. As the display 111, any type of display such as a CRT (Cathode Ray Tube) display, a liquid crystal display (LCD), a plasma display, an organic EL (OEL: Organic Electro-Luminescence) display, or the like can be used.

入力信号処理部105は、プログラム分析装置100に接続された入力デバイス112から入力信号を取得し、プロセッサ101に出力する。入力デバイス112としては、マウスやタッチパネルやタッチパッドやトラックボールなどのポインティングデバイス、キーボード、リモートコントローラ、ボタンスイッチなどを用いることができる。また、プログラム分析装置100に、複数の種類の入力デバイスが接続されていてもよい。   The input signal processing unit 105 acquires an input signal from the input device 112 connected to the program analysis apparatus 100 and outputs it to the processor 101. As the input device 112, a mouse, a touch panel, a touch pad, a pointing device such as a trackball, a keyboard, a remote controller, a button switch, or the like can be used. A plurality of types of input devices may be connected to the program analysis apparatus 100.

媒体リーダ106は、記録媒体113に記録されたプログラムやデータを読み取る読み取り装置である。記録媒体113として、例えば、磁気ディスク、光ディスク、光磁気ディスク(MO:Magneto-Optical disk)、半導体メモリなどを使用できる。磁気ディスクには、フレキシブルディスク(FD:Flexible Disk)やHDDが含まれる。光ディスクには、CD(Compact Disc)やDVD(Digital Versatile Disc)が含まれる。   The medium reader 106 is a reading device that reads programs and data recorded on the recording medium 113. As the recording medium 113, for example, a magnetic disk, an optical disk, a magneto-optical disk (MO), a semiconductor memory, or the like can be used. Magnetic disks include flexible disks (FD: Flexible Disk) and HDDs. The optical disc includes a CD (Compact Disc) and a DVD (Digital Versatile Disc).

媒体リーダ106は、例えば、記録媒体113から読み取ったプログラムやデータを、RAM102やHDD103などの他の記録媒体にコピーする。読み取られたプログラムは、例えば、プロセッサ101によって実行される。なお、記録媒体113は、可搬型記録媒体であってもよく、プログラムやデータの配布に用いられることがある。また、記録媒体113やHDD103を、コンピュータ読み取り可能な記録媒体と言うことがある。   For example, the medium reader 106 copies a program or data read from the recording medium 113 to another recording medium such as the RAM 102 or the HDD 103. The read program is executed by the processor 101, for example. The recording medium 113 may be a portable recording medium and may be used for distributing programs and data. In addition, the recording medium 113 and the HDD 103 may be referred to as computer-readable recording media.

通信インタフェース107は、ネットワーク114に接続され、ネットワーク114を介して他の装置と通信を行うインタフェースである。通信インタフェース107は、スイッチなどの通信装置とケーブルで接続される有線通信インタフェースでもよいし、基地局と無線リンクで接続される無線通信インタフェースでもよい。   The communication interface 107 is an interface that is connected to the network 114 and communicates with other devices via the network 114. The communication interface 107 may be a wired communication interface connected to a communication device such as a switch via a cable, or may be a wireless communication interface connected to a base station via a wireless link.

次に、シンボリック実行によるプログラムの分析について説明する。
図3は、プログラムの第1の例を示す図である。
プログラム141は、分析対象のプログラムの一例である。プログラム141は、変数「性別」の値として2文字の文字列を受け取り、変数「出力」の値として1文字を出力する。プログラム141は、14行目に1つ目の条件分岐文を含み、19行目に2つ目の条件分岐文を含む。14行目の条件分岐文では、変数「性別」の値が「男性」であるか判定される。変数「性別」の値が「男性」である場合には変数「出力」の値が「M」に更新され、そうでない場合には変数「出力」の値が「 」(空白)に更新される。また、19行目の条件分岐文では、変数「性別」の値が「女性」であるか判定される。変数「性別」の値が「女性」である場合には変数「出力」の値が「F」に更新され、そうでない場合には変数「出力」の値は変化しない。そして、プログラム141が終了する。
Next, analysis of a program by symbolic execution will be described.
FIG. 3 is a diagram illustrating a first example of a program.
The program 141 is an example of a program to be analyzed. The program 141 receives a two-character string as the value of the variable “gender” and outputs one character as the value of the variable “output”. The program 141 includes the first conditional branch sentence on the 14th line and the second conditional branch sentence on the 19th line. In the conditional branch sentence on the 14th line, it is determined whether or not the value of the variable “sex” is “male”. If the value of the variable “gender” is “male”, the value of the variable “output” is updated to “M”; otherwise, the value of the variable “output” is updated to “” (blank). . In the conditional branch sentence on the 19th line, it is determined whether the value of the variable “gender” is “female”. If the value of the variable “gender” is “female”, the value of the variable “output” is updated to “F”; otherwise, the value of the variable “output” does not change. Then, the program 141 ends.

プログラム141には3つの実行パスが存在する。変数「性別」の値に応じて、これら3つの実行パスのうちの何れか1つが実行される。変数「性別」の値が「男性」である場合、14行目の分岐条件はYESと判定され、19行目の分岐条件はNOと判定される。この実行パスでは、変数「出力」の値は「M」になる。変数「性別」の値が「女性」である場合、14行目の分岐条件はNOと判定され、19行目の分岐条件はYESと判定される。この実行パスでは、変数「出力」の値は「F」になる。変数「性別」の値が「男性」でも「女性」でもない場合、14行目の分岐条件と19行目の分岐条件の両方がNOと判定される。この実行パスでは、変数「出力」の値は「 」(空白)になる。   The program 141 has three execution paths. Any one of these three execution paths is executed according to the value of the variable “sex”. When the value of the variable “gender” is “male”, the branch condition on the 14th line is determined as YES, and the branch condition on the 19th line is determined as NO. In this execution path, the value of the variable “output” is “M”. When the value of the variable “gender” is “female”, the branch condition on the 14th line is determined as NO, and the branch condition on the 19th line is determined as YES. In this execution path, the value of the variable “output” is “F”. When the value of the variable “gender” is neither “male” nor “female”, it is determined that both the branch condition on the 14th line and the branch condition on the 19th line are NO. In this execution path, the value of the variable “output” is “” (blank).

プログラム141は直列の2つの条件分岐文を含むため、分岐条件の内容を無視すれば、実行パスの候補は4つ存在する。しかし、変数「性別」の値が「男性」であることと変数「性別」の値が「女性」であることは矛盾するため、14行目の分岐条件と19行目の分岐条件の両方がYESと判定されることはない。よって、4つの実行パスの候補のうち、実行される可能性のある有効な実行パスは3つである。   Since the program 141 includes two serial conditional branch statements, there are four execution path candidates if the contents of the branch condition are ignored. However, since the value of the variable “gender” is “male” and the value of the variable “gender” is “female”, both the branch condition on the 14th line and the branch condition on the 19th line are It is not determined as YES. Therefore, of the four execution path candidates, there are three effective execution paths that may be executed.

条件分岐文において、ある分岐方向(YES方向またはNO方向)に進むための条件を満たす変数の値が少なくとも1つ存在するとき、その分岐方向は「充足可能である」と言うことがある。一方、ある分岐方向に進むための条件を満たす変数の値が存在しないとき、その分岐方向は「充足可能でない」と言うことがある。   In a conditional branch sentence, when there is at least one variable value that satisfies a condition for proceeding in a certain branch direction (YES direction or NO direction), the branch direction may be said to be “satisfiable”. On the other hand, when there is no value of a variable that satisfies the condition for proceeding in a certain branch direction, the branch direction may be said to be “not satisfiable”.

プログラム141において、14行目の条件分岐文では変数「性別」の値は制約されていないため、2つの分岐方向は共に充足可能である。一方、19行目の条件分岐文における充足可能性は、14行目の条件分岐文で選択した分岐方向に依存する。14行目のYES方向を選択した場合、19行目のYES方向は充足可能でなくなりNO方向のみ充足可能となる。14行目のNO方向を選択した場合、19行目の2つの分岐方向は共に充足可能である。よって、有効な実行パスは3つであると判断できる。   In the program 141, the value of the variable “gender” is not constrained in the conditional branch statement on the 14th line, so that both of the two branch directions can be satisfied. On the other hand, the satisfiability in the conditional branch sentence on the 19th line depends on the branch direction selected in the conditional branch sentence on the 14th line. When the 14th line YES direction is selected, the 19th line YES direction is no longer satisfiable and only the NO direction can be satisfied. When the NO direction on the 14th row is selected, both of the two branch directions on the 19th row can be satisfied. Therefore, it can be determined that there are three effective execution paths.

ここで、プログラム141をシンボリック実行する例を説明する。プログラム分析装置100は、プログラム141に対する入力を示す変数「性別」に、具体的な文字ではなく任意の定数を示す抽象的なシンボル(記号値)を割り当てる。ここでは、変数名と同じ「性別」をシンボルとして用いる。プログラム分析装置100は、シンボルを用いてプログラム141の命令を擬似的に実行していく。   Here, an example in which the program 141 is symbolically executed will be described. The program analysis apparatus 100 assigns an abstract symbol (symbol value) indicating an arbitrary constant instead of a specific character to the variable “gender” indicating the input to the program 141. Here, the same “sex” as the variable name is used as a symbol. The program analysis apparatus 100 executes instructions of the program 141 in a pseudo manner using symbols.

プログラム141の始点から14行目の条件分岐文の前までは、実行パスの分岐は存在しない。14行目の条件分岐文について、この時点ではその実行パスが選択される条件(パス条件)は存在せず、2つの分岐方向は共に充足可能である。よって、プログラム分析装置100は、14行目の条件分岐文において実行パスを分割し、一方の実行パスを選択する。ここでは、プログラム分析装置100はYES方向の実行パスを選択したとする。   There is no execution path branch from the start point of the program 141 to the conditional branch statement on the 14th line. For the conditional branch statement on the 14th line, there is no condition (path condition) for selecting the execution path at this point, and both of the two branch directions can be satisfied. Therefore, the program analysis apparatus 100 divides the execution path in the conditional branch statement on the 14th line and selects one execution path. Here, it is assumed that the program analysis apparatus 100 has selected an execution path in the YES direction.

次に、19行目の条件分岐文について、この時点におけるパス条件はシンボル「性別」が「男性」であることであるため、YES方向は充足可能でなくNO方向は充足可能である。よって、プログラム分析装置100はNO方向を選択する。その後、この1番目の実行パスは終了する。プログラム分析装置100は、1番目の実行パスのパス条件を、シンボル「性別」が「男性」でありかつシンボル「性別」が「女性」でないと判定する。また、プログラム分析装置100は、1番目の実行パスの処理結果(パス出力)を、変数「出力」の値が「M」であると判定する。   Next, for the conditional branch sentence on the 19th line, the path condition at this point is that the symbol “sex” is “male”, so the YES direction cannot be satisfied and the NO direction can be satisfied. Therefore, the program analysis apparatus 100 selects the NO direction. Thereafter, the first execution path is terminated. The program analysis apparatus 100 determines that the path condition of the first execution path is that the symbol “sex” is “male” and the symbol “sex” is not “female”. Further, the program analysis apparatus 100 determines that the value of the variable “output” is “M” for the processing result (path output) of the first execution path.

1番目の実行パスが終了すると、プログラム分析装置100は、実行パスの直近の分割点まで戻り、未選択の実行パスを選択する。ここでは、プログラム分析装置100は、14行目の条件分岐文まで戻ってNO方向の実行パスを選択する。   When the first execution path ends, the program analysis apparatus 100 returns to the nearest division point of the execution path and selects an unselected execution path. Here, the program analysis apparatus 100 returns to the conditional branch statement on the 14th line and selects an execution path in the NO direction.

19行目の条件分岐文について、この時点におけるパス条件はシンボル「性別」が「男性」でないことであるため、YES方向とNO方向の何れも充足可能である。よって、プログラム分析装置100は、19行目の条件分岐文において実行パスを更に分割し、一方の実行パスを選択する。ここでは、プログラム分析装置100はYES方向の実行パスを選択したとする。その後、この2番目の実行パスは終了する。プログラム分析装置100は、2番目の実行パスのパス条件を、シンボル「性別」が「男性」でなくかつシンボル「性別」が「女性」であると判定する。また、プログラム分析装置100は、2番目の実行パスのパス出力を、変数「出力」の値が「F」であると判定する。   Regarding the conditional branch sentence on the 19th line, since the path condition at this point is that the symbol “sex” is not “male”, both the YES direction and the NO direction can be satisfied. Therefore, the program analysis apparatus 100 further divides the execution path in the conditional branch statement on the 19th line and selects one execution path. Here, it is assumed that the program analysis apparatus 100 has selected an execution path in the YES direction. Thereafter, this second execution path ends. The program analysis device 100 determines that the path condition of the second execution path is that the symbol “sex” is not “male” and the symbol “sex” is “female”. Further, the program analysis apparatus 100 determines that the value of the variable “output” is “F” for the path output of the second execution path.

2番目の実行パスが終了すると、プログラム分析装置100は、19行目の条件分岐文まで戻ってNO方向の実行パスを選択する。その後、この3番目の実行パスは終了する。プログラム分析装置100は、3番目の実行パスのパス条件を、シンボル「性別」が「男性」でなくかつシンボル「性別」が「女性」でないと判定する。また、プログラム分析装置100は、3番目の実行パスのパス出力を、変数「出力」の値が「 」(空白)であると判定する。そして、未選択の実行パスが存在しないためシンボリック実行が終了する。   When the second execution path ends, the program analysis apparatus 100 returns to the conditional branch statement on the 19th line and selects an execution path in the NO direction. Thereafter, the third execution path ends. The program analysis apparatus 100 determines that the path condition of the third execution path is that the symbol “sex” is not “male” and the symbol “sex” is not “female”. Further, the program analysis apparatus 100 determines that the output of the third execution path is “” (blank) as the value of the variable “output”. Then, since there is no unselected execution path, the symbolic execution ends.

なお、プログラム分析装置100は、実行パスの分割点において、その時点のパス条件と各変数の値とを保存しておく。プログラム分析装置100は、1つの実行パスが終了して分割点までバックトラックしたとき、保存しておいたパス条件と各変数の値とを引き継いで、未選択の分岐方向に対応する他の実行パスの探索を続ける。   Note that the program analysis apparatus 100 stores the current path condition and the value of each variable at the division point of the execution path. When one execution path is finished and backtracking to the division point, the program analysis apparatus 100 takes over the saved path condition and the value of each variable, and performs another execution corresponding to the unselected branch direction. Continue searching for paths.

図4は、ロジックテーブルの第1の例を示す図である。
プログラム分析装置100は、プログラム141のシンボリック実行の結果として、ロジックテーブル142を生成する。プログラム分析装置100は、生成したロジックテーブル142を、プログラム分析装置100が備えるディスプレイに表示する。
FIG. 4 is a diagram illustrating a first example of a logic table.
The program analysis apparatus 100 generates the logic table 142 as a result of the symbolic execution of the program 141. The program analysis apparatus 100 displays the generated logic table 142 on a display included in the program analysis apparatus 100.

ロジックテーブル142は、プログラム141に対する入力とプログラム141からの出力との関係(ロジック)を示す。ロジックテーブル142は、パス番号、パス条件およびパス出力の項目を有する。パス番号の項目には、シンボリック実行によって検出された実行パスの識別番号が記載される。パス条件の項目には、実行パスが選択されるための入力の条件が記載される。パス出力の項目には、実行パスの終点における出力変数の値が記載される。パス条件およびパス出力は、シンボルを用いて表されることがある。   The logic table 142 shows the relationship (logic) between the input to the program 141 and the output from the program 141. The logic table 142 includes items of a pass number, a pass condition, and a pass output. In the path number item, an identification number of an execution path detected by symbolic execution is described. In the path condition item, an input condition for selecting an execution path is described. In the path output item, the value of the output variable at the end point of the execution path is described. The path condition and path output may be expressed using symbols.

前述のように、1番目の実行パスのパス条件は、「性別が男性である」かつ「性別が女性でない」ことである。これは、「性別が男性である」と簡約化できる。1番目の実行パスのパス出力は、「出力がMである」ことである。2番目の実行パスのパス条件は、「性別が男性でない」かつ「性別が女性である」ことである。これは、「性別が女性である」と簡約化できる。2番目の実行パスのパス出力は、「出力がFである」ことである。3番目の実行パスのパス条件は、「性別が男性でない」かつ「性別が女性でない」ことである。3番目の実行パスのパス出力は、「出力が空白である」ことである。   As described above, the pass condition of the first execution pass is “gender is male” and “gender is not female”. This can be simplified as “gender is male”. The path output of the first execution path is “output is M”. The pass condition of the second execution pass is “gender is not male” and “gender is female”. This can be simplified as “gender is female”. The path output of the second execution path is “output is F”. The pass condition of the third execution pass is “gender is not male” and “gender is not female”. The path output of the third execution path is “output is blank”.

なお、条件分岐文における充足可能性の判断やパス条件の簡約化には、数式処理技術を利用することができる。プログラム分析装置100は、SMT(Satisfiability Modulo Theories)ソルバやSAT(Satisfiability)ソルバを用いてもよい。パス条件は、例えば、シンボルを含む式をシンボルについて解くことで簡約化できる。   It should be noted that mathematical expression processing techniques can be used to determine the satisfiability of conditional branch sentences and to simplify path conditions. The program analysis apparatus 100 may use an SMT (Satisfiability Modulo Theories) solver or an SAT (Satisfiability) solver. The path condition can be simplified, for example, by solving an expression including the symbol for the symbol.

次に、シンボリック実行におけるパス爆発について説明する。
図5は、プログラムの第2の例を示す図である。
プログラム121は、プログラム141とは異なる分析対象のプログラムの例である。プログラム121は、「入力1」の値として10進数3桁以下の数値を受け取り、「出力1」の値として10進数3桁以下の数値を出力する。プログラム121は、セクションAとセクションBという2つのモジュールを含む。また、プログラム121は、「変数1」という変数を含む。「変数1」は、セクションAとセクションBの両方から参照および更新を行うことができるグローバル変数である。
Next, path explosion in symbolic execution will be described.
FIG. 5 is a diagram illustrating a second example of the program.
The program 121 is an example of an analysis target program different from the program 141. The program 121 receives a numerical value of 3 decimal digits or less as the value of “input 1”, and outputs a numerical value of 3 decimal digits or less as the value of “output 1”. The program 121 includes two modules, section A and section B. The program 121 includes a variable “variable 1”. “Variable 1” is a global variable that can be referenced and updated from both section A and section B.

プログラム121は、受け取った「入力1」の値を「変数1」に代入してセクションAを呼び出す。プログラム121は、セクションAが終了すると「変数1」の値を「出力1」に代入する。そして、プログラム121の処理が終了する。   The program 121 assigns the received value of “input 1” to “variable 1” and calls section A. When section A ends, program 121 assigns the value of “variable 1” to “output 1”. Then, the process of the program 121 ends.

セクションAは、17行目と25行目に条件分岐文を含み、23行目にセクションBを呼び出す呼び出し文を含む。セクションAは、セクションAの外部から与えられる「変数1」の値を使用する。セクションAは、「変数1」の値が10より大きい場合には「変数1」の値を1増加させ、「変数1」の値が10以下である場合には「変数1」の値を1減少させる。次に、セクションAはセクションBを呼び出す。セクションBを呼び出すPERFORM文には、戻り値を格納する変数が明記されていない。このため、セクションBによって「変数1」の値が更新されているか否かは、セクションAの命令文のみからでは不明である。すなわち、PERFORM文では、呼び出し先のセクションの作用は不明となる。その後、セクションAは、「変数1」の値が30より小さい場合には「変数1」の値を3増加させ、「変数1」の値が30以上である場合には「変数1」の値を3減少させる。そして、セクションAの処理が終了する。   Section A includes conditional branch statements on the 17th and 25th lines, and a call statement that calls section B on the 23rd line. Section A uses the value of “variable 1” given from the outside of section A. Section A increments the value of “variable 1” by 1 when the value of “variable 1” is greater than 10, and increments the value of “variable 1” by 1 when the value of “variable 1” is 10 or less. Decrease. Next, section A calls section B. The PERFORM statement that calls section B does not specify a variable for storing the return value. For this reason, whether or not the value of “variable 1” is updated by section B is unknown only from the statement of section A. That is, in the PERFORM statement, the action of the called section is unknown. After that, section A increases the value of “variable 1” by 3 when the value of “variable 1” is smaller than 30, and the value of “variable 1” when the value of “variable 1” is 30 or more. Is reduced by 3. Then, the processing of section A ends.

セクションBは、34行目に条件分岐文を含む。セクションBは、セクションBの外部から与えられる「変数1」の値を使用する。セクションBは、「変数1」の値が20より大きい場合には「変数1」の値を2増加させ、「変数1」の値が20以下である場合には「変数1」の値を2減少させる。そして、セクションBの処理が終了する。   Section B includes a conditional branch statement on the 34th line. Section B uses the value of “variable 1” given from the outside of section B. Section B increases the value of “Variable 1” by 2 when the value of “Variable 1” is greater than 20, and increases the value of “Variable 1” by 2 when the value of “Variable 1” is 20 or less. Decrease. Then, the processing of section B ends.

プログラム分析装置100は、シンボリック実行によって分析する分析範囲を、1つのプログラム全体ではなく、一部のセクションなどプログラム内の一部のモジュールに限定することもできる。これにより、シンボリック実行の計算量を削減することができる。分析範囲は、プログラム分析装置100のユーザが指定することができる。プログラム121については、セクションAを分析範囲に指定することを考える。ただし、ここでは、セクションAの呼び出し先についても連続して実行パスを辿るものとする。   The program analysis apparatus 100 can also limit the analysis range to be analyzed by symbolic execution to some modules in the program, such as some sections, instead of the entire one program. Thereby, the calculation amount of symbolic execution can be reduced. The analysis range can be specified by the user of the program analysis apparatus 100. Regarding the program 121, it is considered that section A is designated as the analysis range. However, here, it is assumed that the call destination of section A also continuously follows the execution path.

セクションAは2つの条件分岐文を含み、セクションBは1つの条件分岐文を含む。よって、セクションAとセクションBに跨がる実行パスの候補は、8つ存在する。ただし、以下に説明するように、有効な実行パスはそのうち4つである。   Section A includes two conditional branch statements, and section B includes one conditional branch statement. Therefore, there are eight execution path candidates that span section A and section B. However, as will be described below, there are four effective execution paths.

プログラム分析装置100は、セクションAの入力が格納される「変数1」にシンボル「変数1_A」を割り当てる。17行目において変数1_Aは制約されていないため、2つの分岐方向は何れも充足可能である。プログラム分析装置100は、YES方向を選択し、「変数1」の値を変数1_A+1に更新する。次に、34行目においてパス条件は変数1_Aが10より大きいことであるため、2つの分岐方向は何れも充足可能である。プログラム分析装置100は、YES方向を選択し、「変数1」の値を変数1_A+1+2=変数1_A+3に更新する。次に、25行目においてパス条件は変数1_Aが10より大きくかつ変数1_A+1が20より大きいことであるため、2つの分岐方向は何れも充足可能である。プログラム分析装置100は、YES方向を選択し、「変数1」の値を変数1_A+1+2+3=変数1_A+6に更新する。   The program analysis apparatus 100 assigns the symbol “variable 1_A” to “variable 1” in which the input of section A is stored. Since the variable 1_A is not restricted in the 17th line, both of the two branch directions can be satisfied. The program analysis apparatus 100 selects the YES direction and updates the value of “variable 1” to the variable 1_A + 1. Next, in the 34th line, since the path condition is that the variable 1_A is larger than 10, both of the two branch directions can be satisfied. The program analysis apparatus 100 selects the YES direction, and updates the value of “variable 1” to variable 1_A + 1 + 2 = variable 1_A + 3. Next, in the 25th line, since the path condition is that the variable 1_A is larger than 10 and the variable 1_A + 1 is larger than 20, both of the two branch directions can be satisfied. The program analysis apparatus 100 selects the YES direction and updates the value of “variable 1” to variable 1_A + 1 + 2 + 3 = variable 1_A + 6.

これにより、1番目の実行パスが終了する。1番目の実行パスのパス条件は、変数1_Aが10より大きく、変数1_A+1が20より大きくかつ変数1_A+1+2が30より小さいことである。すなわち、1番目の実行パスのパス条件は、変数1_Aが19より大きく27より小さいことである。また、1番目の実行パスのパス出力は、「変数1」の値が変数1_A+6であることである。   As a result, the first execution path ends. The path condition of the first execution path is that the variable 1_A is larger than 10, the variable 1_A + 1 is larger than 20, and the variable 1_A + 1 + 2 is smaller than 30. That is, the path condition of the first execution path is that the variable 1_A is greater than 19 and less than 27. The path output of the first execution path is that the value of “variable 1” is variable 1_A + 6.

同様にして、プログラム分析装置100は、プログラム121から残りの3つの実行パスを検出する。2番目の実行パスは、17行目のYES方向と34行目のYES方向と25行目のNO方向を選択したものである。よって、2番目の実行パスのパス条件は、変数1_Aが10より大きく、変数1_A+1が20より大きくかつ変数1_A+1+2が30以上であることである。すなわち、2番目の実行パスのパス条件は、変数1_Aが27以上であることである。また、2番目の実行パスのパス出力は、「変数1」の値が変数1_A+1+2−3=変数1_Aであることである。   Similarly, the program analysis apparatus 100 detects the remaining three execution paths from the program 121. The second execution path is obtained by selecting the YES direction on the 17th line, the YES direction on the 34th line, and the NO direction on the 25th line. Therefore, the path condition of the second execution path is that the variable 1_A is larger than 10, the variable 1_A + 1 is larger than 20, and the variable 1_A + 1 + 2 is 30 or more. That is, the path condition of the second execution path is that the variable 1_A is 27 or more. The path output of the second execution path is that the value of “variable 1” is variable 1_A + 1 + 2−3 = variable 1_A.

3番目の実行パスは、17行目のYES方向と34行目のNO方向と25行目のYES方向を選択したものである。よって、3番目の実行パスのパス条件は、変数1_Aが10より大きく、変数1_A+1が20以下でありかつ変数1_A+1−2が30より小さいことである。すなわち、3番目の実行パスのパス条件は、変数1_Aが10より大きく19以下であることである。また、3番目の実行パスのパス出力は、「変数1」の値が変数1_A+1−2+3=変数1_A+2であることである。   The third execution path is obtained by selecting the 17th line YES direction, the 34th line NO direction, and the 25th line YES direction. Therefore, the path condition of the third execution path is that the variable 1_A is larger than 10, the variable 1_A + 1 is 20 or less, and the variable 1_A + 1−2 is smaller than 30. That is, the path condition of the third execution path is that the variable 1_A is greater than 10 and 19 or less. The path output of the third execution path is that the value of “variable 1” is variable 1_A + 1−2 + 3 = variable 1_A + 2.

4番目の実行パスは、17行目のNO方向と34行目のNO方向と25行目のYES方向を選択したものである。よって、4番目の実行パスのパス条件は、変数1_Aが10以下であり、変数1_A−1が20以下でありかつ変数1_A−1−2が30より小さいことである。すなわち、4番目の実行パスのパス条件は、変数1_Aが10以下であることである。また、4番目の実行パスのパス出力は、「変数1」の値が変数1_A−1−2+3=変数1_Aであることである。他の分岐方向の組み合わせは充足可能でない。   The fourth execution path is obtained by selecting the NO direction on the 17th line, the NO direction on the 34th line, and the YES direction on the 25th line. Therefore, the path condition of the fourth execution path is that the variable 1_A is 10 or less, the variable 1_A-1 is 20 or less, and the variable 1_A-1-2 is smaller than 30. That is, the path condition of the fourth execution path is that the variable 1_A is 10 or less. The path output of the fourth execution path is that the value of “variable 1” is variable 1_A-1-2 + 3 = variable 1_A. Other combinations of branch directions are not satisfiable.

図6は、ロジックテーブルの第2の例を示す図である。
プログラム分析装置100は、上記のシンボリック実行の結果として、ロジックテーブル129を生成する。プログラム分析装置100は、生成したロジックテーブル129を、プログラム分析装置100が備えるディスプレイに表示する。
FIG. 6 is a diagram illustrating a second example of the logic table.
The program analysis apparatus 100 generates the logic table 129 as a result of the above symbolic execution. The program analysis apparatus 100 displays the generated logic table 129 on a display included in the program analysis apparatus 100.

ロジックテーブル129は、分析範囲であるセクションAに対する入力とセクションAからの出力との関係を示す。ロジックテーブル129は、ロジックテーブル142と同様にパス番号、パス条件およびパス出力の項目を有する。ロジックテーブル129には、検出された4つの実行パスのロジックが記載される。パス条件やパス出力は、簡約化されて表示されてもよいし簡約化せずに表示されてもよい。図6では、簡約化前のパス条件およびパス出力と簡約化後のパス条件およびパス出力の両方を表示している。   The logic table 129 shows the relationship between the input to the section A that is the analysis range and the output from the section A. Similar to the logic table 142, the logic table 129 includes items of a pass number, a pass condition, and a pass output. The logic table 129 describes the logic of the four detected execution paths. The pass condition and the pass output may be displayed with simplification or may be displayed without simplification. In FIG. 6, both the path condition and path output before simplification and the path condition and path output after simplification are displayed.

ところで、上記のシンボリック実行の例では、分析範囲であるセクションAと呼び出し先であるセクションBとに跨がる実行パスを直接検出した。しかし、このシンボリック実行の方法では、条件分岐文の増加に応じて検出される実行パスが指数関数的に増加するというパス爆発の問題が生じる。一方、呼び出し文を無視してセクションAのみを分析しても、セクションAのロジックを正しく分析したことにはならない。セクションAが使用する「変数1」の値をセクションBが更新するためである。そこで、プログラム分析装置100は、次のような方法でシンボリック実行を行う。   By the way, in the example of the symbolic execution described above, an execution path straddling the section A as the analysis range and the section B as the call destination is directly detected. However, this symbolic execution method causes a path explosion problem that the number of execution paths detected increases exponentially with the increase in conditional branch statements. On the other hand, ignoring the call statement and analyzing only section A does not correctly analyze the logic of section A. This is because section B updates the value of “variable 1” used by section A. Therefore, the program analysis apparatus 100 performs symbolic execution by the following method.

図7は、シンボリック実行の分割と部分ロジックの結合の例を示す図である。
プログラム分析装置100は、分析範囲であるセクションAのシンボリック実行と呼び出し先であるセクションBのシンボリック実行とを分割して独立に行う。セクションAにN個の条件分岐文が含まれ、セクションBにM個の条件分岐文が含まれる場合、分割しないシンボリック実行の計算量は2N+Mとなる。一方、分割したシンボリック実行の計算量は2N+2Mとなり、分割しない場合よりも計算量が小さくなる。プログラム分析装置100は、セクションAのシンボリック実行によって取得される部分ロジックとセクションBのシンボリック実行によって取得される部分ロジックとを事後的に結合する。
FIG. 7 is a diagram illustrating an example of symbolic execution division and partial logic combination.
The program analysis apparatus 100 divides the symbolic execution of section A, which is the analysis range, and the symbolic execution of section B, which is the call destination, independently. If section A contains N conditional branch statements and section B contains M conditional branch statements, the amount of calculation for symbolic execution without division is 2 N + M. On the other hand, the calculation amount of the divided symbolic execution is 2 N +2 M , and the calculation amount is smaller than the case of not dividing. The program analysis apparatus 100 subsequently combines the partial logic acquired by the symbolic execution of section A and the partial logic acquired by the symbolic execution of section B.

具体的には、プログラム分析装置100は、セクションAの入力を格納する「変数1」にシンボル「X」を割り当て、セクションAのシンボリック実行を開始する。プログラム分析装置100は、セクションBを呼び出す呼び出し文の直前において途中点ロジックを保存しておく。呼び出し文の直前では、パス出力が変数1=X+1であるロジックと、パス出力が変数1=X−1であるロジックとが検出されている。   Specifically, the program analysis apparatus 100 assigns the symbol “X” to “variable 1” that stores the input of section A, and starts symbolic execution of section A. The program analysis apparatus 100 stores the midpoint logic immediately before the call statement that calls the section B. Immediately before the call statement, a logic whose path output is variable 1 = X + 1 and a logic whose path output is variable 1 = X−1 are detected.

次に、プログラム分析装置100は、セクションAのシンボリック実行において、呼び出し文は実行せずにセクションBをスタブ化する。スタブ化において、プログラム分析装置100は、セクションBによって更新される可能性のある更新変数に、シンボル「X」とは独立なシンボルを割り当てる。更新変数は、予めセクションBの命令文を走査することで検索することができる。ここでは、プログラム分析装置100は、「変数1」にシンボル「Z」を割り当てる。プログラム分析装置100は、シンボル「Z」を用いてセクションAのシンボリック実行を継続し、セクションAの終点において終点ロジックを保存する。セクションAの終点では、パス出力が変数1=Z+3であるロジックと、パス出力が変数1=Z−3であるロジックとが検出されている。   Next, in the symbolic execution of section A, program analysis apparatus 100 stubs section B without executing the call statement. In stubbing, the program analysis apparatus 100 assigns a symbol independent of the symbol “X” to an update variable that may be updated by the section B. The update variable can be retrieved by scanning the command statement in section B in advance. Here, the program analysis apparatus 100 assigns the symbol “Z” to “variable 1”. The program analysis apparatus 100 continues symbolic execution of section A using the symbol “Z” and stores the end point logic at the end point of section A. At the end point of section A, a logic whose path output is variable 1 = Z + 3 and a logic whose path output is variable 1 = Z-3 are detected.

また、プログラム分析装置100は、セクションBの入力を格納する「変数1」にシンボル「Y」を割り当て、セクションBのシンボリック実行を開始する。プログラム分析装置100は、セクションBの終点において呼び出し先ロジックを保存する。セクションBの終点では、パス出力が変数1=Y+2であるロジックと、パス出力が変数1=Y−2であるロジックとが検出されている。   Further, the program analysis apparatus 100 assigns the symbol “Y” to “variable 1” that stores the input of section B, and starts symbolic execution of section B. The program analysis apparatus 100 stores the callee logic at the end of section B. At the end point of section B, the logic whose path output is variable 1 = Y + 2 and the logic whose path output is variable 1 = Y−2 are detected.

そして、プログラム分析装置100は、途中点ロジックと終点ロジックと呼び出し先ロジックとを結合して、セクションAとセクションBに跨がるロジックを再現する。プログラム分析装置100は、途中点ロジックが示すパス出力とセクションBの入力を示すシンボル「Y」とを対応付ける。また、プログラム分析装置100は、呼び出し先ロジックが示すパス出力とセクションBのスタブ化に使用したシンボル「Z」とを対応付ける。図7のパス候補テーブル143に示すように、途中点ロジックと終点ロジックと呼び出し先ロジックの組み合わせの候補は8通り存在する。   Then, the program analysis apparatus 100 combines the midpoint logic, the end point logic, and the call destination logic, and reproduces the logic straddling the section A and the section B. The program analysis apparatus 100 associates the path output indicated by the midpoint logic with the symbol “Y” indicating the input of section B. Further, the program analysis apparatus 100 associates the path output indicated by the callee logic with the symbol “Z” used for the section B stubbing. As shown in the path candidate table 143 in FIG. 7, there are eight combinations of combinations of midpoint logic, end point logic, and call destination logic.

すなわち、変数1=X+1と変数1=Y+2と変数1=Z+3との組み合わせから、変数1=X+1+2+3というパス出力が考えられる。変数1=X+1と変数1=Y+2と変数1=Z−3との組み合わせから、変数1=X+1+2−3というパス出力が考えられる。変数1=X+1と変数1=Y−2と変数1=Z+3との組み合わせから、変数1=X+1−2+3というパス出力が考えられる。変数1=X+1と変数1=Y−2と変数1=Z−3との組み合わせから、変数1=X+1−2−3というパス出力が考えられる。   That is, a path output of variable 1 = X + 1 + 2 + 3 can be considered from a combination of variable 1 = X + 1, variable 1 = Y + 2, and variable 1 = Z + 3. From the combination of variable 1 = X + 1, variable 1 = Y + 2, and variable 1 = Z−3, a path output of variable 1 = X + 1 + 2−3 can be considered. From the combination of variable 1 = X + 1, variable 1 = Y−2, and variable 1 = Z + 3, a path output of variable 1 = X + 1−2 + 3 can be considered. From the combination of variable 1 = X + 1, variable 1 = Y-2, and variable 1 = Z-3, a path output of variable 1 = X + 1-2-3 can be considered.

変数1=X−1と変数1=Y+2と変数1=Z+3との組み合わせから、変数1=X−1+2+3というパス出力が考えられる。変数1=X−1と変数1=Y+2と変数1=Z−3との組み合わせから、変数1=X−1+2−3というパス出力が考えられる。変数1=X−1と変数1=Y−2と変数1=Z+3との組み合わせから、変数1=X−1−2+3というパス出力が考えられる。変数1=X−1と変数1=Y−2と変数1=Z−3との組み合わせから、変数1=X−1−2−3というパス出力が考えられる。   From the combination of variable 1 = X−1, variable 1 = Y + 2, and variable 1 = Z + 3, a path output of variable 1 = X−1 + 2 + 3 can be considered. From the combination of variable 1 = X−1, variable 1 = Y + 2 and variable 1 = Z−3, a path output of variable 1 = X−1 + 2−3 can be considered. From the combination of variable 1 = X-1, variable 1 = Y-2, and variable 1 = Z + 3, a path output of variable 1 = X-1-2 + 3 can be considered. From the combination of variable 1 = X-1, variable 1 = Y-2, and variable 1 = Z-3, a path output of variable 1 = X-1-2-3 can be considered.

ただし、前述のように、上記の8通りのロジックの全てが有効であるわけではない。プログラム分析装置100は、途中点ロジックと終点ロジックと呼び出し先ロジックの組み合わせのうち、パス条件が矛盾しない組み合わせのみを選択する。すなわち、プログラム分析装置100は、途中点ロジックのパス条件と終点ロジックのパス条件と呼び出し先ロジックのパス条件とを結合し、結合したパス条件が充足可能であるか判定する。   However, as described above, not all of the above eight logics are valid. The program analysis apparatus 100 selects only combinations in which path conditions do not contradict each other from combinations of midpoint logic, end point logic, and call destination logic. That is, the program analysis apparatus 100 combines the path condition of the midpoint logic, the path condition of the end point logic, and the path condition of the callee logic, and determines whether the combined path condition can be satisfied.

次に、シンボリック実行の分割と部分ロジックの結合の手順について説明する。
図8は、更新変数テーブルとシンボル割り当てテーブルの例を示す図である。
プログラム分析装置100は、分析範囲から、PERFORM文のように作用の記載がない呼び出し文(作用が不明な呼び出し文)を検出する。プログラム分析装置100は、検出した呼び出し文によって呼び出されるモジュールから更新変数を検索し、更新変数テーブル122を生成する。更新変数テーブル122は、モジュール名および更新変数の項目を有する。モジュール名の項目には、セクション名などのモジュール識別情報が記載される。更新変数の項目には、呼び出し先のモジュール内で値が更新される変数の変数名が記載される。更新変数は、1つのモジュールにつき2以上存在することもある。更新変数は、例えば、代入式の左辺やMOVE文の第2引数に記載された変数である。
Next, the procedure for dividing symbolic execution and combining partial logic will be described.
FIG. 8 is a diagram illustrating an example of an update variable table and a symbol allocation table.
The program analysis apparatus 100 detects a call sentence (a call sentence with an unknown action) that does not have an action description, such as a PERFORM statement, from the analysis range. The program analysis apparatus 100 searches for an update variable from the module called by the detected call statement, and generates an update variable table 122. The update variable table 122 has items of module name and update variable. Module identification information such as a section name is described in the module name item. In the update variable item, the variable name of the variable whose value is updated in the called module is described. There may be two or more update variables per module. The update variable is, for example, a variable described in the left side of the assignment expression or the second argument of the MOVE statement.

プログラム分析装置100は、シンボリック実行の途中で作用の記載がない呼び出し文を検出すると、更新変数テーブル122に記載された更新変数にシンボルを割り当てる。プログラム分析装置100は、シンボル割り当てテーブル123を生成する。シンボル割り当てテーブル123は、変数名およびシンボルの項目を有する。変数名の項目には、更新変数の変数名が記載される。シンボルの項目には、呼び出し文の直後に更新変数に割り当てられたシンボルが記載される。一例として、更新変数に割り当てられるシンボルは、変数名、呼び出し文がPERFORM文であることを示す文字列、呼び出し文の行番号、呼び出し先モジュールの名称、その呼び出し文の実行回数を連結したものである。よって、例えば、プログラム121の23行目の通過直後、「変数1」にシンボル「変数1_Perform_23_セクションB_1」が割り当てられる。   When the program analysis apparatus 100 detects a call statement with no description of an action in the middle of symbolic execution, the program analysis apparatus 100 assigns a symbol to the update variable described in the update variable table 122. The program analysis apparatus 100 generates a symbol allocation table 123. The symbol assignment table 123 has items of variable names and symbols. The variable name item describes the variable name of the update variable. In the symbol item, a symbol assigned to the update variable is described immediately after the call statement. As an example, a symbol assigned to an update variable is a concatenation of a variable name, a character string indicating that the calling statement is a PERFORM statement, the line number of the calling statement, the name of the called module, and the number of executions of the calling statement. is there. Thus, for example, immediately after passing through the 23rd line of the program 121, the symbol “variable 1_Perform — 23_section B_1” is assigned to “variable 1”.

図9は、階層的な更新変数の抽出例を示す図である。
分析範囲から呼び出されたモジュールが更に他のモジュールを呼び出している場合、更新変数は階層的に検索される。ここでは、分析範囲がセクション144であり、セクション144からセクション144a(セクションA1)とセクション144b(セクションB1)が呼び出され、セクション144bからセクション144c(セクションB2)が呼び出されるとする。セクション144aは、変数「a11」,「a12」を更新する。セクション144bは、変数「b11」,「b12」を更新する。セクション144cは、変数「b21」を更新する。この場合、プログラム分析装置100は、更新変数テーブル122に対応する更新変数テーブル145を生成する。
FIG. 9 is a diagram illustrating an example of extracting hierarchical update variables.
When a module called from the analysis range calls another module, the update variable is searched hierarchically. Here, it is assumed that the analysis range is the section 144, the section 144a (section A1) and the section 144b (section B1) are called from the section 144, and the section 144c (section B2) is called from the section 144b. The section 144a updates the variables “a11” and “a12”. The section 144b updates the variables “b11” and “b12”. Section 144c updates the variable “b21”. In this case, the program analysis apparatus 100 generates an update variable table 145 corresponding to the update variable table 122.

プログラム分析装置100は、セクション144からセクション144aを辿り、セクション144の1つ目の呼び出し文について変数「a11」,「a12」を更新変数として検出する。プログラム分析装置100は、セクション144aと変数「a11」,「a12」とを対応付けて更新変数テーブル145に登録する。また、プログラム分析装置100は、セクション144からセクション144b,144cを辿り、セクション144の2つ目の呼び出し文について変数「b11」,「b12」,「b21」を更新変数として検出する。プログラム分析装置100は、セクション144bと変数「b11」,「b12」,「b21」とを対応付けて更新変数テーブル145に登録する。   The program analysis apparatus 100 traces the section 144a from the section 144, and detects the variables “a11” and “a12” as update variables for the first call statement of the section 144. The program analysis apparatus 100 registers the section 144a and the variables “a11” and “a12” in the update variable table 145 in association with each other. The program analysis apparatus 100 traces the sections 144b and 144c from the section 144, and detects the variables “b11”, “b12”, and “b21” as update variables for the second call statement of the section 144. The program analysis apparatus 100 associates the section 144b with the variables “b11”, “b12”, and “b21” and registers them in the update variable table 145.

図10は、途中点と呼び出し先と終点のロジックテーブルの例を示す図である。
プログラム分析装置100は、シンボリック実行によって途中点ロジックテーブル124、呼び出し先ロジックテーブル125および終点ロジックテーブル126を生成する。
FIG. 10 is a diagram illustrating an example of a logic table of intermediate points, call destinations, and end points.
The program analysis apparatus 100 generates the midpoint logic table 124, the callee logic table 125, and the end point logic table 126 by symbolic execution.

途中点ロジックテーブル124は、パス番号、パス条件およびパス出力の項目を有する。パス番号の項目には、呼び出し元モジュールの呼び出し文の前までに検出されたロジックの識別番号が記載される。パス条件の項目には、呼び出し文の直前におけるパス条件が記載される。パス出力の項目には、呼び出し文の直前における変数の値が記載される。途中点ロジックテーブル124のパス条件およびパス出力には、呼び出し元モジュールの入力に割り当てられたシンボルを用いることができる。   The midpoint logic table 124 includes items of a pass number, a pass condition, and a pass output. In the item of the pass number, the identification number of the logic detected before the call statement of the caller module is described. In the path condition item, the path condition immediately before the call statement is described. In the path output item, the value of the variable immediately before the call statement is described. For the path condition and path output of the midpoint logic table 124, a symbol assigned to the input of the calling module can be used.

プログラム121について、途中点ロジックテーブル124には、パス条件が「変数1_Aが10より大きい」、パス出力が「変数1=変数1_A+1」というロジックが登録される。また、途中点ロジックテーブル124には、パス条件が「変数1_Aが10以下」、パス出力が「変数1=変数1_A−1」というロジックが登録される。   For the program 121, the logic that the path condition is “variable 1_A is greater than 10” and the path output is “variable 1 = variable 1_A + 1” is registered in the midpoint logic table 124. Further, in the midpoint logic table 124, the logic that the path condition is “variable 1_A is 10 or less” and the path output is “variable 1 = variable 1_A-1” is registered.

呼び出し先ロジックテーブル125は、パス番号、パス条件およびパス出力の項目を有する。パス番号の項目には、呼び出し先モジュールの始点から終点の間に検出されたロジックの識別番号が記載される。パス条件の項目には、呼び出し先モジュールの終点におけるパス条件が記載される。パス出力の項目には、呼び出し先モジュールの終点における変数の値が記載される。呼び出し先ロジックテーブル125のパス条件およびパス出力には、呼び出し先モジュールの入力に割り当てられたシンボルを用いることができる。   The callee logic table 125 includes items of a pass number, a pass condition, and a pass output. In the path number item, an identification number of the logic detected between the start point and the end point of the called module is described. In the path condition item, the path condition at the end point of the called module is described. In the path output item, the value of the variable at the end point of the called module is described. For the path condition and path output of the callee logic table 125, a symbol assigned to the input of the callee module can be used.

プログラム121について、呼び出し先ロジックテーブル125には、パス条件が「変数1_Bが20より大きい」、パス出力が「変数1=変数1_B+2」というロジックが登録される。また、呼び出し先ロジックテーブル125には、パス条件が「変数1_Bが20以下」、パス出力が「変数1=変数1_B−2」というロジックが登録される。なお、シンボル「変数1_B」はセクションBの入力を示す。   For the program 121, the logic that the path condition is “variable 1_B is greater than 20” and the path output is “variable 1 = variable 1_B + 2” is registered in the callee logic table 125. Also, in the callee logic table 125, the logic that the path condition is “variable 1_B is 20 or less” and the path output is “variable 1 = variable 1_B-2” is registered. The symbol “variable 1_B” indicates the input of section B.

終点ロジックテーブル126は、パス番号、パス条件およびパス出力の項目を有する。パス番号の項目には、呼び出し元モジュールの始点から終点の間に検出されたロジックの識別番号が記載される。パス条件の項目には、呼び出し元モジュールの終点におけるパス条件が記載される。パス出力の項目には、呼び出し元モジュールの終点における変数の値が記載される。終点ロジックテーブル126のパス条件およびパス出力には、呼び出し元モジュールの入力に割り当てられたシンボルや、呼び出し文の直後に更新変数に対して割り当てられたシンボルを用いることができる。   The end point logic table 126 includes items of a pass number, a pass condition, and a pass output. In the item of the pass number, an identification number of the logic detected between the start point and the end point of the calling module is described. The path condition item describes the path condition at the end point of the calling module. In the path output item, the value of the variable at the end point of the calling module is described. For the path condition and path output of the end point logic table 126, a symbol assigned to the input of the caller module or a symbol assigned to the update variable immediately after the call statement can be used.

プログラム121について、終点ロジックテーブル126には、パス条件が「変数1_Aが10より大きい」かつ「変数1_Perform_23_セクションB_1が30より小さい」、パス出力が「変数1=変数1_Perform_23_セクションB_1+3」というロジックが登録される。また、終点ロジックテーブル126には、パス条件が「変数1_Aが10より大きい」かつ「変数1_Perform_23_セクションB_1が30以上」、パス出力が「変数1=変数1_Perform_23_セクションB_1−3」というロジックが登録される。   Regarding the program 121, the end point logic table 126 registers logic that the path condition is “variable 1_A is greater than 10” and “variable 1_Perform_23_section B_1 is smaller than 30”, and the path output is “variable 1 = variable 1_Perform_23_section B_1 + 3”. Is done. Further, in the end point logic table 126, the logic that the path condition is “variable 1_A is greater than 10” and “variable 1_Perform_23_section B_1 is 30 or more” and the path output is “variable 1 = variable 1_Perform_23_section B_1-3” is registered. The

また、終点ロジックテーブル126には、パス条件が「変数1_Aが10以下」かつ「変数1_Perform_23_セクションB_1が30より小さい」、パス出力が「変数1=変数1_Perform_23_セクションB_1+3」というロジックが登録される。また、終点ロジックテーブル126には、パス条件が「変数1_Aが10以下」かつ「変数1_Perform_23_セクションB_1が30以上」、パス出力が「変数1=変数1_Perform_23_セクションB_1−3」というロジックが登録される。なお、シンボル「変数1_Perform_23_セクションB」は、呼び出し文の直後に「変数1」に割り当てられたシンボルである。   In the end point logic table 126, the logic that the path condition is “variable 1_A is 10 or less” and “variable 1_Perform_23_section B_1 is smaller than 30” and the path output is “variable 1 = variable 1_Perform_23_section B_1 + 3” is registered. Further, in the end point logic table 126, the logic that the path condition is "variable 1_A is 10 or less" and "variable 1_Perform_23_section B_1 is 30 or more" and the path output is "variable 1 = variable 1_Perform_23_section B_1-3" is registered. . The symbol “variable 1_Perform — 23_section B” is a symbol assigned to “variable 1” immediately after the call statement.

図11は、部分ロジックの簡約化例を示す図である。
プログラム分析装置100は、シンボリック実行が終了すると、途中点ロジックテーブル124、呼び出し先ロジックテーブル125および終点ロジックテーブル126を取得する。プログラム分析装置100は、途中点ロジックテーブル124、呼び出し先ロジックテーブル125および終点ロジックテーブル126をそれぞれ簡約化する。図10に示した途中点ロジックテーブル124および呼び出し先ロジックテーブル125は簡約化する余地がないため、ここでは終点ロジックテーブル126の簡約化の例を説明する。
FIG. 11 is a diagram illustrating a simplified example of partial logic.
When the symbolic execution ends, the program analysis apparatus 100 acquires the midpoint logic table 124, the callee logic table 125, and the end point logic table 126. The program analysis apparatus 100 simplifies the halfway point logic table 124, the callee logic table 125, and the end point logic table 126, respectively. Since there is no room for simplification of the midpoint logic table 124 and the callee logic table 125 shown in FIG. 10, an example of simplification of the end point logic table 126 will be described here.

プログラム分析装置100は、終点ロジックテーブル126から、パス出力が同じでパス条件が異なるロジックを検索する。プログラム分析装置100は、該当する複数のロジックのパス条件を選言(OR)で連結することで、該当する複数のロジックを1つに統合する。図11の例では、図10の終点ロジックテーブル126のロジック#1とロジック#3とが統合され、ロジック#1xに変換されている。また、ロジック#2とロジック#4とが統合され、ロジック#2xに変換されている。   The program analysis apparatus 100 searches the end point logic table 126 for logic having the same path output but different path conditions. The program analysis apparatus 100 integrates a plurality of corresponding logics into one by connecting the path conditions of the corresponding logics with disjunction (OR). In the example of FIG. 11, logic # 1 and logic # 3 in the end point logic table 126 of FIG. 10 are integrated and converted to logic # 1x. Logic # 2 and logic # 4 are integrated and converted to logic # 2x.

ロジック#1xのパス条件は、「変数1_Aが10より大きく変数1_Perform_23_セクションB_1が30より小さい」または「変数1_Aが10以下で変数1_Perform_23_セクションB_1が30より小さい」である。ロジック#1xのパス出力は、「変数1=変数1_Perform_23_セクションB_1+3」である。ロジック#2xのパス条件は、「変数1_Aが10より大きく変数1_Perform_23_セクションB_1が30以上」または「変数1_Aが10以下で変数1_Perform_23_セクションB_1が30以上」である。ロジック#2xのパス出力は、「変数1=変数1_Perform_23_セクションB_1−3」である。   The path condition of the logic # 1x is “variable 1_A is greater than 10 and variable 1_Perform_23_section B_1 is less than 30” or “variable 1_A is 10 or less and variable 1_Perform_23_section B_1 is less than 30”. The path output of the logic # 1x is “variable 1 = variable 1_Perform_23_section B_1 + 3”. The path condition of logic # 2x is “variable 1_A is greater than 10 and variable 1_Perform_23_section B_1 is 30 or more” or “variable 1_A is 10 or less and variable 1_Perform_23_section B_1 is 30 or more”. The path output of the logic # 2x is “variable 1 = variable 1_Perform — 23_section B_1-3”.

プログラム分析装置100は、統合したロジックのパス条件を数式処理技術を用いて簡約化する。図11の例では、ロジック#1xのパス条件は、「変数1_Aが10より大きいかまたは変数1_Aが10以下」かつ「変数1_Perform_23_セクションB_1が30より小さい」と変形できる。よって、ロジック#1xのパス条件は、「変数1_Perform_23_セクションB_1が30より小さい」と簡約化される。また、ロジック#2xのパス条件は、「変数1_Aが10より大きいかまたは変数1_Aが10以下」かつ「変数1_Perform_23_セクションB_1が30以上」と変形できる。よって、ロジック#2xのパス条件は、「変数1_Perform_23_セクションB_1が30以上」と簡約化される。上記のパス条件の簡約化には、例えば、クワイン・マクラスキー法を用いることができる。   The program analysis apparatus 100 simplifies the integrated logic path condition using mathematical expression processing technology. In the example of FIG. 11, the path condition of the logic # 1x can be modified such that “variable 1_A is greater than 10 or variable 1_A is 10 or less” and “variable 1_Perform — 23_section B_1 is less than 30”. Therefore, the path condition of logic # 1x is simplified as “variable 1_Perform — 23_section B_1 is smaller than 30”. Further, the path condition of the logic # 2x can be modified such that “variable 1_A is greater than 10 or variable 1_A is 10 or less” and “variable 1_Perform — 23_section B_1 is 30 or more”. Therefore, the path condition of the logic # 2x is simplified as “variable 1_Perform — 23_section B_1 is 30 or more”. For the simplification of the above path condition, for example, the Quine-Macrasky method can be used.

プログラム分析装置100は、更に、簡約化したパス条件が同じでパス出力が異なるロジックを検索する。プログラム分析装置100は、該当する複数のロジックのパス出力を連言(AND)で連結することで、該当する複数のロジックを1つに統合する。ただし、図11の例では、これに該当するロジックは存在しない。   The program analysis apparatus 100 further searches for logics having the same simplified path condition but different path outputs. The program analysis apparatus 100 integrates a plurality of corresponding logics into one by connecting path outputs of the corresponding logics with conjunctions (AND). However, there is no logic corresponding to this in the example of FIG.

図12は、部分ロジックの結合例を示す図である。
プログラム分析装置100は、途中点ロジックテーブル124、呼び出し先ロジックテーブル125および終点ロジックテーブル126をそれぞれ簡約化すると、これら3つのロジックテーブルのロジックを結合する。まず、プログラム分析装置100は、途中点ロジックテーブル124のロジックと呼び出し先ロジックテーブル125のロジックとを結合し、中間結合ロジックテーブル127を生成する。
FIG. 12 is a diagram illustrating an example of combining partial logics.
When the program analysis apparatus 100 simplifies the midpoint logic table 124, the callee logic table 125, and the end point logic table 126, the logics of these three logic tables are combined. First, the program analysis apparatus 100 combines the logic of the midpoint logic table 124 and the logic of the callee logic table 125 to generate an intermediate combined logic table 127.

プログラム分析装置100は、途中点ロジックテーブル124から1つの途中点ロジックを選択し、呼び出し先ロジックテーブル125から1つの呼び出し先ロジックを選択する。プログラム分析装置100は、選択した途中点ロジックのパス出力を、選択した呼び出し先ロジックのパス条件に用いられているシンボルに代入する。そして、プログラム分析装置100は、代入結果と途中点ロジックのパス条件との連言(AND)を、中間結合ロジックのパス条件として算出する。プログラム分析装置100は、算出した中間結合ロジックのパス条件が充足可能か判定し、充足可能である場合にはその途中点ロジックと呼び出し先ロジックの組み合わせを有効な組み合わせとして採用する。一方、プログラム分析装置100は、充足可能でない場合にはその途中点ロジックと呼び出し先ロジックの組み合わせを無効な組み合わせであるとして採用しない。   The program analysis apparatus 100 selects one waypoint logic from the waypoint logic table 124 and selects one callee logic from the callee logic table 125. The program analysis apparatus 100 substitutes the path output of the selected midpoint logic for the symbol used in the path condition of the selected callee logic. Then, the program analysis apparatus 100 calculates a conjunction (AND) between the substitution result and the path condition of the midpoint logic as the path condition of the intermediate coupling logic. The program analysis apparatus 100 determines whether or not the calculated path condition of the intermediate coupling logic can be satisfied, and if it can be satisfied, adopts a combination of the midpoint logic and the callee logic as an effective combination. On the other hand, when the program analysis device 100 is not satisfiable, the program analysis device 100 does not adopt the combination of the midpoint logic and the callee logic as an invalid combination.

プログラム分析装置100は、有効な組み合わせについて、途中点ロジックのパス出力を、呼び出し先ロジックのパス出力に用いられているシンボルに代入して、中間結合ロジックのパス出力を算出する。プログラム分析装置100は、有効な組み合わせについて算出したパス条件とパス出力とを、中間結合ロジックテーブル127に登録する。   For the effective combination, the program analysis apparatus 100 substitutes the path output of the midpoint logic into the symbol used for the path output of the callee logic, and calculates the path output of the intermediate coupling logic. The program analysis apparatus 100 registers the path condition and path output calculated for the effective combination in the intermediate combination logic table 127.

プログラム121の場合、プログラム分析装置100は、途中点ロジックのパス出力の「変数1」の値を、呼び出し先ロジックのシンボル「変数1_B」に代入することになる。プログラム分析装置100は、途中点ロジック#1と呼び出し先ロジック#1を選択し、「変数1_Aが10より大きい」かつ「変数1_A+1が20より大きい」というパス条件を算出する。これは、「変数1_A+1が20より大きい」と同等である。このパス条件は充足可能である(このパス条件を満たすようなシンボル「変数1_A」が存在する)ため、プログラム分析装置100は、途中点ロジック#1と呼び出し先ロジック#1の組み合わせを、中間結合ロジック#1として採用する。中間結合ロジック#1のパス出力は、「変数1=変数1_A+1+2」である。   In the case of the program 121, the program analysis apparatus 100 substitutes the value of “variable 1” of the path output of the midpoint logic into the symbol “variable 1_B” of the callee logic. The program analysis apparatus 100 selects the midpoint logic # 1 and the callee logic # 1, and calculates a path condition that “variable 1_A is greater than 10” and “variable 1_A + 1 is greater than 20”. This is equivalent to “variable 1_A + 1 is greater than 20”. Since this path condition can be satisfied (there is a symbol “variable 1_A” that satisfies this path condition), the program analysis apparatus 100 performs an intermediate combination of the combination of the midpoint logic # 1 and the callee logic # 1. Adopt as logic # 1. The path output of the intermediate coupling logic # 1 is “variable 1 = variable 1_A + 1 + 2”.

また、プログラム分析装置100は、途中点ロジック#1と呼び出し先ロジック#2を選択し、「変数1_Aが10より大きい」かつ「変数1_A+1が20以下」というパス条件を算出する。このパス条件は充足可能であるため、プログラム分析装置100は、途中点ロジック#1と呼び出し先ロジック#2の組み合わせを、中間結合ロジック#2として採用する。中間結合ロジック#2のパス出力は、「変数1=変数1_A+1−2」である。また、プログラム分析装置100は、途中点ロジック#2と呼び出し先ロジック#1を選択し、「変数1_Aが10以下」かつ「変数1_A+1が20より大きい」というパス条件を算出する。このパス条件は充足可能でないため、プログラム分析装置100は、途中点ロジック#2と呼び出し先ロジック#1の組み合わせを採用しない。   Further, the program analysis apparatus 100 selects the midpoint logic # 1 and the callee logic # 2, and calculates a path condition “variable 1_A is greater than 10” and “variable 1_A + 1 is 20 or less”. Since this path condition can be satisfied, the program analysis apparatus 100 employs a combination of the midpoint logic # 1 and the callee logic # 2 as the intermediate coupling logic # 2. The path output of the intermediate coupling logic # 2 is “variable 1 = variable 1_A + 1−2”. In addition, the program analysis apparatus 100 selects the midpoint logic # 2 and the callee logic # 1, and calculates a path condition that “variable 1_A is 10 or less” and “variable 1_A + 1 is greater than 20”. Since this path condition cannot be satisfied, the program analysis apparatus 100 does not employ a combination of the midpoint logic # 2 and the callee logic # 1.

また、プログラム分析装置100は、途中点ロジック#2と呼び出し先ロジック#2を選択し、「変数1_Aが10以下」かつ「変数1_A+1が20以下」というパス条件を算出する。これは、「変数1_A+1が10以下」と同等である。このパス条件は充足可能であるため、プログラム分析装置100は、途中点ロジック#2と呼び出し先ロジック#2の組み合わせを、中間結合ロジック#3として採用する。中間結合ロジック#3のパス出力は、「変数1=変数1_A−1−2」である。   Further, the program analysis apparatus 100 selects the midpoint logic # 2 and the callee logic # 2, and calculates a path condition “variable 1_A is 10 or less” and “variable 1_A + 1 is 20 or less”. This is equivalent to “variable 1_A + 1 is 10 or less”. Since this path condition can be satisfied, the program analysis apparatus 100 employs a combination of the midpoint logic # 2 and the callee logic # 2 as the intermediate coupling logic # 3. The path output of the intermediate coupling logic # 3 is “variable 1 = variable 1_A-1-2”.

図13は、部分ロジックの結合例を示す図(続き)である。
次に、プログラム分析装置100は、中間結合ロジックテーブル127のロジックと終点ロジックテーブル126のロジックとを結合し、ロジックテーブル128を生成する。
FIG. 13 is a diagram (continued) illustrating an example of combining partial logics.
Next, the program analysis apparatus 100 combines the logic of the intermediate combination logic table 127 and the logic of the end point logic table 126 to generate a logic table 128.

プログラム分析装置100は、中間結合ロジックテーブル127から1つの中間結合ロジックを選択し、終点ロジックテーブル126から1つの終点ロジックを選択する。プログラム分析装置100は、選択した中間結合ロジックのパス出力を、選択した終点ロジックのパス条件に用いられているシンボルに代入する。そして、プログラム分析装置100は、代入結果と中間結合ロジックのパス条件との連言(AND)を、結合したロジックのパス条件として算出する。プログラム分析装置100は、算出したロジックのパス条件が充足可能か判定し、充足可能である場合にはその中間結合ロジックと終点ロジックの組み合わせを有効な組み合わせとして採用する。一方、プログラム分析装置100は、充足可能でない場合にはその中間結合ロジックと終点ロジックの組み合わせを無効な組み合わせであるとして採用しない。   The program analysis apparatus 100 selects one intermediate combination logic from the intermediate combination logic table 127 and selects one end point logic from the end point logic table 126. The program analysis apparatus 100 substitutes the path output of the selected intermediate coupling logic into the symbol used in the path condition of the selected end point logic. Then, the program analysis apparatus 100 calculates a conjunction (AND) between the substitution result and the pass condition of the intermediate join logic as the pass condition of the joined logic. The program analysis apparatus 100 determines whether or not the calculated logic path condition can be satisfied, and if it can be satisfied, adopts the combination of the intermediate coupling logic and the end point logic as an effective combination. On the other hand, when the program analysis apparatus 100 is not satisfiable, the program analysis apparatus 100 does not adopt the combination of the intermediate combination logic and the end point logic as an invalid combination.

プログラム分析装置100は、有効な組み合わせについて、中間結合ロジックのパス出力を、終点ロジックのパス出力に用いられているシンボルに代入して、結合したロジックのパス出力を算出する。プログラム分析装置100は、有効な組み合わせについて算出したパス条件とパス出力とを、ロジックテーブル128に登録する。   The program analysis apparatus 100 calculates the path output of the combined logic by substituting the path output of the intermediate coupling logic into the symbol used for the path output of the end point logic for the effective combination. The program analysis apparatus 100 registers the path condition and path output calculated for the effective combination in the logic table 128.

プログラム121の場合、プログラム分析装置100は、中間結合ロジックのパス出力の「変数1」の値を、終点ロジックのシンボル「変数1_Perform_23_セクションB_1」に代入することになる。プログラム分析装置100は、中間結合ロジック#1と終点ロジック#1xを選択し、「変数1_A+1が20より大きい」かつ「変数1_A+1+2が30より小さい」というパス条件を算出する。このパス条件は充足可能であるため、プログラム分析装置100は、中間結合ロジック#1と終点ロジック#1xの組み合わせをロジック#1として採用する。ロジック#1のパス出力は、「変数1=変数1_A+1+2+3」である。   In the case of the program 121, the program analysis apparatus 100 substitutes the value of “variable 1” of the path output of the intermediate coupling logic into the symbol “variable 1_Perform — 23_section B_1” of the end point logic. The program analysis apparatus 100 selects the intermediate combination logic # 1 and the end point logic # 1x, and calculates a path condition that “variable 1_A + 1 is larger than 20” and “variable 1_A + 1 + 2 is smaller than 30”. Since this path condition can be satisfied, the program analysis apparatus 100 employs a combination of the intermediate combination logic # 1 and the end point logic # 1x as the logic # 1. The path output of the logic # 1 is “variable 1 = variable 1_A + 1 + 2 + 3”.

また、プログラム分析装置100は、中間結合ロジック#1と終点ロジック#2xを選択し、「変数1_A+1が20より大きい」かつ「変数1_A+1+2が30以上」というパス条件を算出する。これは、「変数1_A+1+2が30以上」と同等である。このパス条件は充足可能であるため、プログラム分析装置100は、中間結合ロジック#1と終点ロジック#2xの組み合わせをロジック#2として採用する。ロジック#2のパス出力は、「変数1=変数1_A+1+2−3」である。   Further, the program analysis apparatus 100 selects the intermediate combination logic # 1 and the end point logic # 2x, and calculates a path condition that “the variable 1_A + 1 is larger than 20” and “the variable 1_A + 1 + 2 is 30 or more”. This is equivalent to “variable 1_A + 1 + 2 is 30 or more”. Since this path condition can be satisfied, the program analysis apparatus 100 employs a combination of the intermediate combination logic # 1 and the end point logic # 2x as the logic # 2. The path output of the logic # 2 is “variable 1 = variable 1_A + 1 + 2−3”.

また、プログラム分析装置100は、中間結合ロジック#2と終点ロジック#1xを選択し、「変数1_Aが10より大きい」かつ「変数1_A+1が20以下」かつ「変数1_A+1−2が30より小さい」というパス条件を算出する。これは、「変数1_Aが10より大きい」と同等である。このパス条件は充足可能であるため、プログラム分析装置100は、中間結合ロジック#2と終点ロジック#1xの組み合わせをロジック#3として採用する。ロジック#3のパス出力は、「変数1=変数1_A+1−2+3」である。   Further, the program analysis apparatus 100 selects the intermediate combination logic # 2 and the end point logic # 1x, and states that “variable 1_A is greater than 10”, “variable 1_A + 1 is 20 or less”, and “variable 1_A + 1−2 is less than 30”. Calculate the pass condition. This is equivalent to “the variable 1_A is larger than 10”. Since this path condition can be satisfied, the program analysis apparatus 100 employs a combination of the intermediate combination logic # 2 and the end point logic # 1x as the logic # 3. The path output of the logic # 3 is “variable 1 = variable 1_A + 1−2 + 3”.

また、プログラム分析装置100は、中間結合ロジック#2と終点ロジック#2xを選択し、「変数1_Aが10より大きい」かつ「変数1_A+1が20以下」かつ「変数1_A+1−2が30以上」というパス条件を算出する。このパス条件は充足可能でないため、プログラム分析装置100は、中間結合ロジック#2と終点ロジック#2xの組み合わせを採用しない。   Further, the program analysis apparatus 100 selects the intermediate combination logic # 2 and the end point logic # 2x, and passes the path “variable 1_A is greater than 10”, “variable 1_A + 1 is 20 or less”, and “variable 1_A + 1−2 is 30 or more”. Calculate the conditions. Since this path condition cannot be satisfied, the program analysis apparatus 100 does not employ a combination of the intermediate coupling logic # 2 and the end point logic # 2x.

また、プログラム分析装置100は、中間結合ロジック#3と終点ロジック#1xを選択し、「変数1_Aが10以下」かつ「変数1_A−1−2が30より小さい」というパス条件を算出する。これは、「変数1_Aが10以下」と同等である。このパス条件は充足可能であるため、プログラム分析装置100は、中間結合ロジック#3と終点ロジック#1xの組み合わせをロジック#4として採用する。ロジック#4のパス出力は、「変数1=変数1_A−1−2+3」である。   Further, the program analysis apparatus 100 selects the intermediate combination logic # 3 and the end point logic # 1x, and calculates a path condition that “the variable 1_A is 10 or less” and “the variable 1_A-1-2 is less than 30”. This is equivalent to “variable 1_A is 10 or less”. Since this path condition can be satisfied, the program analysis apparatus 100 employs a combination of the intermediate combination logic # 3 and the end point logic # 1x as the logic # 4. The path output of the logic # 4 is “variable 1 = variable 1_A-1-2 + 3”.

また、プログラム分析装置100は、中間結合ロジック#3と終点ロジック#2xを選択し、「変数1_Aが10以下」かつ「変数1_A−1−2が30以上」というパス条件を算出する。このパス条件は充足可能でないため、プログラム分析装置100は、中間結合ロジック#3と終点ロジック#2xの組み合わせを採用しない。   Further, the program analysis apparatus 100 selects the intermediate combination logic # 3 and the end point logic # 2x, and calculates a path condition of “variable 1_A is 10 or less” and “variable 1_A-1-2 is 30 or more”. Since this path condition is not satisfiable, the program analysis apparatus 100 does not employ a combination of the intermediate combination logic # 3 and the end point logic # 2x.

これにより、4つのロジックが登録されたロジックテーブル128が生成される。ロジックテーブル128は、セクションAとセクションBとに跨がる実行パスを直接検出した場合に生成される図6のロジックテーブル129と同等である。このように、プログラム分析装置100は、シンボリック実行の計算量を削減しても、分析範囲のモジュールのロジックを正しく抽出することができる。なお、プログラム121の例の場合、シンボリック実行の対象となる実行パスの候補が、22×21=8つから22+21=6つに削減される。計算量の削減効果は、条件分岐文が多いほど大きくなる。 As a result, a logic table 128 in which four logics are registered is generated. The logic table 128 is equivalent to the logic table 129 of FIG. 6 that is generated when an execution path straddling the section A and the section B is directly detected. As described above, the program analysis apparatus 100 can correctly extract the logic of the module in the analysis range even if the calculation amount of symbolic execution is reduced. Incidentally, in the example of a program 121, a candidate execution paths to be symbolic execution is reduced from one 2 2 × 2 1 = 8 2 2 +2 1 = 6 one on. The effect of reducing the amount of calculation increases as the number of conditional branch statements increases.

図14は、プログラムの第3の例を示す図である。
プログラム146は、プログラム121と同様にセクションAおよびセクションBを含む。ただし、プログラム146では、セクションBに条件分岐文が追加されている。追加された命令文では、「変数1」の値が25より小さい場合に「変数1」の値を4増加させ、「変数1」の値が25以上である場合に「変数1」の値を4減少させる。
FIG. 14 is a diagram illustrating a third example of the program.
The program 146 includes a section A and a section B like the program 121. However, in the program 146, a conditional branch statement is added to the section B. In the added statement, when the value of “variable 1” is smaller than 25, the value of “variable 1” is increased by 4, and when the value of “variable 1” is 25 or more, the value of “variable 1” is increased. Decrease by 4.

セクションAとセクションBに跨がる実行パスをシンボリック実行によって直接検出する場合、探索する実行パスの候補は22×22=16個になる。一方、セクションAのシンボリック実行とセクションBのシンボリック実行を分割して事後的に部分ロジックを結合する方法によれば、探索する実行パスの候補は22+22=8個になる。この場合、探索する実行パスの候補の数が2分の1に削減される。 When an execution path straddling section A and section B is directly detected by symbolic execution, the number of execution path candidates to be searched is 2 2 × 2 2 = 16. On the other hand, according to the method of combining the partial logic after dividing the symbolic execution of section A and the symbolic execution of section B, the number of execution path candidates to be searched is 2 2 +2 2 = 8. In this case, the number of execution path candidates to be searched is reduced by half.

次に、プログラム分析装置100の機能および処理手順について説明する。
図15は、プログラム分析装置の機能例を示すブロック図である。
プログラム分析装置100は、記憶部120を有する。記憶部120は、例えば、RAM102またはHDD103に確保した記憶領域を用いて実装される。記憶部120は、プログラム121、更新変数テーブル122、シンボル割り当てテーブル123、途中点ロジックテーブル124、呼び出し先ロジックテーブル125、終点ロジックテーブル126、中間結合ロジックテーブル127およびロジックテーブル128を記憶する。
Next, functions and processing procedures of the program analysis apparatus 100 will be described.
FIG. 15 is a block diagram illustrating an example of functions of the program analysis apparatus.
The program analysis apparatus 100 includes a storage unit 120. The storage unit 120 is mounted using, for example, a storage area secured in the RAM 102 or the HDD 103. The storage unit 120 stores a program 121, an update variable table 122, a symbol assignment table 123, a midpoint logic table 124, a callee logic table 125, an end point logic table 126, an intermediate combination logic table 127, and a logic table 128.

また、プログラム分析装置100は、更新変数抽出部131、更新値割り当て部132、シンボリック実行部133、部分ロジック収集部134、ロジック簡約化部135、部分ロジック結合部136および分析結果表示部137を有する。更新変数抽出部131、更新値割り当て部132、シンボリック実行部133、部分ロジック収集部134、ロジック簡約化部135、部分ロジック結合部136および分析結果表示部137は、例えば、プロセッサ101が実行するプログラムモジュールを用いて実装される。   The program analysis apparatus 100 also includes an update variable extraction unit 131, an update value assignment unit 132, a symbolic execution unit 133, a partial logic collection unit 134, a logic simplification unit 135, a partial logic combination unit 136, and an analysis result display unit 137. . The update variable extraction unit 131, the update value assignment unit 132, the symbolic execution unit 133, the partial logic collection unit 134, the logic simplification unit 135, the partial logic combination unit 136, and the analysis result display unit 137 are, for example, programs executed by the processor 101 Implemented using modules.

更新変数抽出部131は、分析するプログラム121およびプログラム121の中の分析範囲が指定されると、分析範囲から、分析範囲外のモジュールを呼び出す呼び出し文であって作用の記載がないもの(例えば、PERFORM文)を検索する。更新変数抽出部131は、検索した呼び出し文の呼び出し先モジュールから、当該呼び出し先モジュールで値が更新される可能性のある更新変数を検索する。これにより、更新変数抽出部131は、更新変数テーブル122を生成して記憶部120に格納する。   When the analysis range in the program 121 to be analyzed and the analysis range in the program 121 is designated, the update variable extraction unit 131 is a call statement that calls a module outside the analysis range from the analysis range and has no description of the action (for example, (PERFORM statement). The update variable extraction unit 131 searches for an update variable whose value may be updated in the call destination module from the call destination module of the retrieved call statement. Thereby, the update variable extraction unit 131 generates the update variable table 122 and stores it in the storage unit 120.

更新値割り当て部132は、シンボル割り当てテーブル123を生成して記憶部120に格納する。更新値割り当て部132は、シンボリック実行部133によるシンボリック実行が、分析範囲外のモジュールを呼び出す呼び出し文であって作用の記載がないものに到達したことを検出する。すると、更新値割り当て部132は、呼び出し先モジュールに対応する更新変数を更新変数テーブル122から検索し、検索された更新変数それぞれに対して新たなシンボルを割り当てる。更新値割り当て部132は、割り当てたシンボルをシンボル割り当てテーブル123に登録し、シンボリック実行部133に通知する。   The update value assignment unit 132 generates the symbol assignment table 123 and stores it in the storage unit 120. The update value assignment unit 132 detects that the symbolic execution by the symbolic execution unit 133 has reached a call statement that calls a module outside the analysis range and has no description of the action. Then, the update value assigning unit 132 searches the update variable table 122 for an update variable corresponding to the callee module, and assigns a new symbol to each searched update variable. The update value assignment unit 132 registers the assigned symbol in the symbol assignment table 123 and notifies the symbolic execution unit 133 of the assigned symbol.

シンボリック実行部133は、更新変数抽出部131が更新変数を抽出した後、シンボリック実行を開始する。シンボリック実行の対象は、プログラム121の中の指定された分析範囲である。ただし、シンボリック実行部133は、呼び出し文が存在する場合、呼び出し先モジュールについて呼び出し元モジュールとは独立にシンボリック実行を行う。シンボリック実行部133は、各モジュールの先頭において当該モジュールの入力に対してシンボルを割り当てる。また、シンボリック実行部133は、分析範囲外のモジュールを呼び出す呼び出し文であって作用の記載がないものに到達すると、呼び出し先モジュールをスタブ化し、更新値割り当て部132から更新変数のシンボルを取得する。呼び出し文以降は、取得したシンボルを用いてシンボリック実行を続ける。   The symbolic execution unit 133 starts symbolic execution after the update variable extraction unit 131 extracts the update variable. The object of symbolic execution is a specified analysis range in the program 121. However, when there is a call statement, the symbolic execution unit 133 performs symbolic execution on the callee module independently of the caller module. The symbolic execution unit 133 assigns a symbol to the input of the module at the head of each module. When the symbolic execution unit 133 reaches a call statement that calls a module outside the analysis range and has no description of the action, the symbolic execution unit 133 converts the call destination module into a stub and acquires the update variable symbol from the update value assignment unit 132. . After the call statement, the symbolic execution is continued using the acquired symbol.

部分ロジック収集部134は、途中点ロジックテーブル124、呼び出し先ロジックテーブル125および終点ロジックテーブル126を生成して記憶部120に格納する。部分ロジック収集部134は、シンボリック実行部133によるシンボリック実行の過程で各種のロジック情報を収集する。部分ロジック収集部134は、シンボリック実行が呼び出し文に到達すると、呼び出し文の直前の途中点ロジックを取得して途中点ロジックテーブル124に登録する。また、部分ロジック収集部134は、シンボリック実行が呼び出し先モジュールの終点に到達すると、その時点の呼び出し先ロジックを取得して呼び出し先ロジックテーブル125に登録する。また、部分ロジック収集部134は、シンボリック実行が呼び出し元モジュールの終点に到達すると、その時点の呼び出し元ロジックを取得して終点ロジックテーブル126に登録する。   The partial logic collection unit 134 generates the halfway point logic table 124, the callee logic table 125, and the end point logic table 126 and stores them in the storage unit 120. The partial logic collection unit 134 collects various types of logic information in the process of symbolic execution by the symbolic execution unit 133. When the symbolic execution reaches the call statement, the partial logic collection unit 134 acquires the midpoint logic immediately before the call statement and registers it in the midpoint logic table 124. Further, when the symbolic execution reaches the end point of the call destination module, the partial logic collection unit 134 acquires the call destination logic at that time and registers it in the call destination logic table 125. Further, when the symbolic execution reaches the end point of the call source module, the partial logic collection unit 134 acquires the call source logic at that time and registers it in the end point logic table 126.

ロジック簡約化部135は、シンボリック実行の終了後、途中点ロジックテーブル124に登録された途中点ロジックを簡約化する。また、ロジック簡約化部135は、シンボリック実行の終了後、呼び出し先ロジックテーブル125に登録された呼び出し先ロジックを簡約化する。また、ロジック簡約化部135は、シンボリック実行の終了後、終点ロジックテーブル126に登録された終点ロジックを簡約化する。   The logic simplification unit 135 simplifies the midpoint logic registered in the midpoint logic table 124 after the end of symbolic execution. Also, the logic simplification unit 135 simplifies the callee logic registered in the callee logic table 125 after the end of symbolic execution. In addition, the logic simplification unit 135 simplifies the end point logic registered in the end point logic table 126 after the end of the symbolic execution.

部分ロジック結合部136は、中間結合ロジックテーブル127とロジックテーブル128を生成して記憶部120に格納する。部分ロジック結合部136は、途中点ロジックテーブル124に登録された途中点ロジックと呼び出し先ロジックテーブル125に登録された呼び出し先ロジックとを結合し、中間結合ロジックを中間結合ロジックテーブル127に登録する。途中点ロジックと呼び出し先ロジックとの結合では、結合後のパス条件が充足可能であるもののみが採用される。部分ロジック結合部136は、中間結合ロジックと終点ロジックテーブル126に登録された終点ロジックとを結合し、結合したロジックをロジックテーブル128に登録する。中間結合ロジックと終点ロジックとの結合では、結合後のパス条件が縦走可能であるもののみが採用される。   The partial logic combination unit 136 generates the intermediate combination logic table 127 and the logic table 128 and stores them in the storage unit 120. The partial logic combining unit 136 combines the midpoint logic registered in the midpoint logic table 124 with the callee logic registered in the callee logic table 125, and registers the intermediate bond logic in the intermediate bond logic table 127. In the combination of the midpoint logic and the callee logic, only those that can satisfy the combined path condition are employed. The partial logic combination unit 136 combines the intermediate combination logic and the end point logic registered in the end point logic table 126 and registers the combined logic in the logic table 128. In the connection between the intermediate connection logic and the end point logic, only the path condition after the connection that can run vertically is adopted.

分析結果表示部137は、生成されたロジックテーブル128をディスプレイ111に表示する。ただし、プログラム分析装置100は、生成されたロジックテーブル128を他の装置に送信してもよい。また、プログラム分析装置100は、ロジックテーブル128の内容を読み上げる音声をスピーカから再生する、ロジックテーブル128を印刷デバイスに出力するなど、他の方法でロジックテーブル128を出力してもよい。   The analysis result display unit 137 displays the generated logic table 128 on the display 111. However, the program analysis apparatus 100 may transmit the generated logic table 128 to another apparatus. In addition, the program analysis apparatus 100 may output the logic table 128 by other methods such as reproducing a sound for reading out the contents of the logic table 128 from a speaker or outputting the logic table 128 to a printing device.

図16は、プログラム分析の手順例を示すフローチャートである。
(S1)プログラム分析装置100は、分析対象のプログラム121の指定およびプログラム121の中の分析範囲とする1以上のモジュールの指定を取得する。これらの指定は、例えば、入力デバイス112を用いてユーザから入力される。
FIG. 16 is a flowchart illustrating a procedure example of program analysis.
(S1) The program analysis apparatus 100 acquires the specification of the analysis target program 121 and the specification of one or more modules as the analysis range in the program 121. These designations are input from the user using the input device 112, for example.

(S2)更新変数抽出部131は、分析範囲の実行時に呼び出される可能性のある分析範囲外のモジュールの更新変数を抽出する。更新変数抽出の詳細は後述する。
(S3)シンボリック実行部133は、分析範囲のモジュールと呼び出し先である分析範囲外のモジュールとについて、別個にシンボリック実行を行う。部分ロジック収集部134は、シンボリック実行が行われている間、途中点ロジックと呼び出し先ロジックと終点ロジックとを収集する。シンボリック実行の詳細は後述する。
(S2) The update variable extraction unit 131 extracts update variables of modules outside the analysis range that may be called when the analysis range is executed. Details of the update variable extraction will be described later.
(S3) The symbolic execution unit 133 performs symbolic execution separately for the module within the analysis range and the module outside the analysis range that is the call destination. The partial logic collection unit 134 collects midway point logic, call destination logic, and end point logic while symbolic execution is being performed. Details of the symbolic execution will be described later.

(S4)ロジック簡約化部135は、収集された途中点ロジックと呼び出し先ロジックと終点ロジックとをそれぞれ簡約化する。ロジック簡約化の詳細は後述する。
(S5)部分ロジック結合部136は、簡約化後の途中点ロジックと呼び出し先ロジックとを結合する。ロジック結合の詳細は後述する。
(S4) The logic simplification unit 135 simplifies the collected midpoint logic, call destination logic, and end point logic. Details of the logic simplification will be described later.
(S5) The partial logic combining unit 136 combines the halfway point logic after the simplification and the callee logic. Details of the logic combination will be described later.

(S6)部分ロジック結合部136は、ステップS5で生成した中間結合ロジックと終点ロジックとを結合する。ロジック結合のアルゴリズムはステップS5と同様である。
(S7)分析結果表示部137は、ステップS6によって結合されたロジックを示すロジックテーブル128をディスプレイ111に表示させる。
(S6) The partial logic combination unit 136 combines the intermediate combination logic and the end point logic generated in step S5. The logic combination algorithm is the same as in step S5.
(S7) The analysis result display unit 137 causes the display 111 to display a logic table 128 indicating the logic combined in step S6.

図17は、更新変数抽出の手順例を示すフローチャートである。
更新変数抽出は、前述のステップS2で実行される。
(S10)更新変数抽出部131は、分析対象のプログラム121の指定およびプログラム121の中の分析範囲とする1以上のモジュールの指定を取得する。更新変数抽出部131は、指定された分析範囲のモジュールに着目する。
FIG. 17 is a flowchart illustrating an exemplary procedure for extracting update variables.
The update variable extraction is executed in the above-described step S2.
(S <b> 10) The update variable extraction unit 131 acquires the specification of the analysis target program 121 and the specification of one or more modules as the analysis range in the program 121. The update variable extraction unit 131 pays attention to the module in the designated analysis range.

(S11)更新変数抽出部131は、着目するモジュールから、分析範囲外のモジュールを呼び出す呼び出し文であって作用の記載がないものを検索する。
(S12)更新変数抽出部131は、ステップS11で該当する呼び出し文が検索されたか判断する。該当する呼び出し文がある場合はステップS13に処理が進み、該当する呼び出し文がない場合はステップS13〜S16の処理をスキップする。
(S11) The update variable extraction unit 131 searches for a call statement that calls a module outside the analysis range and has no description of the action from the module of interest.
(S12) The update variable extraction unit 131 determines whether or not the corresponding call statement has been searched in step S11. If there is a corresponding call statement, the process proceeds to step S13. If there is no corresponding call statement, the processes in steps S13 to S16 are skipped.

(S13)更新変数抽出部131は、呼び出し先モジュールを取得する。
(S14)更新変数抽出部131は、呼び出し先モジュールから、変数の値を更新する変数更新文を検索する。値が更新される変数(更新変数)は、例えば、代入文の左辺に記載された変数や、MOVE文の第2引数として記載された変数などである。
(S13) The update variable extraction unit 131 acquires a call destination module.
(S14) The update variable extraction unit 131 searches the callee module for a variable update statement that updates the value of the variable. The variable whose value is updated (update variable) is, for example, a variable described on the left side of the assignment statement, a variable described as the second argument of the MOVE statement, or the like.

(S15)更新変数抽出部131は、呼び出し先モジュールのモジュール名とステップS14で検索された更新変数の変数名とを対応付けて、更新変数テーブル122に登録する。ただし、呼び出しが階層的に行われる場合にはモジュール名として、分析範囲から呼び出される1段階目のモジュールのモジュール名を用いる。   (S15) The update variable extraction unit 131 associates the module name of the callee module with the variable name of the update variable searched in step S14 and registers it in the update variable table 122. However, when calling is performed hierarchically, the module name of the first-stage module called from the analysis range is used as the module name.

(S16)更新変数抽出部131は、ステップS13で取得した呼び出し先モジュールに着目し、当該呼び出し先モジュールについてステップS11〜S16の処理を再帰的に実行する。呼び出し先モジュールが更に他のモジュールを呼び出す呼び出し文(サブ呼び出し文)を含む場合、再帰的に更新変数が探索される。   (S16) The update variable extraction unit 131 pays attention to the call destination module acquired in step S13, and recursively executes the processes of steps S11 to S16 for the call destination module. When the call destination module further includes a call statement (sub-call statement) for calling another module, the update variable is searched recursively.

図18は、シンボリック実行の手順例を示すフローチャートである。
シンボリック実行は、前述のステップS3で実行される。
(S20)シンボリック実行部133は、分析対象のプログラム121の指定およびプログラム121の中の分析範囲とする1以上のモジュールの指定を取得する。シンボリック実行部133は、指定された分析範囲のモジュールに着目する。
FIG. 18 is a flowchart illustrating a procedure example of symbolic execution.
The symbolic execution is executed in step S3 described above.
(S20) The symbolic execution unit 133 acquires the specification of the analysis target program 121 and the specification of one or more modules as the analysis range in the program 121. The symbolic execution unit 133 focuses on a module in the designated analysis range.

(S21)シンボリック実行部133は、着目するモジュールの入力が格納される入力変数に独立なシンボルを割り当てる。例えば、シンボリック実行部133は、図5のセクションAの「変数1」に対してシンボル「変数1_A」を割り当てる。   (S21) The symbolic execution unit 133 assigns an independent symbol to the input variable in which the input of the module of interest is stored. For example, the symbolic execution unit 133 assigns the symbol “variable 1_A” to “variable 1” in section A of FIG.

(S22)シンボリック実行部133は、プログラム121の処理順序に従い、次に実行されるべき命令文をプログラム121から1つ取得する。
(S23)シンボリック実行部133は、ステップS22で終了文以外の命令文を取得したか判断する。終了文以外の命令文を取得した場合、ステップS24に処理が進む。終了文を取得したか該当する命令文が存在しない場合、ステップS29に処理が進む。
(S22) The symbolic execution unit 133 acquires one instruction statement to be executed next from the program 121 in accordance with the processing order of the program 121.
(S23) The symbolic execution unit 133 determines whether a command statement other than the end statement has been acquired in step S22. If a command statement other than the end statement is acquired, the process proceeds to step S24. If the end sentence has been acquired or there is no corresponding statement, the process proceeds to step S29.

(S24)シンボリック実行部133は、ステップS22で取得した命令文が、分析範囲外のモジュールを呼び出す呼び出し文であって作用の記載がないものであるか判断する。図5のPERFORM文のように、呼び出し先モジュールによって更新される更新変数が明記されていない呼び出し文は、作用の記載がない呼び出し文である。取得した命令文が該当する呼び出し文である場合はステップS25に処理が進み、取得した命令文がそれ以外のものである場合はステップS31に処理が進む。   (S24) The symbolic execution unit 133 determines whether the instruction sentence acquired in step S22 is a call sentence for calling a module outside the analysis range and has no description of the action. Like the PERFORM statement in FIG. 5, a call statement in which an update variable to be updated by the callee module is not specified is a call statement without an action description. If the acquired command statement is a corresponding call statement, the process proceeds to step S25, and if the acquired command statement is other than that, the process proceeds to step S31.

(S25)部分ロジック収集部134は、呼び出し文の直前におけるパス条件とパス出力を途中点ロジックテーブル124に登録する。パス条件は、着目するモジュールの先頭から呼び出し文の直前までに選択した分岐方向の条件を累積したものである。パス出力は、呼び出し文の直前における変数の値である。パス条件やパス出力には、ステップS21で割り当てられたシンボルが用いられることがある。   (S25) The partial logic collection unit 134 registers the path condition and path output immediately before the call statement in the midway logic table 124. The path condition is an accumulation of the branch direction conditions selected from the beginning of the module of interest to immediately before the call statement. The path output is the value of the variable just before the call statement. For the path condition and path output, the symbols assigned in step S21 may be used.

(S26)シンボリック実行部133は、呼び出し文が示す呼び出し先モジュールを分析済みであるか判断する。呼び出し先モジュールを分析済みである場合はステップS28に処理が進み、まだ分析していない場合はステップS27に処理が進む。   (S26) The symbolic execution unit 133 determines whether the callee module indicated by the call statement has been analyzed. If the callee module has been analyzed, the process proceeds to step S28, and if not yet analyzed, the process proceeds to step S27.

(S27)シンボリック実行部133は、呼び出し先モジュールに着目し、ステップS21〜S30の処理を再帰的に実行する。このとき、シンボリック実行部133は、呼び出し元モジュールの分析途中の情報を退避し、呼び出し元モジュールとは独立に呼び出し先モジュールについてシンボリック実行を行う。呼び出し先モジュールのシンボリック実行が終了すると、シンボリック実行部133は、退避しておいた分析途中の情報を用いて呼び出し元モジュールのシンボリック実行を続ける。なお、図18のフローチャートでは、呼び出し元モジュールのシンボリック実行を中断して呼び出し先モジュールのシンボリック実行を行うこととした。しかし、呼び出し元モジュールのシンボリック実行が終わってから、呼び出し先モジュールのシンボリック実行を開始するようにしてもよい。   (S27) The symbolic execution unit 133 pays attention to the called module, and recursively executes the processes of steps S21 to S30. At this time, the symbolic execution unit 133 saves information in the middle of analysis of the caller module, and performs symbolic execution on the callee module independently of the caller module. When the symbolic execution of the callee module is completed, the symbolic execution unit 133 continues the symbolic execution of the caller module using the saved information during the analysis. In the flowchart of FIG. 18, the symbolic execution of the call source module is interrupted and the callee module is executed symbolically. However, the symbolic execution of the callee module may be started after the symbolic execution of the caller module ends.

(S28)更新値割り当て部132は、呼び出し先モジュールに対応する更新変数を、更新変数テーブル122から検索する。更新値割り当て部132は、検索した更新変数に独立のシンボルを割り当て、割り当てたシンボルをシンボル割り当てテーブル123に登録する。また、更新値割り当て部132は、割り当てたシンボルをシンボリック実行部133に通知する。シンボリック実行部133は、呼び出し文の直前において更新変数の値を保持している場合、その値を破棄して更新値割り当て部132から通知されたシンボルを保存する。すなわち、シンボリック実行部133は、更新変数の値が通知されたシンボルによって上書きされたものとして取り扱う。そして、ステップS22に処理が進む。   (S28) The update value assignment unit 132 searches the update variable table 122 for an update variable corresponding to the callee module. The update value assigning unit 132 assigns an independent symbol to the searched update variable, and registers the assigned symbol in the symbol assignment table 123. Also, the update value assigning unit 132 notifies the symbol execution unit 133 of the assigned symbols. When the symbolic execution unit 133 holds the value of the update variable immediately before the call statement, the symbolic execution unit 133 discards the value and saves the symbol notified from the update value assignment unit 132. That is, the symbolic execution unit 133 treats the value of the update variable as being overwritten by the notified symbol. Then, the process proceeds to step S22.

(S29)シンボリック実行部133は、実行パスが終点に到達したと判断する。部分ロジック収集部134は、その時点のパス条件とパス出力を終点ロジックテーブル126に登録する。ただし、呼び出し先モジュールについてのシンボリック実行である場合、部分ロジック収集部134は、その時点のパス条件とパス出力を呼び出し先ロジックテーブル125に登録する。パス条件は、着目するモジュールの先頭から終点までに選択した分岐方向の条件を累積したものである。パス出力は、着目するモジュールの終点における変数の値である。パス条件やパス出力には、ステップS21で割り当てられたシンボルや、ステップS28で割り当てられたシンボルが用いられることがある。   (S29) The symbolic execution unit 133 determines that the execution path has reached the end point. The partial logic collection unit 134 registers the current path condition and path output in the end point logic table 126. However, in the case of symbolic execution for the callee module, the partial logic collection unit 134 registers the current pass condition and pass output in the callee logic table 125. The path condition is an accumulation of the branch direction conditions selected from the beginning to the end point of the module of interest. The path output is the value of the variable at the end point of the module of interest. For the path condition and path output, the symbol allocated in step S21 or the symbol allocated in step S28 may be used.

(S30)シンボリック実行部133は、条件分岐文によって分割された実行パスであって、未選択の実行パスが残っているか判断する。未選択の実行パスがある場合、シンボリック実行部133は、1つ前の分割点までバックトラックし、保存しておいたその分割点におけるパス条件およびパス出力を取得する。シンボリック実行部133は、未選択の分岐方向を選択し、取得したパス条件およびパス出力を用いてその実行パスについてシンボリック実行を続ける。そして、ステップS22に処理が進む。一方、未選択の実行パスがない場合、着目するモジュールのシンボリック実行が終了する。   (S30) The symbolic execution unit 133 determines whether or not there are unselected execution paths that are divided by the conditional branch statement. If there is an unselected execution path, the symbolic execution unit 133 backtracks to the previous division point, and acquires the saved path condition and path output at that division point. The symbolic execution unit 133 selects an unselected branch direction, and continues symbolic execution for the execution path using the acquired path condition and path output. Then, the process proceeds to step S22. On the other hand, if there is no unselected execution path, the symbolic execution of the module of interest ends.

図19は、シンボリック実行の手順例を示すフローチャート(続き)である。
(S31)シンボリック実行部133は、ステップS22で取得した命令文が、変数の値を更新する変数更新文であるか判断する。変数更新文は、例えば、左辺と右辺を等号で結合した代入文やMOVE文などである。取得した命令文が変数更新文である場合はステップS32に処理が進み、それ以外である場合はステップS33に処理が進む。
FIG. 19 is a flowchart (continuation) illustrating an example of the procedure of symbolic execution.
(S31) The symbolic execution unit 133 determines whether the command statement acquired in step S22 is a variable update statement that updates the value of the variable. The variable update statement is, for example, an assignment statement or a move statement in which the left side and the right side are joined with an equal sign. If the acquired command statement is a variable update statement, the process proceeds to step S32; otherwise, the process proceeds to step S33.

(S32)シンボリック実行部133は、変数更新文に従い変数の値を更新する。変数の値はシンボルを含む式で表されることもある。そして、ステップS22に処理が進む。
(S33)シンボリック実行部133は、ステップS22で取得した命令文が、条件分岐文であるか判断する。取得した命令文が条件分岐文である場合はステップS34に処理が進み、それ以外である場合はステップS37に処理が進む。
(S32) The symbolic execution unit 133 updates the value of the variable according to the variable update statement. The value of a variable may be represented by an expression that includes a symbol. Then, the process proceeds to step S22.
(S33) The symbolic execution unit 133 determines whether the instruction statement acquired in step S22 is a conditional branch statement. If the acquired command statement is a conditional branch statement, the process proceeds to step S34, and if not, the process proceeds to step S37.

(S34)シンボリック実行部133は、条件分岐文に記載された分岐条件とその時点の変数の値とその時点のパス条件とに基づいて、YES方向とNO方向の2つの分岐方向それぞれの充足可能性を判定する。変数の値がシンボルを含む式である場合、2つの分岐方向の両方が充足可能であると判定されることもある。   (S34) The symbolic execution unit 133 can satisfy each of the two branch directions of the YES direction and the NO direction based on the branch condition described in the conditional branch statement, the value of the variable at that time, and the path condition at that time. Determine sex. If the value of the variable is an expression that includes a symbol, it may be determined that both of the two branch directions are satisfiable.

(S35)シンボリック実行部133は、2つの分岐方向が共に充足可能であるか判断する。2つの分岐方向が共に充足可能である場合はステップS36に処理が進み、一方の分岐方向のみ充足可能である場合はステップS37に処理が進む。   (S35) The symbolic execution unit 133 determines whether both of the two branch directions can be satisfied. If both branch directions can be satisfied, the process proceeds to step S36. If only one branch direction can be satisfied, the process proceeds to step S37.

(S36)シンボリック実行部133は、実行パスを分割する。シンボリック実行部133は、2つの分岐方向の何れか一方(例えば、YES方向)を選択して、現在の実行パスの進行方向とする。また、シンボリック実行部133は、その時点のパス条件とパス出力を退避しておく。選択しなかった分岐方向に相当する分割された実行パスは、未選択の実行パスとしておく。そして、ステップS22に処理が進む。   (S36) The symbolic execution unit 133 divides the execution path. The symbolic execution unit 133 selects one of the two branch directions (for example, the YES direction) and sets it as the traveling direction of the current execution path. Also, the symbolic execution unit 133 saves the current path condition and path output. The divided execution paths corresponding to the branch direction not selected are set as unselected execution paths. Then, the process proceeds to step S22.

(S37)シンボリック実行部133は、ステップS22で取得した命令文に応じた処理を行う。ステップS35で一方の分岐方向のみ充足可能と判断された場合、シンボリック実行部133は、条件分岐文に従って充足可能な分岐方向を選択することになる。このとき、実行パスは分割されない。そして、ステップS22に処理が進む。   (S37) The symbolic execution unit 133 performs processing according to the command sentence acquired in step S22. If it is determined in step S35 that only one branch direction can be satisfied, the symbolic execution unit 133 selects a branch direction that can be satisfied according to the conditional branch sentence. At this time, the execution path is not divided. Then, the process proceeds to step S22.

図20は、ロジック簡約化の手順例を示すフローチャートである。
ロジック簡約化は前述のステップS4で実行される。
(S40)ロジック簡約化部135は、途中点ロジックテーブル124、呼び出し先ロジックテーブル125および終点ロジックテーブル126のうち1つを選択する。
FIG. 20 is a flowchart illustrating an example of a logic simplification procedure.
The logic simplification is executed in step S4 described above.
(S40) The logic simplification unit 135 selects one of the midpoint logic table 124, the callee logic table 125, and the end point logic table 126.

(S41)ロジック簡約化部135は、ステップS40で選択したロジックテーブルから、パス出力が同じでパス条件が異なる複数のロジックを検索する。
(S42)ロジック簡約化部135は、ステップS41に該当する複数のロジックが検索された場合、検索された複数のロジックのパス条件をORで連結することで、検索された複数のロジックを1つのロジックに統合する。
(S41) The logic simplification unit 135 searches the logic table selected in step S40 for a plurality of logics having the same path output but different path conditions.
(S42) When a plurality of logics corresponding to step S41 are searched, the logic simplification unit 135 connects the searched logics to one by connecting OR the path conditions of the searched logics. Integrate into logic.

(S43)ロジック簡約化部135は、ステップS42で統合した後の各ロジックのパス条件を、冗長性を削減することで簡約化する。
(S44)ロジック簡約化部135は、ステップS43で簡約化した後のロジックのうち、パス条件が同じでパス出力が異なる複数のロジックを検索する。
(S43) The logic simplification unit 135 simplifies the path conditions of each logic after integration in step S42 by reducing redundancy.
(S44) The logic simplification unit 135 searches the logic after the simplification in step S43 for a plurality of logics having the same path condition and different path outputs.

(S45)ロジック簡約化部135は、ステップS44に該当する複数のロジックが検索された場合、検索された複数のロジックのパス出力をANDで連結することで、検索された複数のロジックを1つのロジックに統合する。   (S45) When a plurality of logics corresponding to step S44 are searched, the logic simplification unit 135 concatenates the searched logics into one by connecting AND the path outputs of the searched logics. Integrate into logic.

(S46)ロジック簡約化部135は、ステップS40において、途中点ロジックテーブル124、呼び出し先ロジックテーブル125および終点ロジックテーブル126の全てを選択したか判断する。未選択のロジックテーブルがある場合はステップS40に処理が進み、3つのロジックテーブルの全てを選択した場合はロジック簡約化が終了する。   (S46) The logic simplification unit 135 determines whether all of the midway logic table 124, the callee logic table 125, and the end point logic table 126 have been selected in step S40. If there is an unselected logic table, the process proceeds to step S40, and if all three logic tables are selected, the logic simplification ends.

図21は、ロジック結合の手順例を示すフローチャートである。
ロジック結合は、前述のステップS5およびステップS6で実行される。ステップS5とステップS6では、共通のロジック結合アルゴリズムを使用できる。
FIG. 21 is a flowchart illustrating an exemplary procedure of logic combination.
The logic combination is performed in the above-described step S5 and step S6. In step S5 and step S6, a common logic combination algorithm can be used.

(S50)部分ロジック結合部136は、結合するロジックテーブルT1とロジックテーブルT2を取得する。ステップS5では、ロジックテーブルT1は途中点ロジックテーブル124であり、ロジックテーブルT2は呼び出し先ロジックテーブル125である。ステップS6では、ロジックテーブルT1は中間結合ロジックテーブル127であり、ロジックテーブルT2は終点ロジックテーブル126である。   (S50) The partial logic combination unit 136 acquires the logic table T1 and the logic table T2 to be combined. In step S5, the logic table T1 is the midpoint logic table 124, and the logic table T2 is the callee logic table 125. In step S6, the logic table T1 is the intermediate join logic table 127, and the logic table T2 is the end point logic table 126.

(S51)部分ロジック結合部136は、ロジックテーブルT1からレコードR1を選択する。レコードR1は、ロジックテーブルT1の中の1つのロジックを表す。
(S52)部分ロジック結合部136は、ロジックテーブルT2からレコードR2を選択する。レコードR2は、ロジックテーブルT2の中の1つのロジックを表す。
(S51) The partial logic combination unit 136 selects the record R1 from the logic table T1. The record R1 represents one logic in the logic table T1.
(S52) The partial logic combination unit 136 selects the record R2 from the logic table T2. The record R2 represents one logic in the logic table T2.

(S53)部分ロジック結合部136は、レコードR1のパス出力をレコードR2のパス条件に用いられているシンボルに代入する。部分ロジック結合部136は、代入結果とレコードR1のパス条件とをANDで連結し、結合後のパス条件を算出する。   (S53) The partial logic combination unit 136 substitutes the path output of the record R1 for the symbol used in the path condition of the record R2. The partial logic combining unit 136 connects the substitution result and the path condition of the record R1 with AND, and calculates the combined path condition.

(S54)部分ロジック結合部136は、ステップS53で算出した結合後のパス条件の充足可能性を判定する。結合後のパス条件が充足可能である場合はステップS55に処理が進み、充足可能でない場合はステップS57に処理が進む。   (S54) The partial logic combining unit 136 determines whether or not the combined path condition calculated in step S53 is satisfied. If the combined path condition can be satisfied, the process proceeds to step S55, and if not, the process proceeds to step S57.

(S55)部分ロジック結合部136は、レコードR1のパス出力をレコードR2のパス出力に用いられているシンボルに代入し、結合後のパス出力を算出する。
(S56)部分ロジック結合部136は、ステップS53で算出したパス条件とステップS55で算出したパス出力を結合結果のロジックテーブルに登録する。ステップS5では、結合結果のロジックテーブルは中間結合ロジックテーブル127である。ステップS6では、結合結果のロジックテーブルはロジックテーブル128である。
(S55) The partial logic combination unit 136 substitutes the path output of the record R1 for the symbol used for the path output of the record R2, and calculates the combined path output.
(S56) The partial logic combination unit 136 registers the path condition calculated in step S53 and the path output calculated in step S55 in the logic table of the combination result. In step S5, the logic table of the join result is the intermediate join logic table 127. In step S <b> 6, the logic table of the combination result is the logic table 128.

(S57)部分ロジック結合部136は、ロジックテーブルT2に、ステップS52で未選択のレコードが存在するか判断する。未選択のレコードがある場合はステップS52に処理が進み、全てのレコードを選択した場合はステップS58に処理が進む。   (S57) The partial logic combination unit 136 determines whether there is a record not selected in step S52 in the logic table T2. If there is an unselected record, the process proceeds to step S52. If all records are selected, the process proceeds to step S58.

(S58)部分ロジック結合部136は、ロジックテーブルT1に、ステップS51で未選択のレコードが存在するか判断する。未選択のレコードがある場合はステップS51に処理が進み、全てのレコードを選択した場合はロジック結合が終了する。   (S58) The partial logic combination unit 136 determines whether there is a record not selected in step S51 in the logic table T1. If there is an unselected record, the process proceeds to step S51. If all the records are selected, the logic combination is terminated.

第2の実施の形態のプログラム分析装置100によれば、呼び出し元モジュールのシンボリック実行と呼び出し先モジュールのシンボリック実行とが独立に行われる。呼び出し元モジュールのシンボリック実行では、呼び出し文の直前におけるパス条件とパス出力が保存されると共に、呼び出し文はスキップされ、呼び出し先モジュールで更新される可能性のある更新変数に新たなシンボルが割り当てられる。そして、呼び出し文の直前におけるロジック情報と呼び出し元モジュールの終点におけるロジック情報と呼び出し先モジュールの終点におけるロジック情報とが結合され、実行パスが再現される。   According to the program analysis apparatus 100 of the second embodiment, the symbolic execution of the caller module and the symbolic execution of the callee module are performed independently. In the symbolic execution of the calling module, the path condition and path output immediately before the calling statement are saved, the calling statement is skipped, and new symbols are assigned to update variables that may be updated in the called module. . Then, the logic information immediately before the call statement, the logic information at the end point of the call source module, and the logic information at the end point of the call destination module are combined to reproduce the execution path.

これにより、複数のモジュールに跨がる実行パスを分析する際のパス爆発を抑制し、シンボリック実行の計算量を削減できる。よって、実行パスを効率的に分析することができる。また、呼び出し先モジュールの処理内容を無視しているわけではないため、再現された実行パスは、呼び出し元モジュールの入力と出力の関係を正しく表している。   As a result, it is possible to suppress path explosion when analyzing an execution path extending over a plurality of modules, and to reduce the amount of calculation of symbolic execution. Therefore, the execution path can be analyzed efficiently. Since the processing contents of the callee module are not ignored, the reproduced execution path correctly represents the relationship between the input and output of the caller module.

10 プログラム分析装置
11 記憶部
12 演算部
20 プログラム
21,26 モジュール
22 呼び出し命令
23a,23b 第1の実行パス
24 第1の情報
25 第2の情報
27a,27b 第2の実行パス
28 第3の情報
31a,31b,31c,31d 合成実行パス
32 パス情報
c1,c2,c3 シンボル
DESCRIPTION OF SYMBOLS 10 Program analyzer 11 Memory | storage part 12 Operation part 20 Program 21, 26 Module 22 Call instruction 23a, 23b 1st execution path 24 1st information 25 2nd information 27a, 27b 2nd execution path 28 3rd information 31a, 31b, 31c, 31d Combining execution path 32 Path information c1, c2, c3 symbols

Claims (6)

コンピュータが実行するプログラム分析方法であって、
第1のモジュールと第2のモジュールとを含み、前記第1のモジュールは前記第2のモジュールを呼び出す呼び出し命令を含むプログラムを取得し、
前記第1のモジュールの入力に第1のシンボルを割り当て、前記呼び出し命令の前における第1の処理結果を前記第1のシンボルを用いて表した第1の情報を生成し、前記呼び出し命令の呼び出し結果に第2のシンボルを割り当て、前記第1のモジュールに含まれる複数の第1の実行パスそれぞれの前記呼び出し命令の後における第2の処理結果を前記第2のシンボルを用いて表した第2の情報を生成し、
前記第2のモジュールの入力に第3のシンボルを割り当て、前記第2のモジュールに含まれる複数の第2の実行パスそれぞれの第3の処理結果を前記第3のシンボルを用いて表した第3の情報を生成し、
前記第1の情報が示す前記第1の処理結果と前記第3の情報に用いられた前記第3のシンボルとを対応付け、また、前記第3の情報が示す前記第3の処理結果と前記第2の情報に用いられた前記第2のシンボルとを対応付けることで、前記複数の第1の実行パスと前記複数の第2の実行パスとを合成した複数の合成実行パスそれぞれの処理結果を前記第1のシンボルを用いて表したパス情報を生成する、
プログラム分析方法。
A program analysis method executed by a computer,
A first module and a second module, wherein the first module obtains a program including a call instruction for calling the second module;
A first symbol is assigned to an input of the first module, first information representing a first processing result before the call instruction is expressed using the first symbol, and the call of the call instruction is generated. A second symbol is assigned to the result, and a second processing result after the call instruction of each of the plurality of first execution paths included in the first module is expressed using the second symbol. Generate information for
A third symbol is assigned to the input of the second module, and a third processing result of each of a plurality of second execution paths included in the second module is expressed using the third symbol. Generate information for
The first processing result indicated by the first information is associated with the third symbol used for the third information, and the third processing result indicated by the third information is By associating the second symbol used for the second information, the processing results of the plurality of combined execution paths obtained by combining the plurality of first execution paths and the plurality of second execution paths are obtained. Generating path information represented using the first symbol;
Program analysis method.
前記第2の情報は、前記複数の第1の実行パスそれぞれの第1の実行条件を前記第1および第2のシンボルの少なくとも一方を用いて表し、前記第3の情報は、前記複数の第2の実行パスそれぞれの第2の実行条件を前記第3のシンボルを用いて表し、
前記パス情報の生成では、1つの第1の実行パスに対応する前記第1の実行条件と1つの第2の実行パスに対応する前記第2の実行条件とが矛盾しない場合に、前記1つの第1の実行パスと前記1つの第2の実行パスとを合成する、
請求項1記載のプログラム分析方法。
The second information represents a first execution condition of each of the plurality of first execution paths using at least one of the first and second symbols, and the third information represents the plurality of first execution paths. A second execution condition of each of the two execution paths is expressed using the third symbol;
In the generation of the path information, when the first execution condition corresponding to one first execution path and the second execution condition corresponding to one second execution path do not contradict each other, Combining a first execution path and the one second execution path;
The program analysis method according to claim 1.
前記第1の情報は、前記複数の第1の実行パスを前記呼び出し命令の前まで実行した場合に検出される複数の部分実行パスそれぞれについて前記第1の処理結果を示し、
前記パス情報の生成では、前記複数の部分実行パスの前記第1の処理結果と前記複数の第1の実行パスの前記第2の処理結果と前記複数の第2の実行パスの前記第3の処理結果とを合成する、
請求項1記載のプログラム分析方法。
The first information indicates the first processing result for each of a plurality of partial execution paths detected when the plurality of first execution paths are executed before the call instruction,
In the generation of the path information, the first processing result of the plurality of partial execution paths, the second processing result of the plurality of first execution paths, and the third of the plurality of second execution paths. Combining with the processing result,
The program analysis method according to claim 1.
前記第1のモジュールで使用される変数のうち前記第2のモジュールによって更新される更新変数を前記プログラムから検索し、
前記第2の情報の生成では、前記更新変数に前記第2のシンボルを割り当てる、
請求項1記載のプログラム分析方法。
Search the program for an update variable to be updated by the second module among the variables used in the first module;
In the generation of the second information, the second symbol is assigned to the update variable.
The program analysis method according to claim 1.
第1のモジュールと第2のモジュールとを含み、前記第1のモジュールは前記第2のモジュールを呼び出す呼び出し命令を含むプログラムを記憶する記憶部と、
前記第1のモジュールの入力に第1のシンボルを割り当て、前記呼び出し命令の前における第1の処理結果を前記第1のシンボルを用いて表した第1の情報を生成し、前記呼び出し命令の呼び出し結果に第2のシンボルを割り当て、前記第1のモジュールに含まれる複数の第1の実行パスそれぞれの前記呼び出し命令の後における第2の処理結果を前記第2のシンボルを用いて表した第2の情報を生成し、
前記第2のモジュールの入力に第3のシンボルを割り当て、前記第2のモジュールに含まれる複数の第2の実行パスそれぞれの第3の処理結果を前記第3のシンボルを用いて表した第3の情報を生成し、
前記第1の情報が示す前記第1の処理結果と前記第3の情報に用いられた前記第3のシンボルとを対応付け、また、前記第3の情報が示す前記第3の処理結果と前記第2の情報に用いられた前記第2のシンボルとを対応付けることで、前記複数の第1の実行パスと前記複数の第2の実行パスとを合成した複数の合成実行パスそれぞれの処理結果を前記第1のシンボルを用いて表したパス情報を生成する演算部と、
を有するプログラム分析装置。
A storage unit including a first module and a second module, wherein the first module stores a program including a call instruction for calling the second module;
A first symbol is assigned to an input of the first module, first information representing a first processing result before the call instruction is expressed using the first symbol, and the call of the call instruction is generated. A second symbol is assigned to the result, and a second processing result after the call instruction of each of the plurality of first execution paths included in the first module is expressed using the second symbol. Generate information for
A third symbol is assigned to the input of the second module, and a third processing result of each of a plurality of second execution paths included in the second module is expressed using the third symbol. Generate information for
The first processing result indicated by the first information is associated with the third symbol used for the third information, and the third processing result indicated by the third information is By associating the second symbol used for the second information, the processing results of the plurality of combined execution paths obtained by combining the plurality of first execution paths and the plurality of second execution paths are obtained. A calculation unit for generating path information represented by using the first symbol;
A program analysis apparatus.
コンピュータに、
第1のモジュールと第2のモジュールとを含み、前記第1のモジュールは前記第2のモジュールを呼び出す呼び出し命令を含むプログラムを取得し、
前記第1のモジュールの入力に第1のシンボルを割り当て、前記呼び出し命令の前における第1の処理結果を前記第1のシンボルを用いて表した第1の情報を生成し、前記呼び出し命令の呼び出し結果に第2のシンボルを割り当て、前記第1のモジュールに含まれる複数の第1の実行パスそれぞれの前記呼び出し命令の後における第2の処理結果を前記第2のシンボルを用いて表した第2の情報を生成し、
前記第2のモジュールの入力に第3のシンボルを割り当て、前記第2のモジュールに含まれる複数の第2の実行パスそれぞれの第3の処理結果を前記第3のシンボルを用いて表した第3の情報を生成し、
前記第1の情報が示す前記第1の処理結果と前記第3の情報に用いられた前記第3のシンボルとを対応付け、また、前記第3の情報が示す前記第3の処理結果と前記第2の情報に用いられた前記第2のシンボルとを対応付けることで、前記複数の第1の実行パスと前記複数の第2の実行パスとを合成した複数の合成実行パスそれぞれの処理結果を前記第1のシンボルを用いて表したパス情報を生成する、
処理を実行させる分析プログラム。
On the computer,
A first module and a second module, wherein the first module obtains a program including a call instruction for calling the second module;
A first symbol is assigned to an input of the first module, first information representing a first processing result before the call instruction is expressed using the first symbol, and the call of the call instruction is generated. A second symbol is assigned to the result, and a second processing result after the call instruction of each of the plurality of first execution paths included in the first module is expressed using the second symbol. Generate information for
A third symbol is assigned to the input of the second module, and a third processing result of each of a plurality of second execution paths included in the second module is expressed using the third symbol. Generate information for
The first processing result indicated by the first information is associated with the third symbol used for the third information, and the third processing result indicated by the third information is By associating the second symbol used for the second information, the processing results of the plurality of combined execution paths obtained by combining the plurality of first execution paths and the plurality of second execution paths are obtained. Generating path information represented using the first symbol;
An analysis program that executes processing.
JP2016095882A 2016-05-12 2016-05-12 Program analysis method, program analysis device, and analysis program Active JP6659955B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2016095882A JP6659955B2 (en) 2016-05-12 2016-05-12 Program analysis method, program analysis device, and analysis program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2016095882A JP6659955B2 (en) 2016-05-12 2016-05-12 Program analysis method, program analysis device, and analysis program

Publications (2)

Publication Number Publication Date
JP2017204164A true JP2017204164A (en) 2017-11-16
JP6659955B2 JP6659955B2 (en) 2020-03-04

Family

ID=60322226

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2016095882A Active JP6659955B2 (en) 2016-05-12 2016-05-12 Program analysis method, program analysis device, and analysis program

Country Status (1)

Country Link
JP (1) JP6659955B2 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2019106153A (en) * 2017-12-14 2019-06-27 富士通株式会社 Information processing device, analysis program and analysis method
JP2019139268A (en) * 2018-02-06 2019-08-22 富士通株式会社 Program analysis method, program analysis apparatus and program analysis program
WO2020194455A1 (en) 2019-03-25 2020-10-01 三菱電機株式会社 Test case generation device, test case generation method, and test case generation program
JP2021002276A (en) * 2019-06-24 2021-01-07 富士通株式会社 Analysis program, program analyzing method, and program analyzing apparatus

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2014119869A (en) * 2012-12-14 2014-06-30 Fujitsu Ltd Symbolic execution method, symbolic execution program and symbolic execution device
JP2015032282A (en) * 2013-08-07 2015-02-16 富士通株式会社 Test data generation program, method and device
US9152543B1 (en) * 2014-06-28 2015-10-06 Fujitsu Limited Symbolic execution with automatic abstractions
JP2016009344A (en) * 2014-06-25 2016-01-18 富士通株式会社 Test case generation program, test case generation method, and test case generation device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2014119869A (en) * 2012-12-14 2014-06-30 Fujitsu Ltd Symbolic execution method, symbolic execution program and symbolic execution device
JP2015032282A (en) * 2013-08-07 2015-02-16 富士通株式会社 Test data generation program, method and device
JP2016009344A (en) * 2014-06-25 2016-01-18 富士通株式会社 Test case generation program, test case generation method, and test case generation device
US9152543B1 (en) * 2014-06-28 2015-10-06 Fujitsu Limited Symbolic execution with automatic abstractions

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2019106153A (en) * 2017-12-14 2019-06-27 富士通株式会社 Information processing device, analysis program and analysis method
JP2019139268A (en) * 2018-02-06 2019-08-22 富士通株式会社 Program analysis method, program analysis apparatus and program analysis program
JP6993573B2 (en) 2018-02-06 2022-01-13 富士通株式会社 Program analysis method, program analysis device and program analysis program
WO2020194455A1 (en) 2019-03-25 2020-10-01 三菱電機株式会社 Test case generation device, test case generation method, and test case generation program
JP2021002276A (en) * 2019-06-24 2021-01-07 富士通株式会社 Analysis program, program analyzing method, and program analyzing apparatus
JP7244756B2 (en) 2019-06-24 2023-03-23 富士通株式会社 Analysis program, program analysis method and program analysis device

Also Published As

Publication number Publication date
JP6659955B2 (en) 2020-03-04

Similar Documents

Publication Publication Date Title
JP5347023B2 (en) Branch prediction device, branch prediction method, compiler, compilation method thereof, and branch prediction program recording medium
JP6659955B2 (en) Program analysis method, program analysis device, and analysis program
KR102573518B1 (en) Information processing method and device, electronic device, computer-readable medium and computer program stored in medium
CN105701006B (en) Method and system for the variation-tracking in program debugging
CN106471476A (en) For to optimized code edit and continue and enhanced optimized debugging technology
US9256437B2 (en) Code generation method, and information processing apparatus
JP2020017197A (en) Presentation method of information relating to basis of prediction value output by computing machine system and predictor
US20180173610A1 (en) Method for performing cared-zone code coverage evaluation with no source code modification
CN110580189A (en) method and device for generating front-end page, computer equipment and storage medium
US8898649B2 (en) Application program analysis method, analysis system and recording medium for identifying a contributing factor for an invalid operation of an application program
US20200241992A1 (en) System and method for dynamic domain-specific sequence diagram visualization
US9323719B2 (en) Mathematical expression input apparatus, mathematical expression modification method, and storage medium storing program
JPWO2013105158A1 (en) Data dependency analysis support device, data dependency analysis support program, and data dependency analysis support method
WO2016063502A1 (en) Knowledge management device, knowledge management method, and program recording medium
JP6486574B2 (en) Program code generating apparatus, program code generating method, and program code generating program
WO2018078735A1 (en) Information processing device, information processing method, and information processing program
JPWO2017141893A1 (en) Software analysis apparatus and software analysis method
US20130152049A1 (en) Warning of register and storage area assignment errors
JP2021128779A (en) Method, device, apparatus, and storage medium for expanding data
JP2011170749A (en) Simulation device and simulation method
JP2005332098A (en) Testing item extraction system, testing item extraction device, testing item extraction method used for the device, and program therefor
JP5163172B2 (en) Software test item editing support apparatus and software test item editing support method
JP7260150B2 (en) WEBSITE DESIGN SUPPORT DEVICE, WEBSITE DESIGN SUPPORT METHOD, AND PROGRAM
JPWO2017204139A1 (en) Data processing apparatus, data processing method, and program recording medium
JP2007080049A (en) Built-in program generation method, built-in program development system and information table section

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20190212

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20191209

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: 20200107

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20200120

R150 Certificate of patent or registration of utility model

Ref document number: 6659955

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150