JP2014044678A - Compiler evaluation device, method, and program - Google Patents

Compiler evaluation device, method, and program Download PDF

Info

Publication number
JP2014044678A
JP2014044678A JP2012188008A JP2012188008A JP2014044678A JP 2014044678 A JP2014044678 A JP 2014044678A JP 2012188008 A JP2012188008 A JP 2012188008A JP 2012188008 A JP2012188008 A JP 2012188008A JP 2014044678 A JP2014044678 A JP 2014044678A
Authority
JP
Japan
Prior art keywords
execution
program
test data
source program
compiler
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
JP2012188008A
Other languages
Japanese (ja)
Other versions
JP5908374B2 (en
Inventor
Yoshitomi Sameda
芳富 鮫田
Takayuki Nitta
能之 新田
Naoya Onishi
直哉 大西
Tomoki Enomoto
知己 榎本
Atsushi Kojima
敦 児島
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.)
Toshiba Corp
Original Assignee
Toshiba Corp
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 Toshiba Corp filed Critical Toshiba Corp
Priority to JP2012188008A priority Critical patent/JP5908374B2/en
Publication of JP2014044678A publication Critical patent/JP2014044678A/en
Application granted granted Critical
Publication of JP5908374B2 publication Critical patent/JP5908374B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a compiler evaluation technique which allows a single compiler to check whether or not a source program and an execution program match with each other.SOLUTION: A compiler evaluation device 10 includes: a first holding unit 11 that holds a source program which is described in a programming language; a second holding unit 12 that holds an execution program into which the source program has been compiled so as to be executed by a processor; a test data generation unit 15 that generates test data on the basis of at least either the source program or execution program; a third holding unit 13 that holds the test data and transmits it to execution means (a target CPU 21) of the execution program; an interpreter 17 that inputs the test data and executes the source program; and a determination unit 18 that compares an execution result of the execution means (the target CPU 21) and an execution result of the interpreter 17 and determines whether they match with each other.

Description

本発明は、ソースプログラムを実行プログラムにコンパイルするコンパイラの評価技術に関する。   The present invention relates to a compiler evaluation technique for compiling a source program into an execution program.

プログラミング言語で記述されたソースプログラムは、内容が完全に一致した状態で、ターゲットマシンに直接理解される実行プログラムにコンパイルされることが望まれる。
ソースプログラムと、このソースプログラムからコンパイルされた実行プログラムとの一致又は不一致は、例えば次のようにして確認することができる。
It is desirable that a source program written in a programming language be compiled into an execution program that can be directly understood by the target machine, with the contents completely matched.
The match or mismatch between the source program and the execution program compiled from the source program can be confirmed as follows, for example.

つまり、ソースプログラムのコンパイラを複数用意し、互いに異なる動作環境で動作する複数の実行プログラムを生成する。そして、生成された複数の実行プログラムに対し、同一の入力値を与え、得られた出力値のそれぞれを比較することによって、コンパイラのバグを間接的に検出することができる。
この2種類のコンパイラにおいて、共通の箇所に同じバグが存在する可能性は極めて低い。このため、出力結果に不一致が存在すれば、いずれか一方のコンパイラにバグの存在が推定される(例えば、特許文献1,2)。
That is, a plurality of source program compilers are prepared, and a plurality of execution programs that operate in different operating environments are generated. Then, it is possible to indirectly detect a compiler bug by giving the same input value to a plurality of generated execution programs and comparing the obtained output values.
In these two types of compilers, it is very unlikely that the same bug exists at a common location. For this reason, if there is a discrepancy in the output results, the presence of a bug in one of the compilers is estimated (for example, Patent Documents 1 and 2).

特開2005−141406号公報JP-A-2005-141406 特開2004−227129号公報JP 2004-227129 A

上述したソースプログラムと実行プログラムとの一致・不一致の確認作業は、バグ位置が不一致であることが期待される、製造元の異なる2種類のコンパイラが必要となる。
しかし、CPUによっては、このように2種類のコンパイラを入手することが困難な場合があり、この場合は、ソースプログラムと実行プログラムの一致・不一致を確認することが不可能である。
The above-described confirmation work of matching / mismatching between the source program and the execution program requires two types of compilers from different manufacturers that are expected to have mismatched bug positions.
However, depending on the CPU, it may be difficult to obtain two types of compilers in this way. In this case, it is impossible to confirm the match / mismatch between the source program and the execution program.

本発明はこのような事情を考慮してなされたもので、単独のコンパイラで、ソースプログラムと実行プログラムとの一致・不一致を確認することができるコンパイラ評価技術を提供することを目的とする。   The present invention has been made in consideration of such circumstances, and an object of the present invention is to provide a compiler evaluation technique capable of confirming the match / mismatch between a source program and an execution program with a single compiler.

コンパイラ評価装置において、プログラミング言語で記述されたソースプログラムを保持する第1保持部と、前記ソースプログラムをプロセッサで実行できるようにコンパイルした実行プログラムを保持する第2保持部と、前記ソースプログラム及び前記実行プログラムの少なくとも一方に基づいてテストデータを生成するテストデータ生成部と、前記テストデータを保持し前記実行プログラムの実行手段に送出する第3保持部と、前記テストデータを入力し前記ソースプログラムを実行するインタープリタと、前記実行プログラムの実行手段の実行結果及び前記インタープリタの実行結果を対比して一致するか否かを判定する判定部とを、備えることを特徴とする。   In the compiler evaluation apparatus, a first holding unit for holding a source program described in a programming language, a second holding unit for holding an execution program compiled so that the source program can be executed by a processor, the source program, and the A test data generation unit that generates test data based on at least one of the execution programs, a third holding unit that holds the test data and sends the test data to the execution unit of the execution program, and inputs the test data to the source program An interpreter to be executed, and a determination unit that determines whether or not the execution result of the execution unit of the execution program and the execution result of the interpreter match are determined.

本発明により、単独のコンパイラで、ソースプログラムと実行プログラムとの一致・不一致を確認することができるコンパイラ評価技術が提供される。   According to the present invention, there is provided a compiler evaluation technique capable of confirming a match / mismatch between a source program and an execution program with a single compiler.

本発明の第1実施形態に係るコンパイラ評価装置を示すブロック図。1 is a block diagram showing a compiler evaluation apparatus according to a first embodiment of the present invention. ソースプログラムを構成する関数の一例を示す図。The figure which shows an example of the function which comprises a source program. 図2に示すソースプログラムの関数に対応する実行プログラムを示す図。The figure which shows the execution program corresponding to the function of the source program shown in FIG. 第1実施形態におけるテストデータ生成部のアルゴリズムを示すフローチャート。The flowchart which shows the algorithm of the test data generation part in 1st Embodiment. 第1実施形態におけるテストデータを示す表。The table | surface which shows the test data in 1st Embodiment. インタープリタのアルゴリズムを示すフローチャート。The flowchart which shows the algorithm of an interpreter. 判定部のアルゴリズムを示すフローチャート。The flowchart which shows the algorithm of a determination part. 第1実施形態におけるテストデータに基づく判定結果を示す表。The table | surface which shows the determination result based on the test data in 1st Embodiment. 第2実施形態におけるテストデータ生成部のアルゴリズムを示すフローチャート。The flowchart which shows the algorithm of the test data generation part in 2nd Embodiment. 第2実施形態におけるテストデータを示す表。The table | surface which shows the test data in 2nd Embodiment. 第2実施形態におけるテストデータに基づく判定結果を示す表。The table | surface which shows the determination result based on the test data in 2nd Embodiment. 本発明の第3実施形態に係るコンパイラ評価装置を示すブロック図。The block diagram which shows the compiler evaluation apparatus which concerns on 3rd Embodiment of this invention. 第3実施形態におけるターゲットCPUエミュレータのアルゴリズムを示すフローチャート。The flowchart which shows the algorithm of the target CPU emulator in 3rd Embodiment. 本発明の第4実施形態に係るコンパイラ評価装置を示すブロック図。The block diagram which shows the compiler evaluation apparatus which concerns on 4th Embodiment of this invention. 第4実施形態に係るコンパイラ評価装置の変形例を示すブロック図。The block diagram which shows the modification of the compiler evaluation apparatus which concerns on 4th Embodiment. 内部範囲(a,b)が設定されたソースプログラムの一例を示す図。The figure which shows an example of the source program in which the internal range (a, b) was set. 比較範囲(A,B)が設定された実行プログラムの一例を示す図。The figure which shows an example of the execution program in which the comparison range (A, B) was set. 第4実施形態における範囲設定部のアルゴリズムを示すフローチャート。The flowchart which shows the algorithm of the range setting part in 4th Embodiment. 第4実施形態において範囲設定されたプログラム(範囲a,A)における実行結果の判定結果を示す表。The table | surface which shows the determination result of the execution result in the program (range a, A) by which the range was set in 4th Embodiment. 第4実施形態において範囲設定されたプログラム(範囲b,B)における実行結果の判定結果を示す表。The table | surface which shows the determination result of the execution result in the program (range b, B) by which the range was set in 4th Embodiment. 第5実施形態における範囲設定部のアルゴリズムを示すフローチャート。The flowchart which shows the algorithm of the range setting part in 5th Embodiment. 第5実施形態において範囲設定されたプログラム(範囲a,A)における実行結果の判定結果を示す表。The table | surface which shows the determination result of the execution result in the program (range a, A) by which the range was set in 5th Embodiment. 第5実施形態において範囲設定されたプログラム(範囲b,B)における実行結果の判定結果を示す表。The table | surface which shows the determination result of the execution result in the program (range b, B) by which the range was set in 5th Embodiment. (A)実行プログラムから入力変数を抽出する方法において実行プログラムから入力変数を抽出するアルゴリズムを示す図、(B)実行プログラムから入力変数を抽出する方法において実行プログラムから入力変数を抽出する例を示す図。(A) The figure which shows the algorithm which extracts an input variable from an execution program in the method of extracting an input variable from an execution program, (B) The example which extracts the input variable from an execution program in the method of extracting an input variable from an execution program is shown Figure.

(第1実施形態)
以下、本発明の実施形態を添付図面に基づいて説明する。
図1に示すように第1実施形態に係るコンパイラ評価装置10は、プログラミング言語で記述されたソースプログラムを保持する第1保持部11と、このソースプログラムをプロセッサで実行できるようにコンパイルした実行プログラムを保持する第2保持部12と、このソースプログラム及び実行プログラムの少なくとも一方に基づいてテストデータを生成するテストデータ生成部15と、このテストデータを保持し実行プログラムの実行手段(ターゲットCPU21)に送出する第3保持部13と、テストデータを入力しソースプログラムを実行するインタープリタ17と、実行プログラムの実行手段(ターゲットCPU21)の実行結果及びインタープリタ17の実行結果を対比して一致するか否かを判定する判定部18とを、備えている。
(First embodiment)
Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings.
As shown in FIG. 1, a compiler evaluation apparatus 10 according to the first embodiment includes a first holding unit 11 that holds a source program described in a programming language, and an execution program that is compiled so that the source program can be executed by a processor. A second holding unit 12 that holds the test data, a test data generation unit 15 that generates test data based on at least one of the source program and the execution program, and execution means (target CPU 21) for holding the test data and executing the program Whether or not the third holding unit 13 to be sent out, the interpreter 17 that inputs test data and executes the source program, and the execution result of the execution means (target CPU 21) of the execution program and the execution result of the interpreter 17 match. A determination unit 18 for determining That.

第1保持部11は、プログラミング言語で記述されたソースプログラムを外部入力し保持するものである。
図2は、ソースプログラムを構成する関数の一例を示し、図3はこの図2に示すソースプログラムの関数に対応する実行プログラムを示している。
The first holding unit 11 externally inputs and holds a source program described in a programming language.
FIG. 2 shows an example of a function constituting the source program, and FIG. 3 shows an execution program corresponding to the function of the source program shown in FIG.

ソースプログラムは、プログラマが読み書きすることを前提に作成されたもので、一連の処理を実行する関数を単位として、複数の関数が羅列して構成されている。
そして、関数は、if, while, do-while, for, switch等で定義されるプログラムパスの組み合わせからなり、入力変数を受け取って、実行結果を引き渡す。
The source program is created on the assumption that the programmer reads and writes, and is configured by arranging a plurality of functions in units of functions that execute a series of processes.
The function is a combination of program paths defined by if, while, do-while, for, switch, etc., receives an input variable, and delivers an execution result.

コンパイラ14は、第1保持部11からソースプログラムを取得して、プロセッサ(ターゲットCPU21)において実行可能な実行プログラムにコンパイルするものである。
プロセッサは、ソースプログラムを直接理解することができないために、図3で示されるようなバイナリコードで表される実行プログラムにより処理がなされる。
The compiler 14 acquires a source program from the first holding unit 11 and compiles it into an execution program that can be executed by the processor (target CPU 21).
Since the processor cannot directly understand the source program, processing is performed by an execution program represented by binary code as shown in FIG.

第1実施形態におけるテストデータ生成部15は、ソースプログラムを構成する関数(図2)を単位として抽出された入力変数(int a, int b)の組み合わせに基づくテストデータ(図5)を生成するものである。
そして、生成されたテストデータ(図5)は、第3保持部13に保持される。
The test data generation unit 15 in the first embodiment generates test data (FIG. 5) based on a combination of input variables (int a, int b) extracted in units of functions (FIG. 2) constituting the source program. Is.
Then, the generated test data (FIG. 5) is held in the third holding unit 13.

図4のフローチャートに基づいて第1実施形態におけるテストデータ生成部15のアルゴリズムを説明する(適宜、図1,図2参照)。
テストデータ生成部15は、第1保持部11からソースプログラムを読み込み(S11)、ソースプログラムの入力変数(int a, int b)を抽出する(S12)。
The algorithm of the test data generation unit 15 in the first embodiment will be described based on the flowchart of FIG. 4 (see FIGS. 1 and 2 as appropriate).
The test data generation unit 15 reads the source program from the first holding unit 11 (S11), and extracts input variables (int a, int b) of the source program (S12).

そして、第2保持部12から実行プログラムを読み込み(S13)、実行プログラムの入力変数(R1,R2)を抽出する(S14)。   Then, the execution program is read from the second holding unit 12 (S13), and the input variables (R1, R2) of the execution program are extracted (S14).

図24(A)は、実行プログラムから入力変数を抽出するアルゴリズムを示す図である。図24(A)に示すように、実行プログラムを逆アセンブルし、ソースプログラムと実行プログラムを比較して、ソースプログラムの入力変数に対応する実行プログラムの入力変数を決定する。   FIG. 24A is a diagram showing an algorithm for extracting input variables from the execution program. As shown in FIG. 24A, the execution program is disassembled, the source program and the execution program are compared, and the input variable of the execution program corresponding to the input variable of the source program is determined.

図24(B)は、実行プログラムから入力変数を抽出する例を示す図である。図24(B)の例のように、"c = 0"に対応するアセンブラは"LDI R10,0"でありcとR10が対応し、"a++"に対応するアセンブラは"ADDI R1,R1,1"でありaとR1が対応し、"while(a < b)"に対応するアセンブラは"CMP R1,R2"でありbとR2が対応することを決定する。   FIG. 24B is a diagram illustrating an example of extracting input variables from the execution program. As in the example of FIG. 24B, the assembler corresponding to “c = 0” is “LDI R10,0”, c and R10 are corresponding, and the assembler corresponding to “a ++” is “ADDI R1, R1,” The assembler corresponding to “while (a <b)” is “CMP R1, R2”, and b and R2 are determined to correspond to “while (a <b)”.

さらに、図5に示すように、テストデータ生成部15は、入力変数の全ての組み合わせについて、テストデータ出力する(S15)。   Furthermore, as shown in FIG. 5, the test data generation unit 15 outputs test data for all combinations of input variables (S15).

変数aおよびbが8ビットの場合、変数a、bの値の範囲は、-128〜+127であるので、入力変数の全ての組合せは、
(a,b) : (-128,-128) , (-128,-127), ... , (+127,+127)
となる。テストデータは、2の16乗通り必要である。
When variables a and b are 8 bits, the range of values of variables a and b is -128 to +127, so all combinations of input variables are
(a, b): (-128, -128), (-128, -127), ..., (+ 127, + 127)
It becomes. The test data is required to be 2 to the 16th power.

変数aおよびbが16ビットの場合、変数a、bの値の範囲は、-32768〜+32767であるので、入力変数の全ての組合せは、
(a,b) : (-32768,-32768) , (-32768,-32767), ... , (+32767,+32767)
となる。テストデータは2の32乗通り必要である。
If the variables a and b are 16 bits, the range of values of the variables a and b is -32768 to +32767, so all combinations of input variables are
(a, b): (-32768, -32768), (-32768, -32767), ..., (+ 32767, + 32767)
It becomes. Test data is required to be 2 to the power of 32.

このテストデータの生成は、上述の方法でソースプログラムおよび実行プログラムから抽出した入力変数のいずれか一方に基づいて生成することができる。
なお、図5において、多数あるテストデータがのうち一部を示している。
The test data can be generated based on one of the input variables extracted from the source program and the execution program by the method described above.
In FIG. 5, a part of the large number of test data is shown.

第3保持部13は、保持しているテストデータをインタープリタ17及び実行プログラムの実行手段(ターゲットCPU21)に送出する。
第1実施形態における実行プログラムの実行手段(ターゲットCPU21)は外部機器20に設けられている。
このために、第1実施形態のコンパイラ評価装置10は、外部機器20に接続して、ソースプログラム及び実行プログラムの一致・不一致を判定する。
The third holding unit 13 sends the held test data to the interpreter 17 and execution program execution means (target CPU 21).
Execution means (target CPU 21) of the execution program in the first embodiment is provided in the external device 20.
For this purpose, the compiler evaluation apparatus 10 according to the first embodiment is connected to the external device 20 to determine whether the source program and the execution program match.

ターゲットCPU21は、第2保持部12から実行プログラムを取得し、第3保持部13から入力変数の組み合わせの異なる複数のテストデータを入力して実行する。そして、ターゲットCPU21は、この実行結果を判定部18に出力する。
インタープリタ17は、第1保持部11からソースプログラムを取得し、第3保持部13から入力変数の組み合わせの異なる複数のテストデータを入力して実行する。そして、インタープリタ17は、この実行結果を判定部18に出力する。
The target CPU 21 acquires an execution program from the second holding unit 12 and inputs and executes a plurality of test data having different combinations of input variables from the third holding unit 13. Then, the target CPU 21 outputs this execution result to the determination unit 18.
The interpreter 17 acquires a source program from the first holding unit 11 and inputs and executes a plurality of test data having different combinations of input variables from the third holding unit 13. Then, the interpreter 17 outputs the execution result to the determination unit 18.

図6のフローチャートに基づいてインタープリタ17のアルゴリズムを説明する(適宜、図1参照)。
インタープリタ17は、第1保持部11からソースプログラムを読み込み(S21)、ソースプログラムの構文解析を行って中間コードを生成する(S22)。
そして、インタープリタ17は、第3保持部13からテストデータを読み込み(S23)、中間コードを実行し(S24)、実行結果を判定部18に出力する(S25)。
The algorithm of the interpreter 17 will be described based on the flowchart of FIG. 6 (see FIG. 1 as appropriate).
The interpreter 17 reads the source program from the first holding unit 11 (S21), performs syntax analysis of the source program, and generates an intermediate code (S22).
The interpreter 17 reads the test data from the third holding unit 13 (S23), executes the intermediate code (S24), and outputs the execution result to the determination unit 18 (S25).

判定部18は、実行プログラムの実行手段(ターゲットCPU21)の実行結果及びインタープリタ17の実行結果を対比して一致するか否かを判定する。
ここで、複数のテストデータについての実行結果のうち、同一のテストデータについてのソースプログラムと実行プログラムの実行結果を対比するためには、同一のテストデータを順にソースプログラムと実行プログラムに入力して実行させて実行結果を順に比較する方法や、実効結果にテストデータの識別情報を付加することでソースプログラムと実行プログラムの実行結果を同一のテストデータについてソートし比較する方法等を適用することができる。
The determination unit 18 compares the execution result of the execution means (target CPU 21) of the execution program and the execution result of the interpreter 17 to determine whether or not they match.
Here, among the execution results for a plurality of test data, in order to compare the execution results of the source program and the execution program for the same test data, the same test data is sequentially input to the source program and the execution program. It is possible to apply a method of comparing the execution results in order, or a method of sorting and comparing the execution results of the source program and the execution program with respect to the same test data by adding test data identification information to the effective results. it can.

そして、判定部18は、一致又は不一致の判定結果を結果出力部19に送出し、さらにこの判定結果に基づいてコンパイラ14にバグが含まれるか否かの認定結果も結果出力部19に送出する。   Then, the determination unit 18 transmits a determination result of coincidence or mismatch to the result output unit 19, and further transmits a determination result as to whether or not the compiler 14 includes a bug based on the determination result to the result output unit 19. .

図7のフローチャートに基づいて判定部18のアルゴリズムを説明する(適宜、図1及び図8参照)。ここで図8は、第1実施形態におけるテストデータに基づく判定結果を示す表である。
判定部18は、実行プログラムの実行手段(ターゲットCPU21)及びインタープリタ17から、入力変数の組み合わせ([int a, int b], [R1, R2])が同一のテストデータの実行結果(c, R10)をそれぞれ読み込む(S31)。
そして、これら二つの実行結果(c, R10)を対比して一致しているか否かを判定し(S32)、「一致」又は「不一致」の判定結果を出力する(S33,S34)。
そして、生成したテストデータのうち一つでも「不一致」の判定結果が得られた場合はコンパイラ14にバグが含まれると認定され、全てが「一致」の場合はバグが発見されないと認定され、その旨が表示される(S35)。
The algorithm of the determination part 18 is demonstrated based on the flowchart of FIG. 7 (refer FIG.1 and FIG.8 suitably). Here, FIG. 8 is a table showing determination results based on the test data in the first embodiment.
The determination unit 18 executes the execution results (c, R10) of the test data having the same combination of input variables ([int a, int b], [R1, R2]) from the execution means (target CPU 21) and the interpreter 17 of the execution program. ) Are read (S31).
Then, these two execution results (c, R10) are compared to determine whether or not they match (S32), and a determination result of “match” or “mismatch” is output (S33, S34).
If even one of the generated test data results in a “mismatch” determination, it is certified that the compiler 14 contains a bug, and if all match, it is certified that no bug is found, A message to that effect is displayed (S35).

(第2実施形態)
次に図1を参照して本発明における第2実施形態について説明する。
なお第2実施形態におけるコンパイラ評価装置10において、テストデータ生成部15の作用を除くその他の構成は、第1実施形態と共通するために重複する説明を省略する。
(Second Embodiment)
Next, a second embodiment of the present invention will be described with reference to FIG.
Note that in the compiler evaluation apparatus 10 in the second embodiment, the other configurations except for the operation of the test data generation unit 15 are the same as those in the first embodiment, and thus redundant description is omitted.

第2実施形態におけるテストデータ生成部15は、ソースプログラムを構成する関数(図2)を単位として抽出されたプログラムパスの実行又は不実行の組み合わせに基づくテストデータ(図10)を生成するものである。
ここで、プログラムパスとは、if, while, do-while, for, switch等により規定されたデータ処理の実行順番を制御す命令である。
The test data generation unit 15 in the second embodiment generates test data (FIG. 10) based on a combination of execution or non-execution of program paths extracted in units of functions (FIG. 2) constituting the source program. is there.
Here, the program path is an instruction that controls the execution order of data processing defined by if, while, do-while, for, switch, and the like.

図9のフローチャートに基づいて第2実施形態におけるテストデータ生成部15のアルゴリズムを説明する(適宜、図1参照)。
ここで、図9のステップS41からステップS44は、図4のステップS11からステップS14に対応するので重複する説明を省略する。
Based on the flowchart of FIG. 9, the algorithm of the test data generation part 15 in 2nd Embodiment is demonstrated (refer FIG. 1 suitably).
Here, steps S41 to S44 in FIG. 9 correspond to steps S11 to S14 in FIG.

ソースプログラムの関数を構成するif, switch, while, do-while, for等で規定されるプログラムパスの構造解析が行なわれる(S45)。
なお、制御構造の条件分岐に用いられる変数については、全てのプログラムパスを実行するテストデータを生成する。この場合、ランダムに値を割り当てて全てのプログラムパスを実行する値を用いる方法、条件分岐の条件から全てのプログラムパスを実行する値を求める方法、などを用いる。
そして、図10に示すように、テストデータ生成部15は、プログラムパスの実行又は不実行の全ての組み合わせについて、対応するテストデータ出力する(S46)。
The structure analysis of the program path defined by if, switch, while, do-while, for, etc., constituting the function of the source program is performed (S45).
For variables used for conditional branching of the control structure, test data for executing all program paths is generated. In this case, a method that uses a value that randomly assigns a value and executes all program paths, a method that obtains a value that executes all program paths from conditional branch conditions, and the like are used.
Then, as shown in FIG. 10, the test data generation unit 15 outputs corresponding test data for all combinations of execution or non-execution of the program path (S46).

図7のフローチャートに基づいて第2実施形態における判定部18のアルゴリズムを説明する(適宜、図1及び図11参照)。図11は、第2実施形態におけるテストデータに基づく判定結果を示す表である。
判定部18は、実行プログラムの実行手段(ターゲットCPU21)及びインタープリタ17から、プログラムパスの実行又は不実行の組み合わせ([int a, int b], [R1, R2])が同一のテストデータの実行結果(c, R10)をそれぞれ読み込む(S31)。
Based on the flowchart of FIG. 7, the algorithm of the determination part 18 in 2nd Embodiment is demonstrated (refer FIG.1 and FIG.11 suitably). FIG. 11 is a table showing determination results based on test data in the second embodiment.
The determination unit 18 executes test data having the same combination of program path execution or non-execution ([int a, int b], [R1, R2]) from the execution means (target CPU 21) and the interpreter 17 of the execution program. Each result (c, R10) is read (S31).

そして、これら二つの実行結果を対比して一致しているか否かを判定し(S32)、「一致」又は「不一致」の判定結果を出力する(S33,S34)。
そして、生成したテストデータのうち一つでも「不一致」の判定結果が得られた場合はコンパイラ14にバグが含まれると認定され、全てが「一致」の場合はバグが発見されないと認定され、その旨が表示される(S35)。
第2実施形態によれば、一致・不一致の判定を行うテストデータの数を削減することができ、コンパイラ14にバグが含まれるか否かの認定を簡素化できる。
Then, these two execution results are compared to determine whether or not they match (S32), and a determination result of “match” or “mismatch” is output (S33, S34).
If even one of the generated test data results in a “mismatch” determination, it is certified that the compiler 14 contains a bug, and if all match, it is certified that no bug is found, A message to that effect is displayed (S35).
According to the second embodiment, it is possible to reduce the number of test data for performing a match / mismatch determination, and it is possible to simplify recognition of whether or not a bug is included in the compiler 14.

(第3実施形態)
次に図12を参照して本発明における第3実施形態について説明する。
なお第3実施形態におけるコンパイラ評価装置10は、実行プログラムの実行手段がターゲットCPUをエミュレートするために内蔵されたエミュレータ22である点を除き、その他の構成は、第1実施形態及び第2実施形態と共通する。なお、図12において図1と共通の構成又は機能を有する部分は、同一符号で示し、重複する説明を省略する。
(Third embodiment)
Next, a third embodiment of the present invention will be described with reference to FIG.
The compiler evaluation apparatus 10 according to the third embodiment is the same as the first embodiment and the second embodiment except that the execution unit of the execution program is an emulator 22 built in to emulate the target CPU. Common with form. In FIG. 12, parts having the same configuration or function as those in FIG. 1 are denoted by the same reference numerals, and redundant description is omitted.

このエミュレータ22は、第2保持部12から実行プログラムを取得し、第3保持部13から複数のテストデータを入力して実行する。そして、エミュレータ22は、この実行結果を判定部18に出力する。   The emulator 22 acquires an execution program from the second holding unit 12 and inputs a plurality of test data from the third holding unit 13 for execution. Then, the emulator 22 outputs the execution result to the determination unit 18.

図13のフローチャートに基づいてターゲットCPUのエミュレータ22のアルゴリズムを説明する(適宜、図12参照)。
エミュレータ22は、第2保持部12から実行プログラムを読み込む(S51)。そして、第3保持部13からテストデータを読み込んで実行プログラムを実行し(S52)、実行結果を判定部18に出力する(S53)。
第3実施形態によれば、一つのコンピュータのみで、ソースプログラムと実行プログラムの一致・不一致を判定することができる。
The algorithm of the emulator 22 of the target CPU will be described based on the flowchart of FIG. 13 (see FIG. 12 as appropriate).
The emulator 22 reads the execution program from the second holding unit 12 (S51). Then, the test data is read from the third holding unit 13 and the execution program is executed (S52), and the execution result is output to the determination unit 18 (S53).
According to the third embodiment, it is possible to determine the match / mismatch between the source program and the execution program with only one computer.

(第4実施形態)
次に図14を参照して本発明における第4実施形態について説明する。
図14は第4実施形態におけるコンパイラ評価装置の基本構成を示す構成図を示し、図15は第4実施形態の変形例を示している。そして、図14及び図15は、それぞれ図1及び図12に対応している。
なお、図14及び図15において図1及び図12と共通の構成又は機能を有する部分は、同一符号で示し、重複する説明を省略する。
(Fourth embodiment)
Next, a fourth embodiment of the present invention will be described with reference to FIG.
FIG. 14 is a block diagram showing the basic configuration of the compiler evaluation apparatus in the fourth embodiment, and FIG. 15 shows a modification of the fourth embodiment. 14 and 15 correspond to FIGS. 1 and 12, respectively.
In FIGS. 14 and 15, portions having the same configuration or function as those in FIGS. 1 and 12 are denoted by the same reference numerals, and redundant description is omitted.

第4実施形態に係るコンパイラ評価装置10は、ソースプログラムを構成する関数(図16)の内部範囲(a,b)を設定するとともにこの内部範囲(a,b)に対応する前記実行プログラム(図17)の比較範囲(A,B)を設定する範囲設定部16をさらに備えている。   The compiler evaluation apparatus 10 according to the fourth embodiment sets an internal range (a, b) of a function (FIG. 16) constituting a source program and also executes the execution program (FIG. 16) corresponding to the internal range (a, b). A range setting unit 16 for setting the comparison range (A, B) of 17) is further provided.

図18のフローチャートに基づいて第4実施形態における範囲設定部16のアルゴリズムを説明する(適宜、図14参照)。なお図19は第4実施形態において範囲設定されたプログラム(範囲a,A)における実行結果の一致・不一致の判定結果を示し、図20は範囲設定されたプログラム(範囲b,B)における実行結果の一致・不一致の判定結果を示している。   Based on the flowchart of FIG. 18, the algorithm of the range setting part 16 in 4th Embodiment is demonstrated (refer FIG. 14 suitably). Note that FIG. 19 shows the determination result of the match / mismatch of the execution results in the range-set program (range a, A) in the fourth embodiment, and FIG. 20 shows the execution result in the range-set program (range b, B). Match / mismatch judgment results are shown.

範囲設定部16は、第1保持部11からソースプログラムを読み込み(S61)、関数の内部範囲(a,b)を設定する(S62)。
なお、この内部範囲の設定方法は、ソースプログラムに#pragma命令で指定する方法、ソースプログラムの何行目〜何行目と別ファイル指定する方法等が挙げられる。
そして、第2保持部12から実行プログラムを読み込み(S63)、内部範囲(a,b)に対応する実行プログラムの比較範囲(A,B)を設定する(S64)。
The range setting unit 16 reads the source program from the first holding unit 11 (S61), and sets the internal range (a, b) of the function (S62).
Examples of the method for setting the internal range include a method of specifying a #pragma instruction in the source program, a method of specifying a file in what number line to what line of the source program, and the like.
Then, the execution program is read from the second holding unit 12 (S63), and the comparison range (A, B) of the execution program corresponding to the internal range (a, b) is set (S64).

テストデータ生成部15は、ソースプログラムの内部範囲(a,b)及び前記実行プログラムの比較範囲(A,B)の少なくとも一方に基づいてテストデータを生成する。
第4実施形態によれば、プログラムを構成する関数にさらに内部範囲を設定するので、一致・不一致の判定を行うテストデータの数を削減することができ、コンパイラ14にバグが含まれるか否かの認定を簡素化できる。
The test data generation unit 15 generates test data based on at least one of the internal range (a, b) of the source program and the comparison range (A, B) of the execution program.
According to the fourth embodiment, since the internal range is further set in the functions constituting the program, it is possible to reduce the number of test data for determining match / mismatch, and whether or not the compiler 14 includes a bug. Can be simplified.

(第5実施形態)
次に図21を参照して本発明における第5実施形態について説明する。
なお第5実施形態におけるコンパイラ評価装置10は、範囲設定部16(図14,図15)が、ソースプログラムのプログラムパスを単位として内部範囲(a,b:図16)及び比較範囲(A,B:図17)を設定する点を除き、その他の構成は、第4実施形態と共通するために重複する説明を省略する。
(Fifth embodiment)
Next, a fifth embodiment of the present invention will be described with reference to FIG.
In the compiler evaluation apparatus 10 according to the fifth embodiment, the range setting unit 16 (FIGS. 14 and 15) has an internal range (a, b: FIG. 16) and a comparison range (A, B) with the program path of the source program as a unit. : Except for the point of setting FIG. 17), the other configurations are the same as those in the fourth embodiment, and thus redundant description is omitted.

図21のフローチャートに基づいて第5実施形態における範囲設定部16のアルゴリズムを説明する(適宜、図14参照)。なお図22は第5実施形態において範囲設定されたプログラム(範囲a,A)における実行結果の一致・不一致の判定結果を示し、図23は範囲設定されたプログラム(範囲b,B)における実行結果の一致・不一致の判定結果を示している。   Based on the flowchart of FIG. 21, the algorithm of the range setting part 16 in 5th Embodiment is demonstrated (refer FIG. 14 suitably). FIG. 22 shows the determination result of the match / mismatch of the execution results in the range-set program (range a, A) in the fifth embodiment, and FIG. 23 shows the execution result in the range-set program (range b, B). Match / mismatch judgment results are shown.

範囲設定部16は、第1保持部11からソースプログラムを読み込み(S71)、ソースプログラムの関数を構成するif, switch, while, do-while, for等で規定されるプログラムパスを抽出する(S72)。
そして、第2保持部12から実行プログラムを読み込み(S73)、内部範囲(a,b)に対応する実行プログラムの比較範囲(A,B)を設定する(S74)。
The range setting unit 16 reads the source program from the first holding unit 11 (S71), and extracts the program path defined by if, switch, while, do-while, for, etc. that constitutes the function of the source program (S72). ).
Then, the execution program is read from the second holding unit 12 (S73), and the comparison range (A, B) of the execution program corresponding to the internal range (a, b) is set (S74).

テストデータ生成部15は、ソースプログラムの内部範囲(a,b)及び前記実行プログラムの比較範囲(A,B)の少なくとも一方に基づいてテストデータを生成する。
第5実施形態によれば、プログラムを構成する関数にさらにプログラムパスを単位として内部範囲を設定するので、一致・不一致の判定を行うテストデータの数を削減することができ、コンパイラ14にバグが含まれるか否かの認定を簡素化できる。
The test data generation unit 15 generates test data based on at least one of the internal range (a, b) of the source program and the comparison range (A, B) of the execution program.
According to the fifth embodiment, since an internal range is further set for each function constituting the program in units of program paths, the number of test data for determining match / mismatch can be reduced, and the compiler 14 has a bug. It can simplify the certification of inclusion.

以上述べた少なくともひとつの実施形態のコンパイラ評価装置によれば、生成したテストデータに対し、ソースプログラムから直接得られる実行結果と実行プログラムから直接得られる実行結果とを対比することにより、コンパイラのバグの有無を評価することが可能となる。   According to the compiler evaluation apparatus of at least one embodiment described above, a compiler bug can be obtained by comparing the execution result directly obtained from the source program with the execution result directly obtained from the execution program against the generated test data. It becomes possible to evaluate the presence or absence of.

本発明のいくつかの実施形態を説明したが、これらの実施形態は、例として提示したものであり、発明の範囲を限定することは意図していない。これら実施形態は、その他の様々な形態で実施されることが可能であり、発明の要旨を逸脱しない範囲で、種々の省略、置き換え、変更、組み合わせを行うことができる。これら実施形態やその変形は、発明の範囲や要旨に含まれると同様に、特許請求の範囲に記載された発明とその均等の範囲に含まれるものである。
また、コンパイラ評価装置の構成要素は、コンピュータのプロセッサで実現することも可能であり、コンパイラ評価プログラムにより動作させることが可能である。
Although several embodiments of the present invention have been described, these embodiments are presented by way of example and are not intended to limit the scope of the invention. These embodiments can be implemented in various other forms, and various omissions, replacements, changes, and combinations can be made without departing from the scope of the invention. These embodiments and their modifications are included in the scope and gist of the invention, and are also included in the invention described in the claims and the equivalents thereof.
The components of the compiler evaluation apparatus can be realized by a computer processor and can be operated by a compiler evaluation program.

10…コンパイラ評価装置、11…第1保持部、12…第2保持部、13…第3保持部、14…コンパイラ、15…テストデータ生成部、16…範囲設定部、17…インタープリタ、18…判定部、19…結果出力部、20…外部機器、21…ターゲットCPU、22…エミュレータ。   DESCRIPTION OF SYMBOLS 10 ... Compiler evaluation apparatus, 11 ... 1st holding | maintenance part, 12 ... 2nd holding | maintenance part, 13 ... 3rd holding | maintenance part, 14 ... Compiler, 15 ... Test data generation part, 16 ... Range setting part, 17 ... Interpreter, 18 ... Determination unit, 19 ... result output unit, 20 ... external device, 21 ... target CPU, 22 ... emulator.

Claims (8)

プログラミング言語で記述されたソースプログラムを保持する第1保持部と、
前記ソースプログラムをプロセッサで実行できるようにコンパイルした実行プログラムを保持する第2保持部と、
前記ソースプログラム及び前記実行プログラムの少なくとも一方に基づいてテストデータを生成するテストデータ生成部と、
前記テストデータを保持し前記実行プログラムの実行手段に送出する第3保持部と、
前記テストデータを入力し前記ソースプログラムを実行するインタープリタと、
前記実行プログラムの実行手段の実行結果及び前記インタープリタの実行結果を対比して一致するか否かを判定する判定部とを、備えることを特徴とするコンパイラ評価装置。
A first holding unit for holding a source program written in a programming language;
A second holding unit holding an execution program compiled so that the source program can be executed by a processor;
A test data generation unit that generates test data based on at least one of the source program and the execution program;
A third holding unit for holding the test data and sending it to the execution means of the execution program;
An interpreter for inputting the test data and executing the source program;
A compiler evaluation apparatus comprising: a determination unit that compares the execution result of the execution unit of the execution program and the execution result of the interpreter to determine whether or not they match.
前記テストデータ生成部は、前記ソースプログラムを構成する関数を単位として抽出された入力変数の組み合わせに基づく前記テストデータを生成する請求項1に記載のコンパイラ評価装置。   The compiler evaluation apparatus according to claim 1, wherein the test data generation unit generates the test data based on a combination of input variables extracted in units of functions constituting the source program. 前記テストデータ生成部は、前記ソースプログラムを構成する関数を単位として抽出されたプログラムパスの実行又は不実行の組み合わせに基づく前記テストデータを生成する請求項1に記載のコンパイラ評価装置。   The compiler evaluation apparatus according to claim 1, wherein the test data generation unit generates the test data based on a combination of execution or non-execution of a program path extracted with a function constituting the source program as a unit. 前記実行プログラムの実行手段は、ターゲットCPUをエミュレートするために内蔵されたエミュレータ又は外部機器に設けられた前記ターゲットCPUである請求項1から請求項3のいずれか1項に記載のコンパイラ評価装置。   4. The compiler evaluation apparatus according to claim 1, wherein the execution unit of the execution program is an emulator built in to emulate a target CPU or the target CPU provided in an external device. 5. . 前記ソースプログラムを構成する関数の内部範囲を設定するとともにこの内部範囲に対応する前記実行プログラムの比較範囲を設定する範囲設定部をさらに備え、
前記テストデータ生成部は、前記ソースプログラムの内部範囲及び前記実行プログラムの比較範囲の少なくとも一方に基づいてテストデータを生成する請求項1から請求項4のいずれか1項に記載のコンパイラ評価装置。
A range setting unit for setting an internal range of functions constituting the source program and setting a comparison range of the execution program corresponding to the internal range;
5. The compiler evaluation apparatus according to claim 1, wherein the test data generation unit generates test data based on at least one of an internal range of the source program and a comparison range of the execution program.
前記範囲設定部は、前記ソースプログラムのプログラムパスを単位として前記内部範囲及び前記比較範囲を設定する請求項5に記載のコンパイラ評価装置。   The compiler evaluation apparatus according to claim 5, wherein the range setting unit sets the internal range and the comparison range in units of a program path of the source program. プログラミング言語で記述されたソースプログラムを保持するステップと、
前記ソースプログラムをプロセッサで実行できるようにコンパイルした実行プログラムを保持するステップと、
前記ソースプログラム及び前記実行プログラムの少なくとも一方に基づいてテストデータを生成するステップと、
前記テストデータを保持しこのテストデータを前記実行プログラムの実行手段に送出するステップと、
前記テストデータを入力し前記ソースプログラムを実行するステップと、
前記実行プログラムの実行結果及び前記ソースプログラムの実行結果を対比して一致するか否かを判定するステップとを、含むことを特徴とするコンパイラ評価方法。
Holding a source program written in a programming language;
Holding an execution program compiled so that the source program can be executed by a processor;
Generating test data based on at least one of the source program and the execution program;
Holding the test data and sending the test data to the execution means of the execution program;
Inputting the test data and executing the source program;
And comparing the execution result of the execution program and the execution result of the source program to determine whether or not they match each other.
コンピュータに、
プログラミング言語で記述されたソースプログラムを保持させるステップ、
前記ソースプログラムをプロセッサで実行できるようにコンパイルした実行プログラムを保持させるステップ、
前記ソースプログラム及び前記実行プログラムの少なくとも一方に基づいてテストデータを生成させるステップ、
前記テストデータを保持させこのテストデータを前記実行プログラムの実行手段に送出させるステップ、
前記テストデータを入力させ前記ソースプログラムを実行させるステップ、
前記実行プログラムの実行結果及び前記ソースプログラムの実行結果を対比させて一致するか否かを判定させるステップを、実行させることを特徴とするコンパイラ評価プログラム。
On the computer,
Holding a source program written in a programming language;
Holding an execution program compiled so that the source program can be executed by a processor;
Generating test data based on at least one of the source program and the execution program;
Holding the test data and sending the test data to the execution means of the execution program;
Inputting the test data and executing the source program;
A compiler evaluation program for executing the step of comparing the execution result of the execution program and the execution result of the source program to determine whether or not they match.
JP2012188008A 2012-08-28 2012-08-28 Compiler evaluation apparatus, method, and program Expired - Fee Related JP5908374B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2012188008A JP5908374B2 (en) 2012-08-28 2012-08-28 Compiler evaluation apparatus, method, and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2012188008A JP5908374B2 (en) 2012-08-28 2012-08-28 Compiler evaluation apparatus, method, and program

Publications (2)

Publication Number Publication Date
JP2014044678A true JP2014044678A (en) 2014-03-13
JP5908374B2 JP5908374B2 (en) 2016-04-26

Family

ID=50395877

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2012188008A Expired - Fee Related JP5908374B2 (en) 2012-08-28 2012-08-28 Compiler evaluation apparatus, method, and program

Country Status (1)

Country Link
JP (1) JP5908374B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102322965B1 (en) 2020-03-23 2021-11-09 주식회사 티맥스 소프트 Universal runtime verification system between source language and language converted through transpiler

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01155438A (en) * 1987-12-12 1989-06-19 Hitachi Ltd Compiler test system
JP2005032213A (en) * 2003-07-09 2005-02-03 Matsushita Electric Ind Co Ltd Program generation device
JP2005141406A (en) * 2003-11-05 2005-06-02 Toyota Motor Corp Compiler inspection system and compiler inspection program
JP2007041804A (en) * 2005-08-02 2007-02-15 Sharp Corp Program generation device, program verification device, and verification program
JP2012073692A (en) * 2010-09-28 2012-04-12 Hitachi Ltd Maintenance support device for embedded system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01155438A (en) * 1987-12-12 1989-06-19 Hitachi Ltd Compiler test system
JP2005032213A (en) * 2003-07-09 2005-02-03 Matsushita Electric Ind Co Ltd Program generation device
JP2005141406A (en) * 2003-11-05 2005-06-02 Toyota Motor Corp Compiler inspection system and compiler inspection program
JP2007041804A (en) * 2005-08-02 2007-02-15 Sharp Corp Program generation device, program verification device, and verification program
JP2012073692A (en) * 2010-09-28 2012-04-12 Hitachi Ltd Maintenance support device for embedded system

Also Published As

Publication number Publication date
JP5908374B2 (en) 2016-04-26

Similar Documents

Publication Publication Date Title
Wang et al. Reassembleable disassembling
US8898647B2 (en) Method and apparatus for test coverage analysis
TWI463404B (en) Compiling systems and methods
CN103197942B (en) A kind of generation method of patch, the method for patch installing and device
KR101053104B1 (en) Computer Software Test Method and System
CN105676808B (en) A kind of implementation method of industrial control system logic break point debugging function
US20170139678A1 (en) Verification property integration apparatus, verification property integration method, and storage medium
Grimmer et al. Supporting program analysis for non-mainstream languages: experiences and lessons learned
CN113342323A (en) Method and device for software online development
JP6759851B2 (en) Program generation program, program generation method, program generator and compilation program
JP5908374B2 (en) Compiler evaluation apparatus, method, and program
JP6790869B2 (en) Compilation method, compilation program and information processing equipment
Yang et al. Kernelgpt: Enhanced kernel fuzzing via large language models
CN110472411B (en) Memory overflow processing method, device, equipment and readable storage medium
JP2013152559A (en) Program comparison analysis device and program comparison analysis method
WO2014117668A1 (en) Method for generating codes in secure environment to improve software protection strength
JP2008165342A (en) Source code creating method, device and program
Gerasimov et al. Reachability confirmation of statically detected defects using dynamic analysis
JP2016128941A (en) Output determination device, output determination method, output determination program, and static analysis device
JP2014126900A (en) Program analysis device, program analysis method, and program analysis program
Weston et al. Interaction analysis for fault-tolerance in aspect-oriented programming
Zakharov et al. Compositional environment modelling for verification of GNU C programs
JP6326838B2 (en) Program processing apparatus, program processing method, and program processing program
KR102524627B1 (en) System for obfuscation of binary programs using intermediate language and method therefor
Gregor et al. Using LLVM-based JIT compilation in genetic programming

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20150127

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20150811

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20150818

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20151014

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20160323

R151 Written notification of patent or utility model registration

Ref document number: 5908374

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151

LAPS Cancellation because of no payment of annual fees