JP2014203384A - Unit test support device, and unit test support program - Google Patents

Unit test support device, and unit test support program Download PDF

Info

Publication number
JP2014203384A
JP2014203384A JP2013081223A JP2013081223A JP2014203384A JP 2014203384 A JP2014203384 A JP 2014203384A JP 2013081223 A JP2013081223 A JP 2013081223A JP 2013081223 A JP2013081223 A JP 2013081223A JP 2014203384 A JP2014203384 A JP 2014203384A
Authority
JP
Japan
Prior art keywords
function
replaced
address
unit
replacement
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
JP2013081223A
Other languages
Japanese (ja)
Other versions
JP6061763B2 (en
Inventor
勝己 奥田
Katsumi Okuda
勝己 奥田
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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric 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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP2013081223A priority Critical patent/JP6061763B2/en
Publication of JP2014203384A publication Critical patent/JP2014203384A/en
Application granted granted Critical
Publication of JP6061763B2 publication Critical patent/JP6061763B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a unit test support device capable of simplifying a work in a unit test of a software.SOLUTION: A function replacement part 121 inputs an identifier of a replaced function 112 rewritten in a test object program 110, and an identifier of a substitution function 102 for rewriting the replaced function 112. An address solution part 122 acquires an address of a rewritten position of the test object program 110 from the identifier of the replaced function 112. A program rewritable part 123 rewrites the test object program 110 at the address acquired by the address solution part 122 to rewrite the replaced function 112 with the substitution function 102.

Description

この発明は、ソフトウェアの単体試験を行うための単体試験支援装置およびそのプログラムに関するものである。   The present invention relates to a unit test support apparatus and a program for performing a unit test of software.

ソフトウェア技術者は、ソフトウェアの単体試験において、試験対象プログラムを関数単位で試験をする場合がある。一般に、単体試験は、試験対象関数と試験ドライバと試験スタブとから構成される。試験ドライバは、試験の事前条件を設定し、試験対象関数を呼び出し、事後条件を確認する。試験スタブは、試験対象関数が呼び出す別の関数のダミーである。試験時のソフトウェア構成として試験対象関数が使用する関数をダミーの試験スタブに置き換えることで、試験対象関数の実行フローを制御しやすくなる。この結果、ソフトウェア技術者は、試験を効率化に進めることができる。   A software engineer may test a program under test in units of functions in a software unit test. In general, a unit test is composed of a test target function, a test driver, and a test stub. The test driver sets the test precondition, calls the function under test, and checks the postcondition. The test stub is a dummy of another function called by the test target function. By replacing the function used by the test target function with a dummy test stub as the software configuration at the time of the test, the execution flow of the test target function can be easily controlled. As a result, the software engineer can proceed with testing more efficiently.

一般に、関数のダミースタブによる置換は、被置換関数の定義を含むオブジェクトファイルの代わりに、ダミースタブの定義を含むオブジェクトファイルを試験ドライバや試験対象関数を含むファイルとリンクすることによって行われる。従って、試験対象関数と試験スタブによる被置換候補の関数とが同一ソースファイルに記述されている場合は、被置換候補の関数を試験スタブで置き換えるのは困難である。   In general, replacement of a function with a dummy stub is performed by linking an object file including a definition of a dummy stub with a file including a test driver or a test target function instead of an object file including a definition of a function to be replaced. Therefore, when the function to be tested and the function to be replaced by the test stub are described in the same source file, it is difficult to replace the function to be replaced with the test stub.

このため、試験スタブを用いた試験を行うソフトウェア開発では、ソフトウェアの構成として不自然であっても被置換候補の関数を試験対象プログラムとは別のソースファイル中で記述したり、試験時のみプリプロセッサディレクティブなどで被置換候補の関数をコンパイル対象から除外するなどの工夫が必要であった。結果として、試験スタブを利用することで、場合によってはソフトウェアの保守性が悪くなるなどの問題があった。   For this reason, in software development for testing using test stubs, even if the software configuration is unnatural, the replacement candidate function can be described in a source file separate from the test target program, or the preprocessor can be used only during testing. It was necessary to devise such as excluding replacement candidate functions from the compilation target by directives. As a result, the use of the test stub has a problem that the maintainability of the software deteriorates in some cases.

このような問題を解決するためには、被置換対象の関数が試験対象プログラムと同じファイルで定義されている場合でも、ソースコードを変更せずにプログラムの挙動を変更する仕組みが必要となる。そのような仕組みを提供する方法としてコードを変換する方法があった(例えば特許文献1)。   In order to solve such a problem, even if the function to be replaced is defined in the same file as the test target program, a mechanism for changing the behavior of the program without changing the source code is required. As a method of providing such a mechanism, there has been a method of converting a code (for example, Patent Document 1).

特開2009−237610号公報JP 2009-237610 A

しかしながら、従来の方法では、試験ドライバでの試験記述とは別に、関数フックの条件を記述する必要があった。このため、試験ケースを作成するためにソフトウェア技術者が複数のファイルを編集する必要があり、作業が煩雑であるという問題があった。   However, in the conventional method, it is necessary to describe the function hook conditions separately from the test description in the test driver. For this reason, in order to create a test case, a software engineer needs to edit a plurality of files, and there is a problem that the work is complicated.

この発明は、上記のような問題点を解決するためになされたものであり、ソフトウェアの単体試験における作業を簡略化することのできる単体試験支援装置を得ることを目的とする。   The present invention has been made to solve the above-described problems, and an object of the present invention is to provide a unit test support apparatus that can simplify the work in the unit test of software.

この発明に係る単体試験支援装置は、試験対象プログラム中で書き換えられる被置換関数の識別子と、被置換関数を書き換えるための置換関数の識別子を入力する関数置換部と、被置換関数の識別子から試験対象プログラムの書換え位置のアドレスを取得するアドレス解決部と、アドレス解決部が取得したアドレスの試験対象プログラムを書き換えることで被置換関数を置換関数で書き換えるプログラム書換え部とを備えたものである。   The unit test support apparatus according to the present invention tests from the identifier of the function to be replaced that is rewritten in the program to be tested, the function replacement unit that inputs the identifier of the replacement function for rewriting the function to be replaced, and the identifier of the function to be replaced. An address resolution unit that acquires the address of the rewrite position of the target program, and a program rewrite unit that rewrites the function to be replaced with a replacement function by rewriting the test target program at the address acquired by the address resolution unit.

この発明の単体試験支援装置は、被置換関数の識別子から試験対象プログラムの書換え位置のアドレスを取得し、このアドレスの試験対象プログラムを書き換えることで被置換関数を置換関数で書き換えるようにしたので、ソフトウェアの単体試験における作業を簡略化することができる。   Since the unit test support device of the present invention acquires the address of the rewriting position of the test target program from the identifier of the replacement function, and rewrites the replacement target function with the replacement function by rewriting the test target program of this address, Work in software unit tests can be simplified.

この発明の実施の形態1による単体試験支援装置を示す構成図である。It is a block diagram which shows the unit test assistance apparatus by Embodiment 1 of this invention. この発明の実施の形態1による単体試験支援装置の試験ドライバの動作を示すフローチャートである。It is a flowchart which shows operation | movement of the test driver of the unit test assistance apparatus by Embodiment 1 of this invention. この発明の実施の形態1による単体試験支援装置の関数置換前の関数呼出しを模式的に示す説明図である。It is explanatory drawing which shows typically the function call before the function substitution of the unit test assistance apparatus by Embodiment 1 of this invention. この発明の実施の形態1による単体試験支援装置の関数先頭書換えによる関数置換後の関数呼出しを模式的に示す説明図である。It is explanatory drawing which shows typically the function call after function substitution by the function head rewriting of the unit test assistance apparatus by Embodiment 1 of this invention. この発明の実施の形態1による単体試験支援装置の関数先頭書換えによる試験支援部の処理を示すフローチャートである。It is a flowchart which shows the process of the test assistance part by the function head rewriting of the unit test assistance apparatus by Embodiment 1 of this invention. この発明の実施の形態1による単体試験支援装置のオブジェクトファイル読出し処理の詳細を示すフローチャートである。It is a flowchart which shows the detail of the object file read-out process of the unit test assistance apparatus by Embodiment 1 of this invention. この発明の実施の形態1による単体試験支援装置のステップST502の関数先頭アドレス取得処理の詳細を示すフローチャートである。It is a flowchart which shows the detail of the function head address acquisition process of step ST502 of the unit test assistance apparatus by Embodiment 1 of this invention. この発明の実施の形態1による単体試験支援装置のシンボル検索処理の詳細を示すフローチャートである。It is a flowchart which shows the detail of the symbol search process of the unit test assistance apparatus by Embodiment 1 of this invention. この発明の実施の形態2による単体試験支援装置の関数先頭アドレス取得処理を示すフローチャートである。It is a flowchart which shows the function head address acquisition process of the unit test assistance apparatus by Embodiment 2 of this invention. この発明の実施の形態3による単体試験支援装置の関数先頭アドレス取得処理を示すフローチャートである。It is a flowchart which shows the function head address acquisition process of the unit test assistance apparatus by Embodiment 3 of this invention. この発明の実施の形態4による単体試験支援装置の関数先頭アドレス取得を模式的に示す説明図である。It is explanatory drawing which shows typically the function head address acquisition of the unit test assistance apparatus by Embodiment 4 of this invention. この発明の実施の形態4による単体試験支援装置の関数先頭アドレス取得処理を示すフローチャートである。It is a flowchart which shows the function head address acquisition process of the unit test assistance apparatus by Embodiment 4 of this invention. この発明の実施の形態4による単体試験支援装置のセクション先頭アドレス取得を模式的に示す説明図である。It is explanatory drawing which shows typically the section head address acquisition of the unit test assistance apparatus by Embodiment 4 of this invention. この発明の実施の形態4による単体試験支援装置のセクション先頭アドレス取得処理を示すフローチャートである。It is a flowchart which shows the section head address acquisition process of the unit test assistance apparatus by Embodiment 4 of this invention. この発明の実施の形態5による単体試験支援装置の試験支援部の処理を示すフローチャートである。It is a flowchart which shows the process of the test assistance part of the unit test assistance apparatus by Embodiment 5 of this invention. この発明の実施の形態6による単体試験支援装置の関数置換前の共有ライブラリ関数呼出しを模式的に示す説明図である。It is explanatory drawing which shows typically the shared library function call before the function substitution of the unit test assistance apparatus by Embodiment 6 of this invention. この発明の実施の形態6による単体試験支援装置の関数置換後の共有ライブラリ関数呼出しを模式的に示す説明図である。It is explanatory drawing which shows typically the shared library function call after the function substitution of the unit test assistance apparatus by Embodiment 6 of this invention. この発明の実施の形態6による単体試験支援装置の試験支援部の処理を示すフローチャートである。It is a flowchart which shows the process of the test assistance part of the unit test assistance apparatus by Embodiment 6 of this invention. この発明の実施の形態6による単体試験支援装置の関数アドレス参照書換え処理を示すフローチャートである。It is a flowchart which shows the function address reference rewriting process of the unit test assistance apparatus by Embodiment 6 of this invention. この発明の実施の形態7による単体試験支援装置の関数置換処理を示すフローチャートである。It is a flowchart which shows the function substitution process of the unit test assistance apparatus by Embodiment 7 of this invention. この発明の実施の形態8による単体試験支援装置を示す構成図である。It is a block diagram which shows the unit test assistance apparatus by Embodiment 8 of this invention. この発明の実施の形態9による単体試験支援装置を示す構成図である。It is a block diagram which shows the unit test assistance apparatus by Embodiment 9 of this invention.

実施の形態1.
図1は、この発明の実施の形態1による単体試験支援装置を示す構成図である。
図1に示す単体試験支援装置は、試験設定部100、試験対象プログラム110、試験支援部120、言語処理部130を備えている。この単体試験支援装置は、試験対象プログラム110中の試験対象関数111の単体試験を想定している。単体試験の目的は、試験対象関数111が仕様通りに実装されていることを確認することである。
Embodiment 1 FIG.
FIG. 1 is a block diagram showing a unit test support apparatus according to Embodiment 1 of the present invention.
The unit test support apparatus shown in FIG. 1 includes a test setting unit 100, a test target program 110, a test support unit 120, and a language processing unit 130. This unit test support apparatus assumes a unit test of the test target function 111 in the test target program 110. The purpose of the unit test is to confirm that the test target function 111 is implemented as specified.

試験設定部100は、試験ドライバ101と置換関数(試験スタブ)102とを含んでいる。試験設定部100は、試験記述プログラムを計算機が実行することで実現されている。この試験記述プログラムは1つ以上のソースプログラムから構成されているものとする。   The test setting unit 100 includes a test driver 101 and a replacement function (test stub) 102. The test setting unit 100 is realized by a computer executing a test description program. This test description program is composed of one or more source programs.

試験時には、試験対象プログラム110が本来利用する被置換関数112を試験スタブである置換関数102で置き換えて試験対象関数111を実行する。試験対象関数111の呼出しを行うのが、試験ドライバ101である。また、試験ドライバ101は、試験支援部120の関数置換部121を呼び出すことで、実行時に被置換関数112を置換関数102に置き換える機能を有している。   During the test, the test target function 111 is executed by replacing the replacement function 112 originally used by the test target program 110 with the replacement function 102 which is a test stub. The test driver 101 calls the test target function 111. Further, the test driver 101 has a function of replacing the function to be replaced 112 with the replacement function 102 at the time of execution by calling the function replacement unit 121 of the test support unit 120.

試験対象プログラム110は、試験対象となるプログラムであり、試験対象関数111は、試験対象プログラム110における単体試験の対象となる関数である。また、被置換関数112は、試験対象関数111からcallされ、置換関数102で置換される関数である。   The test target program 110 is a program to be tested, and the test target function 111 is a function to be a unit test target in the test target program 110. The replacement function 112 is a function that is called from the test target function 111 and replaced by the replacement function 102.

試験支援部120は、試験ドライバ101によって呼び出され、試験対象プログラム110における被置換関数112を置換関数102に置き換える処理を行うものであり、関数置換部121、アドレス解決部122、プログラム書換え部123を備えている。関数置換部121は、被置換関数112の識別子と置換関数102の識別子とを入力し、これらの入力に基づいてアドレス解決部122とプログラム書換え部123とを実行させる機能を有している。アドレス解決部122は、被置換関数112の識別子からプログラムの書換え位置のアドレスを取得する処理部である。プログラム書換え部123は、アドレス解決部122が取得したアドレスのプログラムを書き換えることで被置換関数112を置換関数102で置き換える処理部である。   The test support unit 120 is called by the test driver 101 and performs processing for replacing the function to be replaced 112 in the test target program 110 with the replacement function 102. The function replacement unit 121, the address resolution unit 122, and the program rewrite unit 123 are I have. The function replacement unit 121 has a function of inputting the identifier of the function to be replaced 112 and the identifier of the replacement function 102 and causing the address resolution unit 122 and the program rewriting unit 123 to execute based on these inputs. The address resolution unit 122 is a processing unit that acquires the address of the rewrite position of the program from the identifier of the function 112 to be replaced. The program rewriting unit 123 is a processing unit that replaces the replacement function 112 with the replacement function 102 by rewriting the program at the address acquired by the address resolution unit 122.

言語処理部130は、試験設定部100が用いる試験記述プログラムと、試験対象プログラム110と、試験支援部120における置換え結果と、必要なライブラリとから試験を行うための実行可能ファイルを作成する処理部であり、試験プログラム140は、その実行可能ファイルである。   The language processing unit 130 is a processing unit that creates an executable file for performing a test from the test description program used by the test setting unit 100, the test target program 110, the replacement result in the test support unit 120, and a necessary library. The test program 140 is an executable file.

なお、試験設定部100および試験支援部120におけるそれぞれの機能部と言語処理部130は、それぞれの機能を実現するためのプログラムと、これらのプログラムを実行するためのCPUやメモリといったハードウェアによって構成され、コンピュータを用いて実現されている。また、これらのプログラムは、ソースコードやリロケータブルなオブジェクトファイル、静的ライブラリ、共有ライブラリなどの形式で記憶媒体に格納可能である。   The function units and the language processing unit 130 in the test setting unit 100 and the test support unit 120 are configured by programs for realizing the respective functions and hardware such as a CPU and a memory for executing these programs. And implemented using a computer. These programs can be stored in a storage medium in the form of source code, relocatable object file, static library, shared library, or the like.

次に、試験設定部100における試験ドライバ101について説明する。試験ドライバ101の主な処理は、試験対象関数111の実行に必要な事前条件を設定した後、試験対象関数111を呼び出し、呼出し後の事後条件を確認することである。
図2に、試験ドライバ101の処理フローを示す。
試験ドライバ101は、ステップST201で試験対象関数が実行の前提とする事前条件を設定する。具体的には、試験対象関数111が利用する入力変数の初期化などを行う。ステップST202は、試験対象関数111が利用する関数を置換関数102に置き換える処理である。試験ドライバ101は、試験支援部120が提供する関数置換部121を呼び出すことで、試験支援部120が、被置換関数112を置換関数102に置き換える。本実施の形態では、試験対象プログラム110自身の識別子と被置換関数112の識別子と置換関数102の識別子とを関数置換部121への入力とする。以下の説明では、具体的に試験対象プログラム110自身の識別子として試験対象プログラム110のファイル名、被置換関数112の識別子として被置換関数の名前、置換関数102の識別子として置換関数のアドレスを使用するが、識別子の形式をこれに限定するものではない点に注意が必要である。なお、置換関数102のアドレスは、C/C++言語によって構成されている試験ドライバ101の場合、アドレス参照の演算子である&で取得可能な値である。
Next, the test driver 101 in the test setting unit 100 will be described. The main process of the test driver 101 is to set a precondition necessary for the execution of the test target function 111, call the test target function 111, and confirm the post condition after the call.
FIG. 2 shows a processing flow of the test driver 101.
In step ST201, the test driver 101 sets a precondition that is assumed to be executed by the test target function. Specifically, initialization of input variables used by the test target function 111 is performed. Step ST202 is processing to replace the function used by the test target function 111 with the replacement function 102. The test driver 101 calls the function replacement unit 121 provided by the test support unit 120, so that the test support unit 120 replaces the replaced function 112 with the replacement function 102. In the present embodiment, the identifier of the test target program 110 itself, the identifier of the function to be replaced 112, and the identifier of the replacement function 102 are input to the function replacement unit 121. In the following description, the file name of the test target program 110 is specifically used as the identifier of the test target program 110, the name of the function to be replaced is used as the identifier of the function to be replaced 112, and the address of the replacement function is used as the identifier of the replacement function 102. However, it should be noted that the identifier format is not limited to this. In the case of the test driver 101 configured in the C / C ++ language, the address of the replacement function 102 is a value that can be acquired by & as the address reference operator.

ステップST203では、試験対象関数111の呼出しを行う。このとき試験ドライバ101は、後で試験対象関数111の戻り値があれば記憶する。
ステップST204は、試験対象関数111が期待通りに動作したか否かを確認する処理である。事後条件として試験対象関数111が変更した値やステップST203で記憶した試験対象関数の戻り値などを確認する。一般的なxUNITなどの試験フレームワークを用いる場合、事後条件の確認には、試験ドライバ101は、フレームワークが提供するアサーションなどを利用する。
In step ST203, the test target function 111 is called. At this time, if there is a return value of the test target function 111 later, the test driver 101 stores it.
Step ST204 is processing for confirming whether or not the test target function 111 operates as expected. As a post-condition, a value changed by the test target function 111, a return value of the test target function stored in step ST203, and the like are confirmed. When a general test framework such as xUNIT is used, the test driver 101 uses an assertion provided by the framework to check the post-condition.

次に、関数置換処理について説明する。
始めに、図3と図4とを用いて、試験対象関数111における関数置換前後の関数呼出しの様子を説明した後、関数置換処理の説明を行う。
図3は、関数置換前の関数呼出しの模式図である。試験対象関数301と被置換関数302とは、計算機の主記憶上に格納されたプログラムである。これら試験対象関数301と被置換関数302は、図1の試験対象関数111と被置換関数112に対応している。試験対象関数301は、被置換関数302への呼出し命令CALLを含んでいる。計算機が被置換関数302への呼出し命令を実行すると、計算機のプログラムカウンタは、被置換関数302のアドレスに移る。計算機は、被置換関数302を実行し、被置換関数302の関数復帰命令retを実行すると試験対象関数301に制御が移動する。
Next, function replacement processing will be described.
First, referring to FIG. 3 and FIG. 4, the state of function calls before and after function replacement in the test target function 111 will be described, and then function replacement processing will be described.
FIG. 3 is a schematic diagram of a function call before function replacement. The test target function 301 and the function to be replaced 302 are programs stored in the main memory of the computer. The test target function 301 and the replaced function 302 correspond to the test target function 111 and the replaced function 112 in FIG. The test target function 301 includes a call instruction CALL to the replaced function 302. When the computer executes a call instruction to the function to be replaced 302, the program counter of the computer moves to the address of the function to be replaced 302. When the computer executes the function to be replaced 302 and executes the function return instruction ret of the function to be replaced 302, the control is transferred to the test target function 301.

図4は、本実施の形態における関数先頭書換えによる関数置換後の関数呼出しの模式図である。図4では、図3に加えて主記憶上の置換関数403も記載している。ここで、試験対象関数401と被置換関数402および置換関数403は、図1の試験対象関数111と被置換関数112及び置換関数102に対応している。
図3と異なるのは、被置換関数402の先頭部分である。被置換関数402の先頭部分の命令は、置換関数403への無条件分岐命令JMP命令に書き換わっている。計算機は、試験対象関数401の被置換関数402への呼出し命令CALLを実行すると、プログラムカウンタは、被置換関数402の先頭アドレスとなる。先頭には置換関数403への無条件分岐命令が存在するため、計算機の制御は直ちに置換関数403の先頭に移る。置換関数403中で関数復帰命令retが実行されると、制御は試験対象関数401中の被置換関数402呼出し命令の直後の命令に移る。
FIG. 4 is a schematic diagram of function call after function replacement by function head rewriting in the present embodiment. FIG. 4 also shows a replacement function 403 on the main memory in addition to FIG. Here, the test target function 401, the replaced function 402, and the replacement function 403 correspond to the test target function 111, the replaced function 112, and the replacement function 102 in FIG.
The difference from FIG. 3 is the head portion of the function to be replaced 402. The instruction at the head of the function to be replaced 402 is rewritten as an unconditional branch instruction JMP instruction to the replacement function 403. When the computer executes a call instruction CALL to the replacement function 402 of the test target function 401, the program counter becomes the start address of the replacement function 402. Since there is an unconditional branch instruction to the replacement function 403 at the head, the computer control immediately moves to the head of the replacement function 403. When the function return instruction ret is executed in the replacement function 403, control is transferred to the instruction immediately after the replacement function 402 call instruction in the test target function 401.

次に、図3の関数呼出しを図4の関数呼出しに変更するための関数置換処理について図5を用いて説明する。
図5は、関数先頭書換えによる図1の試験支援部120の処理フローである。なお、図1のアドレス解決部122の処理がステップST502に対応し、プログラム書換え部123の処理がステップST503に対応する。
関数置換処理の入力は、試験対象プログラム110のファイル名、被置換関数112の名前、置換関数102のアドレスである。本処理の概要は、入力となる試験対象プログラム110の実行可能ファイルを解析し、プログラム書換え箇所のアドレスを解決し、当該箇所のプログラムを書き換えることである。本実施の形態では、プログラム書換え箇所は被置換関数112の先頭アドレスである。また、被置換関数112の先頭アドレスの取得を試験対象プログラム110のシンボル情報から行う。以下の説明では、シンボル情報として試験対象プログラム110の実行可能ファイルに含まれるシンボルテーブルを想定するが、シンボルテーブルの代わりに言語処理系が生成するMAPファイルを用いても同様の結果を得ることができる。
Next, a function replacement process for changing the function call of FIG. 3 to the function call of FIG. 4 will be described with reference to FIG.
FIG. 5 is a processing flow of the test support unit 120 of FIG. 1 by function head rewriting. Note that the processing of the address resolution unit 122 in FIG. 1 corresponds to step ST502, and the processing of the program rewriting unit 123 corresponds to step ST503.
The input of the function replacement process is the file name of the test target program 110, the name of the function to be replaced 112, and the address of the replacement function 102. The outline of this process is to analyze the executable file of the test target program 110 to be input, resolve the address of the program rewrite location, and rewrite the program at that location. In the present embodiment, the program rewrite location is the start address of the function to be replaced 112. Further, the start address of the function to be replaced 112 is acquired from the symbol information of the test target program 110. In the following description, the symbol table included in the executable file of the test target program 110 is assumed as the symbol information, but the same result can be obtained by using a MAP file generated by the language processor instead of the symbol table. it can.

ステップST501は、後で被置換関数112の先頭アドレスを取得するために必要なシンボルテーブルなどの情報を主記憶上にロードする処理である。本処理の詳細は図6を用いて後述する。なお、本実施の形態の説明では、オブジェクトファイルの情報を一括してステップST501で主記憶上にロードするものとしたが、情報を用いるときにその都度ファイルにアクセスするようにしてもよい。   Step ST501 is a process of loading information such as a symbol table necessary for obtaining the head address of the function to be replaced 112 later onto the main memory. Details of this processing will be described later with reference to FIG. In the description of the present embodiment, the object file information is collectively loaded onto the main memory in step ST501. However, the file may be accessed each time information is used.

ステップST502は、被置換関数112の名前を入力とし、ステップST502で読み出したシンボルテーブルから被置換関数112の先頭アドレスを取得する処理である。本処理の詳細については図7を用いて後述する。   In step ST502, the name of the function to be replaced 112 is input, and the start address of the function to be replaced 112 is acquired from the symbol table read in step ST502. Details of this processing will be described later with reference to FIG.

ステップST503では、ステップST502で取得した被置換関数の先頭アドレスの命令を置換関数への無条件分岐命令に書き換える。具体例として、単体試験をAMD64アーキテクチャのCPUの計算機上で行う場合、無条件分岐命令は、オペコードが0xE9のJMP命令である。当該JMP命令は、プログラムカウンタ相対ジャンプ命令である。ここでは、ジャンプ命令のオペランドに、(置換関数のアドレス)−(関数の先頭アドレス)−(JMP命令の命令バイト長)を設定する。なお、JMP命令の命令バイト長の値は5である。
このように、プログラム書換え部123の処理であるステップST503において、関数の先頭アドレスのコードを置換関数に無条件分岐する命令に書き換えることによって、試験対象プログラム110が被置換関数112を呼び出すと、結果的に置換関数が実行される効果を得ることができる。
In step ST503, the instruction at the head address of the function to be replaced acquired in step ST502 is rewritten to an unconditional branch instruction to the replacement function. As a specific example, when the unit test is performed on a CPU of an AMD64 architecture CPU, the unconditional branch instruction is a JMP instruction whose operation code is 0xE9. The JMP instruction is a program counter relative jump instruction. Here, (replacement function address) − (function start address) − (JMP instruction byte length) is set as the operand of the jump instruction. Note that the value of the instruction byte length of the JMP instruction is 5.
Thus, in step ST503, which is the processing of the program rewriting unit 123, when the test target program 110 calls the function to be replaced 112 by rewriting the code at the head address of the function to an instruction that unconditionally branches to the replacement function, the result Thus, the effect that the replacement function is executed can be obtained.

以下では、ステップST501のオブジェクトファイル読出し処理と、ステップST502の関数先頭アドレス取得処理について説明する。具体的にオブジェクトファイルのフォーマットとしては、ELF(Executable and Linkable Format)を想定して説明するが、Windows PE(Windowsは登録商標/以下省略して記載)やMach−Oなどの異なるオブジェクトファイルフォーマットでも本発明は同様に適用可能である。   Hereinafter, the object file read process in step ST501 and the function head address acquisition process in step ST502 will be described. Specifically, the object file format will be described assuming ELF (Executable and Linkable Format), but different object file formats such as Windows PE (Windows is a registered trademark / hereinafter abbreviated) and Mach-O are also used. The present invention is equally applicable.

図6は、図5におけるオブジェクトファイル読出し処理の詳細を示すフローチャートであり、ここでは、ELFファイルの読出し処理を示している。ELFファイルの読出し処理フローでは、ELFファイルの名前を入力として、ELFファイルの解析に必要となる情報をメモリ上に読み出す。ここで読み出す情報は、本実施の形態では特に図5のステップST502で関数先頭アドレス取得に必要となるシンボルテーブルである。   FIG. 6 is a flowchart showing details of the object file reading process in FIG. 5, and here, the ELF file reading process is shown. In the ELF file read processing flow, information necessary for the analysis of the ELF file is read out to the memory by using the name of the ELF file as input. The information read out here is a symbol table necessary for acquiring the function head address in step ST502 of FIG. 5 in the present embodiment.

ステップST601は、ELFファイル名のファイルのオープン処理である。このとき、ファイルのオープンには、ELFファイル読出し処理の入力として与えられるファイル名を用いる。オープンしたファイルはクローズする必要があるが、クローズ処理については本発明とは直接関係しないため、クローズ処理の説明は、以後、省略するものとする。   Step ST601 is an ELF file name file open process. At this time, the file name given as the input of the ELF file reading process is used to open the file. Although it is necessary to close the opened file, since the close process is not directly related to the present invention, the description of the close process will be omitted hereinafter.

ステップST602では、ELFファイルの先頭に格納されたファイルヘッダを読み出す処理である。ファイルヘッダは、後の処理で利用するセクションヘッダテーブルのオフセットとセクションヘッダの個数などを保持している。   In step ST602, the file header stored at the head of the ELF file is read. The file header holds an offset of a section header table used in later processing, the number of section headers, and the like.

ステップST603は、セクションヘッダテーブルを読み出す処理である。ステップST602で読み出したELFヘッダに含まれるセクションヘッダテーブルの位置と個数を参照し、ELFファイル中の当該位置からセクションデータテーブルをメモリに読み出す。このとき、セクションヘッダテーブルの位置は、ファイルヘッダのe_shoffフィールドに格納されている。また、セクションヘッダの個数はe_shnumに格納されている。   Step ST603 is processing to read the section header table. With reference to the position and number of section header tables included in the ELF header read in step ST602, the section data table is read from the corresponding position in the ELF file into the memory. At this time, the position of the section header table is stored in the e_shoff field of the file header. The number of section headers is stored in e_shnum.

ステップST604は、セクションヘッダ用の文字列テーブルをファイルからメモリに読み出す処理である。まず、ステップST602で読み出したファイルヘッダのe_shstrndxフィールドの値を用いて、ステップST603で読み出したセクションヘッダテーブルの先頭から数えてe_shstrndx番目のセクションヘッダから、セクションヘッダ用文字列テーブルのファイル中でのオフセットとサイズを取得する。セクションヘッダ用文字列テーブルのオフセットとサイズとは、それぞれセクションヘッダのsh_offsetフィールドとsh_sizeフィールドとから取得可能である。   Step ST604 is a process of reading the character string table for the section header from the file to the memory. First, using the value of the e_shstrndx field of the file header read in step ST602, the offset in the section header string table file from the e_shstrndx-th section header counted from the beginning of the section header table read in step ST603 And get the size. The offset and size of the section header character string table can be obtained from the sh_offset field and sh_size field of the section header, respectively.

ステップST605は、文字列テーブルを読み出す処理である。ELFファイルでは、文字列テーブルは、名前が.strtabのセクションに格納されている。まず、セクションヘッダテーブルから名前が.strtabのセクション名を取得する。セクションヘッダの名前は、セクションヘッダのsh_nameフィールドの値を用いて取得可能である。具体的には、セクションヘッダ用の文字列テーブル先頭からsh_nameフィールドバイト目に存在するゼロ終端文字列がセクションヘッダ名である。   Step ST605 is processing to read the character string table. In the ELF file, the string table is stored in a section with the name .strtab. First, the section name with the name .strtab is obtained from the section header table. The name of the section header can be obtained using the value of the sh_name field of the section header. Specifically, the zero-terminated character string existing in the sh_name field byte from the head of the character string table for the section header is the section header name.

ステップST606は、シンボルテーブルを読み出す処理である。シンボルテーブルは、名前が.symtabのセクションである。ステップST605における文字列テーブルの場合と同様に.symtabをセクションヘッダテーブルから検索し、セクションヘッダに記載された位置からシンボルテーブルをメモリに読み出す。このとき、シンボルの位置とサイズとは、それぞれセクションヘッダのsh_offsetフィールドとsh_sizeフィールドの値である。なおsh_sizeの値とシンボルテーブルエントリの商は、シンボルテーブルのエントリ数となる。ステップST606では、エントリ数もメモリに記憶しておく。   Step ST606 is processing to read a symbol table. The symbol table is a section with the name .symtab. As in the case of the character string table in step ST605, .symtab is searched from the section header table, and the symbol table is read into the memory from the position described in the section header. At this time, the symbol position and size are the values of the sh_offset field and sh_size field of the section header, respectively. Note that the quotient of the sh_size value and the symbol table entry is the number of symbol table entries. In step ST606, the number of entries is also stored in the memory.

ステップST607は、リロケーションテーブルを読み出す処理である。リロケーションテーブルは、リロケーション対象となるセクションごとに存在する。また、各々のリロケーションテーブルも、独立したセクションに格納されている。リロケーションテーブルが格納されているセクションは、.relまたは.relaに続ききリロケーション対象となるセクション名で始まる名前を持つセクションに格納されている。例えば、.textセクションのリロケーションテーブルであれば、.rel.textまたは.rela.textを名前に持つセクションに格納されている。ステップST607では、.relまたは.relaのセクションをメモリ上にロードする。   Step ST607 is processing to read the relocation table. A relocation table exists for each section to be relocated. Each relocation table is also stored in an independent section. The section in which the relocation table is stored is stored in a section having a name that starts with the name of the section to be relocated following .rel or .rela. For example, a relocation table for a .text section is stored in a section whose name is .rel.text or .rela.text. In step ST607, the .rel or .rela section is loaded into the memory.

次に、図7を用いてステップST502の関数先頭アドレス取得処理の詳細を説明する。図7は、実行可能ファイルシンボル情報による関数先頭アドレス取得処理のフローである。本処理では、被置換関数112の名前を入力とし、ステップST501で読み出したシンボルテーブルから被置換関数112の名前と一致するシンボルを検索することで、被置換関数112のアドレスを取得する。   Next, details of the function head address acquisition process in step ST502 will be described with reference to FIG. FIG. 7 is a flow of function start address acquisition processing based on executable file symbol information. In this process, the name of the function to be replaced 112 is input, and the symbol matching the name of the function to be replaced 112 is searched from the symbol table read in step ST501, thereby acquiring the address of the function to be replaced 112.

ステップST701では、被置換関数112の名前をシンボル名とするシンボルテーブルエントリを検索する処理である。シンボル検索処理の詳細は、図8を用いて後述する。ここでは、シンボルテーブル検索処理への入力とする検索条件として、シンボルの名前が被置換関数112の名前と一致することを指定する。なお、シンボル名は、シンボルテーブルエントリのst_nameフィールドの値を文字列テーブルのインデックスとして読み出せるゼロ終端文字列から得られる。シンボル検索処理からは、検索条件に合致するシンボルの一覧が得られる。   Step ST701 is a process of searching for a symbol table entry having the name of the function to be replaced 112 as a symbol name. Details of the symbol search processing will be described later with reference to FIG. Here, it is specified that the name of the symbol matches the name of the function to be replaced 112 as a search condition to be input to the symbol table search process. The symbol name is obtained from a zero-terminated character string from which the value of the st_name field of the symbol table entry can be read as an index of the character string table. From the symbol search process, a list of symbols that match the search conditions is obtained.

ステップST702は、ステップST701で検索したシンボルがシンボルテーブル中に見つかったか否かに基づく条件分岐処理である。シンボルが見つかったか否かは、ステップST701で得られるシンボル一覧が空でないか否かで判定可能である。シンボルが見つからなかった場合、エラーで終了する。一方、シンボルが見つかっている場合、ステップST703に分岐する。   Step ST702 is a conditional branch process based on whether or not the symbol searched in step ST701 is found in the symbol table. Whether or not a symbol is found can be determined based on whether or not the symbol list obtained in step ST701 is not empty. If no symbol is found, exit with an error. On the other hand, if a symbol is found, the process branches to step ST703.

ステップST703は、ステップST701で検索したシンボルがシンボルテーブル中に2つ以上見つかったか否かに基づく条件分岐処理である。シンボルが2つ以上みつかった場合は、エラーで終了する。一方、見つかったシンボルが1つのみである場合、ステップST704に分岐する。   Step ST703 is a conditional branch process based on whether or not two or more symbols searched in step ST701 are found in the symbol table. If more than one symbol is found, exit with an error. On the other hand, if only one symbol is found, the process branches to step ST704.

ステップST704では、見つかったシンボルの値、すなわち被置換関数112のアドレスを主力結果に格納する。シンボルの値は、ステップST701で検索の結果として唯一の得られたシンボルテーブルエントリのst_valueフィールドの値である。   In step ST704, the value of the found symbol, that is, the address of the function to be replaced 112 is stored in the main result. The value of the symbol is the value of the st_value field of the symbol table entry obtained only as a result of the search in step ST701.

このように、アドレス解決部122の処理であるステップST502が、被置換関数112の名前を用いて試験対象プログラム110の実行可能ファイルのシンボル情報を検索することで、被置換関数112の先頭アドレスを取得できるため、試験対象プログラム110がデバッグ情報を保持していなくても被置換関数112の先頭アドレスを取得することができる効果を得ることができる。   As described above, step ST502, which is the process of the address resolution unit 122, searches the symbol information of the executable file of the test target program 110 using the name of the function 112 to be replaced, thereby obtaining the start address of the function 112 to be replaced. Therefore, even if the test target program 110 does not hold debug information, it is possible to obtain the effect that the start address of the function to be replaced 112 can be acquired.

次に、ステップST701のシンボル検索処理について図8を用いて説明する。
シンボル検索処理は、シンボルテーブルエントリを巡回し、入力とする検索条件と一致するを持つシンボルテーブルエントリの一覧を返す処理である。ステップST801は、検索結果をクリアする処理である。ステップST802〜ST805は、シンボルテーブルエントリを巡回するループ処理である。すなわち、ステップST803でシンボルが検索条件と一致するかを判定し、一致した場合はステップST804で検索結果にシンボルテーブルエントリを追加し、一致しなかった場合はそのまま次のシンボルテーブルエントリに進む。シンボルテーブルエントリ数は、図6のELFファイル読出し処理のステップST606処理時に記憶した値を参照することで得られる。
Next, the symbol search process in step ST701 will be described with reference to FIG.
The symbol search process is a process that circulates through the symbol table entries and returns a list of symbol table entries that match the input search conditions. Step ST801 is processing to clear the search result. Steps ST802 to ST805 are a loop process for circulating symbol table entries. That is, in step ST803, it is determined whether the symbol matches the search condition. If the symbol matches, the symbol table entry is added to the search result in step ST804, and if not, the process proceeds to the next symbol table entry. The number of symbol table entries can be obtained by referring to the value stored at the time of step ST606 of the ELF file reading process of FIG.

このように、実施の形態1では、関数置換部121を試験ドライバ101から呼び出せるようにすることで、試験ドライバ101の処理中で被置換関数112を置換関数102で置き換えることができる。また、アドレス解決部122を設けることで、プログラム書換え対象となるアドレスを試験対象プログラム110の実行時に取得できることができる。また、プログラム書換え部123を設けることで、試験ドライバ101の実行時に被置換関数112の呼出しを置換関数102の呼出しとすることができる。   As described above, in the first embodiment, the function replacement unit 121 can be called from the test driver 101, so that the function to be replaced 112 can be replaced with the replacement function 102 during the process of the test driver 101. In addition, by providing the address resolution unit 122, it is possible to acquire an address that is a target of program rewriting when the test target program 110 is executed. Also, by providing the program rewriting unit 123, the replacement function 112 can be called when the test driver 101 is executed.

以上説明したように、実施の形態1の単体試験支援装置によれば、試験対象プログラム中で書き換えられる被置換関数の識別子と、被置換関数を書き換えるための置換関数の識別子を入力する関数置換部と、被置換関数の識別子から試験対象プログラムの書換え位置のアドレスを取得するアドレス解決部と、アドレス解決部が取得したアドレスの試験対象プログラムを書き換えることで被置換関数を置換関数で書き換えるプログラム書換え部とを備えたので、ソフトウェアの単体試験における作業を簡略化することができる。   As described above, according to the unit test support apparatus of the first embodiment, the function replacement unit that inputs the identifier of the replacement function to be rewritten in the test target program and the identifier of the replacement function for rewriting the replacement function An address resolution unit that acquires the address of the rewriting position of the test target program from the identifier of the function to be replaced, and a program rewriting unit that rewrites the replacement function with the replacement function by rewriting the test target program at the address acquired by the address resolution unit Therefore, the software unit test can be simplified.

また、実施の形態1の単体試験支援装置によれば、アドレス解決部は、被置換関数の識別子から試験対象プログラムの書換え位置のアドレスとして被置換関数の先頭アドレスを取得し、プログラム書換え部は、先頭アドレスからのメモリ内容を置換関数に直接または間接的に分岐する1つ以上の命令に書き換えるようにしたので、試験対象プログラムが被置換関数を呼び出すと結果的に置換関数が実行されることを容易に実現することができる。   Further, according to the unit test support apparatus of the first embodiment, the address resolution unit acquires the start address of the function to be replaced as the address of the rewrite position of the test target program from the identifier of the function to be replaced. Since the memory contents from the start address are rewritten to one or more instructions that branch directly or indirectly to the replacement function, the replacement function is executed when the program under test calls the function to be replaced. It can be easily realized.

また、実施の形態1の単体試験支援装置によれば、アドレス解決部は、被置換関数の識別子を用いて試験対象プログラムのシンボル情報を検索することで、被置換関数の先頭アドレスを取得するようにしたので、試験対象プログラムがデバッグ情報を備えていなくても被置換関数の先頭アドレスを取得することができる。   Further, according to the unit test support apparatus of the first embodiment, the address resolution unit retrieves the symbol information of the test target program using the identifier of the function to be replaced, thereby acquiring the start address of the function to be replaced. Therefore, even if the test target program does not have debug information, the start address of the function to be replaced can be acquired.

また、実施の形態1の単体試験支援プログラムによれば、ソフトウェアの単体試験を行うためのコンピュータを、試験対象プログラム中で書き換えられる被置換関数の識別子と、被置換関数を書き換えるための置換関数の識別子を入力する関数置換部と、被置換関数の識別子から試験対象プログラムの書換え位置のアドレスを取得するアドレス解決部と、アドレス解決部が取得したアドレスの試験対象プログラムを書き換えることで被置換関数を置換関数で書き換えるプログラム書換え部として機能させるようにしたので、ソフトウェアの単体試験における作業を簡略化することができる単体試験支援装置をコンピュータ上に実現することができる。   Further, according to the unit test support program of the first embodiment, the computer for performing the unit test of the software includes the identifier of the replacement function to be rewritten in the test target program and the replacement function for rewriting the replacement function. The function replacement unit for inputting the identifier, the address resolution unit for acquiring the address of the rewriting position of the test target program from the identifier of the function to be replaced, and the function to be replaced by rewriting the test target program of the address acquired by the address resolution unit Since it is made to function as a program rewriting unit for rewriting with a replacement function, a unit test support device that can simplify the work in the unit test of software can be realized on a computer.

実施の形態2.
実施の形態1では、試験対象プログラム110のソースファイル群のうち、複数のソースファイルで同一名のローカル関数が定義されている場合、シンボルテーブルには、同一のシンボル名を持つエントリが複数存在する。このような場合は、被置換関数112の先頭アドレスを正しく解決できないことが問題となる。具体的には、図7のステップST703でシンボルが複数見つかるため、エラーとなる。このような問題を解決するのが実施の形態2である。なお、図面上の構成は図1と同様であるため、図1の構成を用いて説明する。
Embodiment 2. FIG.
In the first embodiment, when a local function having the same name is defined in a plurality of source files in the source file group of the test target program 110, a plurality of entries having the same symbol name exist in the symbol table. . In such a case, the problem is that the start address of the function to be replaced 112 cannot be resolved correctly. Specifically, an error occurs because a plurality of symbols are found in step ST703 of FIG. The second embodiment solves such a problem. The configuration on the drawing is the same as that in FIG. 1 and will be described using the configuration in FIG.

本実施の形態では、試験ドライバ101から被置換関数112が定義されているソースファイルを関数置換部121に伝達することで、シンボル解決が曖昧になることを回避することが基本的な仕組みである。このようにすることで、1つのソースファイルで同名の関数が複数定義されることはないため、ソースファイルと関数名で試験対象プログラム110に含まれる被置換関数112を一意に識別することができる。すなわち、実施の形態2では、アドレス解決部122が、被置換関数112の名前と被置換関数112を含むソースファイルの識別子を用いて試験対象プログラム110のデバッグ情報を検索することで、被置換関数112の先頭アドレスを取得するよう構成されている。その他の構成は実施の形態1と同様である。   In the present embodiment, the basic mechanism is to avoid ambiguity of symbol resolution by transmitting the source file in which the replacement function 112 is defined from the test driver 101 to the function replacement unit 121. . In this way, since a plurality of functions having the same name are not defined in one source file, the replacement function 112 included in the test target program 110 can be uniquely identified by the source file and the function name. . That is, in the second embodiment, the address resolution unit 122 searches the debug information of the test target program 110 using the name of the function 112 to be replaced and the identifier of the source file including the function 112 to be replaced, thereby replacing the function to be replaced. The first address of 112 is acquired. Other configurations are the same as those of the first embodiment.

以下、本実施の形態の動作説明として実施の形態1との差分を説明する。
まず、実施の形態2では、図5のステップST502の関数先頭アドレス取得処理が、シンボル情報ではなく、試験対象プログラム110のデバッグ情報を用いる点と、被置換関数112を含むソースファイルの名前を余分に入力とする点とが実施の形態1と異なる。また、関数置換部121への入力として、被置換関数112を含むソースファイル識別子が入力に加わる。同様に、図2のステップST202では、入力にソースファイル識別子が入力として加わる。
Hereinafter, differences from the first embodiment will be described as an operation description of the present embodiment.
First, in the second embodiment, the function head address acquisition process in step ST502 of FIG. 5 uses the debug information of the test target program 110 instead of the symbol information, and the name of the source file including the replaced function 112 is extra. This is different from the first embodiment in that it is input. In addition, as an input to the function replacement unit 121, a source file identifier including the function to be replaced 112 is added to the input. Similarly, in step ST202 of FIG. 2, the source file identifier is added as an input to the input.

以下の説明では、識別子としてソースファイル名を用いるものとするが、最終的にソースファイル名に変換可能であれば任意の識別子で代用可能である。例えば、一般にオブジェクトファイル名とソースファイル名との相違は拡張子の部分だけであることを利用すると、オブジェクトファイル名やそのベースファイル名を識別子としても容易にソースファイル名を得ることができる。   In the following description, the source file name is used as the identifier. However, any identifier can be used as long as it can be finally converted into the source file name. For example, if the fact that the difference between an object file name and a source file name is generally only an extension is used, the source file name can be easily obtained using the object file name or its base file name as an identifier.

次に、本実施の形態における、図5のステップST502の関数先頭アドレス取得処理を、図9を用いて説明する。
図9は、デバッグ情報による関数先頭アドレス取得処理のフローである。処理の入力は、被置換関数112の名前と被置換関数112を含むソースファイルの名前である。
ステップST901では、関数置換処理の入力の試験対象プログラム110に含まれるデバッグ情報から、ソース名と被置換関数名をキーとして被置換関数112のアドレスを取得する。本処理において、デバッグ情報からソース名と関数名の対で関数のアドレスを取得する処理は公知であるため、ここでは処理の概要のみを示す。デバッグ情報がDWARF形式の場合、デバッグ情報は、.debug_infoセクションに格納されている。ステップST901では、はじめにタグがDW_TAG_compilation_unitであるDIEの中から属性DW_AT_nameがソースファイル名と一致するDIE検索する。次に当該DIEの後続DIEのうちタグがDW_TAG_subprogramの中からDW_AT_nameが関数名と一致するDIEを検索する。結果として見つかったDIEの属性DW_AT_low_pcの値が求める関数先頭アドレスである。
Next, the function head address acquisition process in step ST502 of FIG. 5 in the present embodiment will be described with reference to FIG.
FIG. 9 is a flow of a function head address acquisition process using debug information. The input of the process is the name of the function 112 to be replaced and the name of the source file containing the function 112 to be replaced.
In step ST901, the address of the function to be replaced 112 is acquired from the debug information included in the test target program 110 that is the input of the function replacement process, using the source name and the function name to be replaced as keys. In this process, since the process of acquiring the address of the function from the debug information by the pair of the source name and the function name is known, only the outline of the process is shown here. If the debug information is in DWARF format, the debug information is stored in the .debug_info section. In step ST901, first, a DIE search is performed in which the attribute DW_AT_name matches the source file name from the DIEs whose tag is DW_TAG_compilation_unit. Next, a DIE whose tag has the same DW_AT_name as the function name is searched from DW_TAG_subprogram among subsequent DIEs of the DIE. The value of the DIE attribute DW_AT_low_pc found as a result is the function start address to be obtained.

ステップST902は、ステップST901の結果に基づく条件分岐処理である。ステップST901で被置換関数112のアドレスを取得することができなかった場合、エラー終了する。一方、ステップST901でアドレスを取得できた場合、ステップST903に分岐する。ステップST903では、ステップST901で取得した被置換関数112の値を結果として出力する。   Step ST902 is a conditional branch process based on the result of step ST901. If the address of the function to be replaced 112 cannot be acquired in step ST901, the process ends in error. On the other hand, if the address can be acquired in step ST901, the process branches to step ST903. In step ST903, the value of the function to be replaced 112 acquired in step ST901 is output as a result.

以上説明したように、実施の形態2の単体試験支援装置によれば、アドレス解決部は、被置換関数の名前と被置換関数を含むソースファイルの識別子を用いて試験対象プログラムのデバッグ情報を検索することで、被置換関数の先頭アドレスを取得するようにしたので、試験対象プログラム中に被置換関数と同じ名前を持つ関数が複数存在する場合であっても、被置換関数を一意に取得することができる。   As described above, according to the unit test support apparatus of the second embodiment, the address resolution unit searches for debug information of the test target program using the name of the function to be replaced and the identifier of the source file including the function to be replaced. As a result, the start address of the function to be replaced is acquired, so even if there are multiple functions with the same name as the function to be replaced in the test target program, the function to be replaced is uniquely acquired. be able to.

実施の形態3.
実施の形態2では、被置換関数112が定義されているファイル名を用いて被置換関数112の先頭アドレスを取得した。このため、被置換関数112を定義しているソースファイルを変更した場合は、正しく試験が実行できないことになる。具体的には、被置換関数112を定義しているソースファイルが変更された場合、図9のステップST902において、被置換関数112の情報が見つからないため、エラー終了する。従って、被置換関数112を定義しているソースファイルが変更された後も正しく試験を実行するためには、試験ドライバ101側の修正も必要となる。具体的には、図2のステップST202の入力の被置換関数112を含むソースファイル識別子を更新する必要がある。ソースファイルが変更される例としては、試験対象関数111と同じソースファイルに定義されていた被置換関数112が、リファクタリングなどで別のソースファイルに移動される場合などが挙げられる。
Embodiment 3 FIG.
In the second embodiment, the start address of the function to be replaced 112 is acquired using the file name in which the function to be replaced 112 is defined. For this reason, if the source file defining the function to be replaced 112 is changed, the test cannot be executed correctly. Specifically, when the source file defining the function to be replaced 112 is changed, information on the function to be replaced 112 is not found in step ST902 in FIG. Therefore, in order to correctly execute the test even after the source file defining the replaced function 112 is changed, the test driver 101 side needs to be corrected. Specifically, it is necessary to update the source file identifier including the input function 112 to be replaced in step ST202 of FIG. As an example of changing the source file, there is a case where the function to be replaced 112 defined in the same source file as the test target function 111 is moved to another source file by refactoring or the like.

このような問題を解決するのが、本実施の形態である。すなわち、被置換関数112が定義されているファイルが変更されても、試験ドライバ101側の変更を不要とする。以下では実施の形態2との差分で本実施の形態を説明する。なお、図面上の構成は図1と同様である。   This embodiment solves such a problem. That is, even if the file in which the function to be replaced 112 is defined is changed, the change on the test driver 101 side is not required. Hereinafter, the present embodiment will be described based on differences from the second embodiment. The configuration on the drawing is the same as in FIG.

本実施の形態が実施の形態2とは異なる点は、関数置換部121の入力として被置換関数112のソースファイル識別子ではなく、試験対象関数111のソースファイル識別子を用いる点である。すなわち、実施の形態3のアドレス解決部122は、被置換関数112の名前と、試験対象関数111のソースプログラム識別子とを用いて被置換関数112の先頭アドレスを取得し、見つからなければ被置換関数112の名前のみを用いて被置換関数112の先頭アドレスを検索するよう構成されている。その他の構成は実施の形態1と同様である。   This embodiment is different from the second embodiment in that the source file identifier of the test target function 111 is used as the input of the function replacing unit 121 instead of the source file identifier of the function 112 to be replaced. That is, the address resolution unit 122 according to the third embodiment obtains the head address of the function to be replaced 112 using the name of the function to be replaced 112 and the source program identifier of the function to be tested 111. The head address of the function to be replaced 112 is searched using only the name 112. Other configurations are the same as those of the first embodiment.

以降の説明では、ソースファイル識別子としてソースファイル名を用いることを想定して説明する。
図5のステップST502の関数先頭アドレス取得処理の入力は、被置換関数112を含むソースファイルの名前ではなく、試験対象関数111のソースファイル識別子である。また、関数置換部121への入力も同様に、被置換関数112を含むソースファイル識別子ではなく、試験対象関数111のソースファイル識別子である。同様に、図2のステップST202では、試験対象関数111のソースファイル識別子を入力とする。
In the following description, it is assumed that the source file name is used as the source file identifier.
The input of the function head address acquisition process in step ST502 in FIG. 5 is not the name of the source file including the function to be replaced 112 but the source file identifier of the test target function 111. Similarly, the input to the function replacement unit 121 is not the source file identifier including the function to be replaced 112 but the source file identifier of the test target function 111. Similarly, in step ST202 of FIG. 2, the source file identifier of the test target function 111 is input.

次に、本実施の形態における、図5のステップST502の関数先頭アドレス取得処理を、図10を用いて説明する。
図10は、ソースファイル名を用いた関数先頭アドレス取得処理を示すフローチャートである。処理の入力は、被置換関数112の名前と、試験対象関数111を含むソースファイルの名前である。
ステップST1001では、試験対象関数111を含むソースファイルの名前と被置換関数112の名前とで関数のアドレスを検索する。具体的には、試験対象関数111のソースファイルに定義されている関数の中から被置換関数112の名前を持つ関数のアドレスを取得する。この処理は実施の形態2におけるステップST901と概ね同じである。
Next, the function head address acquisition process in step ST502 of FIG. 5 in the present embodiment will be described with reference to FIG.
FIG. 10 is a flowchart showing a function head address acquisition process using a source file name. The input of the process is the name of the function 112 to be replaced and the name of the source file containing the test target function 111.
In step ST1001, the address of the function is searched based on the name of the source file including the test target function 111 and the name of the function to be replaced 112. Specifically, the address of the function having the name of the function to be replaced 112 is acquired from the functions defined in the source file of the test target function 111. This process is substantially the same as step ST901 in the second embodiment.

ステップST1002では、ステップST1001の処理結果に基づく分岐処理である。ステップST1001で被置換関数112の情報が見つかった場合、ステップST1003に分岐する。それ以外の場合は、ステップST1004に分岐する。
ステップST1003では、ステップST1001で見つかった被置換関数の情報から先頭アドレスを取得し、処理の結果として出力する。
Step ST1002 is a branching process based on the processing result of step ST1001. If information on the function to be replaced 112 is found in step ST1001, the process branches to step ST1003. Otherwise, the process branches to step ST1004.
In step ST1003, the head address is acquired from the information on the function to be replaced found in step ST1001, and is output as the processing result.

ステップST1004では、関数名が被置換関数と一致するグローバル関数を検索する処理である。この処理は公知であるため、ここでは処理の概要のみを示す。具体的にデバッグ情報がDWARF形式の場合、タグがDW_TAG_subprogramのDIEの中から、属性DW_AT_nameが被置換関数の名前と一致しており、かつ属性DW_AT_externalが1のDIEを検索すればよい。見つかったDIEの属性DW_AT_low_pcの値が求めるアドレスである。   Step ST1004 is a process of searching for a global function whose function name matches the function to be replaced. Since this process is known, only an outline of the process is shown here. Specifically, when the debug information is in DWARF format, a DIE whose attribute DW_AT_name matches the name of the function to be replaced and whose attribute DW_AT_external is 1 may be searched from the DIEs having the tag DW_TAG_subprogram. This is the address for which the value of the found DIE attribute DW_AT_low_pc is obtained.

ステップST1005は、ステップST1004の結果に基づく分岐処理である。ステップST1004で被置換関数112の情報が見つかった場合、ステップST1006に分岐する。それ以外の場合、エラー終了する。
ステップST1006は、ステップST1004で見つかった被置換関数112の情報から先頭アドレスを取得し、処理の結果として出力する。
Step ST1005 is a branching process based on the result of step ST1004. If information on the function to be replaced 112 is found in step ST1004, the process branches to step ST1006. Otherwise, end in error.
In step ST1006, the head address is acquired from the information of the function to be replaced 112 found in step ST1004, and is output as a processing result.

このように、アドレス解決部122の処理であるステップST502の実現手段として、関数アドレス取得処理において、被置換関数112の名前とソースプログラム識別子とを用いて被置換関数112の先頭アドレスを取得し(ステップST1001)、見つからなければ被置換関数112の名前のみを用いて被置換関数112の先頭アドレスを検索する(ステップST1004)手段を持つことで、被置換関数112が定義されているファイルの位置に依存することなく、被置換関数112を置換関数102で置き換えることができる。このため、試験ドライバ101作成後に、被置換関数112が別のファイルに移動された場合においても、試験ドライバ101を修正する必要がなくなるという効果を得ることができる。   As described above, as the means for realizing step ST502, which is the process of the address resolution unit 122, in the function address acquisition process, the start address of the function to be replaced 112 is acquired using the name of the function to be replaced 112 and the source program identifier ( Step ST1001) If it is not found, only the name of the function to be replaced 112 is used to search for the start address of the function to be replaced 112 (step ST1004), so that the replaced function 112 is defined at the position of the file. The replacement function 112 can be replaced with the replacement function 102 without depending on it. Therefore, even when the replacement function 112 is moved to another file after the test driver 101 is created, it is possible to obtain an effect that the test driver 101 does not need to be corrected.

なお、上記説明では、試験対象関数111のソースプログラム識別子をソースプログラムのファイル名として説明したが、試験対象関数111の名前や試験対象関数111のアドレスで代用することも可能である。試験対象プログラム110のデバッグ情報を検索すれば、試験対象関数111の名前や試験対象関数111のアドレスから試験対象関数111を定義しているソースプログラムを特定することができるためである。   In the above description, the source program identifier of the test target function 111 is described as the file name of the source program. However, the name of the test target function 111 or the address of the test target function 111 can be substituted. This is because searching the debug information of the test target program 110 can identify the source program defining the test target function 111 from the name of the test target function 111 and the address of the test target function 111.

また、試験対象関数111のソースプログラム識別子としてファイル名ではなく試験対象関数111のアドレスを用いることで、試験対象関数111のソースファイルの名前が変更されても試験ドライバ101を変更する必要がなくなるという効果を新たに得ることもできる。   Further, by using the address of the test target function 111 instead of the file name as the source program identifier of the test target function 111, it is not necessary to change the test driver 101 even if the name of the source file of the test target function 111 is changed. A new effect can also be obtained.

以上説明したように、アドレス解決部は、被置換関数の名前と、試験対象プログラムが実行される場合に被置換関数を呼び出す試験対象関数のソースプログラム識別子とを用いて被置換関数の先頭アドレスを取得し、見つからなければ被置換関数の名前のみを用いて被置換関数の先頭アドレスを検索するようにしたので、被置換関数が定義されているファイルの位置に依存することなく、被置換関数を置換関数で置き換えることができる。このため、試験ドライバ作成後に、被置換関数が別のファイルに移動された場合においても、試験ドライバを修正する必要がないという効果が得られる。   As described above, the address resolution unit uses the name of the function to be replaced and the source program identifier of the function to be tested that calls the function to be replaced when the program to be tested is executed to determine the start address of the function to be replaced. If it is not found, the head address of the function to be replaced is searched using only the name of the function to be replaced. Therefore, the function to be replaced is not dependent on the position of the file where the function to be replaced is defined. Can be replaced with a replacement function. For this reason, even when the replacement function is moved to another file after the test driver is created, there is an effect that it is not necessary to modify the test driver.

実施の形態4.
実施の形態2、3では、被置換関数112のアドレスを取得するためにデバッグ情報を用いた。このため、被置換関数112を含むオブジェクトファイル自体がデバッグ情報を保持する必要がある。そのためには、被置換関数112を定義するソースファイルのコンパイル時にデバッグ情報の出力オプションがコンパイラに指定されている必要がある。従って、被置換関数112を含むオブジェクトファイルのソースコードが得られない場合などに、実施の形態2は適用できないことになる。本実施の形態では、この問題を解決する方法を提供する。なお、本実施の形態においても、図面上の構成は図1と同様である。
Embodiment 4 FIG.
In the second and third embodiments, debug information is used to obtain the address of the function 112 to be replaced. For this reason, the object file itself including the function to be replaced 112 needs to hold debug information. For this purpose, an option for outputting debug information needs to be specified in the compiler when compiling a source file that defines the function to be replaced 112. Therefore, the second embodiment cannot be applied when the source code of the object file including the replaced function 112 cannot be obtained. In the present embodiment, a method for solving this problem is provided. In the present embodiment also, the configuration on the drawing is the same as that in FIG.

本実施の形態では、図10のステップST1001とステップST1004でデバッグ情報を用いた関数の先頭アドレス取得処理の代わりにシンボル情報を用いた関数先頭アドレス取得処理を行うことを特徴とする。すなわち、実施の形態4のアドレス解決部122は、被置換関数112の名前と、試験対象プログラム110が実行される場合に被置換関数112を呼び出す試験対象関数111のリロケータブルファイルとを用いて被置換関数112の先頭アドレスを取得し、見つからなければ被置換関数112の名前のみを用いて被置換関数112の先頭アドレスを検索するよう構成されている。   This embodiment is characterized in that function start address acquisition processing using symbol information is performed instead of function start address acquisition processing using debug information in steps ST1001 and ST1004 of FIG. That is, the address resolution unit 122 of the fourth embodiment uses the name of the function to be replaced 112 and the relocatable file of the test target function 111 that calls the function to be replaced 112 when the test target program 110 is executed. If the head address of the function 112 is not found, the head address of the function 112 to be replaced is searched using only the name of the function 112 to be replaced.

次に、実施の形態4の単体試験支援装置の動作について説明する。
始めに、処理が単純なステップST1004のシンボル情報を用いた関数先頭アドレス取得処理を説明する。ステップST1004では、グローバルな被置換関数112のアドレスを取得することが目的である。そこで、本実施の形態では、ステップST501で読み出した試験対象プログラム110のシンボルテーブルから、被置換関数112の名前と一致しかつグローバルなシンボルのエントリを取得すればよい。シンボル検索処理は実施の形態1で示した通りである。なお、シンボルがグローバルであるか否かは、シンボルテーブルエントリのst_infoの上位4ビットがSTB_GLOBALか否かで判定可能である。また、シンボルが関数か否かは、シンボルテーブルエントリのst_infoフィールドの下位4ビットがSTT_FUNCか否かで判定可能である。
Next, the operation of the unit test support apparatus according to the fourth embodiment will be described.
First, the function head address acquisition process using the symbol information in step ST1004 where the process is simple will be described. In step ST1004, the purpose is to acquire the address of the global replacement function 112. Therefore, in the present embodiment, an entry of a global symbol that matches the name of the function to be replaced 112 may be acquired from the symbol table of the test target program 110 read out in step ST501. The symbol search process is as described in the first embodiment. Whether or not a symbol is global can be determined by whether or not the upper 4 bits of st_info of the symbol table entry are STB_GLOBAL. Whether a symbol is a function or not can be determined by checking whether the lower 4 bits of the st_info field of the symbol table entry are STT_FUNC.

次に、図11と図12を用いてステップST1001に対応する処理について説明する。
図11は、リロケータブルファイルのシンボル情報による関数先頭アドレス取得の模式図である。アドレス空間1101は、試験対象プログラム110を含むプロセスのアドレス空間である。また、リロケータブルファイル1103は、試験対象関数111を含むリロケータブルファイルである。リロケータブルファイル1103は、コードを含む.textセクション1105を保持している。また、.textセクション1105の中に図1の被置換関数112に対応する被置換関数1106が存在するものとする。.textセクション1105は、アドレス空間1101においては、セクション先頭アドレスB1102の位置にマップされている。また、リロケータブルファイル1103は、リロケータブルファイルシンボルテーブル1104も含んでいる。リロケータブルファイルシンボルテーブル1104は、被置換関数1106に対応するエントリをもつ。当該シンボルテーブルエントリには、被置換関数の.textセクション1105からのオフセットAが値として記憶されている。本実施の形態では、計算機が(セクション先頭アドレスB)+(オフセットA)を計算することで、ロケータブルファイルのシンボル情報による関数先頭アドレス取得処理を実現する。
Next, processing corresponding to step ST1001 will be described using FIG. 11 and FIG.
FIG. 11 is a schematic diagram of function start address acquisition based on symbol information of a relocatable file. The address space 1101 is an address space of a process including the test target program 110. The relocatable file 1103 is a relocatable file including the test target function 111. The relocatable file 1103 holds a .text section 1105 including a code. Further, it is assumed that a replaced function 1106 corresponding to the replaced function 112 in FIG. 1 exists in the .text section 1105. The .text section 1105 is mapped to the position of the section head address B1102 in the address space 1101. The relocatable file 1103 also includes a relocatable file symbol table 1104. The relocatable file symbol table 1104 has an entry corresponding to the replaced function 1106. In the symbol table entry, an offset A from the .text section 1105 of the function to be replaced is stored as a value. In this embodiment, the computer calculates (section start address B) + (offset A), thereby realizing function start address acquisition processing based on symbol information of the locable file.

図12は、リロケータブルファイルのシンボル情報による関数先頭アドレス取得処理を示すフローチャートである。
ステップST1201は、被置換関数1106を含むリロケータブルファイル名を入力としてオブジェクトファイル読出し処理を行う。オブジェクトファイル読出し処理は、実施の形態1で示した通りである。リロケータブルファイル1103の名前は、ソースファイル名の拡張子を変更して得られる。例えば、C言語のソースファイルであれば、拡張子を.cから.oや.objに変更すればよい。
FIG. 12 is a flowchart showing a function head address acquisition process based on symbol information of a relocatable file.
In step ST1201, an object file read process is performed with the relocatable file name including the function to be replaced 1106 as an input. The object file reading process is as described in the first embodiment. The name of the relocatable file 1103 is obtained by changing the extension of the source file name. For example, in the case of a C language source file, the extension may be changed from .c to .o or .obj.

ステップST1202では、被置換関数名のシンボルをステップST1201で読み出したシンボルテーブルから検索する処理である。シンボル検索処理は実施の形態1で示した通りである。ここでは、シンボル検索処理の入力に与える検索条件は、シンボルの名前が被置換関数1106の名前と一致することである。シンボルテーブルエントリのシンボル名は、シンボルテーブルエントリのst_nameフィールドを、ステップST1201で読み出した文字列テーブルのインデックスとして読み出せるゼロ終端文字列である。   In step ST1202, the symbol of the function name to be replaced is searched from the symbol table read in step ST1201. The symbol search process is as described in the first embodiment. Here, the search condition given to the input of the symbol search process is that the name of the symbol matches the name of the function to be replaced 1106. The symbol name of the symbol table entry is a zero-terminated character string that can be read as the index of the character string table read in step ST1201 from the st_name field of the symbol table entry.

ステップST1202で得られるシンボルテーブルエントリのst_valueフィールドは、関数が定義されているセクションの先頭からのオフセットである。なお、ここでは説明を単純化するため関数が定義されているセクションが標準的な.textセクションであると想定して説明するが、別のセクションであってもよい。その場合は、シンボルが存在するセクションをステップST1202で記憶し、ステップST1205の処理では記憶したセクションを対象として先頭アドレスを取得すればよい。シンボルテーブルエントリのst_shndxフィールドの参照で行うことで、シンボルが存在するセクションを特定することができる。   The st_value field of the symbol table entry obtained in step ST1202 is an offset from the beginning of the section in which the function is defined. In addition, here, in order to simplify the description, it is assumed that the section in which the function is defined is a standard .text section, but another section may be used. In that case, the section in which the symbol exists is stored in step ST1202, and in the process of step ST1205, the start address may be acquired for the stored section. By referring to the st_shndx field of the symbol table entry, the section where the symbol exists can be specified.

ステップST1203では、ステップST1202の処理結果に基づく条件分岐処理である。ステップST1202でシンボルが見つからなかった場合、エラーとして終了する。一方、ステップST1202で条件と一致するシンボルが見つかった場合はステップST1204に分岐する。   Step ST1203 is a conditional branch process based on the process result of step ST1202. If no symbol is found in step ST1202, the process ends as an error. On the other hand, if a symbol matching the condition is found in step ST1202, the process branches to step ST1204.

ステップST1204では、見つかったシンボルの値を変数Aに格納する。次に、ステップST1205では、ステップST1201で読み出したリロケータブルファイル1103における.textセクション1105のアドレス空間1101における先頭アドレスを取得する処理である。ステップST1205の詳細については図13と図14とを用いて後述する。   In step ST1204, the value of the found symbol is stored in variable A. Next, in step ST1205, it is a process which acquires the head address in the address space 1101 of the .text section 1105 in the relocatable file 1103 read in step ST1201. Details of step ST1205 will be described later with reference to FIGS.

ステップST1206では、ステップST1205で取得したセクション先頭アドレスをBに格納する。また、ステップST1207では、A+Bの計算によって関数先頭アドレスを計算し、結果として出力する。   In step ST1206, the section head address acquired in step ST1205 is stored in B. In step ST1207, the function head address is calculated by calculating A + B and output as a result.

次に、図12におけるステップST1205のセクション先頭アドレス取得処理について図13と図14とを用いて説明する。
図13は、セクション先頭アドレス取得の模式図である。アドレス空間1301は、試験対象プログラム110のプロセスのアドレス空間である。リロケータブルファイル1303は、試験対象プログラム110を含むリロケータブルファイルであり、.textセクション1304とリロケータブルファイルシンボルテーブル1306を含む。また、.textセクション1304には任意のグローバル関数G1305が1つ含まれるものとする。リロケータブルファイルシンボルテーブル1306は、グローバル関数G1305に対応するエントリを保持している。当該エントリは、グローバル関数G1305の.textセクション1304からのオフセットXを保持している。また、実行可能ファイルシンボルテーブル1307は、試験対象プログラム110の実行可能ファイルのシンボルテーブルである。実行可能ファイルシンボルテーブル1307も、グローバル関数G1305に対応するエントリを保持している。当該エントリは、アドレス空間1301におけるグローバル関数G1305のアドレスYを保持している。本実施の形態では、ステップST1205におけるセクション先頭アドレス取得処理が、(グローバル関数G1305のアドレスY)−(グローバル関数G1305のセクション先頭1からのオフセットX)を計算することでテキスト先頭アドレスを求める。
Next, the section head address acquisition processing in step ST1205 in FIG. 12 will be described using FIG. 13 and FIG.
FIG. 13 is a schematic diagram of section start address acquisition. An address space 1301 is an address space of a process of the test target program 110. The relocatable file 1303 is a relocatable file including the test target program 110, and includes a .text section 1304 and a relocatable file symbol table 1306. Further, it is assumed that the .text section 1304 includes one arbitrary global function G1305. The relocatable file symbol table 1306 holds an entry corresponding to the global function G1305. This entry holds the offset X from the .text section 1304 of the global function G1305. The executable file symbol table 1307 is a symbol table of an executable file of the test target program 110. The executable file symbol table 1307 also holds an entry corresponding to the global function G1305. This entry holds the address Y of the global function G1305 in the address space 1301. In the present embodiment, the section head address acquisition processing in step ST1205 calculates the text head address by calculating (address Y of global function G1305) − (offset X from section head 1 of global function G1305).

図14は、セクション先頭アドレス取得処理を示すフローチャートである。セクション先頭アドレス取得処理の入力は、実行可能ファイルの名前と本処理の呼出し元で読み出したリロケータブルの情報とである。
ステップST1401は、ステップST1201で読み出したリロケータブルファイルからグローバルな関数のシンボルを取得する処理である。シンボル検索処理は、実施の形態1で説明した通りであるが、検索条件としては、シンボルがグローバルな関数であることを指定する。シンボルがグローバルか否かはシンボルテーブルエントリのst_infoの上位4ビットがSTB_GLOBALか否かで判定可能である。また、シンボルが関数か否かは、シンボルテーブルエントリのst_infoフィールドの下位4ビットがSTT_FUNCか否かで判定可能である。
FIG. 14 is a flowchart showing the section head address acquisition process. The input of the section head address acquisition process is the name of the executable file and the relocatable information read by the caller of this process.
Step ST1401 is processing for acquiring a symbol of a global function from the relocatable file read out in step ST1201. The symbol search process is as described in the first embodiment, but the search condition specifies that the symbol is a global function. Whether or not a symbol is global can be determined by whether or not the upper 4 bits of st_info of the symbol table entry are STB_GLOBAL. Whether a symbol is a function or not can be determined by checking whether the lower 4 bits of the st_info field of the symbol table entry are STT_FUNC.

ステップST1402は、ステップST1401の結果に基づく条件分岐処理である。ステップST1401でシンボルが見つからなかった場合、エラー終了する。一方、シンボルが見つかった場合、ステップST1403に分岐する。ステップST1403では、ステップST1401で得られたシンボル一覧の先頭を変数Xに代入する処理である。ここではシンボル一覧の先頭を選択したが、実際にはシンボルがグローバルの関数である条件を満足する任意のシンボルをXに代入してよい。   Step ST1402 is a conditional branch process based on the result of step ST1401. If no symbol is found in step ST1401, the process ends in error. On the other hand, if a symbol is found, the process branches to step ST1403. In step ST1403, the symbol list obtained in step ST1401 is assigned to the variable X. Although the top of the symbol list is selected here, in practice, any symbol that satisfies the condition that the symbol is a global function may be substituted for X.

ステップST1404では、実行可能ファイル名を入力としてオブジェクトファイル読出し処理を行う。オブジェクトファイル読出し処理の詳細は、実施の形態1で説明した通りである。なお、ステップST501でも同じ情報を読み出しているため、その情報をそのまま用いることで本処理を省略することも可能である。
ステップST1405では、ステップST1404で読み出したファイル情報からシンボルを検索する処理である。このとき、検索条件として、ステップST1403で代入したシンボルXの名前と一致することを指定する。
ステップST1406は、ステップST1405の結果に基づく条件分岐処理である。ステップST1405でシンボルが見つからなかった場合はエラー終了する。一方、シンボルが見つかった場合はステップST1407に分岐する。
In step ST1404, an object file read process is performed with an executable file name as an input. Details of the object file read processing are as described in the first embodiment. Since the same information is read out also in step ST501, this process can be omitted by using the information as it is.
In step ST1405, a symbol is searched from the file information read in step ST1404. At this time, the search condition is designated to match the name of the symbol X assigned in step ST1403.
Step ST1406 is a conditional branch process based on the result of step ST1405. If no symbol is found in step ST1405, the process ends in error. On the other hand, if a symbol is found, the process branches to step ST1407.

ステップST1407では、ステップST1406の結果で得られたシンボル一覧の先頭を変数Yに代入する処理である。ステップST1405では、グローバルな関数のシンボルXの名前で検索しているため、通常結果として得られる一覧は、1つのシンボルのみ含む。
ステップST1408では、Y−Xを計算することでセクション先頭アドレスを計算する。シンボルの値は、具体的にはXとYとそれぞれのst_valueフィールドの値である。Yのシンボル値は、グローバル関数の先頭アドレスであり、Xのシンボル値は、セクション先頭からのオフセットである。両者の差をとることで、セクション先頭のアドレスを取得することができる。
Step ST1407 is a process of substituting the top of the symbol list obtained as a result of step ST1406 for variable Y. In step ST1405, since the search is performed using the name of the symbol X of the global function, the list obtained as a normal result includes only one symbol.
In step ST1408, the section head address is calculated by calculating YX. Specifically, the symbol value is the value of the st_value field of each of X and Y. The symbol value of Y is the start address of the global function, and the symbol value of X is an offset from the beginning of the section. By taking the difference between the two, the head address of the section can be acquired.

以上説明したように、実施の形態4の単体試験支援装置によれば、アドレス解決部は、被置換関数の名前と、試験対象プログラムが実行される場合に被置換関数を呼び出す試験対象関数のリロケータブルファイルとを用いて被置換関数の先頭アドレスを取得し、見つからなければ被置換関数の名前のみを用いて被置換関数の先頭アドレスを検索するようにしたので、被置換関数が定義されているファイルの位置に依存することなく、被置換関数を置換関数で置き換えることができる。このため、試験ドライバ作成後に、被置換関数が別のファイルに移動された場合においても、試験ドライバを修正する必要がなくなるという効果を得ることができる。   As described above, according to the unit test support apparatus of the fourth embodiment, the address resolution unit includes the name of the function to be replaced and the relocatable function of the test target function that calls the function to be replaced when the test target program is executed. Since the start address of the function to be replaced is obtained using the file, and the start address of the function to be replaced is searched using only the name of the function to be replaced if it is not found, the file in which the function to be replaced is defined The function to be replaced can be replaced with a replacement function without depending on the position of. For this reason, even when the function to be replaced is moved to another file after the test driver is created, it is possible to obtain an effect that it is not necessary to modify the test driver.

また、実施の形態4の単体試験支援装置によれば、アドレス解決部は、被置換関数の定義を含むリロケータブルファイルのシンボル情報と試験プログラムのシンボル情報とセクション先頭アドレスとから、被置換関数の先頭アドレスを算出するようにしたので、デバッグ情報を用いることなく試験対象関数と同じファイルで定義された被置換関数のアドレスを取得することができる。このとき、被置換関数がローカル関数で、同名のローカル関数が試験プログラムに複数含まれていても被置換関数のアドレスを一意に特定することができる。被置換関数がローカル関数の場合、試験対象関数が呼び出す被置換関数は、必ず被置換関数と同じソースファイルで唯一定義されているためである。   Also, according to the unit test support apparatus of the fourth embodiment, the address resolution unit determines the start of the replacement function from the symbol information of the relocatable file including the definition of the replacement function, the symbol information of the test program, and the section start address. Since the address is calculated, the address of the function to be replaced defined in the same file as the function to be tested can be acquired without using debug information. At this time, even if the function to be replaced is a local function and a plurality of local functions with the same name are included in the test program, the address of the function to be replaced can be uniquely specified. This is because when the function to be replaced is a local function, the function to be called called by the test target function is always defined only in the same source file as the function to be replaced.

実施の形態5.
実施の形態1〜4では、それぞれアドレス解決部122は異なる関数先頭アドレスの取得手段を用いて先頭アドレスの取得を行った。具体的には、実施の形態1では、図7に示した実行可能ファイルのシンボル情報を用いた関数先頭アドレス取得手段を用いた。また、実施の形態2では、図9に示したデバッグ情報による関数先頭アドレス取得手段を用いた。また、実施の形態3では、図10のソースファイル名を用いた関数先頭アドレス取得手段としてデバッグ情報を用いて実現する手段を示した。また、実施の形態4では、図10のソースファイル名を用いた関数先頭アドレス取得手段としてリロケータブルファイルのシンボル情報を用いて実現する手段について示した。このように、アドレス解決部122における関数先頭アドレス取得手段は複数存在する。それぞれの関数先頭アドレス取得手段は、シンボル情報やデバッグ情報など異なる情報を用いて被置換関数112のアドレスを取得する。このため、試験ドライバ作成者は、利用可能な情報を元に適切な関数先頭アドレス取得手段を選択する必要があるという問題があった。上記問題を解決するのが本実施の形態である。
Embodiment 5. FIG.
In the first to fourth embodiments, each address resolution unit 122 acquires the start address using different function start address acquisition means. Specifically, in the first embodiment, the function head address acquisition unit using the symbol information of the executable file shown in FIG. 7 is used. Further, in the second embodiment, the function head address acquisition means based on the debug information shown in FIG. 9 is used. In the third embodiment, the means realized by using debug information as the function head address acquisition means using the source file name of FIG. 10 is shown. In the fourth embodiment, the means realized by using the symbol information of the relocatable file as the function head address acquisition means using the source file name of FIG. 10 is shown. Thus, there are a plurality of function head address acquisition means in the address resolution unit 122. Each function head address acquisition unit acquires the address of the function to be replaced 112 using different information such as symbol information and debug information. Therefore, there is a problem that the test driver creator needs to select an appropriate function head address acquisition unit based on available information. The present embodiment solves the above problem.

本実施の形態では、複数の関数先頭アドレス取得手段の試行手段を備えたアドレス解決部122を持つことを特徴とする。すなわち、実施の形態5のアドレス解決部122は、試験対象プログラム110のデバッグ情報の有無、または、試験対象関数111のリロケータブルファイルの有無に基づいて、被置換関数112の先頭アドレスを取得する手段を選択するよう構成されている。   The present embodiment is characterized by having an address resolution unit 122 including a plurality of function head address acquisition means trial means. That is, the address resolution unit 122 according to the fifth embodiment has means for acquiring the start address of the function to be replaced 112 based on the presence / absence of debug information of the test target program 110 or the presence / absence of the relocatable file of the test target function 111. Configured to select.

本実施の形態における試験支援部120の処理フローを図15に示す。
関数置換部121の入力は、試験対象関数111のソースファイル名、試験対象プログラム110の実行可能ファイル名、被置換関数112の名前である。
ステップST1501は、試験対象プログラム110の実行可能ファイルの情報を読み出す処理である。本処理は、ステップST501と同じである。ステップST1502は、デバッグ情報があるか否に基づく分岐処理である。デバッグ情報が存在する場合はステップST1505に分岐し、それ以外の場合は、ステップST1504に分岐する。デバッグ情報があるか否かは、ステップST1501で読み出したセクションヘッダテーブルを検索し、デバッグ情報を含むセクションの存在有無を確認することで行うことができる。例えば、実行可能ファイルのフォーマットがELF形式でデバッグ情報のフォーマットがDWARFである場合、.debug_infoセクションがあればデバッグ情報が存在するとみなし、なければ存在しないとみなせばよい。
The processing flow of the test support unit 120 in this embodiment is shown in FIG.
The input of the function replacement unit 121 is the source file name of the test target function 111, the executable file name of the test target program 110, and the name of the function 112 to be replaced.
Step ST1501 is a process of reading information on the executable file of the test target program 110. This process is the same as step ST501. Step ST1502 is a branch process based on whether or not there is debug information. If there is debug information, the process branches to step ST1505. Otherwise, the process branches to step ST1504. Whether or not there is debug information can be determined by searching the section header table read in step ST1501 and confirming whether or not there is a section including debug information. For example, if the executable file format is ELF format and the debug information format is DWARF, it can be assumed that debug information exists if there is a .debug_info section, and that it does not exist otherwise.

ステップST1503は、デバッグ情報を用いた関数先頭アドレス取得処理である。本処理は、実施の形態3における図10の処理と同じである。   Step ST1503 is a function head address acquisition process using debug information. This process is the same as the process of FIG. 10 in the third embodiment.

ステップST1504は、試験対象関数111のソースファイルに対応するリロケータブルファイルの有無による条件分岐処理である。リロケータブルファイルの有無確認は、ソースファイル名から取得したリロケータブルファイル名がファイルシステム上に存在するか否かで行うことができる。リロケータブルファイルが存在すればステップST1505に分岐し、それ以外の場合はステップST1506に分岐する。   Step ST1504 is a conditional branch process based on the presence or absence of a relocatable file corresponding to the source file of the test target function 111. The presence / absence of the relocatable file can be confirmed by checking whether or not the relocatable file name acquired from the source file name exists on the file system. If there is a relocatable file, the process branches to step ST1505. Otherwise, the process branches to step ST1506.

ステップST1505は、リロケータブルファイルのシンボル情報を用いた関数先頭アドレス取得処理である。本処理は、実施の形態4の説明に基づく図10の処理と同じである。
ステップST1506は、実行可能ファイルシンボル情報による関数先頭アドレス取得処理である。本処理は、実施の形態1の図7の処理と同じである。
ステップST1507は、ステップST1503、またはステップST1505またはステップST1506で取得した関数先頭アドレスに置換関数102への無条件分岐命令を書き込む処理である。本処理の詳細は実施の形態1で示した通りである。
Step ST1505 is a function head address acquisition process using the symbol information of the relocatable file. This process is the same as the process of FIG. 10 based on the description of the fourth embodiment.
Step ST1506 is a function head address acquisition process using executable file symbol information. This process is the same as the process of FIG. 7 of the first embodiment.
Step ST1507 is a process of writing an unconditional branch instruction to the replacement function 102 to the function start address acquired in step ST1503, step ST1505, or step ST1506. Details of this processing are as described in the first embodiment.

以上説明したように、実施の形態5の単体試験支援装置によれば、アドレス解決部は、試験対象プログラムのデバッグ情報の有無、または、試験対象関数のリロケータブルファイルの有無に基づいて、被置換関数の先頭アドレスを取得する手段を選択するようにしたので、試験ドライバ作成者は、被置換関数の先頭アドレスを取得する手段が利用可能な情報試験ドライバを作成するといったことがなく、試験ドライバ作成者の負担を軽減することができる。   As described above, according to the unit test support apparatus of the fifth embodiment, the address resolution unit determines whether the function to be replaced is based on the presence or absence of debug information of the test target program or the presence or absence of the relocatable file of the test target function. Since the means for acquiring the start address of the test driver is selected, the test driver creator does not create an information test driver that can use the means for acquiring the start address of the function to be replaced. Can be reduced.

実施の形態6.
実施の形態1では、被置換関数自体を書き換えることで関数置換処理を実現している。しかし、被置換関数が共有ライブラリ関数の場合には置換できないことが問題となる。一般に、共有ライブラリは複数のプロセスから共有されるため、共有ライブラリ関数が書き換わると試験対象プログラム110以外のプログラムにも影響を及ぼすことになる。そこで、被置換関数112が共有ライブラリ関数の場合の関数置換処理を実現するのが本実施の形態である。
Embodiment 6 FIG.
In the first embodiment, the function replacement process is realized by rewriting the function to be replaced itself. However, if the function to be replaced is a shared library function, the problem is that it cannot be replaced. In general, since the shared library is shared by a plurality of processes, if the shared library function is rewritten, the program other than the test target program 110 is affected. Thus, in the present embodiment, the function replacement process when the function to be replaced 112 is a shared library function is realized.

本実施の形態におけるアドレス解決部122は、試験対象プログラム110のアドレス空間において被置換関数112を参照している箇所のアドレスを取得し、プログラム書換え部123は、アドレス解決部122が取得したアドレスの箇所を置換関数102のアドレス参照に書き換えるよう構成されている。その他の構成は図1に示した実施の形態1と同様である。   The address resolution unit 122 according to the present embodiment acquires the address of the location that refers to the function to be replaced 112 in the address space of the test target program 110, and the program rewrite unit 123 uses the address acquired by the address resolution unit 122. The location is rewritten to the address reference of the replacement function 102. Other configurations are the same as those of the first embodiment shown in FIG.

始めに、図16と図17とを用いて、試験対象関数111における関数置換前後の関数呼出しの様子を説明した後、関数置換処理の説明を行う。
図16は、関数置換前の共有ライブラリ関数呼出しの模式図である。ここでは、具体的にオブジェクトファイルの形式がELFの場合の共有ライブラリ関数呼出しの様子を示すが、Windows PEやMach−oも類似のトランポリンコードを用いた共有ライブラリ関数呼出しとなるため、本発明を適用することが可能である。なお、ここではダイナミックリンクが完了している状態を示す。
First, using FIG. 16 and FIG. 17, the state of function calls before and after function replacement in the test target function 111 will be described, and then function replacement processing will be described.
FIG. 16 is a schematic diagram of a shared library function call before function replacement. Here, the state of a shared library function call when the object file format is ELF is specifically shown. However, since Windows PE and Mach-o are also a shared library function call using a similar trampoline code, the present invention is It is possible to apply. Here, the state where the dynamic link is completed is shown.

試験対象関数1601と被置換関数1604とPLT1602とGOT.PLT1603は、計算機の主記憶上に格納されたプログラムおよびデータである。なお、試験対象関数1601と被置換関数1604は、図1における試験対象関数111と被置換関数112に対応するプログラムである。試験対象関数1601は、共有ライブラリの被置換関数呼出し時には、被置換関数1604を直接呼び出す代わりに被置換関数1604に対応するPLT(Procedure Linkage Table)のエントリPLT[n]を呼び出す。当該PLTのエントリPLT[N]は、被置換関数1604に対応するGOT.PLT1603のエントリに格納されたアドレスにジャンプする。GOT.PLT1603のエントリGOT[N]が被置換関数1604のアドレスを含んでいる。この結果、PLTエントリPLT[N]のジャンプ命令を介して被置換関数1604が呼び出される。被置換関数1604中で関数復帰命令RETが実行されると、試験対象関数1601の被置換関数1604呼出し命令の直後の命令に処理制御が移る。   The test target function 1601, the function to be replaced 1604, the PLT 1602, the GOT. The PLT 1603 is a program and data stored on the main memory of the computer. The test target function 1601 and the replacement function 1604 are programs corresponding to the test target function 111 and the replacement function 112 in FIG. When calling the replacement function of the shared library, the test target function 1601 calls an entry PLT [n] of a PLT (Procedure Linkage Table) corresponding to the replacement function 1604 instead of directly calling the replacement function 1604. The entry PLT [N] of the PLT includes GOT. Jump to the address stored in the entry of PLT1603. GOT. The entry GOT [N] of the PLT 1603 includes the address of the function to be replaced 1604. As a result, the function to be replaced 1604 is called through the jump instruction of the PLT entry PLT [N]. When the function return instruction RET is executed in the function to be replaced 1604, the processing control is transferred to the instruction immediately after the instruction to call the function to be replaced 1604 of the function to be tested 1601.

図17は、関数置換後の共有ライブラリ関数呼出しの模式図である。なお、図17において、試験対象関数1701、被置換関数1704および置換関数1705は、それぞれ図1における試験対象関数111、被置換関数112および置換関数102に対応するプログラムである。置換関数1705は主記憶に格納された置換関数である。GOT.PLT1703の被置換関数1704に対応するエントリGOT[N]が被置換関数1704のアドレスではなく、置換関数1705のアドレスを保持する。この結果、試験対象関数1701がPLT1702のエントリPLT[N]を呼び出すと、GOT.PLT[N]が保持する置換関数1705のアドレスに間接ジャンプする。その結果、処理制御は置換関数1705の先頭に移る。置換関数1705中で関数復帰命令RETが実行されると、処理制御は、試験対象関数1701の被置換関数1704呼出しの直後の命令に移る。   FIG. 17 is a schematic diagram of a shared library function call after function replacement. In FIG. 17, a test target function 1701, a replaced function 1704, and a replacement function 1705 are programs corresponding to the test target function 111, the replaced function 112, and the replacement function 102 in FIG. A replacement function 1705 is a replacement function stored in the main memory. GOT. The entry GOT [N] corresponding to the function to be replaced 1704 of the PLT 1703 holds the address of the replacement function 1705, not the address of the function to be replaced 1704. As a result, when the test target function 1701 calls the entry PLT [N] of the PLT 1702, an indirect jump is made to the address of the replacement function 1705 held by GOT.PLT [N]. As a result, the process control shifts to the head of the replacement function 1705. When the function return instruction RET is executed in the replacement function 1705, the process control is transferred to the instruction immediately after the replacement target function 1704 of the test target function 1701 is called.

次に、図16の共有ライブラリ関数呼出しを図17の共有ライブラリ関数呼出しに変更する関数置換処理を図18を用いて説明する。
図18は、共有ライブラリ関数用の試験支援部120の処理フローである。ステップST1801では、試験対象プログラム110のファイル名を入力としてオブジェクトファイルを読み出す。本処理の詳細は、実施の形態1に示したので省略する。
Next, a function replacement process for changing the shared library function call of FIG. 16 to the shared library function call of FIG. 17 will be described with reference to FIG.
FIG. 18 is a processing flow of the test support unit 120 for the shared library function. In step ST1801, the object file is read with the file name of the test target program 110 as an input. The details of this process have been described in Embodiment 1, and will be omitted.

ステップST1802は、関数アドレス参照書換え処理である。関数アドレス参照処理への入力としてGOT.PLT用のダイナミックリロケーションテーブルを渡す。ELFファイルの場合、.rela.pltまたは.rel.pltが関数アドレス参照処理への入力とするリロケーションテーブルを保持している。   Step ST1802 is a function address reference rewriting process. Pass the dynamic relocation table for GOT.PLT as input to the function address reference process. In the case of an ELF file, .rela.plt or .rel.plt holds a relocation table that is input to the function address reference process.

次に、ステップST1802の関数アドレス参照書換え処理の詳細を図19のフローチャートを用いて説明する。
関数アドレス参照書換え処理では、リロケーション情報を利用することで、.GOT.PLT中の被置換関数112のエントリを、被置換関数112のアドレスから置換関数102のアドレスに書き換える。
図19に示す関数アドレス参照書換え処理では、被置換関数112の名前と.textセクション先頭アドレスと置換関数102のアドレスとを入力とする。また、関数アドレス参照書換え処理では、ステップST1901で読出した.textセクションのリロケーションテーブルも利用する。
Next, details of the function address reference rewriting process in step ST1802 will be described using the flowchart of FIG.
In the function address reference rewriting process, the relocation information is used to rewrite the entry of the function to be replaced 112 in .GOT.PLT from the address of the function to be replaced 112 to the address of the replacement function 102.
In the function address reference rewriting process shown in FIG. 19, the name of the function to be replaced 112, the .text section start address, and the address of the replacement function 102 are input. In the function address reference rewriting process, the relocation table of the .text section read in step ST1901 is also used.

ステップST1901からステップST1905は、ステップST1901で読み出したセクションのリロケーションテーブルのエントリを巡回するループ処理である。
ステップST1902は、巡回中のリロケーションテーブルエントリの対象が被置換関数112か否かに基づく条件分岐処理である。巡回エントリの対象が被置換関数112でない場合、ステップST1903とステップST1904をスキップする。一方、巡回中のエントリが被置換関数112に対応する場合ステップST1903に分岐する。
Steps ST1901 to ST1905 are loop processing for circulating through the entries in the relocation table of the section read out in step ST1901.
Step ST1902 is conditional branch processing based on whether or not the target of the relocation table entry being visited is the replaced function 112. When the target of the cyclic entry is not the replacement function 112, step ST1903 and step ST1904 are skipped. On the other hand, if the entry in circulation corresponds to the function to be replaced 112, the process branches to step ST1903.

巡回中のエントリが被置換関数112に対応するか否かは、リロケーションテーブルエントリがリンクしているシンボルテーブルエントリの名前が被置換関数112の名前と一致しているか否かで確認可能である。リロケーションテーブルエントリがリンクしているシンボルは、リロケーションテーブルエントリのr_infoフィールドを参照することで取得可能である。r_infoフィールドからシンボルテーブルインデックスを取得し、ステップST1901で読み出したシンボルテーブルにアクセスすることで目的とするシンボルを得ることができる。さらにシンボルテーブルエントリのst_nameフィールドから文字列テーブルのインデックスを読出し、ステップST1901で読み出した文字列テーブルにアクセスすることでシンボルの名前を取得できる。   Whether or not the entry in circulation corresponds to the replaced function 112 can be confirmed by whether or not the name of the symbol table entry to which the relocation table entry is linked matches the name of the replaced function 112. The symbol to which the relocation table entry is linked can be obtained by referring to the r_info field of the relocation table entry. A target symbol can be obtained by acquiring a symbol table index from the r_info field and accessing the symbol table read in step ST1901. Further, the symbol name can be acquired by reading the index of the character string table from the st_name field of the symbol table entry and accessing the character string table read in step ST1901.

ステップST1903は、被置換関数の参照箇所のアドレスを取得する処理である。ここでは、被置換関数の呼出し箇所のアドレスをリロケーションテーブルエントリのオフセットから取得する。具体的には、リロケーションテーブルエントリのオフセットは、r_offsetフィールドの値である。この値は、図16のGOT.PLT1603のエントリGOT[N]のアドレスである。   Step ST1903 is processing for acquiring the address of the reference location of the function to be replaced. Here, the address of the place where the function to be replaced is called is obtained from the offset of the relocation table entry. Specifically, the offset of the relocation table entry is the value of the r_offset field. This value is the same as the GOT. This is the address of the entry GOT [N] of the PLT 1603.

ステップST1904は、ステップST1903で取得した被置換関数参照箇所のアドレスに存在するデータを置換関数102のアドレスに書き換える処理である。この結果として図17のようにGOT.PLT1703のエントリGOT[N]は、置換関数1705のアドレスを保持するようになる。   Step ST1904 is a process of rewriting data existing at the address of the replacement function reference location acquired in step ST1903 to the address of the replacement function 102. As a result, as shown in FIG. The entry GOT [N] of the PLT 1703 holds the address of the replacement function 1705.

以上説明したように、実施の形態6の単体試験支援装置によれば、アドレス解決部は、試験プログラムのアドレス空間において被置換関数を参照している箇所のアドレスを取得し、プログラム書換え部は、アドレス解決部が取得したアドレスの箇所を置換関数のアドレス参照に書き換えるようにしたので、被置換関数が共有ライブラリ中の関数である場合にも被置換関数を置換関数に置き換えることができる。   As described above, according to the unit test support apparatus of the sixth embodiment, the address resolution unit acquires the address of the location that refers to the function to be replaced in the address space of the test program, and the program rewriting unit Since the address portion acquired by the address resolution unit is rewritten with the address reference of the replacement function, the replacement function can be replaced with the replacement function even when the replacement function is a function in the shared library.

実施の形態7.
実施の形態6では、被置換関数112が共有ライブラリの場合の関数置換処理を示した。しかし、このような場合、試験ドライバ作成者は、被置換関数112が共有ライブラリ関数か否かで試験ドライバ101の仕様に対応した関数置換処理を選択する必要がある。そこで、本実施の形態では、被置換関数112が共有ライブラリ関数か否かに関わらず関数を置換することができる関数置換処理について示す。即ち、実施の形態7におけるアドレス解決部122は、被置換関数112が共有ライブラリか否かを判定し、共有ライブラリであった場合に実施の形態6の処理を行い、かつ、プログラム書換え部も実施の形態6の処理を行うよう構成されている。その他の構成は図1に示した実施の形態1と同様である。
Embodiment 7 FIG.
In the sixth embodiment, the function replacement process in the case where the function to be replaced 112 is a shared library is shown. However, in such a case, the test driver creator needs to select a function replacement process corresponding to the specification of the test driver 101 depending on whether or not the function to be replaced 112 is a shared library function. Therefore, in this embodiment, a function replacement process that can replace a function regardless of whether or not the function to be replaced 112 is a shared library function will be described. That is, the address resolution unit 122 according to the seventh embodiment determines whether or not the function to be replaced 112 is a shared library, and if it is a shared library, performs the processing according to the sixth embodiment and also implements the program rewriting unit. It is comprised so that the process of the form 6 may be performed. Other configurations are the same as those of the first embodiment shown in FIG.

本実施の形態による関数置換処理を図20のフローチャートに示す。
ステップST2001では、試験対象プログラム110のオブジェクトファイル情報を読み出す処理である。本処理の詳細は実施の形態1の説明で示した通りである。
The function replacement process according to the present embodiment is shown in the flowchart of FIG.
In step ST2001, object file information of the test target program 110 is read. Details of this processing are as described in the description of the first embodiment.

ステップST2002は、被置換関数112が共有ライブラリ関数か否かに基づく分岐処理である。被置換関数112が共有ライブラリ関数であれば、ステップST2003に分岐し、それ以外の場合はステップST2004に分岐する。被置換関数112が共有ライブラリ関数か否かは、GOT.PLT用のダイナミックリロケーションテーブルエントリを探索し、被置換関数112に対応するエントリの有無で判定可能である。被置換関数112に対応するエントリが見つかった場合、被置換関数112は共有ライブラリ関数である。   Step ST2002 is a branch process based on whether or not the function to be replaced 112 is a shared library function. If the replaced function 112 is a shared library function, the process branches to step ST2003; otherwise, the process branches to step ST2004. Whether or not the function to be replaced 112 is a shared library function can be determined by searching a dynamic relocation table entry for GOT.PLT and by the presence or absence of an entry corresponding to the function to be replaced 112. If an entry corresponding to the function to be replaced 112 is found, the function to be replaced 112 is a shared library function.

ステップST2003は、関数アドレス参照書換え処理である。本処理は、実施の形態6の図19の処理と同様であるため、ここでの説明は省略する。
ステップST2004は、関数先頭アドレス取得処理である。関数先頭アドレスの取得手段は任意であり、実施の形態1〜5で示した関数先頭アドレス取得処理などを利用すればよい。
ステップST2005では、ステップST2004で取得した関数先頭アドレスのコードを置換関数102への無条件分岐命令に書き換える。本処理の詳細は実施の形態1に示した通りである。
Step ST2003 is a function address reference rewriting process. Since this process is the same as the process of FIG. 19 according to the sixth embodiment, a description thereof is omitted here.
Step ST2004 is a function head address acquisition process. The function start address acquisition means is arbitrary, and the function start address acquisition processing described in the first to fifth embodiments may be used.
In step ST2005, the code of the function start address acquired in step ST2004 is rewritten to an unconditional branch instruction to the replacement function 102. Details of this processing are as shown in the first embodiment.

以上説明したように、実施の形態7の単体試験支援装置によれば、アドレス解決部は、被置換関数が共有ライブラリか否かを判定し、共有ライブラリであった場合にアドレスの取得を行い、かつ、プログラム書換え部によるアドレスの書換えを行うようにしたので、試験ドライバ作成者は、被置換関数が共有ライブラリか否かで関数置換処理を選択することなく、試験ドライバを作成することができる。また、被置換関数が後で共有ライブラリ関数に変更された場合であっても試験ドライバを修正する必要がなくなる。   As described above, according to the unit test support apparatus of the seventh embodiment, the address resolution unit determines whether or not the function to be replaced is a shared library, and if it is a shared library, acquires an address. In addition, since the address is rewritten by the program rewriting unit, the test driver creator can create a test driver without selecting a function replacement process depending on whether or not the function to be replaced is a shared library. Further, even when the function to be replaced is changed to a shared library function later, it is not necessary to modify the test driver.

実施の形態8.
実施の形態1〜7では、実行中の試験プログラム自体を動的に書き換えることで、被置換関数を置換関数に置き換えた。このため、関数置換処理を呼び出す試験ドライバの実行後に別の試験ドライバを呼び出すと、別の試験ドライバが期待通りに動作しない場合があることが問題となる。そこで、本実施の形態では、置換した関数を元に戻す手段を実施の形態1〜7に加えるようにしたものである。
Embodiment 8 FIG.
In the first to seventh embodiments, the function to be replaced is replaced with the replacement function by dynamically rewriting the test program being executed. For this reason, when another test driver is called after execution of the test driver that calls the function replacement process, another test driver may not operate as expected. Therefore, in the present embodiment, means for restoring the replaced function is added to the first to seventh embodiments.

本実施の形態の全体構成図を図21に示す。本構成では、実施の形態1〜7のいずれかの構成に加えて関数置換復元部124が存在する。本実施の形態におけるプログラム書換え部123は、被置換関数112を置換関数102で置き換えた場合、置き換えたアドレスとサイズと置き換え前のデータの組を置き換え履歴として記憶するよう構成されている。また、関数置換復元部124は、記憶した置き換え履歴に基づいて、関数置換を復元する処理部である。その他の構成は図1と同様であるため、対応する部分に同一符号を付してその説明を省略する。   FIG. 21 shows an overall configuration diagram of the present embodiment. In this configuration, a function replacement restoration unit 124 is present in addition to any of the configurations of the first to seventh embodiments. The program rewriting unit 123 according to the present embodiment is configured to store, as a replacement history, a set of a replaced address and size and data before replacement when the function to be replaced 112 is replaced with the replacement function 102. The function replacement restoration unit 124 is a processing unit that restores function replacement based on the stored replacement history. Since other configurations are the same as those in FIG. 1, the corresponding parts are denoted by the same reference numerals and description thereof is omitted.

本実施の形態において、置換した関数の復元は、プログラム書換え部123と関数置換復元部124とが協調して動作することで実現される。具体的には関数置換処理では、処理中でプログラムを書き換えると同時に、書き換えたアドレスと書き換えたサイズと書換え前のデータとからなる組を置換履歴としてメモリ上に記憶する。さらに関数置換処理では、関数置換処理実行中においてメモリ上に記憶した置換履歴の識別子を出力する。例として、置換履歴一覧の識別子には、置換換履歴一覧を記憶したメモリのアドレスを用いればよい。
なお、置換履歴を記憶するタイミングを具体的に記述すると、図5におけるステップST503、図15におけるステップ1507、図19におけるステップST1904、図20におけるステップST2005である。
In the present embodiment, the restoration of the replaced function is realized by the program rewriting unit 123 and the function replacement restoring unit 124 operating in cooperation. Specifically, in the function replacement process, the program is rewritten during the process, and at the same time, a set consisting of the rewritten address, the rewritten size, and the data before rewriting is stored in the memory as a replacement history. Further, in the function replacement process, the identifier of the replacement history stored in the memory during the function replacement process is output. For example, the identifier of the replacement history list may be an address of a memory that stores the replacement history list.
The timing for storing the replacement history is specifically described as step ST503 in FIG. 5, step 1507 in FIG. 15, step ST1904 in FIG. 19, and step ST2005 in FIG.

次に関数置換復元部124の動作について示す。関数置換復元部124は、プログラム書換え部123が出力した置換履歴識別子を入力とし、対応する置換履歴に格納されたアドレスに対して書換え前のデータを書き換えたデータのサイズ分だけ書き戻すことで、関数置換を復元する。   Next, the operation of the function replacement restoration unit 124 will be described. The function replacement restoration unit 124 receives the replacement history identifier output from the program rewriting unit 123 as an input, and rewrites the data before rewriting to the address stored in the corresponding replacement history by the rewritten data size. Restore function substitution.

以上説明したように、実施の形態8の単体試験支援装置によれば、被置換関数を置換関数で置き換えた場合、置き換えたアドレスとサイズと置き換え前のデータの組を置き換え履歴として記憶すると共に、記憶した置き換え履歴に基づいて、関数置換を復元する関数置換復元部を備えたので、関数置換処理を行った場合でも、試験対象プログラム全体に関数置換処理による影響が及ぶことを防ぐことができる。   As described above, according to the unit test support device of the eighth embodiment, when a function to be replaced is replaced with a replacement function, a set of the replaced address and size and the data before replacement is stored as a replacement history. Since the function replacement restoring unit that restores the function replacement based on the stored replacement history is provided, it is possible to prevent the function replacement process from being affected by the function replacement process even when the function replacement process is performed.

実施の形態9.
実施の形態1では、ジャンプコード挿入処理においてメモリ上の関数アドレスをジャンプコードに入れ換えることで関数の置換を行った。しかし、Linux(Linuxは登録商標/以下省略して記載)などのオペレーティングシステムでは、セキュリティ対策などのため、コード領域への書き込みが禁止されている場合が多い。したがって、Linuxのようにコード領域への書込みを禁止しているオペレーティングシステム上では、実施の形態1のジャンプコード挿入処理において、メモリアクセス違反が発生してしまう。この問題を解決するのが本実施の形態である。
Embodiment 9 FIG.
In the first embodiment, the function replacement is performed by replacing the function address on the memory with the jump code in the jump code insertion process. However, in an operating system such as Linux (Linux is a registered trademark / hereinafter abbreviated), writing to a code area is often prohibited for security measures. Therefore, a memory access violation occurs in the jump code insertion process of the first embodiment on an operating system that prohibits writing to the code area, such as Linux. This embodiment solves this problem.

本実施の形態の単体試験支援装置の全体構成図を図22に示す。
本実施の形態では、試験支援部120bとして、実施の形態1〜8のいずれかの構成に加えてメモリ解除部125が加わっていることが特徴である。なお、図22では、実施の形態1〜7の構成に対してメモリ解除部125を付加した構成を示している。メモリ解除部125は、プログラム書換え部123によるプログラム書換え処理の前にメモリ保護解除処理を行う処理部である。他の構成は、実施の形態1〜8のいずれかと同様であるため、ここでの説明は省略する。
An overall configuration diagram of the unit test support apparatus of the present embodiment is shown in FIG.
The present embodiment is characterized in that a memory release unit 125 is added to the test support unit 120b in addition to the configuration of any of the first to eighth embodiments. 22 shows a configuration in which a memory release unit 125 is added to the configurations of the first to seventh embodiments. The memory release unit 125 is a processing unit that performs a memory protection release process before the program rewrite process by the program rewrite unit 123. Other configurations are the same as those in any one of the first to eighth embodiments, and thus the description thereof is omitted here.

本実施の形態において、メモリ解除部125は、プログラム書換え部123における被置換関数112の置換関数102での書換え処理の前にメモリ解除処理を実行し、書換え対象領域のメモリ保護を解除する。このメモリ解除処理を実行するタイミングとしては、具体的には図5におけるステップST503を実行する直前などが該当するが、書換え前であれば、どのタイミングであってもよい。   In the present embodiment, the memory release unit 125 executes a memory release process before the rewrite function 102 of the replacement function 112 in the program rewrite unit 123, and releases the memory protection of the rewrite target area. The timing for executing the memory release processing specifically corresponds to immediately before executing step ST503 in FIG. 5, but any timing may be used as long as it is before rewriting.

メモリ解除処理の具体的な例として、Linuxの場合のメモリ保護解除処理を以下に示す。Linuxの場合、メモリ保護解除をmprotectシステムコールを用いて行う。mprotectの第一引数のアドレスは、シンボルアドレスを含むページの先頭アドレスである必要がある。ページ先頭アドレスは、シンボルアドレスの下位12ビットの値をゼロとすることで求めえられる。mprotectの第二引数は、権限を設定する対象領域のサイズである。シンボルアドレス+シンボルサイズーページ先頭アドレスをmprotectの第二引数とする。mprotectの第3引数は、プロテクションの属性である。ここでは、読出し/書込み/実行の権限を与えるために、PROT_READ | PROT_WRITE |PROT_EXECを与える。ここで、|は、ビットごとの論理和演算を意味する。また、PROT_READ, PROT_WRITE,PROT_EXECは、読出し、書込み、実行の権限を与えることを意味する。   As a specific example of the memory release process, the memory protection release process in the case of Linux is shown below. In the case of Linux, the memory protection is canceled using the mprotect system call. The address of the first argument of mprotect must be the top address of the page including the symbol address. The page head address can be obtained by setting the lower 12 bits of the symbol address to zero. The second argument of mprotect is the size of the target area for which authority is set. Symbol address + symbol size-page start address is the second argument of mprotect. The third argument of mprotect is a protection attribute. Here, PROT_READ | PROT_WRITE | PROT_EXEC is given to give the authority of reading / writing / execution. Here, | means a bitwise OR operation. PROT_READ, PROT_WRITE, and PROT_EXEC mean that the authority of reading, writing, and execution is given.

以上説明したように、実施の形態9の単体試験支援装置によれば、プログラム書換え部によるプログラム書換え処理の前にメモリ保護解除処理を行うメモリ解除部を備えたので、コード領域にメモリ保護をかけているオペレーティングシステム上で被置換関数を置換関数に置き換えることができる。   As described above, according to the unit test support apparatus of the ninth embodiment, since the memory release unit that performs the memory protection release process before the program rewrite process by the program rewrite unit is provided, the code area is protected from memory. A function to be replaced can be replaced with a replacement function on an operating system.

なお、本願発明はその発明の範囲内において、各実施の形態の自由な組み合わせ、あるいは各実施の形態の任意の構成要素の変形、もしくは各実施の形態において任意の構成要素の省略が可能である。   In the present invention, within the scope of the invention, any combination of the embodiments, or any modification of any component in each embodiment, or omission of any component in each embodiment is possible. .

100 試験設定部、101 試験ドライバ、102 置換関数、110 試験対象プログラム、111 試験対象関数、112 被置換関数、120,120a,120b 試験支援部、121 関数置換部、122 アドレス解決部、123 プログラム書換え部、124 関数置換復元部、125 メモリ解除部、130 言語処理部、140 試験プログラム。   100 test setting unit, 101 test driver, 102 replacement function, 110 test target program, 111 test target function, 112 function to be replaced, 120, 120a, 120b test support unit, 121 function replacement unit, 122 address resolution unit, 123 program rewrite Part, 124 function replacement restoration part, 125 memory release part, 130 language processing part, 140 test program.

Claims (13)

試験対象プログラム中で書き換えられる被置換関数の識別子と、前記被置換関数を書き換えるための置換関数の識別子を入力する関数置換部と、
前記被置換関数の識別子から前記試験対象プログラムの書換え位置のアドレスを取得するアドレス解決部と、
前記アドレス解決部が取得したアドレスの前記試験対象プログラムを書き換えることで前記被置換関数を前記置換関数で書き換えるプログラム書換え部とを備えた単体試験支援装置。
A function replacement unit for inputting an identifier of a function to be rewritten in the program to be tested, and an identifier of a replacement function for rewriting the function to be replaced;
An address resolution unit for acquiring an address of a rewrite position of the test target program from the identifier of the function to be replaced;
A unit test support apparatus comprising: a program rewriting unit that rewrites the function to be replaced with the replacement function by rewriting the program to be tested at the address acquired by the address resolution unit.
前記アドレス解決部は、前記被置換関数の識別子から前記試験対象プログラムの書換え位置のアドレスとして当該被置換関数の先頭アドレスを取得し、
前記プログラム書換え部は、前記先頭アドレスからのメモリ内容を前記置換関数に直接または間接的に分岐する1つ以上の命令に書き換えることを特徴とする請求項1記載の単体試験支援装置。
The address resolution unit obtains a head address of the function to be replaced as an address of a rewrite position of the test target program from the identifier of the function to be replaced,
2. The unit test support apparatus according to claim 1, wherein the program rewriting unit rewrites the memory contents from the head address into one or more instructions that branch directly or indirectly to the replacement function.
前記アドレス解決部は、前記被置換関数の識別子を用いて前記試験対象プログラムのシンボル情報を検索することで、前記被置換関数の先頭アドレスを取得することを特徴とする請求項2記載の単体試験支援装置。   3. The unit test according to claim 2, wherein the address resolution unit obtains a head address of the replaced function by searching symbol information of the test target program using an identifier of the replaced function. Support device. 前記アドレス解決部は、前記被置換関数の名前と当該被置換関数を含むソースファイルの識別子を用いて前記試験対象プログラムのデバッグ情報を検索することで、前記被置換関数の先頭アドレスを取得することを特徴とする請求項2の単体試験支援装置。   The address resolution unit obtains a start address of the replaced function by searching for debug information of the test target program using a name of the replaced function and an identifier of a source file including the replaced function. The unit test support device according to claim 2. 前記アドレス解決部は、前記被置換関数の名前と、前記試験対象プログラムが実行される場合に前記被置換関数を呼び出す試験対象関数のソースプログラム識別子とを用いて前記被置換関数の先頭アドレスを取得し、見つからなければ前記被置換関数の名前のみを用いて当該被置換関数の先頭アドレスを検索することを特徴とする請求項2記載の単体試験支援装置。   The address resolution unit obtains the start address of the replaced function using the name of the replaced function and the source program identifier of the test target function that calls the replaced function when the test target program is executed. 3. A unit test support apparatus according to claim 2, wherein if it is not found, the head address of the function to be replaced is searched using only the name of the function to be replaced. 前記アドレス解決部は、前記被置換関数の名前と、前記試験対象プログラムが実行される場合に前記被置換関数を呼び出す試験対象関数のリロケータブルファイルとを用いて前記被置換関数の先頭アドレスを取得し、見つからなければ前記被置換関数の名前のみを用いて当該被置換関数の先頭アドレスを検索することを特徴とする請求項2記載の単体試験支援装置。   The address resolution unit uses the name of the function to be replaced and the relocatable file of the function to be tested that calls the function to be replaced when the program to be tested is executed to obtain the start address of the function to be replaced. 3. The unit test support apparatus according to claim 2, wherein if it is not found, the head address of the function to be replaced is searched using only the name of the function to be replaced. 前記アドレス解決部は、前記被置換関数の定義を含むリロケータブルファイルのシンボル情報と前記試験プログラムのシンボル情報とセクション先頭アドレスとから、前記被置換関数の先頭アドレスを算出することを特徴とする請求項2記載の単体試験支援装置。   The address resolution unit calculates a head address of the replaced function from symbol information of a relocatable file including the definition of the replaced function, symbol information of the test program, and a section head address. 2. The unit test support apparatus according to 2. 前記アドレス解決部は、前記試験対象プログラムのデバッグ情報の有無、または、前記試験対象関数のリロケータブルファイルの有無に基づいて、前記被置換関数の先頭アドレスを取得する手段を選択することを特徴とする請求項1記載の単体試験支援装置。   The address resolution unit selects a means for acquiring a head address of the function to be replaced based on the presence or absence of debug information of the test target program or the presence or absence of a relocatable file of the test target function. The unit test support device according to claim 1. 前記アドレス解決部は、前記試験対象プログラムのアドレス空間において前記被置換関数を参照している箇所のアドレスを取得し、
前記プログラム書換え部は、前記アドレス解決部が取得したアドレスの箇所を前記置換関数のアドレス参照に書き換えることを特徴とする請求項1記載の単体試験支援装置。
The address resolution unit obtains an address of a location referring to the function to be replaced in an address space of the test target program;
The unit test support apparatus according to claim 1, wherein the program rewriting unit rewrites the location of the address acquired by the address resolution unit to an address reference of the replacement function.
前記アドレス解決部は、前記被置換関数が共有ライブラリか否かを判定し、当該共有ライブラリであった場合に前記アドレスの取得を行い、かつ、前記プログラム書換え部による前記アドレスの書換えを行うことを特徴とする請求項9記載の単体試験支援装置。   The address resolution unit determines whether the function to be replaced is a shared library, acquires the address when the function is the shared library, and rewrites the address by the program rewriting unit. 10. The unit test support device according to claim 9, 前記被置換関数を前記置換関数で置き換えた場合、置き換えたアドレスとサイズと置き換え前のデータの組を置き換え履歴として記憶すると共に、
前記記憶した置き換え履歴に基づいて、関数置換を復元する関数置換復元部を備えたことを特徴とする請求項1記載の単体試験支援装置。
When the replaced function is replaced with the replacement function, the replacement address and size and the data set before replacement are stored as a replacement history,
The unit test support apparatus according to claim 1, further comprising a function replacement restoration unit that restores function replacement based on the stored replacement history.
プログラム書換え部によるプログラム書換え処理の前にメモリ保護解除処理を行うメモリ解除部を備えたことを特徴とする請求項1記載の単体試験支援装置。   The unit test support apparatus according to claim 1, further comprising a memory release unit that performs a memory protection release process before the program rewrite process by the program rewrite unit. ソフトウェアの単体試験を行うためのコンピュータを、
試験対象プログラム中で書き換えられる被置換関数の識別子と、前記被置換関数を書き換えるための置換関数の識別子を入力する関数置換部と、
前記被置換関数の識別子から前記試験対象プログラムの書換え位置のアドレスを取得するアドレス解決部と、
前記アドレス解決部が取得したアドレスの前記試験対象プログラムを書き換えることで前記被置換関数を前記置換関数で書き換えるプログラム書換え部として機能させるための単体試験支援プログラム。
A computer for software unit testing,
A function replacement unit for inputting an identifier of a function to be rewritten in the program to be tested, and an identifier of a replacement function for rewriting the function to be replaced;
An address resolution unit for acquiring an address of a rewrite position of the test target program from the identifier of the function to be replaced;
A unit test support program for functioning as a program rewriting unit that rewrites the function to be replaced with the replacement function by rewriting the test target program at the address acquired by the address resolution unit.
JP2013081223A 2013-04-09 2013-04-09 Unit test support device and unit test support program Active JP6061763B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2013081223A JP6061763B2 (en) 2013-04-09 2013-04-09 Unit test support device and unit test support program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2013081223A JP6061763B2 (en) 2013-04-09 2013-04-09 Unit test support device and unit test support program

Publications (2)

Publication Number Publication Date
JP2014203384A true JP2014203384A (en) 2014-10-27
JP6061763B2 JP6061763B2 (en) 2017-01-18

Family

ID=52353742

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2013081223A Active JP6061763B2 (en) 2013-04-09 2013-04-09 Unit test support device and unit test support program

Country Status (1)

Country Link
JP (1) JP6061763B2 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07319683A (en) * 1994-05-30 1995-12-08 Nippon Telegr & Teleph Corp <Ntt> In-operation program updating system
JP2008123438A (en) * 2006-11-15 2008-05-29 Fujitsu Ltd Computer system, program information collection method, and computer program
JP2009015428A (en) * 2007-07-02 2009-01-22 Nippon Telegr & Teleph Corp <Ntt> Program update method, information processor, program, and recording medium
JP2012164098A (en) * 2011-02-06 2012-08-30 Mitsubishi Electric Corp Entry rewriting device and entry rewriting program

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07319683A (en) * 1994-05-30 1995-12-08 Nippon Telegr & Teleph Corp <Ntt> In-operation program updating system
JP2008123438A (en) * 2006-11-15 2008-05-29 Fujitsu Ltd Computer system, program information collection method, and computer program
JP2009015428A (en) * 2007-07-02 2009-01-22 Nippon Telegr & Teleph Corp <Ntt> Program update method, information processor, program, and recording medium
JP2012164098A (en) * 2011-02-06 2012-08-30 Mitsubishi Electric Corp Entry rewriting device and entry rewriting program

Also Published As

Publication number Publication date
JP6061763B2 (en) 2017-01-18

Similar Documents

Publication Publication Date Title
Williams-King et al. Egalito: Layout-agnostic binary recompilation
ElWazeer et al. Scalable variable and data type detection in a binary rewriter
CN107451474B (en) Software bug fixing method and device for terminal
US20080127113A1 (en) Method and system for implementing watchpoints
JP7042270B2 (en) Self debugging
US10795659B1 (en) System and method for live patching processes in user space
CN107480476B (en) Android native layer instruction compiling virtualization shell adding method based on ELF infection
Stüttgen et al. Robust Linux memory acquisition with minimal target impact
Dong et al. Orplocator: Identifying read points of configuration options via static analysis
US9047403B2 (en) Debugger with previous version feature
US20110029953A1 (en) System and Method for Scalable Handling of Debug Information
US5963741A (en) Information processor which rewrites instructions in program to dynamically change program structure and method therefor
JP2008052688A (en) Patch data generation device for program
JP6061763B2 (en) Unit test support device and unit test support program
Hill et al. Pin++: an object-oriented framework for writing pintools
JP5550578B2 (en) Entry rewriting device and entry rewriting program
CN112148581A (en) Code specification checking method, device, system and storage medium
JP2011090511A (en) Execution program, compiler, and device and method of correcting execution program operation
Korenčik et al. On Symbolic Execution of Decompiled Programs
Momeni et al. LDMBL: An architecture for reducing code duplication in heavyweight binary instrumentations
JP2007041777A (en) Language processing method
Yin et al. PAST: accurate instrumentation on fully optimized program
KARAPATEAS RETARGETING AN ASSEMBLY OPTIMIZER FOR THE MIPS/SCALE ASSEMBLY
Ghafari Detecting Variadic Functions in Stripped Binaries from C/C++
JP5109808B2 (en) Additional executable information generating apparatus, information processing apparatus, and program

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20151015

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20160729

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20160809

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20160923

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20161213

R150 Certificate of patent or registration of utility model

Ref document number: 6061763

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250