Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
JP2795309B2 - Code addition method for profiler - Google Patents
[go: Go Back, main page]

JP2795309B2 - Code addition method for profiler - Google Patents

Code addition method for profiler

Info

Publication number
JP2795309B2
JP2795309B2 JP7296167A JP29616795A JP2795309B2 JP 2795309 B2 JP2795309 B2 JP 2795309B2 JP 7296167 A JP7296167 A JP 7296167A JP 29616795 A JP29616795 A JP 29616795A JP 2795309 B2 JP2795309 B2 JP 2795309B2
Authority
JP
Japan
Prior art keywords
address
profiler
shared object
text
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP7296167A
Other languages
Japanese (ja)
Other versions
JPH09114696A (en
Inventor
広丘 村松
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.)
NEC Corp
Original Assignee
Nippon Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nippon Electric Co Ltd filed Critical Nippon Electric Co Ltd
Priority to JP7296167A priority Critical patent/JP2795309B2/en
Publication of JPH09114696A publication Critical patent/JPH09114696A/en
Application granted granted Critical
Publication of JP2795309B2 publication Critical patent/JP2795309B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明はプロファイラ用コー
ド追加方式に関し、特にダイナミックリンクされている
実行可能プログラム(以下、ダイナミックリンク実行可
能プログラムという)が参照する共有オブジェクトに対
してプロファイラ用コードを追加するプロファイラ用コ
ード追加方式に関する。なお、プロファイラとは、実行
オブジェクトの性能を解析するためのプログラムをい
う。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a profiler code addition method, and more particularly to a method of adding a profiler code to a shared object referred to by a dynamically linked executable program (hereinafter referred to as a "dynamic link executable program"). It relates to a method for adding a profiler code. The profiler is a program for analyzing the performance of an execution object.

【0002】[0002]

【従来の技術】従来は、Cコンパイラなどで生成した実
行可能プログラムの性能データを収集するために、元の
実行可能プログラムにプロファイラ用コードを追加した
プロファイラ用実行可能プログラムについて、以下のよ
うに行われていた。
2. Description of the Related Art Conventionally, in order to collect performance data of an executable program generated by a C compiler or the like, a profiler executable program obtained by adding a profiler code to an original executable program is executed as follows. Had been

【0003】(1) 実行可能プログラムが持つテキス
トから、先頭のみから入ることができ、最後からのみ抜
け出すことのできるブロックに分割し、それぞれのブロ
ックの実行をカウントする命令を含む同等のプログラム
を出力する。
(1) From the text of an executable program, the program is divided into blocks that can be entered only from the beginning and can be exited only from the end, and output an equivalent program including an instruction for counting the execution of each block. I do.

【0004】(2) 実行可能プログラムがダイナミッ
クリンクされている場合、作成されたプロファイラ用実
行可能プログラムの実行で、元の実行可能プログラムが
参照する共有オブジェクトに飛び込む場合、戻りアドレ
スを記憶させ、戻ってきた後の処理が続行されるように
する。
(2) When the executable program is dynamically linked, when the created profiler executable program is executed and jumps into a shared object referenced by the original executable program, the return address is stored and the return is performed. So that the process after it arrives can be continued.

【0005】(3) 前記に加えて、実行可能プログラ
ムの関数をすべて測定できるようにするために、共有オ
ブジェクトに飛び込み、戻ってくる前に、さらに、実行
可能プログラムの別の関数を呼び出した場合も、作成さ
れる新しいテキストの方に飛び込ませる。
(3) In addition to the above, when another function of the executable program is called before jumping into the shared object and returning, so that all functions of the executable program can be measured. Also jump into the new text being created.

【0006】また、従来技術としては、特開昭64−3
5637号公報に開示された「プログラムトレース方
式」がある。この方式は、オブジェクトプログラム自身
をコード変換し、モニタ呼出しの割込み命令を埋め込
み、割込み発生時にプログラムトレースを行うことによ
り、被測定プログラムのオブジェクトプログラムだけで
性能測定を可能とするものである。
The prior art is disclosed in JP-A-64-3
There is a “program trace method” disclosed in Japanese Patent No. 5637. This method converts the code of an object program itself, embeds an interrupt instruction for a monitor call, and traces a program when an interrupt occurs, thereby enabling performance measurement only with the object program of the program to be measured.

【0007】[0007]

【発明が解決しようとする課題】上述した従来の方式で
は、対象となる実行可能プログラムがスタティックリン
クあるいはダイナミックリンクされていても性能データ
は一通り解析可能であるが、特に実行可能プログラムが
ダイナミックリンクされている場合には、それが参照す
る共有オブジェクトについてプロファイラ用コードが追
加されていないため、共有オブジェクトに対する性能デ
ータについては解析できないという問題点があった。
In the above-described conventional method, the performance data can be analyzed even if the target executable program is statically linked or dynamically linked. In this case, there is a problem that the performance data for the shared object cannot be analyzed because the profiler code is not added to the shared object referred to by the profiler.

【0008】また、特開昭64−35637号公報に開
示された「プログラムトレース方式」では、オブジェク
トを用意するだけで性能を測定可能なプログラムトレー
ス方式を提供しており、その点では、解決しようとする
課題は本発明と類似するものであるが、性能を測定した
いオブジェクトに対してのみ、モニタ呼出しの割込み命
令を埋め込むため、生成されるオブジェクトがダイナミ
ックリンクされている場合、そのオブジェクトが参照す
る共有オブジェクトに対しては割込み発生時のプログラ
ムトレースが行えないという問題点があった。
In the "program trace method" disclosed in Japanese Patent Application Laid-Open No. 64-35637, a program trace method capable of measuring the performance only by preparing an object is provided. The problem is similar to that of the present invention. However, in order to embed an interrupt instruction of a monitor call only for an object whose performance is to be measured, if an object to be generated is dynamically linked, the object refers to the object. There has been a problem that a program trace cannot be performed on a shared object when an interrupt occurs.

【0009】本発明の目的は、上述の点に鑑み、一般的
なコンパイラによりダイナミックリンクで生成されるオ
ブジェクトについて、それが参照する共有オブジェクト
の情報を取得し、それをもとに実行される共有オブジェ
クトの動作を示すデータを記録するプロファイラ用コー
ドを追加して、実行可能プログラムの実行性能の解析お
よび向上をより容易にするようにしたプロファイラ用コ
ード追加方式を提供することにある。
In view of the above, it is an object of the present invention to obtain information on a shared object referred to by an object generated by a general compiler by dynamic link, and execute a shared object executed based on the information. It is another object of the present invention to provide a profiler code addition method that adds a profiler code for recording data indicating an operation of an object, and makes it easier to analyze and improve the execution performance of an executable program.

【0010】[0010]

【課題を解決するための手段】本発明のプロファイラ用
コード追加方式は、ダイナミックリンク実行可能プログ
ラムが持っているダイナミックリンク情報から当該ダイ
ナミックリンク実行可能プログラムが参照する共有オブ
ジェクト名を抽出し、それをもとに対象となる共有オブ
ジェクトを入力する共有オブジェクト入力手段と、前記
共有オブジェクトが持つ関数プロローグ,データセクシ
ョンに存在するテキストセクション上の仮想アドレス,
およびGOTを参照してテキストアドレスを得る命令コ
ードからリロケーション情報を抽出しリロケーション情
報テーブルを作成するリロケーション情報抽出手段と、
前記共有オブジェクトと同等の機能を持ちプロファイラ
用コードを追加したプロファイラ用共有オブジェクトを
生成し、かつ前記リロケーション情報テーブルを参照し
て必要な命令コードあるいはデータの内容を更新するプ
ロファイラ用共有オブジェクト生成手段とを有する。
According to the profiler code addition method of the present invention, a shared object name referred to by a dynamic link executable program is extracted from dynamic link information held by the dynamic link executable program, and is extracted. A shared object input means for inputting a target shared object, a function prologue of the shared object, a virtual address on a text section existing in a data section,
Relocation information extracting means for extracting relocation information from an instruction code for obtaining a text address with reference to GOT and a GOT to create a relocation information table;
A profiler shared object generating means for generating a profiler shared object having the same function as the shared object and adding a profiler code, and updating necessary instruction code or data content by referring to the relocation information table; Having.

【0011】[0011]

【発明の実施の形態】次に、本発明について図面を参照
して詳細に説明する。
Next, the present invention will be described in detail with reference to the drawings.

【0012】[0012]

【実施例】図1は、本発明の一実施例に係るプロファイ
ラ用コード追加方式の構成を示すブロック図である。本
実施例のプロファイラ用コード追加方式は、共有オブジ
ェクト1と、ダイナミックリンク実行可能プログラム2
と、共有オブジェクト入力手段3と、リロケーション情
報抽出手段4と、リロケーション情報テーブル5と、プ
ロファイラ用共有オブジェクト生成手段6と、プロファ
イラ用共有オブジェクトプログラム7とから構成されて
いる。
FIG. 1 is a block diagram showing the configuration of a profiler code addition system according to an embodiment of the present invention. The method for adding a profiler code according to the present embodiment includes a shared object 1 and a dynamic link executable program 2.
, A shared object input means 3, a relocation information extracting means 4, a relocation information table 5, a profiler shared object generating means 6, and a profiler shared object program 7.

【0013】本発明の前提となるダイナミックリンク方
式では、実行時のテキストアドレスは、グローバルオフ
セットテーブル(以下、GOTと略記する)のアドレス
からの相対値で表せるものとする。また、共有オブジェ
クト1あるいはダイナミックリンク実行可能プログラム
2の作成時に定まる固定値である関数アドレスとGOT
アドレスとの相対値と、共有オブジェクト1あるいはダ
イナミックリンク実行可能プログラム2の各関数の実行
時にその先頭で実際にその関数が割り付いたアドレスと
を加算することにより、実行時のGOTアドレスを算出
し、その値が設定されるグローバルポインタgpを持つ
ものとする。したがって、グローバルポインタgpは、
共有オブジェクト1内で一意な値を持ち、共有オブジェ
クト1の起点となるアドレスを持っている。GOTアド
レスを共有オブジェクト1の起点となるアドレスとする
のは、共有オブジェクト1は命令コードが位置独立なも
のとして、プロセスごとに変化してもよいアドレスをも
ってロードされる性質があることから、それぞれの共有
オブジェクト1内で関数などの存在情報を1つのGOT
にまとめることができれば、実行時の関数アクセスに矛
盾が起きなくなるためで、しかもそれは関数のアクセス
効率の向上に寄与する。
In the dynamic link system which is a premise of the present invention, a text address at the time of execution can be represented by a relative value from an address of a global offset table (hereinafter abbreviated as GOT). Also, a function address, which is a fixed value determined when the shared object 1 or the dynamic link executable program 2 is created, and GOT
The GOT address at the time of execution is calculated by adding the relative value to the address and the address to which the function is actually allocated at the beginning of each function of the shared object 1 or the dynamic link executable program 2 at the time of execution. , A global pointer gp to which the value is set. Therefore, the global pointer gp is
It has a unique value within shared object 1 and has an address that is the starting point of shared object 1. The GOT address is used as the starting point of the shared object 1 because the shared object 1 has a characteristic that the instruction code is position-independent and is loaded with an address that may change for each process. The presence information such as functions in the shared object 1 is GOT
The reason for this is that inconsistencies do not occur in function access at the time of execution, and this contributes to improvement in the access efficiency of functions.

【0014】また、本発明の前提となるダイナミックリ
ンク方式では、GOTが絶対仮想アドレスを持つ。絶対
仮想アドレスとは、ダイナミックリンク実行可能プログ
ラム2を実行するとき、そのダイナミックリンク実行可
能プログラム2のファイル上のセグメントを仮想メモリ
上のセグメントに論理的にコピーするが、プロセスを正
常に実行するために、そのプログラムが作られたときに
割り当てられた、セグメントを配置しなければならない
アドレスをいう。この絶対仮想アドレスから、コピー前
のテキストアドレスとの相対値をもって一意的に実行時
のテキストアドレスを表せる。また、命令記述セクショ
ン(テキストセクション)中の関数プロローグでその関
数が持つテキストアドレスと、関数プロローグの命令コ
ードで定められたGOTとの相対値とを加算したものが
GOTアドレスとなり、そのGOTアドレスは対象とな
る共有オブジェクト1内、あるいは対象となるダイナミ
ックリンク実行可能プログラム2内で一意な値を持つこ
とになる。その値は、グローバルポインタgpの値にも
なる。
In the dynamic link system which is a premise of the present invention, the GOT has an absolute virtual address. The absolute virtual address means that when the dynamic link executable program 2 is executed, a segment on the file of the dynamic link executable program 2 is logically copied to a segment on the virtual memory, but the process is executed normally. And the address at which the segment must be allocated when the program is created. From this absolute virtual address, a text address at the time of execution can be uniquely represented by a relative value to the text address before copying. The GOT address is obtained by adding the text address of the function in the function prologue in the instruction description section (text section) and the relative value to the GOT defined by the instruction code of the function prologue. It has a unique value in the target shared object 1 or the target dynamic link executable program 2. That value also becomes the value of the global pointer gp.

【0015】図2は、リロケーション情報抽出手段4を
詳細に表す図である。リロケーション情報抽出手段4
は、関数プロローグ検出部41と、データ用テキストア
ドレス検出部42と、GOT参照テキストアドレス検出
部43とから構成されている。
FIG. 2 is a diagram showing the relocation information extracting means 4 in detail. Relocation information extraction means 4
Is composed of a function prologue detection section 41, a data text address detection section 42, and a GOT reference text address detection section 43.

【0016】図3を参照すると、共有オブジェクト1
は、オブジェクトファイルを解釈するための情報を主に
集めたオブジェクトヘッダと、セグメントや,システム
が実行プログラムをロードするために必要な情報を集め
たプログラムヘッダと、テキストセクション,ダイナミ
ックセクション,シンボルテーブル等を含むテキストセ
グメントと、データセクション,GOT等を含むデータ
セグメントと、セクション情報ヘッダテーブルとから構
成されている。テキストセクションの命令記述セクショ
ン中には、関数プロローグと、GOT参照命令コードと
が含まれる。また、データセクション中には、テキスト
セクション内の仮想アドレスそのものがデータになって
いるものが含まれている場合がある。例えば、例外的
に、静的関数のアドレスを初期値に書くプログラムが存
在し、そういうプログラムをコンパイルして実行可能プ
ログラムを生成するとき、自動的にデータセクション内
に仮想アドレスそのものが書き込まれる場合がある。
Referring to FIG. 3, shared object 1
Is an object header that mainly collects information for interpreting an object file, a segment, a program header that collects information necessary for the system to load an execution program, a text section, a dynamic section, a symbol table, and the like. , A data segment including a data section, GOT, and the like, and a section information header table. The instruction description section of the text section includes a function prologue and a GOT reference instruction code. In some cases, the data section includes a data section in which the virtual address itself in the text section is data. For example, exceptionally, there is a program that writes the address of a static function to the initial value, and when compiling such a program to generate an executable program, the virtual address itself is automatically written in the data section. is there.

【0017】図4を参照すると、GOTは、データセグ
メントの一部として、内容がすべて絶対仮想アドレスで
あるエントリをいくつかもっている。共有オブジェクト
1の命令コードは、絶対仮想アドレスを含むことができ
ない位置独立な命令コードであるため、絶対仮想アドレ
スを持つGOTによって、位置独立な命令コードと、実
行時プログラムテキストとの共有性を崩さないアドレシ
ングを可能にしている。このGOTは、2つの論理的な
エントリを含み、GOTの前半部分をローカルエント
リ、後半部分を外部エントリとする。それらは、すべて
絶対仮想アドレスで構成されるものとする。ローカルエ
ントリは、対象オブジェクト中の特殊関数入口アドレス
やベースアドレス(テキストセグメントの開始アドレ
ス)などを含んでおり、共有オブジェクト1のベースア
ドレスが、そのデフォルトベースアドレスと異なってい
る場合のリロケーションに使われるものとする。外部エ
ントリは、対象オブジェクトでは未定義のシンボルの絶
対仮想アドレスを含む。GOT参照とは、ローカルエン
トリを使ったグローバルポインタgpのオフセット付き
参照のことをいう。
Referring to FIG. 4, the GOT has, as part of a data segment, several entries whose contents are all absolute virtual addresses. Since the instruction code of the shared object 1 is a position-independent instruction code that cannot include an absolute virtual address, the GOT having the absolute virtual address breaks the sharing between the position-independent instruction code and the runtime program text. No addressing is possible. This GOT includes two logical entries, and the first half of the GOT is a local entry and the second half is an external entry. They are all composed of absolute virtual addresses. The local entry includes a special function entry address and a base address (start address of a text segment) in the target object, and is used for relocation when the base address of the shared object 1 is different from its default base address. Shall be. The external entry contains the absolute virtual address of a symbol that is not defined in the target object. The GOT reference is a reference with offset of the global pointer gp using a local entry.

【0018】図5を参照すると、ダイナミックリンク実
行可能プログラム2は、オブジェクトヘッダと、プログ
ラムヘッダと、テキストセクション,ダイナミックセク
ション等を含むテキストセグメントと、データセクショ
ン,GOT等を含むデータセグメントと、セクション情
報ヘッダテーブルとから構成されている。ダイナミック
セクション中には、共有オブジェクト名が記述されたダ
イナミックリンク情報が含まれている。
Referring to FIG. 5, the dynamic link executable program 2 includes an object header, a program header, a text segment including a text section and a dynamic section, a data segment including a data section and a GOT, and section information. And a header table. The dynamic section includes dynamic link information in which a shared object name is described.

【0019】図6を参照すると、リロケーション情報テ
ーブル5は、type,addressおよびinfo
mationからなるリロケーション情報が複数格納さ
れる。typeには、関数プロローグ,仮想アドレスお
よびGOT参照の3種類がある。また、typeの種類
によってinfomationが指す意味が変わってく
る。すなわち、typeが関数プロローグの場合には、
infomationはグローバルポインタgpの値−
関数アドレス(address)、仮想アドレスの場合
には、該当するaddressが指しているデータセク
ション上の領域の内容、すなわち仮想アドレスそのも
の、GOT参照の場合には、GOT参照付命令コードが
示すターゲットテキストアドレスをそれぞれ指す。
Referring to FIG. 6, the relocation information table 5 includes type, address, and info.
A plurality of pieces of relocation information consisting of a “mation” are stored. There are three types of function prologue, virtual address and GOT reference. Further, the meaning indicated by information changes depending on the type of type. That is, if type is a function prologue,
information is the value of the global pointer gp−
In the case of a function address (address) or a virtual address, the contents of the area on the data section indicated by the corresponding address, that is, the virtual address itself, and in the case of GOT reference, the target text address indicated by the instruction code with GOT reference Respectively.

【0020】図7を参照すると、プロファイラ用共有オ
ブジェクト7は、オブジェクトヘッダと、プログラムヘ
ッダと、テキストセクション,ダイナミックセクション
等を含むテキストセグメントと、データセクション,G
OT等を含むデータセグメントと、プロファイラ用コー
ド追加テキストセクション,マップテーブル等を含む新
テキストセグメントと、セクション情報ヘッダテーブル
とから構成されている。新テキストセクションの新命令
記述セクション(プロファイラ用コード追加テキストセ
クション)中には、プロファイラ用コード(呼ばれ回数
カウント)と、更新部分を含む関数プロローグと、更新
部分を含むGOT参照命令コードとが含まれる。また、
データセクション中には、テキストセクション内の仮想
アドレスの更新部分が含まれている。さらに、マップテ
ーブルには、1ワードごとに元のテキストセクションの
命令コード1つ1つに対応するプロファイラ用テキスト
アドレスが書き込まれている。
Referring to FIG. 7, the profiler shared object 7 includes an object header, a program header, a text segment including a text section, a dynamic section, etc., a data section, and a G section.
The data segment includes an OT and other data segments, a new text segment including a profiler code addition text section, a map table, and the like, and a section information header table. The new instruction description section of the new text section (profiler code addition text section) includes a profiler code (call count), a function prolog including an updated part, and a GOT reference instruction code including an updated part. It is. Also,
The data section includes an updated portion of the virtual address in the text section. Further, a profiler text address corresponding to each instruction code of the original text section is written in the map table for each word.

【0021】図8は、共有オブジェクト1のテキストセ
グメント中にかならず存在するシンボルテーブルの内容
を示す図である。シンボルテーブルは、Index,シ
ンボル値,サイズ,型,属性,存在セクションおよび名
前からなるシンボル情報が複数格納される。シンボルの
型が関数のものであり、かつテキストセクション内に存
在するシンボルについて、各々が保持しているシンボル
値が、各々の関数に対する関数入ロアドレスになる。
FIG. 8 is a diagram showing the contents of the symbol table which is always present in the text segment of the shared object 1. The symbol table stores a plurality of pieces of symbol information including Index, symbol value, size, type, attribute, existing section, and name. For a symbol whose symbol type is that of a function and exists in the text section, the symbol value held by each becomes the function entry address for each function.

【0022】図9を参照すると、共有オブジェクト入力
手段3の処理は、ダイナミックリンク実行可能プログラ
ム入力ステップS31と、共有オブジェクト参照判定ス
テップS32と、共有オブジェクト名抽出ステップS3
3と、共有オブジェクトオープンステップS34と、共
有オブジェクトオープン完了判定ステップS35とから
なる。
Referring to FIG. 9, the processing of the shared object input means 3 includes a dynamic link executable program input step S31, a shared object reference determination step S32, and a shared object name extraction step S3.
3, a shared object open step S34, and a shared object open completion determination step S35.

【0023】図10を参照すると、リロケーション情報
抽出手段4の処理は、共有オブジェクト抽出完了判定ス
テップS44と、共有オブジェクトシンボルテーブル読
込みステップS45と、関数かつテキストセクション内
シンボル判定ステップS46と、リロケーション情報テ
ーブルへの書込み準備ステップS47と、読込みシンボ
ル情報次NULL判定ステップS48と、共有オブジェ
クトデータセグメント読込みステップS49と、テキス
トセクション上仮想アドレス判定ステップS4aと、リ
ロケーション情報テーブル書込み準備ステップS4b
と、読込みデータ次NULL判定ステップS4cと、共
有オブジェクトテキストセクション読込みステップS4
dと、命令コードGOT参照判定ステップS4eと、リ
ロケーション情報テーブル書込み準備ステップS4f
と、読込み命令コード次NULL判定ステップS4g
と、リロケーション情報テーブル書込み処理ステップS
4hと、抽出共有オブジェクト数インクリメントステッ
プS4iとからなる。
Referring to FIG. 10, the processing of the relocation information extracting means 4 includes a shared object extraction completion determining step S44, a shared object symbol table reading step S45, a function and text section symbol determining step S46, and a relocation information table. , Writing symbol information next NULL determination step S48, shared object data segment reading step S49, text section virtual address determination step S4a, and relocation information table writing preparation step S4b.
Read data next NULL determination step S4c, and shared object text section read step S4
d, instruction code GOT reference determination step S4e, and relocation information table writing preparation step S4f.
And read instruction code next NULL determination step S4g
And relocation information table writing processing step S
4h and an extracted shared object number increment step S4i.

【0024】図11を参照すると、プロファイラ用共有
オブジェクト生成手段6の処理は、生成プロファイラ用
共有オブジェクト数判定ステップS61と、共有オブジ
ェクトテキストセクション読込みステップS62と、最
小ブロック先頭判定ステップS63と、元命令コードメ
モリ書込みステップS64と、プロファイラ用コード追
加・元命令コードメモリ書込みステップS65と、リロ
ケーション情報テーブル読込みステップS66と、該当
命令コードおよびデータセクション更新ステップS67
と、読込みリロケーション情報次NULL判定ステップ
S68と、プロファイラ用コード追加テキストセクショ
ンへのメモリ内容書込みステップS69と、共有オブジ
ェクト構造のプロファイラ用共有オブジェクトへのコピ
ーステップS6aと、生成プロファイラ用共有オブジェ
クト数インクリメントステップS6bとからなる。
Referring to FIG. 11, the processing of the profiler shared object generation means 6 includes a generation profiler shared object number determination step S61, a shared object text section reading step S62, a minimum block head determination step S63, an original instruction Code memory writing step S64, profiler code addition / original instruction code memory writing step S65, relocation information table reading step S66, and corresponding instruction code and data section updating step S67
Reading relocation information next NULL determination step S68, writing the memory contents to the profiler code addition text section S69, copying the shared object structure to the profiler shared object S6a, and incrementing the generated profiler shared object number S6b.

【0025】次に、このように構成された本実施例のプ
ロファイラ用コード追加方式の動作について説明する。
Next, the operation of the profiler code addition system of the embodiment constructed as described above will be described.

【0026】まず、共有オブジェクト入力手段3は、性
能測定対象となるダイナミックリンク実行可能プログラ
ム2をコマンドライン上で入力すると(ステップS3
1)、入力されたダイナミックリンク実行可能プログラ
ム2中にダイナミックリンク情報の入ったダイナミック
セクションが存在するかどうかに基づいてダイナミック
リンク実行可能プログラム2が共有オブジェクト1を参
照しているかどうかを検証する(ステップS32)。ダ
イナミックリンク実行可能プログラム2が共有オブジェ
クト1を参照していなければ、共有オブジェクト入力手
段3は、ただちに処理を終了する。ダイナミックリンク
実行可能プログラム2が共有オブジェクト1を参照して
いれば、共有オブジェクト入力手段3は、ダイナミック
セクション中のダイナミックリンク情報から共有オブジ
ェクト名の並びをすべて抽出し(ステップS33)、共
有オブジェクト名を抽出した各々の共有オブジェクト1
をオープンする(ステップS34)。続いて、共有オブ
ジェクト入力手段3は、オープンした共有オブジェクト
1の数と抽出した共有オブジェクト1の数とを比較し
(ステップS35)、オープンした共有オブジェクト1
の数が抽出した共有オブジェクト1の数より小さけれ
ば、ステップS34に制御を戻して次の共有オブジェク
ト1をオープンし、オープンした共有オブジェクト1の
数が抽出した共有オブジェクト1の数以上になれば、処
理を終了してリロケーション情報抽出手段4に制御を渡
す。
First, the shared object input means 3 inputs the dynamic link executable program 2 whose performance is to be measured on a command line (step S3).
1) It is verified whether or not the dynamic link executable program 2 refers to the shared object 1 based on whether or not there is a dynamic section containing dynamic link information in the input dynamic link executable program 2 ( Step S32). If the dynamic link executable program 2 does not refer to the shared object 1, the shared object input means 3 immediately terminates the processing. If the dynamic link executable program 2 refers to the shared object 1, the shared object input means 3 extracts all the shared object names from the dynamic link information in the dynamic section (step S33), and changes the shared object name. Each extracted shared object 1
Is opened (step S34). Subsequently, the shared object input unit 3 compares the number of the opened shared objects 1 with the number of the extracted shared objects 1 (step S35).
If the number of shared objects 1 is smaller than the number of extracted shared objects 1, control is returned to step S34 to open the next shared object 1, and if the number of opened shared objects 1 is equal to or greater than the number of extracted shared objects 1, After the processing is completed, control is passed to the relocation information extracting means 4.

【0027】次に、リロケーション情報抽出手段4は、
共有オブジェクト入力手段3によって得られた、オープ
ンした共有オブジェクト1の数より、リロケーション情
報を抽出するために使われる共有オブジェクト1の数が
少ない限りは、ステップS45〜S4iの処理を繰り返
し行うことを決定する(ステップS44)。
Next, the relocation information extracting means 4
As long as the number of shared objects 1 used for extracting the relocation information is smaller than the number of opened shared objects 1 obtained by the shared object input means 3, it is determined that the processes of steps S45 to S4i are repeatedly performed. (Step S44).

【0028】まず、関数プロローグ検出部41は、入力
された共有オブジェクト1中に含まれるシンボルテーブ
ルの読込みを1シンボル情報ずつ行い(ステップS4
5)、読み込まれたシンボル情報について型が関数“F
UNC”でかつ存在セクションがテキストセクションに
なっているシンボルであるかどうかを調べる(ステップ
S46)。この条件を満たすシンボル情報のみ、リロケ
ーション情報テーブル5に書き込まれるものとするため
に、関数プロローグ検出部41は、次の共有オブジェク
ト1が入力される前に一括してリロケーション情報テー
ブル5に書き込めるようにメモリにシンボル情報を記憶
させる(ステップS47)。次に、関数プロローグ検出
部41は、シンボルテーブル内のシンボル情報をすべて
読み込んだかどうかのチェックを行い(ステップS4
8)、まだ残っている場合は、ステップS45〜S48
の処理を繰り返し行い、終了するとデータ用テキストア
ドレス検出部42に制御を移す。
First, the function prologue detection unit 41 reads a symbol table included in the input shared object 1 one symbol information at a time (step S4).
5) For the read symbol information, the type is a function "F
It is checked whether or not the symbol is “UNC” and the existing section is a text section (step S 46). Only the symbol information that satisfies this condition is written in the relocation information table 5. 41 stores the symbol information in the memory so that the symbol information can be collectively written to the relocation information table 5 before the next shared object 1 is input (step S47). It is checked whether all the symbol information has been read (step S4).
8) If still remaining, steps S45 to S48
Are repeated, and when the processing is completed, the control is transferred to the data text address detecting section 42.

【0029】データ用テキストアドレス検出部42は、
共有オブジェクト1のデータセグメント中のデータセク
ションのデータを読み込む前に、共有オブジェクト1が
持つテキストセクションの最小アドレスおよび最大アド
レスを記憶させる。次に、データ用テキストアドレス検
出部42は、データセクションを1ワードずつ読み込み
(ステップS49)、その内容が記憶した最小アドレス
より大きく、かつ記憶した最大アドレスより小さいも
の、すなわちテキストセクション上の仮想アドレスにな
っているものを検出し(ステップS4aでイエス)、条
件を満たすデータのみをリロケーション情報テーブル5
に書き込めるようにメモリに記憶させる(ステップS4
b)。また、データ用テキストアドレス検出部42は、
該当データセグメント領域の更新のために、該当するテ
キストアドレスが格納されている場所を記憶する必要が
あり、データセグメント上の該当する仮想アドレスを各
々記録する。プロファイラ用共有オブジェクト7は、テ
キストセグメントの方ではなく、新テキストセグメント
中のテキストを実行するからである。続いて、データ用
テキストアドレス検出部42は、データセグメント内の
データをすべて読み込んだかどうかのチェックを行い
(ステップS4c)、まだ残っている場合はステップS
49〜4cの処理を繰り返し行い、終了したときにはG
OT参照テキストアドレス検出部43に制御を移す。
The data text address detection unit 42
Before reading the data of the data section in the data segment of the shared object 1, the minimum address and the maximum address of the text section of the shared object 1 are stored. Next, the data text address detection unit 42 reads the data section one word at a time (step S49), and the content is larger than the stored minimum address and smaller than the stored maximum address, that is, the virtual address on the text section. Are detected (yes in step S4a), and only the data that satisfies the condition is stored in the relocation information table 5.
(Step S4)
b). Further, the data text address detection unit 42
In order to update the corresponding data segment area, it is necessary to store the location where the corresponding text address is stored, and record the corresponding virtual address on the data segment. This is because the profiler shared object 7 executes the text in the new text segment, not the text segment. Subsequently, the data text address detection unit 42 checks whether or not all the data in the data segment has been read (step S4c).
49 to 4c are repeatedly performed.
The control is transferred to the OT reference text address detection unit 43.

【0030】GOT参照テキストアドレス検出部43
は、入力された共有オブジェクト1のテキストセグメン
ト中のテキストセクションを最初から1命令コードずつ
読み込んで行く(ステップS4d)。次に、GOT参照
テキストアドレス検出部43は、1命令コードずつ読み
込まれた命令コードからGOT参照に該当する命令オペ
ランドをもった命令コードを抽出し(ステップS4
e)、かつ、その命令オペランドであるオフセット値
が、GOTアドレスと一致した場合の、GOT参照時の
プログラムカウンタ,GOT参照によって得られるター
ゲットテキストアドレス,およびその値とGOTアドレ
スとの差分を記録する。
GOT reference text address detector 43
Reads the text section in the text segment of the input shared object 1 one instruction code at a time from the beginning (step S4d). Next, the GOT reference text address detection unit 43 extracts an instruction code having an instruction operand corresponding to the GOT reference from the instruction codes read one by one (Step S4).
e) When the offset value, which is the instruction operand, matches the GOT address, the program counter at the time of GOT reference, the target text address obtained by GOT reference, and the difference between the value and the GOT address are recorded. .

【0031】GOT参照に該当する命令オペランドを持
つ命令コードは、以下のパターンのみである。ただし、
x,yはレジスタを、zzz,uuuは任意のオフセッ
トをそれぞれ表す。
An instruction code having an instruction operand corresponding to the GOT reference has only the following patterns. However,
x and y represent registers, and zzz and uuu represent arbitrary offsets, respectively.

【0032】 lw x,−0xzzz(gp) nop addiu y,x,0xuuuLw x, -0xzzz (gp) nop addiy, x, 0xuuu

【0033】GOT参照テキストアドレス検出部43
は、以上の命令パターンの条件を満たすものをすべて検
出する。それらのうち、検出した命令パターンが持つG
OT参照時のオフセットの内容(ここでは、xレジスタ
に入る値を指している)がGOTアドレスと一致したも
ののみを検出し、その際のプログラムカウンタ(テキス
トアドレス),GOT参照によって得られるターゲット
テキストアドレス(ここでは、yレジスタに入る値を指
している),および、上記で得られるターゲットテキス
トアドレスは、テキストセグメントのテキストセクショ
ン中に存在するので、プロファイラ用共有オブジェクト
7の、上記ターゲットテキストアドレスに対応した新テ
キストセグメントのプロファイラ用コード追加テキスト
セクション中のテキストアドレスに変換する必要がある
ため、上記ターゲットテキストアドレスとGOTアドレ
スとの差分をメモリに記録する(ステップS4f)。
GOT reference text address detector 43
Detects all that satisfy the conditions of the above instruction patterns. Among them, the G of the detected instruction pattern
Only those whose contents of the offset when referring to the OT (here, the value stored in the x register) matches the GOT address are detected, and the program counter (text address) at that time and the target text obtained by the GOT reference Since the address (here, pointing to the value in the y register) and the target text address obtained above are present in the text section of the text segment, the target text address of the profiler shared object 7 is Since it is necessary to convert the corresponding new text segment into a text address in the profiler code addition text section, the difference between the target text address and the GOT address is recorded in the memory (step S4f).

【0034】続いて、GOT参照テキストアドレス検出
部43は、テキストセクション内のデータ、すなわちす
べての命令コードを読み込んだかどうかのチェックを行
い(ステップS4g)、まだ残っている場合は、ステッ
プS4d〜S4gの処理を繰り返し行い、終了したとき
にステップS4hに進む。
Subsequently, the GOT reference text address detecting section 43 checks whether or not the data in the text section, that is, all the instruction codes have been read (step S4g), and if there are any remaining, the steps S4d to S4g. Are repeated, and when the process is completed, the process proceeds to step S4h.

【0035】次に、リロケーション情報抽出手段4は、
関数プロローグ検出部41,データ用テキストアドレス
検出部42およびGOT参照テキストアドレス検出部4
3によりメモリに蓄えられたリロケーション情報をプロ
ファイラ用コードの追加後のターゲットアドレス更新の
ためにリロケーション情報テーブル5に書き込み(ステ
ップS4h)、リロケーション情報を抽出するために使
われた共有オブジェクト1の数を1つインクリメントし
て(ステップS4i)、ステップS44に制御を戻し、
ステップS44で抽出した共有オブジェクト1の数が参
照した共有オブジェクト1の数以上になると、制御をプ
ロファイラ用共有オブジェクト生成手段6に移す。
Next, the relocation information extracting means 4
Function prologue detection unit 41, data text address detection unit 42, and GOT reference text address detection unit 4
3, the relocation information stored in the memory is written into the relocation information table 5 for updating the target address after the addition of the profiler code (step S4h), and the number of shared objects 1 used for extracting the relocation information is determined. The control is incremented by one (step S4i), and the control returns to step S44.
When the number of shared objects 1 extracted in step S44 becomes equal to or greater than the number of referenced shared objects 1, control is transferred to the profiler shared object generation means 6.

【0036】プロファイラ用共有オブジェクト生成手段
6は、まず、すべての参照する共有オブジェクト1の数
より、生成したプロファイラ用共有オブジェクト7の数
が少ない限りは、ステップS62〜S6bの処理を繰り
返し行うことを決定する(ステップS61)。
The profiler shared object generating means 6 first repeats the processing of steps S62 to S6b as long as the number of generated profiler shared objects 7 is smaller than the number of all referenced shared objects 1. It is determined (step S61).

【0037】次に、プロファイラ用共有オブジェクト生
成手段6は、入力された共有オブジェクト1中に含まれ
るテキストセクションの読込みを1命令コードずつ行う
(ステップS62)。このとき、プロファイラ用コード
を追加する際に何命令コード増加するかを1命令コード
ずつ計算しておく。
Next, the profiler shared object generating means 6 reads the text section contained in the input shared object 1 one instruction code at a time (step S62). At this time, how many instruction codes increase when adding a profiler code is calculated for each instruction code.

【0038】続いて、プロファイラ用共有オブジェクト
生成手段6は、読み込んだ1命令コードについて、先頭
のみから入ることができ最後からのみ抜けることができ
る最小ブロックの先頭になっているかどうかをチェック
し(ステップS63)、そうでなければ元の命令コード
をそのままプロファイラ用共有オブジェクト7内の新テ
キストセグメント内の命令コードとしてコピーするため
にメモリに書き込み(ステップS64)、そうであると
きは元の命令コードに先立ってプロファイラ用コードを
追加した一連の命令コードをメモリに書き込み、元の命
令コードをそのままプロファイラ用共有オブジェクト7
内の新テキストセグメント内の命令コードとしてコピー
するためにメモリに書き込む(ステップS65)。
Subsequently, the profiler shared object generating means 6 checks whether the read one instruction code is at the head of the smallest block which can be entered only from the beginning and can be escaped only from the end (step). S63) Otherwise, the original instruction code is written into the memory to copy it as it is as the instruction code in the new text segment in the shared object 7 for profiler (step S64). Prior to this, a series of instruction codes to which the profiler code has been added are written into the memory, and the original instruction code is directly used as the profiler shared object 7.
Is written to the memory to be copied as an instruction code in a new text segment in (step S65).

【0039】次に、プロファイラ用共有オブジェクト生
成手段6は、リロケーション情報抽出手段4により得ら
れたリロケーション情報テーブル5に含まれるすべての
リロケーション情報を読み込み(ステップS66)、該
当するリロケーション情報が存在した場合、その部分に
ついて必要に応じて内容を更新する(ステップS6
7)。
Next, the profiler shared object generating means 6 reads all the relocation information contained in the relocation information table 5 obtained by the relocation information extracting means 4 (step S66), and if the corresponding relocation information exists. The content is updated as necessary for that portion (step S6).
7).

【0040】詳しくは、プロファイラ用共有オブジェク
ト生成手段6は、リロケーション情報テーブル5から読
み込んだリロケーション情報が関数プロローグの場合
は、プロファイラ用共有オブジェクト7における矛盾の
ない参照、つまり各関数呼出しの際の元の共有オブジェ
クト1と同等の動作を示すために、プロファイラ用共有
オブジェクト7の関数プロローグを、関数プロローグ検
出部41で検出された共有オブジェクト1の関数入ロア
ドレスに対応するプロファイラ用コードの関数入ロアド
レスとプロファイラ用コードのGOTとの相対値からプ
ロフアイラ用コードのGOTアドレスを算出し、その値
をグローバルポインタgpに設定する命令コードにす
る。
More specifically, if the relocation information read from the relocation information table 5 is a function prologue, the profiler shared object generation means 6 refers to the profiler shared object 7 without any inconsistencies, that is, the source of each function call. In order to show the same operation as that of the shared object 1 of the profiler, the function prologue of the profiled shared object 7 is converted into a function entry of the profiler code corresponding to the function entry address of the shared object 1 detected by the function prologue detection unit 41. The GOT address of the profiler code is calculated from the relative value between the address and the GOT of the profiler code, and the value is used as an instruction code for setting the global pointer gp.

【0041】プロファイラ用共有オブジェクト7が実行
されるとき、テキストセグメントの方ではなく、新テキ
ストセグメントの方のテキストセクションにある命令コ
ードを実行するので、元の関数プロローグに対応するプ
ロファイラ用コード追加テキストセクション中の関数プ
ロローグを生成する際に生じるアドレス上の差分を吸収
する必要がある。よって、関数プロローグは、以下のパ
ターンになっている。
When the profiler shared object 7 is executed, the instruction code in the text section of the new text segment is executed instead of the text segment. Therefore, the profiler code addition text corresponding to the original function prologue is executed. It is necessary to absorb the difference in addresses generated when generating the function prologue in the section. Therefore, the function prolog has the following pattern.

【0042】 (A) lui gp,0xzzzz (B) addiu gp,gp,0xuuu (C) addu gp,gp,t9(A) lui gp, 0xzzzz (B) addi gp, gp, 0xuuu (C) addu gp, gp, t9

【0043】リロケーション情報テーブル5中のinf
omation(=グローバルポインタgpの値−ad
dress)から下線部分を更新することにより、
(A)および(B)の命令コードをもってプロファイラ
用コードのGOTとの相対値がグローバルポインタgp
に代入され、(C)の命令コードでプロファイラ用コー
ドの関数入口アドレスを保持するt9レジスタの内容と
上で求まったグローバルポインタgpの内容との加算結
果を新たにグローバルポインタgpに代入する。この
際、マップテーブルを用いてプロファイラ用コードの関
数入口アドレスを算出する(ステップS67)。すなわ
ち、(A)〜(C)の命令コードが、プロファイラ用コ
ードのGOTとの相対値と、プロファイラ用コードの関
数入口アドレスとを合わせた値をグローバルポインタg
pに設定する命令コードである。
Inf in relocation information table 5
operation (= value of global pointer gp−ad
dress) to update the underlined part,
With the instruction codes of (A) and (B), the relative value of the profiler code to GOT is set to the global pointer gp.
And the result of addition of the contents of the t9 register holding the function entry address of the profiler code with the instruction code of (C) and the contents of the global pointer gp obtained above is newly assigned to the global pointer gp. At this time, the function entry address of the profiler code is calculated using the map table (step S67). That is, the instruction code of (A) to (C) sets the value obtained by combining the relative value of the profiler code with GOT and the function entry address of the profiler code as the global pointer g.
Instruction code to be set in p.

【0044】また、プロファイラ用共有オブジェクト生
成手段6は、リロケーション情報テーブル5から読み込
まれたリロケーション情報のtypeがテキストセクシ
ョン上の仮想アドレスである場合は、それが指す領域に
アクセスされることを防ぐために、データ用テキストア
ドレス検出部42で検出されたテキストセクション上の
仮想アドレスからプロファイラ用コード上の仮想アドレ
ス変換値を算出し、それをデータセグメント上の元の仮
想アドレスが埋め込まれているデータセクション領域に
オーバライトする(ステップS67)。
When the type of the relocation information read from the relocation information table 5 is a virtual address on a text section, the profiler shared object generating means 6 prevents the area indicated by the virtual address from being accessed. A virtual address conversion value on the profiler code is calculated from the virtual address on the text section detected by the data text address detection unit 42, and is converted into a data section area in which the original virtual address on the data segment is embedded. Is overwritten (step S67).

【0045】詳しくは、プロファイラ用共有オブジェク
ト7は、新テキストセグメントのプロファイラ用コード
追加テキストセクションにある命令コードを実行するの
で、その実行中に元のテキストセクション上の仮想アド
レスがデータとして存在するデータセクションにアクセ
スした場合、動作不正になる可能性がある。このため、
プロファイラ用共有オブジェクト生成手段6は、リロケ
ーション情報テーブル5を順次に参照するとき、typ
eが仮想アドレスだった場合には、データ用テキストア
ドレス検出部42で記録したテキストアドレスからプロ
ファイラ用コード上のテキストアドレスに変換したもの
を、データセクション上の該当する領域に書き込む必要
がある。この際、マップテーブルと、データ用テキスト
アドレス検出部42で記録したデータセグメント上の仮
想アドレスとを用いる。例えば、データセクションに、
テキストアドレスである『400520』が存在する場
合、リロケーション情報テーブル5中のinfomat
ionを参照すると、データセクションの、addre
ssが示す領域付近において、『0000000040
2823290040052000000000』が、
『0000000040282329004a0048
00000000』のように、400520というテキ
ストアドレスに、対応するプロファイラ用コード上のテ
キストアドレス4a1800をオーバライトする(ステ
ップS67)。『400520』というテキストアドレ
スは、図3中の命令記述セクションを参照すると、元の
9番目の命令に対応する仮想アドレスであり、図7中の
マップテーブルの、それに対応する9番目の仮想アドレ
スが『4a0048』になっているためである。
More specifically, since the profiler shared object 7 executes the instruction code in the profiler code addition text section of the new text segment, the virtual address on the original text section exists as data during the execution. Accessing a section may result in incorrect operation. For this reason,
When sequentially referring to the relocation information table 5, the profiler shared object generating means 6
If e is a virtual address, it is necessary to write a text address recorded by the data text address detection unit 42 into a text address on the profiler code in a corresponding area in the data section. At this time, the map table and the virtual address on the data segment recorded by the data text address detection unit 42 are used. For example, in the data section:
If the text address “400520” exists, the format in the relocation information table 5
When referring to the "ion", in the data section, "addre"
In the vicinity of the area indicated by ss, “0000000000040”
28232900 400520 00000000]
"000000000282232900 4a0048
"00000000", the text address 4a1800 on the corresponding profiler code is overwritten to the text address 400520 (step S67). Referring to the instruction description section in FIG. 3, the text address “400520” is a virtual address corresponding to the original ninth instruction, and the corresponding ninth virtual address in the map table in FIG. This is because it is "4a0048".

【0046】さらに、プロファイラ用共有オブジェクト
生成手段6は、リロケーション情報テーブル5から読み
込まれたリロケーション情報のtypeがGOT参照で
ある場合は、プロファイラ用共有オブジェクト7におけ
る矛盾のない動作のために、GOT参照テキストアドレ
ス検出部43で検出された元のターゲットテキストアド
レス(ジャンプ命令などが示す飛び先アドレスのうち、
テキストセクション内に存在するアドレス)から対応す
るプロファイラ用ターゲットテキストアドレス(プロフ
ァイラ用コード追加テキストセクション内に存在する、
ジャンプ命令などが示す飛び先アドレス)を算出し、そ
の値と元のターゲットテキストアドレスとの差分を算出
する。
Further, when the type of the relocation information read from the relocation information table 5 is a GOT reference, the profiler shared object generating means 6 performs GOT reference for consistent operation in the profiler shared object 7. The original target text address detected by the text address detection unit 43 (of the jump destination address indicated by the jump instruction or the like,
From the corresponding target text address for the profiler (address present in the text section)
A destination address indicated by a jump instruction or the like is calculated, and a difference between the value and the original target text address is calculated.

【0047】GOTを参照して得るターゲットテキスト
アドレスをジャンプ先アドレスとして使う場合が多いた
め、テキストセクションにある命令コードを用いないプ
ロファイラ用共有オブジェクト7では、動作不正になる
可能性がある。よって、プロファイラ用共有オブジェク
ト生成手段6は、リロケーション情報テーブル5を順次
参照するとき、typeがGOT参照だった場合には、
GOT参照テキストアドレス検出部43で記録したター
ゲットテキストアドレスを基に、対応するプロファイラ
用ターゲットテキストアドレスにマップテーブルを参照
して変換する。そのようにして求まったプロファイラ用
ターゲットテキストアドレスと元のターゲットテキスト
アドレスとの差分を算出する。次に、プロファイラ用共
有オブジェクト生成手段6は、前記で求まった差分に、
GOT参照テキストアドレス検出部43で記録した元の
ターゲットテキストアドレスとGOTアドレスとの差分
を加算した値を、新しいターゲットアドレスを算出可能
にする命令コードの一部に書き込むことにより、該当す
る命令コードを更新する。プロファイラ用共有オブジェ
クト生成手段6は、GOTを参照して得るテキストアド
レスをプロファイラ用共有オブジェクト7においても矛
盾なく正常に動作させるために、ジャンプ先アドレスが
最初からプロファイラ用共有オブジェクト7中の新テキ
ストセグメントの範囲内でなければならない。よって、
先に記録した「元のターゲットテキストアドレスとGO
Tアドレスとの差分」と、先に算出した「プロファイラ
用ターゲットテキストアドレスと元のターゲットテキス
トアドレスとの差分」とを加算したものを、「0xuu
u」の部分にオーバライトすることで該当する命令コー
ドを更新する(ステップS67)。
In many cases, a target text address obtained by referring to the GOT is used as a jump destination address. Therefore, in the profiler shared object 7 that does not use the instruction code in the text section, the operation may be incorrect. Therefore, when the profiler shared object generating means 6 sequentially refers to the relocation information table 5, if the type is a GOT reference,
Based on the target text address recorded by the GOT reference text address detection unit 43, the target text address is converted into a corresponding target text address for profiler by referring to a map table. The difference between the profiler target text address thus obtained and the original target text address is calculated. Next, the profiler shared object generation means 6 adds
By writing a value obtained by adding the difference between the original target text address and the GOT address recorded by the GOT reference text address detection unit 43 into a part of the instruction code that enables the calculation of a new target address, the corresponding instruction code is written. Update. The profiler shared object generating means 6 generates a new text segment in the profiler shared object 7 from the beginning so that the text address obtained by referring to the GOT can operate normally in the profiler shared object 7 without inconsistency. Must be within the range. Therefore,
The original target text address and GO
The difference between the “T difference from the T address” and the previously calculated “difference between the target text address for profiler and the original target text address” is defined as “0xuu”.
The corresponding instruction code is updated by overwriting the "u" part (step S67).

【0048】続いて、プロファイラ用共有オブジェクト
生成手段6は、テキストセクション内のすべての命令コ
ードを読み込んだかどうかのチェックを行い(ステップ
S68)、まだ残っている場合には、ステップS62〜
S68の処理を繰り返し行い、終了したときにステップ
S69に進む。
Subsequently, the profiler shared object generating means 6 checks whether or not all instruction codes in the text section have been read (step S68).
The process of S68 is repeated, and when the process is completed, the process proceeds to step S69.

【0049】次に、プロファイラ用共有オブジェクト生
成手段6は、ステップS64およびS65でメモリに蓄
えられた命令コードを、生成するプロファイラ用共有オ
ブジェクト7内のプロファイラ用コード追加テキストセ
クションに書き込む(ステップS69)。この際、ステ
ップS62で計算した増加する命令コード数を仮想アド
レスに変換した値を元の命令コード数と同じ数だけ、マ
ップテーブルに書き込んでいる。
Next, the profiler shared object generation means 6 writes the instruction code stored in the memory in steps S64 and S65 into the profiler code addition text section in the profiler shared object 7 to be generated (step S69). . At this time, a value obtained by converting the increasing instruction code number calculated in step S62 into a virtual address is written in the map table by the same number as the original instruction code number.

【0050】続いて、プロファイラ用共有オブジェクト
生成手段6は、元の共有オブジェクト1が持つ構造、す
なわち、オブジェクトヘッダ,プログラムヘッダ,テキ
ストセグメント,更新したデータセグメント,セクショ
ン情報ヘッダテーブルをプロファイラ用共有オブジェク
ト7にコピーする(ステップS6a)。
Subsequently, the profiler shared object generator 6 converts the structure of the original shared object 1, that is, the object header, program header, text segment, updated data segment, and section information header table into the profiler shared object 7. (Step S6a).

【0051】最後に、プロファイラ用共有オブジェクト
生成手段6は、生成したプロファイラ用共有オブジェク
ト7の数を1つインクリメントし(ステップS6b)、
ステップS61に制御を戻し、ステップS61で生成し
たプロファイラ用共有オブジェクト7の数が参照した共
有オブジェクト1の数以上になると、一連の処理を終了
する。
Finally, the profiler shared object generating means 6 increments the number of the generated profiler shared objects 7 by one (step S6b).
Control is returned to step S61, and when the number of profiler shared objects 7 generated in step S61 is equal to or greater than the number of referenced shared objects 1, a series of processes is terminated.

【0052】[0052]

【発明の効果】以上説明したように本発明は、共有オブ
ジェクト入力手段,リロケーション情報抽出手段および
プロファイラ用共有オブジェクト生成手段を設けたこと
により、従来、詳細な性能データ解析を可能にするため
に、実行可能プログラムをスタティックリンクで生成し
ていたのを、実行可能プログラムがダイナミックリンク
で生成されている場合においても、プロファイラ用実行
可能プログラムの実行時に、共有オブジェクトではな
く、プロファイラ用共有オブジェクトを参照するため、
共有オブジェクトに関するプロファイルが可能になり、
より詳細な性能データ解析を行うことができるという効
果がある。
As described above, according to the present invention, the provision of the shared object input means, the relocation information extraction means and the profiled shared object generation means has been conventionally performed to enable detailed performance data analysis. Although the executable program is generated by the static link, even when the executable program is generated by the dynamic link, the executable object for the profiler refers to the shared object for the profiler instead of the shared object when the executable program for the profiler is executed. For,
Profiling on shared objects is possible,
There is an effect that more detailed performance data analysis can be performed.

【0053】また、先頭のみから入ることができ、最後
からのみ抜け出すことのできる最小ブロックのアクセス
の有無を性能評価の一つとして観察することができるた
め、特開昭64−35637号公報の特定命令コードを
トレース機能呼出命令コードに変換することよりも、通
常のコンパイル範囲内で生成したオブジェクトを使用し
て、より効率的なプロファイルを行うことができるとい
う効果がある。
Further, the presence / absence of access to the smallest block that can enter only from the beginning and exit only from the end can be observed as one of the performance evaluations. There is an effect that more efficient profiling can be performed by using an object generated within a normal compilation range, rather than converting an instruction code into a trace function call instruction code.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明の一実施例に係るプロファイラ用コード
追加方式の構成を示すブロック図である。
FIG. 1 is a block diagram showing a configuration of a profiler code addition method according to an embodiment of the present invention.

【図2】図1中のリロケーション情報抽出手段の詳細処
理図である。
FIG. 2 is a detailed processing diagram of a relocation information extraction unit in FIG. 1;

【図3】図1中の共有オブジェクトの内容を示す図であ
る。
FIG. 3 is a diagram showing contents of a shared object in FIG. 1;

【図4】図3中のグローバルオフセットテーブルの内容
を示す図である。
FIG. 4 is a diagram showing contents of a global offset table in FIG. 3;

【図5】図1中のダイナミックリンク実行可能プログラ
ムの内容を示す図である。
FIG. 5 is a diagram showing the contents of a dynamic link executable program in FIG. 1;

【図6】図1中のリロケーション情報テーブルの内容を
示す図である。
FIG. 6 is a diagram showing contents of a relocation information table in FIG. 1;

【図7】図1中のプロファイラ用共有オブジェクトの内
容を示す図である。
FIG. 7 is a diagram showing contents of a profiler shared object in FIG. 1;

【図8】図3中のシンボルテーブルの内容を示す図であ
る。
FIG. 8 is a diagram showing contents of a symbol table in FIG. 3;

【図9】図1中の共有オブジェクト入力手段の処理を示
す流れ図である。
FIG. 9 is a flowchart showing processing of a shared object input unit in FIG. 1;

【図10】図1中のリロケーション情報抽出手段の処理
を示す流れ図である。
FIG. 10 is a flowchart showing a process of a relocation information extracting unit in FIG. 1;

【図11】図1中のプロファイラ用共有オブジェクト生
成手段の処理を示す流れ図である。
FIG. 11 is a flowchart showing a process of a profiler shared object generation unit in FIG. 1;

【符号の説明】[Explanation of symbols]

1 共有オブジェクト 2 ダイナミックリンク実行可能プログラム 3 共有オブジェクト入力手段 4 リロケーション情報抽出手段 5 リロケーション情報テーブル 6 プロファイラ用共有オブジェクト生成手段 7 プロファイラ用共有オブジェクト 41 関数プロローグ検出部 42 データ用テキストアドレス検出部 43 GOT参照テキストアドレス検出部 REFERENCE SIGNS LIST 1 shared object 2 dynamic link executable program 3 shared object input means 4 relocation information extraction means 5 relocation information table 6 profiler shared object generation means 7 profiler shared object 41 function prologue detection unit 42 data text address detection unit 43 GOT reference Text address detector

Claims (3)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 ダイナミックリンク実行可能プログラム
が持っているダイナミックリンク情報から当該ダイナミ
ックリンク実行可能プログラムが参照する共有オブジェ
クト名を抽出し、それをもとに対象となる共有オブジェ
クトを入力する共有オブジェクト入力手段と、 前記共有オブジェクトが持つ関数プロローグ,データセ
クションに存在するテキストセクション上の仮想アドレ
ス,およびGOTを参照してテキストアドレスを得る命
令コードからリロケーション情報を抽出しリロケーショ
ン情報テーブルを作成するリロケーション情報抽出手段
と、 前記共有オブジェクトと同等の機能を持ちプロファイラ
用コードを追加したプロファイラ用共有オブジェクトを
生成し、かつ前記リロケーション情報テーブルを参照し
て必要な命令コードあるいはデータの内容を更新するプ
ロファイラ用共有オブジェクト生成手段とを有すること
を特徴とするプロファイラ用コード追加方式。
1. A shared object input for extracting a shared object name referred to by a dynamic link executable program from dynamic link information of the dynamic link executable program and inputting a target shared object based on the extracted name. Means for extracting relocation information from a function prologue of the shared object, a virtual address on a text section existing in a data section, and an instruction code for obtaining a text address by referring to GOT, and relocation information extraction for creating a relocation information table Means for generating a profiler shared object having a function equivalent to that of the shared object and having a profiler code added thereto, and referring to the relocation information table to obtain a required instruction code. There profiler code additional method characterized by having a shared object generating means for profiler to update the contents of the data.
【請求項2】 前記リロケーション情報抽出手段が、前
記共有オブジェクトに含まれるシンボルテーブルから型
が関数のシンボル情報を検出する関数プロローグ検出部
と、前記共有オブジェクトに含まれるデータセグメント
からテキストセクション上の仮想アドレスを検出するデ
ータ用テキストアドレス検出部と、前記共有オブジェク
トに含まれるテキストセクションからGOT参照に該当
する命令オペランドを持つ命令コードを検出するGOT
参照テキストアドレス検出部とからなる請求項1記載の
プロファイラ用コード追加方式。
2. A function prologue detecting unit for detecting symbol information of a function type from a symbol table included in the shared object, a relocation information extracting unit, and a virtual section on a text section from a data segment included in the shared object. A data text address detection unit for detecting an address, and a GOT for detecting an instruction code having an instruction operand corresponding to a GOT reference from a text section included in the shared object
2. The method according to claim 1, further comprising a reference text address detector.
【請求項3】 前記プロファイラ用共有オブジェクト生
成手段が、前記リロケーション情報テーブルのリロケー
ション情報が関数プロローグの場合に前記プロファイラ
用共有オブジェクトの関数プロローグを前記関数プロロ
ーグ検出部で検出された共有オブジェクトの関数入ロア
ドレスに対応するプロファイラ用コードの関数入ロアド
レスとプロファイラ用コードのGOTとの相対値からプ
ロファイラ用コードのGOTアドレスを算出し、その値
をグローバルポインタに設定する命令コードにし、前記
リロケーション情報テーブルのリロケーション情報がテ
キストセクション上の仮想アドレスである場合に前記デ
ータ用テキストアドレス検出部で検出されたテキストセ
クション上の仮想アドレスからプロファイラ用コード上
の仮想アドレス変換値を算出し、それをデータセグメン
ト上の元の仮想アドレスが埋め込まれているところにオ
ーバライトし、前記リロケーション情報テーブルのリロ
ケーション情報がGOT参照であった場合に前記GOT
参照テキストアドレス検出部で記録したターゲットテキ
ストアドレスを基に、対応するプロファイラ用ターゲッ
トテキストアドレスにマップテーブルを参照して変換
し、前記プロファイラ用ターゲットテキストアドレスと
元のターゲットテキストアドレスとの差分を算出し、新
しいターゲットアドレスを命令コードに更新する請求項
2記載のプロファイラ用コード追加方式。
3. The profiler shared object generating means, when the relocation information in the relocation information table is a function prologue, enters the function prologue of the profiler shared object into the function of the shared object detected by the function prologue detection unit. Calculating the GOT address of the profiler code from a relative value between the function input address of the profiler code corresponding to the program address and the GOT of the profiler code, converting the value into an instruction code for setting a global pointer, When the relocation information is a virtual address on a text section, a virtual address on the profiler code is converted from a virtual address on the text section detected by the data text address detection unit. Calculates the value and overwrites it in the data segment where the original virtual address is embedded. If the relocation information in the relocation information table is a GOT reference,
Based on the target text address recorded by the reference text address detection unit, the target text address for the profiler is converted to the corresponding target text address by referring to the map table, and the difference between the target text address for the profiler and the original target text address is calculated. 3. The method according to claim 2, wherein the new target address is updated to an instruction code.
JP7296167A 1995-10-19 1995-10-19 Code addition method for profiler Expired - Fee Related JP2795309B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP7296167A JP2795309B2 (en) 1995-10-19 1995-10-19 Code addition method for profiler

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP7296167A JP2795309B2 (en) 1995-10-19 1995-10-19 Code addition method for profiler

Publications (2)

Publication Number Publication Date
JPH09114696A JPH09114696A (en) 1997-05-02
JP2795309B2 true JP2795309B2 (en) 1998-09-10

Family

ID=17830034

Family Applications (1)

Application Number Title Priority Date Filing Date
JP7296167A Expired - Fee Related JP2795309B2 (en) 1995-10-19 1995-10-19 Code addition method for profiler

Country Status (1)

Country Link
JP (1) JP2795309B2 (en)

Also Published As

Publication number Publication date
JPH09114696A (en) 1997-05-02

Similar Documents

Publication Publication Date Title
US5987250A (en) Transparent instrumentation for computer program behavior analysis
EP0591360B1 (en) Method and apparatus for modifying relocatable object code files
US6286132B1 (en) Debugging support apparatus, a parallel execution information generation device, a computer-readable recording medium storing a debugging support program, and a computer-readable recording medium storing a parallel execution information generation program
US8381194B2 (en) Methods and apparatuses for selective code coverage
US20080127113A1 (en) Method and system for implementing watchpoints
EP1012722A1 (en) Accurate profile and timing information for multitasking systems
KR20060044639A (en) Methods and systems for detecting potential races in multithreaded programs
US5862382A (en) Program analysis system and program analysis method
JP3699154B2 (en) Method and apparatus for self-describing encoding of data
JPH06324881A (en) Compiler device with memory data overlap judgment function
US7086033B2 (en) Software debugger having a monitor for monitoring conditional statements within a software program
US7698690B2 (en) Identifying code that wastes time performing redundant computation
CN116340081B (en) RISCV memory access violation detection method and device based on hardware virtualization
US20020129336A1 (en) Automatic symbol table selection in a multi-cell environment
JP2795309B2 (en) Code addition method for profiler
JP4503203B2 (en) Method and apparatus for creating test program for evaluating information processing apparatus, and program describing processing for the same
Vitovská Instrumentation of LLVM IR
JP4860564B2 (en) Program profiling apparatus, program profiling method, and program
JP2004287858A (en) Program test equipment
JP3011115B2 (en) Debug system
JPH0784797A (en) Method and apparatus for registering source code line number in load module
JP3728368B2 (en) Resource conflict check device, assemble device, link device, instruction pipeline simulation device, resource conflict check method, and medium on which resource conflict check program is recorded
JP2662533B2 (en) Logic analyzer
JP2000242529A (en) Program development support device, development support system, and recording medium
JP2002189613A (en) Software development support apparatus, software development support method, and computer-readable recording medium storing software development support program

Legal Events

Date Code Title Description
LAPS Cancellation because of no payment of annual fees