JP5572619B2 - Computer for calculating the number of trace information, method for calculating the number of trace information, and program for calculating the number of trace information - Google Patents
Computer for calculating the number of trace information, method for calculating the number of trace information, and program for calculating the number of trace information Download PDFInfo
- Publication number
- JP5572619B2 JP5572619B2 JP2011264227A JP2011264227A JP5572619B2 JP 5572619 B2 JP5572619 B2 JP 5572619B2 JP 2011264227 A JP2011264227 A JP 2011264227A JP 2011264227 A JP2011264227 A JP 2011264227A JP 5572619 B2 JP5572619 B2 JP 5572619B2
- Authority
- JP
- Japan
- Prior art keywords
- program
- trace information
- computer
- execution
- node
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
Description
本発明は、トレーサによって取得するトレース情報の数を算出する計算機、トレーサによって取得するトレース情報の数を算出する方法及びトレーサによって取得するトレース情報の数を算出させるプログラムに関する。 The present invention relates to a computer for calculating the number of trace information acquired by a tracer, a method for calculating the number of trace information acquired by the tracer, and a program for calculating the number of trace information acquired by the tracer.
企業で使用される計算機システムには、高い信頼性が求められているため、何らかの障害が発生した場合、システム保守担当者は迅速にその障害からシステムを回復させなければならない。そのため、システム保守担当者は、プログラムの構造やプログラム実行時の挙動を把握するための支援ツールであるプログラムトレーサ(以下、「トレーサ」という。)を使用し、プログラム実行における障害箇所を即時に発見している。トレーサは、実行プログラムにおけるメソッドの呼出し情報をトレースファイルとして出力するため、その出力されたトレース情報を解析することにより、障害発生を再現せずとも障害発生過程を把握することができる。 A computer system used in a company is required to have high reliability. Therefore, when a failure occurs, a system maintenance person must quickly recover the system from the failure. For this reason, system maintenance personnel use program tracer (hereinafter referred to as “tracer”), which is a support tool for grasping the program structure and behavior during program execution, to instantly find the faulty part in program execution. doing. Since the tracer outputs method call information in the execution program as a trace file, by analyzing the output trace information, it is possible to grasp the failure occurrence process without reproducing the failure occurrence.
特許文献1に開示されているトレース情報の取得方法のように、サンプリングを用い、取得するトレース情報を間引くことによってオーバヘッドを低減する手法が存在する。しかしながら、障害解析では正確なプログラム実行経路を取得する必要があるため、サンプリングを適用するには好ましくない。また、別のオーバヘッド対策として、トレーサ内部にトレース情報を一時的に保持するバッファを用意する手法がある。この手法ではメモリ上のバッファにキャッシュすることによって、ファイルなどへの外部出力を軽減できるため、オーバヘッドを削減することができる。しかし、トレース対象となるプログラムのトレース情報がバッファのサイズを超えた場合、外部出力を行うか、もしくは取得情報の一部を上書きする必要があり、前者の場合は高オーバヘッド、後者の場合は情報損失という問題が発生する。
As in the trace information acquisition method disclosed in
上記の問題を解決する方法として、特許文献2には、マルチタスク環境で動作する通信制御プログラムを一例とするアプリケーションプログラムを実行する際に用いられるバッファのバッファサイズを調整する技術が開示されている。特許文献2には、アプリケーションプログラムを実行する際、プログラムの実行パターンと割り当てたバッファサイズとを記録し、記録した実行パターンが再度出現したとき、それに対応するサイズのバッファを割り当てる技術が開示されている。
As a method for solving the above problem,
特許文献2に開示された技術は、通常の運用時のようにプログラムの実行パターンが繰り返し現れる場合、そのプログラムを一度実行した後であれば、プログラム実行1回あたりに取得されるトレース情報の数を求めることができる。しかし、システム障害が発生した場合、通常とは異なるプログラムの実行パターンが現れるため、プログラム実行1回あたりに取得されるトレース情報の数は求めることはできない。また、取得されるトレース情報の数をプログラム実行前に求めることはできないため、トレース情報を格納するために必要なバッファのサイズを予め決定しておくことは困難である。
In the technique disclosed in
本発明の代表的な一形態によれば、トレーサによって取得するトレース情報の数を算出する計算機であって、前記計算機は、プログラムの流れを制御する要素を特定する制御部を有し、前記制御部は、前記プログラムの実行前に前記要素の数を特定し、前記特定した要素の数を基に、取得するトレース情報の数を算出することを特徴とする。 According to a representative aspect of the present invention, a computer that calculates the number of trace information acquired by a tracer, the computer having a control unit that identifies an element that controls a flow of a program, the control The unit specifies the number of elements before execution of the program, and calculates the number of pieces of trace information to be acquired based on the specified number of elements.
本発明によれば、トレーサによって取得するトレース情報の数を、プログラムを実行する前に算出することができる。 According to the present invention, the number of pieces of trace information acquired by the tracer can be calculated before executing the program.
[第1の実施形態]
本発明を適用した計算機システムの第1の実施形態では、プログラムの障害解析に用いるトレーサにおいて、対象システム上のプログラム1回の実行で実行され得るプログラム構成要素の数をソースプログラム及びバイナリから求めるための方法を説明する。ここで、プログラム構成要素とは、プログラムの流れを制御する要素である。具体的には、メソッド、ループ、条件分岐、再帰、引数・返り値及びローカル変数等の変数アクセスを指す。なお、本実施形態はJava(登録商標)で記述されたシステムを対象として説明するが、他の言語で記述されたシステムに対しても有効である。また、以下の記述において、単にプログラムという場合、Javaのバイトコード(バイナリ)を指すこととする。ただし、プログラムの具体例を用いて説明する場合においては、説明の容易化のためプログラムをソースコードの形式で表現している。
[First Embodiment]
In the first embodiment of the computer system to which the present invention is applied, in the tracer used for program failure analysis, the number of program components that can be executed in one execution of the program on the target system is obtained from the source program and binary. The method will be described. Here, the program component is an element that controls the flow of the program. Specifically, it refers to variable access such as method, loop, conditional branch, recursion, argument / return value, and local variable. Although this embodiment will be described for a system described in Java (registered trademark), it is also effective for systems described in other languages. Further, in the following description, the term “program” refers to Java bytecode (binary). However, in the case of description using a specific example of the program, the program is expressed in the form of source code for easy explanation.
一般に、トレース対象のプログラム中にあるループ及び再帰内では、メソッドの呼出しをはじめとするプログラム構成要素の実行が著しく多くなってしまう。そのため、ループ及び再帰中の全てのプログラム構成要素に関する情報を取得するには、バッファサイズも取得数に比例して確保する必要があり、メモリを枯渇させる虞やメモリを計画的に使用することができない虞がある。 In general, in a loop and recursion in a program to be traced, the execution of program components such as method calls is remarkably increased. For this reason, in order to obtain information on all program components in the loop and recursion, it is necessary to secure the buffer size in proportion to the number of acquisitions. There is a possibility that it cannot be done.
本実施形態では、トレース対象のJavaプログラムからプログラム構成要素ツリーを生成する。そして、プログラム構成要素ツリーを元に、プログラム実行1回あたりのプログラム構成要素数を求め、トレース情報を格納するバッファのサイズを算出する。また、ループや再帰処理内部で障害が発生したとしても、障害を再現することなく障害発生原因を特定するために必要な、「ループや再帰が実行された履歴」、「ループや再帰の繰り返し回数」及び「繰り返しを構成する要素群の最終実行履歴」のみをバッファに格納する。これにより、プログラムにループや再帰の実行があったとしても、そのループや再帰の実行に伴う全てのトレース情報を取得する必要はないため、メモリの枯渇を生じさせることなく、メモリを計画的に使用することができる。 In the present embodiment, a program component tree is generated from a Java program to be traced. Then, based on the program component tree, the number of program components per program execution is obtained, and the size of the buffer storing the trace information is calculated. In addition, even if a failure occurs in the loop or recursion process, the "History of loop or recursion execution" or "Loop or recursion repeat count" required to identify the cause of the failure without reproducing the failure. "And" Last execution history of element group constituting repetition "are stored in the buffer. As a result, even if a loop or recursion is executed in the program, it is not necessary to acquire all trace information associated with the execution of the loop or recursion. Can be used.
以降では、図面を用いて本実施形態の構成及び処理の流れを詳細に説明する。
図1は、本発明を適用した第1の実施形態である計算機101の全体構成を示す。
計算機101は、CPU102とメモリ103とを有する。CPU102はJava仮想マシン104を実行する。Java仮想マシン104は、プログラム読込部105、静的解析データ生成部106、静的解析データ読込部107、バッファサイズ計算部108、プログラム書換部109、プログラム実行部110、トレース情報取得部111及びトレース情報出力部112を含む。上記の機能部は、CPU102と、プログラム113とが協働することにより実現される。
メモリ103は、プログラム113、拡張プログラム114、静的解析データ115及びトレース情報117を保持するバッファ116を有する。なお、プログラム113、拡張プログラム114、静的解析データ115はメモリ103上ではなく、外部記憶装置118に格納されていることもある。また、本実施形態では、メモリ103内にバッファ116を設けることとして説明するが、バッファ116をCPU102に設ける構成でもよい。
Hereinafter, the configuration and processing flow of the present embodiment will be described in detail with reference to the drawings.
FIG. 1 shows the overall configuration of a
The
The
プログラム読込部105は、メモリ103に格納されたプログラム113を読込む。
静的解析データ生成部106は、読込んだプログラム113の静的解析データ115を生成する。なお、静的解析データ115は、プログラム構成要素の実行順序を示す情報である。本実施形態では、プログラム構成要素をノードとしたツリー(以下、「プログラム構成要素ツリー」という。)で、静的解析データ115を構成するものとする。
静的解析データ読込部107は、静的解析データ生成部106で生成された静的解析データ115をメモリ103上から読込む。
バッファサイズ計算部108は、読込んだ静的解析データ115からバッファサイズを計算し、計算したバッファサイズのバッファ116をメモリ103上に生成する。
プログラム書換部109は、プログラム113にトレース情報117を取得するためのプローブを挿入し、プローブを挿入した拡張プログラム114をメモリ103に配置する。
プログラム実行部110は、拡張プログラム114をメモリ103から読込み、実行する。
トレース情報取得部111は、実行した拡張プログラム114からトレース情報117を取得し、取得したトレース情報117をバッファ116に格納する。
トレース情報出力部112は、バッファ116に格納したトレース情報117を外部記憶装置118に出力する。トレース情報117は、プログラム113を実行する度に取得されるため、取得済みのトレース情報117を外部記憶装置118に出力することで、バッファ116の使用量やメモリ103の負荷を低減することができる。
The
The static analysis
The static analysis
The buffer size calculation unit 108 calculates a buffer size from the read
The
The
The trace
The trace information output unit 112 outputs the
図2は、本実施形態の計算機101で実行する処理全体の流れを示すフローチャートである。
はじめに、S201で、プログラム読込部105が、メモリ103上に格納されているプログラム113を読込む。
次に、S202で、静的解析データ生成部106が、静的解析データ115が未生成であるか否かを確認する。静的解析データ115が未生成である場合(S202:Yes)、S203で、静的解析データ生成部106が、メモリ103上にあるプログラム113から静的解析データ115を生成し、メモリ103に配置する(静的解析データ生成処理)。静的解析データ115が生成済みである場合(S202:No)、S204で、静的解析データ読込部107が、メモリ103上から静的解析データ115を読込む(静的解析データ読込処理)。
次に、S205で、バッファサイズ計算部108が、静的解析データ115を基にバッファサイズを計算し、メモリ103上に計算したバッファサイズのバッファ116を生成する(バッファサイズ計算処理)。
次に、S206で、プログラム書換部109が、読込んだプログラム113にトレース情報117を取得するためのプローブを挿入し、プローブ挿入済みのプログラムを拡張プログラム114としてメモリ103に配置する(プログラム書換処理)。
次に、S207で、プログラム実行部110が、拡張プログラム114をメモリ103から読込み、読込んだ拡張プログラム114を実行しながらトレース情報117を取得する(プログラム実行処理)。このとき、取得したトレース情報117に障害発生しているか否かを確認する。なお、障害発生とは、Java仮想マシン104やJava仮想マシン104上で動作しているスレッド(Javaスレッド)が不正終了するような障害、任意もしくは特定の例外が発生する障害及び結果的に不正が発生する障害のことを指す。
次に、S208で、トレース情報取得部111が、取得したトレース情報117を、バッファ116に格納する(トレース情報取得処理)。
最後に、S209で、トレース情報出力部112が、システムの障害発生等を契機に、バッファ116に格納したトレース情報117を画面や外部出力デバイス(不図示)に出力する(トレース情報出力処理)。
FIG. 2 is a flowchart showing the overall flow of processing executed by the
First, in S <b> 201, the
Next, in S202, the static analysis
In step S <b> 205, the buffer size calculation unit 108 calculates the buffer size based on the
Next, in S206, the
Next, in S207, the
Next, in S208, the trace
Finally, in S209, the trace information output unit 112 outputs the
以下、図2に示した各処理について、より詳細に説明する。
図3は、静的解析データ生成部106が行う静的解析データ生成処理(図2のS203)の処理の流れを示すフローチャートを示す。静的解析データ生成処理は、プログラム113を元にプログラム構成要素ツリーを生成する。なお、プログラム構成要素ツリーでは、プログラム構成要素をノードとして扱う。また、ループや条件分岐等のボディ部(ループや条件分岐内における実処理部分)に存在する構成要素は、それらを内包する構成要素(ループノード、条件分岐ノード、再帰ノード)を親ノードとする子ノードとして扱う。
Hereinafter, each process shown in FIG. 2 will be described in more detail.
FIG. 3 is a flowchart showing the flow of the static analysis data generation process (S203 in FIG. 2) performed by the static analysis
はじめに、S301で、トレース対象のプログラム113に対して制御フロー解析を実行する。制御フロー解析とは、プログラム113を実行したときのプログラムの流れを、プログラム構成要素単位で抽出することをいう。
次に、S302で、プログラム113から始点メソッドを探索し、探索した始点メソッドに対応するノードを生成する。始点メソッドはJavaでいうmainメソッド、スレッドプログラミングのrunメソッド、サーブレットのdoGetメソッド等の処理の始点となるメソッドとする。なお、始点メソッドはユーザが任意で指定することもできる。
次に、S303で、生成したノードをカレントノードに設定する。カレントノードとは、プログラム構成要素ツリーに子ノードを追加する際の親ノードを意味する。
次に、S304で、設定したカレントノードに属するプログラム内から子ノードとなる次のプログラム構成要素を探す。
次に、S305で、探索したプログラム構成要素が、カレントノードに対応するプログラム構成要素の最後かどうかを確認する。すなわち、親ノードがメソッドノードなら、メソッドを構成する最終要素、ループノードならループボディを構成する最終要素であるかを確認する。
First, in S301, a control flow analysis is executed for the
Next, in S302, a start point method is searched from the
Next, in S303, the generated node is set as the current node. The current node means a parent node when a child node is added to the program component tree.
Next, in S304, the next program component that becomes a child node is searched for in the program belonging to the set current node.
In step S305, it is checked whether the searched program component is the last program component corresponding to the current node. That is, if the parent node is a method node, it is confirmed whether it is the last element constituting the method, and if it is a loop node, it is the last element constituting the loop body.
ここで、設定したカレントノードに対応するプログラム構成要素の最後でない場合(S305:No)、S306で、S301で抽出したプログラム構成要素を制御フロー順に読込む。
そして、S307で、読込んだプログラム構成要素が、ノード生成対象であるかを確認する。ここで、ノード生成対象である場合(S307:Yes)、S308で、ノード生成処理を行う。ノード生成対象でない場合(S307:No)、S305に戻る(ノード生成処理)。
次に、S309で、現在のカレントノードから生成した新しいノードにカレントノードの変更を行う(カレントノード変更処理)。そして、S305に戻りカレントノードに対応するプログラム構成要素の最後かどうかを確認する。
If it is not the last program component corresponding to the set current node (S305: No), the program component extracted in S301 is read in the order of control flow in S306.
In step S307, it is confirmed whether the read program component is a node generation target. Here, if it is a node generation target (S307: Yes), node generation processing is performed in S308. If it is not a node generation target (S307: No), the process returns to S305 (node generation processing).
Next, in S309, the current node is changed to a new node generated from the current current node (current node changing process). Then, the process returns to S305 to check whether it is the last program component corresponding to the current node.
一方、設定したカレントノードがプログラム構成要素の最後である場合(S305:Yes)、S310で、そのカレントノードが始点メソッドのプログラム構成要素の最後であるかを確認する。
カレントノードが、始点メソッドのプログラム構成要素の最後でない場合(S310:No)、S311で、現在カレントノードとして設定されているカレントノードを親ノードに設定する(カレントノード復元処理)。
他方、カレントノードが、始点メソッドのプログラム構成要素の最後である場合(S310:Yes)、S312で、生成したプログラム構成要素ツリーを静的解析データ115として、メモリ103に出力しノード生成処理を終了する。
On the other hand, if the set current node is the last program component (S305: Yes), it is checked in S310 whether the current node is the last program component of the start method.
If the current node is not the last program component of the start point method (S310: No), the current node currently set as the current node is set as the parent node in S311 (current node restoration process).
On the other hand, if the current node is the last program component of the start method (S310: Yes), the generated program component tree is output to the
以上の静的解析データ生成処理について、具体例を用いてさらに詳細に説明する。図4Aに、計算機で実行されるプログラム113の一例として、プログラム401を示す。また、図4Bに、図4Aで示したプログラム401にノード生成処理を実行した場合のプログラム構成要素ツリーを示す。
まず、プログラム401について、制御フロー解析を行う(図3のS301)。そして、プログラム401からプログラムの始点メソッドであるmainメソッド402を探索し、mainメソッド402のノード405を生成する(S302)。次いで、ノード405をカレントノードに設定し(S303)、mainメソッド402内の次のプログラム構成要素を探す(S304)。その結果、mainメソッド402内のmethodA403のプログラム構成要素を抽出し、methodA403はプログラム構成要素の最後ではなく(S305:No)、さらにノード生成対象のプログラムであるため(S307:Yes)、methodA403のノード406を生成する(S308)。そして、カレントノード変更処理を行い(S309)、methodA403内の次のプログラム構成要素としてmethodB404を抽出し、methodB404のノード408を生成する。
The static analysis data generation process described above will be described in more detail using a specific example. FIG. 4A shows a
First, a control flow analysis is performed on the program 401 (S301 in FIG. 3). Then, the
図5は、静的解析データ生成部106が行うノード生成処理(図3のS308)の処理の流れを示すフローチャートを示す。ノード生成処理は、図3のS308でノード生成対象と判断されたノード(メソッドノード、再帰ノード、ループノード及び条件分岐ノード等)を生成する。なお、プログラム構成要素の判定には、図3のS301で得た制御フロー解析の結果を用いる。
はじめに、S501で、ノード生成対象のプログラム構成要素がメソッドを呼出すプログラム構成要素であるか否かを確認する。メソッドを呼出すプログラム構成要素である場合(S501:Yes)、S502で、そのプログラム構成要素が再帰メソッドであるか否かを判断する。そして、再帰メソッドである場合(S502:Yes)、S503で、再帰メソッドノードを生成する。再帰メソッドでない場合(S502:No)、S504で、メソッドノードを生成する。
FIG. 5 is a flowchart showing a process flow of the node generation process (S308 in FIG. 3) performed by the static analysis
First, in S501, it is confirmed whether or not the program component that is a node generation target is a program component that calls a method. If it is a program component that calls a method (S501: Yes), in S502, it is determined whether or not the program component is a recursive method. If the method is a recursive method (S502: Yes), a recursive method node is generated in S503. If it is not a recursive method (S502: No), a method node is generated in S504.
例えば、図6Aは、再帰メソッド602を含むプログラム601を示す。プログラム601のプログラム構成要素ツリーは、図6Bの603あるいは608のように表現される。methodBは602のように自分自身のメソッドを呼び出す再帰メソッドであり、プログラム構成要素ツリー603のノード606として表現される。また、ノード606内に示す数字は再帰ノードに一意に割り当てられる再帰IDである。また、再帰メソッドは、プログラム構成要素ツリー608の再帰ノード611のように1つのノードとして扱ってもよい。なお、図7Aに示すプログラム701のように、複数メソッドにまたがる再帰呼出しの場合、プログラム構成要素ツリーは図7Bで表現される。
For example, FIG. 6A shows a
次に、ノード生成対象のプログラム構成要素がメソッドを呼出すプログラム構成要素でない場合(S501:No)、S505で、そのプログラム構成要素がループを示すプログラム構成要素であるか否かを判断する。そして、ループを示すプログラム構成要素である場合(S505:Yes)、S506で、ループノードを生成する。 Next, when the program component that is a node generation target is not a program component that calls a method (S501: No), in S505, it is determined whether or not the program component is a program component that indicates a loop. If it is a program component indicating a loop (S505: Yes), a loop node is generated in S506.
例えば、図8Aに示すループを含むプログラム801に対するプログラム構成要素ツリーは、図8Bで示される。ループを示す802部分は、ループノードとして図8Bのforループノード807として示される。なお、forループノード807内の数字はループIDを表す。また、803及び804で示すループ内のメソッド呼出し群は、forループノード807の子ノード808及び809として示される。なお、図8は、forループのみの記載について例示しているが、whileループ、do whileループにおいても、forループと同様に、それぞれwhileループノード、do whileループノードと示しても良い。
For example, a program component tree for
次に、ノード生成対象のプログラム構成要素がループを示すプログラム構成要素でない場合(S505:No)、S507で、そのプログラム構成要素が条件分岐を示すプログラム構成要素であるか否かを判断する。条件分岐を示すプログラム構成要素である場合(S507:Yes)、S508で、条件分岐ノードを生成する。条件分岐を示すプログラム構成要素でない場合(S507:No)、ノード生成処理を終了する。 Next, when the program component to be generated is not a program component indicating a loop (S505: No), it is determined in S507 whether the program component is a program component indicating a conditional branch. If it is a program component indicating a conditional branch (S507: Yes), a conditional branch node is generated in S508. If it is not a program component indicating a conditional branch (S507: No), the node generation process is terminated.
例えば、図9Aに示す条件分岐を含むプログラム901のプログラム構成要素ツリーは、図9Bで示される。なお、902及び903の条件分岐を示す部分は、プログラム構成要素ツリー上では条件分岐ノード906及び909で表現される。なお、903のelse if文は902のif文で生成した条件分岐ノード906の子ノードとして表現され、904のelse文は903のelse if文で生成した条件分岐ノード909の子ノードとして表現される。また、906及び909の条件分岐ノード内の数字は条件分岐IDを表す。
For example, the program component tree of the
図10は、静的解析データ生成部106が行うカレントノード変更処理(図3のS309)の処理の流れを示すフローチャートを示す。カレントノード変更処理は、ノード生成処理(図3のS308)で生成した各ノードを、順にカレントノードに設定する。
はじめに、S1001で、ノード生成処理(図3のS308)で生成したノードがメソッドノードであるか否かを確認する。
生成したノードが、メソッドノードである場合(S1001:Yes)、S1002で、次に読み込む構成要素の位置を呼出し先メソッドの先頭とする。
そして、S1003で、ノード生成処理で生成したノードをカレントノードに設定し、カレントノード変更処理を終了する。
また、生成したノードが、メソッドノードでない場合(S1001:No)、S1003を実行し、カレントノード変更処理を終了する。
FIG. 10 is a flowchart showing the flow of the current node change process (S309 in FIG. 3) performed by the static analysis
First, in S1001, it is confirmed whether or not the node generated in the node generation process (S308 in FIG. 3) is a method node.
If the generated node is a method node (S1001: Yes), in S1002, the position of the component to be read next is set as the head of the call destination method.
In step S1003, the node generated by the node generation process is set as the current node, and the current node change process ends.
If the generated node is not a method node (S1001: No), S1003 is executed, and the current node change process is terminated.
図11は、静的解析データ生成部106が行うカレントノード復元処理(図3のS312)の処理の流れを示すフローチャートを示す。カレントノード復元処理は、カレントノードをカレントノードの親ノードに設定する。
はじめに、S1101で、プログラム構成要素の最後がメソッドであるか否かを確認する。プログラム構成要素の最後がメソッドである場合(S1101:Yes)、S1102で、プログラム113中のメソッドの呼出し元がある箇所に移動し、カレントノード復元処理を再開する。
そして、S1103で、現在カレントノードとして設定しているノードをカレントノードの親ノードに設定し、カレントノード復元処理を終了する。
また、プログラム構成要素の最後がメソッドでない場合(S1101:No)、S1103を実行しカレントノード復元処理を終了する。
以上が、静的解析データ生成処理の流れである。
FIG. 11 is a flowchart showing the flow of the current node restoration process (S312 in FIG. 3) performed by the static analysis
First, in S1101, it is confirmed whether or not the last program component is a method. If the last program component is a method (S1101: Yes), in S1102, the method is moved to a location where the method call source is located in the
In step S1103, the node currently set as the current node is set as the parent node of the current node, and the current node restoration process is terminated.
If the last program component is not a method (S1101: No), S1103 is executed and the current node restoration process is terminated.
The above is the flow of the static analysis data generation process.
次いで、図12にバッファサイズ計算処理の流れを示すフローチャートを示す。バッファサイズ計算処理は、静的解析データ115中のプログラム構成要素ツリーのノード数に基づいてバッファサイズを算出し、求めたバッファサイズのバッファ116を確保する。
はじめに、S1201で、静的解析データ115からプログラム構成要素ツリーの総ノード数を取得する。例えば、図9Bに示すプログラム構成要素ツリーの総ノード数は905〜912の8である。
次に、S1202で、総ノード数をもとにバッファサイズを算出する。なお、本実施形態では、バッファサイズを、「バッファサイズ=プログラム構成要素ツリーの総ノード数×1プログラム構成要素分のトレース情報を取得するのに必要なバッファサイズ」より求めるものとする。
次に、S1203で、メモリ103に算出したバッファサイズのバッファ領域をバッファ116として確保する。
FIG. 12 is a flowchart showing the flow of the buffer size calculation process. In the buffer size calculation process, the buffer size is calculated based on the number of nodes of the program component tree in the
First, in S1201, the total number of nodes in the program component tree is acquired from the
In step S1202, the buffer size is calculated based on the total number of nodes. In this embodiment, the buffer size is obtained from “buffer size = total number of nodes in the program component tree × buffer size necessary to acquire trace information for one program component”.
In step S <b> 1203, a buffer area having the buffer size calculated in the
なお、本実施形態では、メソッドの階層的な呼出し関係を把握するために、メソッドの開始時と終了時にトレース情報117を取得するものとするが、どのタイミングでトレース情報117を取得するかは、ユーザが指定することができる。また、本実施形態では、条件分岐、ループ及び再帰に関しても、メソッドの場合と同様に各要素の開始及び終了時にトレース情報117を取得するものとする。
In this embodiment, in order to grasp the hierarchical calling relationship of methods, the
そして、本実施形態では、1プログラム構成要素分の情報を取得するのに必要なバッファサイズを2とする。例えば、図9Bで示されるプログラム構成要素ツリーの総ノード数は、前述のように8であるため、図9Aのプログラム901の実行により取得するトレース情報117を格納するために必要なバッファサイズは、8×2=16と算出される。また、このバッファサイズはトレーサが保持する配列の長さであり、プログラム901の場合、メモリ103上のバッファ116は配列長16の配列となる。
なお、本実施形態では、1プログラム構成要素分のトレース情報117を取得するために必要なバッファサイズを2としているが、バッファサイズはトレース情報117を格納するバッファ116の仕様によってユーザが適宜指定することができる。
In this embodiment, the buffer size required to acquire information for one program component is set to 2. For example, since the total number of nodes in the program component tree shown in FIG. 9B is 8, as described above, the buffer size required to store the
In the present embodiment, the buffer size necessary to acquire the
図13は、プログラム書換部109が行うプログラム書換処理(図2のS206)の処理の流れを示すフローチャートを示す。プログラム書換処理は、プログラム読込処理(図2のS201)で読込んだプログラム113のトレース情報117を取得するために、プログラム113にプローブを挿入する。なお、本実施形態では、Javaが持つBytecode Instrumentation機能を用いて、トレーサで取得する各イベントに該当するバイトコードの前後にイベントを取得するためのプローブを挿入する。
FIG. 13 is a flowchart showing the flow of the program rewriting process (S206 in FIG. 2) performed by the
はじめに、S1301で、メモリ103上のプログラム113に読込むクラスがあるか否かを確認する。ここでいうクラスとは、Javaソースコードから生成したバイトコード群(バイナリ)とする。読込むクラスがある場合(S1301:Yes)、S1302で、メモリ103上のプログラム113からクラスを読込む。
次に、S1303で、読込んだクラスがプログラム書換え対象のクラスか否かを確認する。読込んだクラスが書換え対象である場合(S1303:Yes)、S1304に進む。書換え対象のメソッドがない場合(S1303:No)、S1301に戻る。
次に、S1304で、書換え対象のメソッドがあるか否かを確認する。書換え対象のメソッドがある場合(S1304:Yes)、S1305で、再帰関連、メソッド関連、ループ関連及び条件分岐関連の各ノードに対応するイベント取得用プローブを挿入する。書換え対象のメソッドがない場合(S1304:No)、S1301に戻る。
そして、S1301で読込むクラスがない場合(S1301:No)、S1306で、書換えたプログラムを拡張プログラム114としてメモリ103に出力し、プログラム書換処理を終了する。
First, in S1301, it is confirmed whether or not there is a class to be read in the
In step S1303, it is checked whether the read class is a class to be rewritten. If the read class is the target of rewriting (S1303: Yes), the process proceeds to S1304. If there is no method to be rewritten (S1303: No), the process returns to S1301.
In step S1304, it is confirmed whether there is a method to be rewritten. When there is a method to be rewritten (S1304: Yes), in S1305, an event acquisition probe corresponding to each node related to recursion, method, loop, and conditional branch is inserted. If there is no method to be rewritten (S1304: No), the process returns to S1301.
If there is no class to be read in S1301 (S1301: No), the rewritten program is output to the
なお、本実施形態で取得するイベントは、「メソッドの開始・終了」、「再帰の開始・終了」、「ループの開始・終了」及び「条件分岐の開始・終了」であるとする。図14に、プログラム1401に、「メソッドの開始・終了」、「再帰の開始・終了」、「ループの開始・終了」のプローブを挿入したイメージを示し、図15に「条件分岐の開始・終了」のプローブを挿入したイメージを示す。
The events acquired in this embodiment are assumed to be “method start / end”, “recursion start / end”, “loop start / end”, and “conditional branch start / end”. 14 shows an image in which probes of “method start / end”, “recursion start / end”, and “loop start / end” are inserted in the
代表して、図15に示すプローブ挿入後のイメージについて詳細に説明する。
methodEntry 1502は、メソッドの開始イベントを取得するためのプローブである。methodEntry 1502を用いることで、メソッド固有のIDを取得し、どのメソッドが開始したかを把握することができる。なお、methodEntry 1502はメソッドの処理の先頭に挿入する。
ifEntry 1503は、条件分岐の開始イベントを取得するためのプローブである。ifEntry 1503を用いることで、条件分岐固有のIDと条件分岐が保持する条件とを取得し、どの条件分岐が開始したかを把握することができる。なお、ifEntry 1503は条件分岐の処理の先頭に挿入する。
As a representative, the image after the probe insertion shown in FIG. 15 will be described in detail.
A
The
recursiveEntry 1504は、再帰の開始イベントを取得するためのプローブである。recursiveEntry 1504を用いることで、再帰固有のIDと再帰の繰り返し回数とを取得し、どの再帰が何回繰り返し実行されたのかを把握することができる。なお、recursiveEntry 1504は、再帰メソッドの処理の先頭に挿入する。
recursiveExit 1505は、再帰の終了イベントを取得するためのプローブである。recursiveExit 1505を用いることで、再帰固有のIDを取得し、どの再帰が実行終了したかを把握することができる。なお、recursiveExit 1505は、再帰処理終了直後に挿入する。
The
The
forLoopEntry 1506は、ループ(forループ)の開始イベントを取得するためのプローブである。forLoopEntry 1506を用いることで、ループ固有のIDとループの繰り返し回数とを取得し、どのループが何回繰り返し実行されたかを把握することができる。なお、forLoopEntry 1506はループ内の繰り返し処理の先頭に挿入する。また、このforLoopEntry 1506は何度も実行される。これは、forLoopEntry 1506の実行により、繰り返し回数を把握するためである。
forLoopExit 1507は、forループの終了イベントを取得するためのプローブである。forLoopExit 1507を用いることで、ループ固有のIDを取得し、どのループが実行終了したかを把握することができる。なお、forLoopExit 1507は、ループ処理終了直後に挿入する。
The forLoopEntry 1506 is a probe for acquiring a start event of a loop (for loop). By using forLoopEntry 1506, it is possible to acquire a loop-specific ID and the number of loop repetitions, and to know which loop has been repeatedly executed. The forLoopEntry 1506 is inserted at the beginning of the iterative process in the loop. The forLoopEntry 1506 is executed many times. This is because the number of repetitions is grasped by executing forLoopEntry 1506.
The
methodExit 1508は、メソッドの終了イベントを取得するためのプローブである。methodExit 1508を用いることで、メソッド固有のIDを取得し、どのメソッドが終了したかを把握することができる。なお、methodExit 1508は、メソッド内の処理の最後に挿入する。
ifExit 1509は、条件分岐の終了イベントを取得するためのプローブである。ifExit 1509を用いることで、条件分岐固有のIDを取得し、どの条件分岐が終了したかを把握することができる。なお、ifExit 1509は条件分岐の最後に挿入する。
A
The
また、1504及び1506にプローブの引数として記載されているcount1及びcount2は、ループあるいは再帰の繰り返し回数を表している変数であり、ループあるいは再帰の開始イベントを検出する度に1ずつ増加する。なお、上記のcount1及びcount2の繰り返し回数は、ループID及び再帰IDにつき一つ割り当てられる。 In addition, count1 and count2 described as probe arguments in 1504 and 1506 are variables indicating the number of loop or recursion iterations, and increase by 1 each time a loop or recursion start event is detected. The number of repetitions of count1 and count2 is assigned to each loop ID and recursion ID.
また、本実施形態では、1506及び1507のループに関するプローブをforループに限定して記述しているが、whileループあるいはdo whileループに対してwhileLoopEntryあるいはdoWhileLoopEntryのプローブといったforループ同様のプローブを設定しても良い。
そして、本実施形態では、各プローブの取得項目に関しても、取得項目を限定した記載となっているが、イベントの発生時間などの付加情報を取得してもよい。また、取得するイベントについても、上記した「メソッドの開始・終了」、「再帰の開始・終了」、「ループの開始・終了」及び「条件分岐の開始・終了」の8つのイベントに限定しているが、引数・返り値などの変数の取得・変更イベントなどのイベントを対象としても良い。
In this embodiment, the probes related to the
In the present embodiment, the acquisition items of each probe are also described with limited acquisition items, but additional information such as the occurrence time of an event may be acquired. Also, the events to be acquired are limited to the above-mentioned eight events of “method start / end”, “recursion start / end”, “loop start / end”, and “condition branch start / end”. However, it is also possible to target events such as acquisition / change events of variables such as arguments and return values.
以上で説明したプログラム書換処理により、プローブを挿入したプログラム113を拡張プログラム114に書換える。また、拡張プログラム114は、生成後メモリ103に格納される。なお、このプログラム書換処理は、パッケージ名やクラス名などのユーザ指定がある場合、プログラム113全てに対して実施する必要はなく、指定されたメソッドに対してのみ実施してもよい。
The
図16は、トレース情報取得部111が行うトレース情報取得処理(図2のS208)の処理の流れを示すフローチャートである。トレース情報取得処理では、拡張プログラム114を実行することで得たトレース情報117をメモリ103上のバッファ116に格納する。
はじめに、S1601で、プローブを埋め込んだ拡張プログラム114を実行し、トレース情報117を取得する。
つぎに、S1602で、取得したトレース情報117が、ループの開始あるいは再帰の開始であるか否かを確認する。トレース情報117がループの開始あるいは再帰の開始である場合(S1602:Yes)、S1603で、ループあるいは再帰による繰り返し処理を初期化するために、ループあるいは再帰開始以降のトレース情報117をバッファ116から削除する。なお、初期化オーバヘッドが大きい場合、次のトレース情報117の格納位置を示すポインタを、ループノードもしくは再帰ノードの位置に戻してデータを上書きするようにしてもよい。
次に、S1604で、ループあるいは再帰による繰り返し処理を行った回数を記録する繰り返しカウンタの値を1増加させる。
そして、S1605で、トレース情報117を繰り返しカウンタの値とともにバッファ116に格納し、トレース情報117の取得処理を終了する。繰り返しカウンタは、ループ開始及び再帰開始の各イベントに対応するトレース情報117とともにバッファ116に格納する。
また、S1601で取得したトレース情報117が、ループあるいは再帰開始でない場合(S1602:No)、S1606で、取得したトレース情報117をバッファ116に格納する。
FIG. 16 is a flowchart showing the flow of the trace information acquisition process (S208 in FIG. 2) performed by the trace
First, in S1601, the
Next, in S1602, it is confirmed whether the acquired
In step S1604, the value of the iteration counter that records the number of times the iteration processing by loop or recursion has been performed is incremented by one.
In step S1605, the
If the
このように、本実施形態では、バッファ116内に格納したループや再帰などの繰り返し部分に該当するトレース情報117に対しては、トレース情報117の削除あるいは上書きを行う。そのため、ループや再帰が実行されたという履歴と、ループや再帰の繰り返し回数、その繰り返しの最終実行履歴のみがバッファ116上に残ることになる。これにより、プログラム113中に含まれる繰り返し処理によって、ループや再帰のプログラムを実行した際に発生するトレース情報117を全てバッファ116上に残すことは不要となり、必要以上に大きいサイズのバッファ116を確保しておく必要や、確保しておいたバッファ116が不足してしまうことはなく、メモリ103を計画的に効率よく使用することができる。
As described above, in this embodiment, the
次に、図17を用いて、ループが含まれるプログラム113及びバッファ116の格納例について説明する。図17Aに、ループが含まれるプログラムの一例としてプログラム1701を示し、図17Bに、バッファ116上での格納例を示す
図17Bにおいて、「C」はメソッドの開始イベント、「Le」はループの開始イベント、「R」はメソッドの終了イベント又「Lx」はループの終了イベントをそれぞれ示す。矢印1723〜1727は、トレース情報117の次の格納先を指すポインタを示す。1707〜1712は、バッファ116上に格納されるトレース情報の第1状態から第6状態までの状態遷移図を示す。なお、1707〜1712で示す各状態遷移図は、バッファ116条にトレース情報117を格納する様の一部を模式的に示したものである。
Next, a storage example of the
まず、図17Aに示すプログラム1701を実行すると、mainメソッド1702の開始イベント及びその内部のmethodA1703の開始イベントが発生するため、第1状態1707のように、mainメソッドの開始イベント1713及びmethodAメソッドの開始イベント1714の2つの開始イベント示すトレース情報117が格納される。
次に、methodA1703内のループ1704が1回実行されると、第2状態1708のように、ループの開始イベント1715、methodB1705の開始イベント1716、methodB1705の終了イベント1717、methodC1706の開始イベント1718、methodC1706の終了イベント1719を示すトレース情報117が格納される。
First, when the
Next, when the
そして、1719の次の格納位置を示すポインタ1724をループ開始イベントLe 1715の位置に戻すことで、第3状態1709のようにループ開始イベントLe 1715から最後のメソッド終了イベントR 1719までのトレース情報117を削除する。あるいは、ポインタ1724をループ開始イベントLe 1715の位置に戻して、次回以降はトレース情報117を上書きして格納していく。これは、ループ開始イベントが再度発生するため、過去に取得した繰り返しデータの削除あるいは上書きによって繰り返し部分のトレース情報117を同じ格納先に格納するためである。
Then, by returning the
次に、繰り返し部分のトレース情報117の初期化後、第4状態1710のように、再度ループの開始イベント1715に対応するトレース情報117を格納する。このとき繰り返しカウンタをトレース情報117の付随情報として格納する。
次に、ループ処理が終了するとき、第5状態1711のように、バッファ116の最後にループ終了イベント1720を示すトレース情報117を格納する。
最後に、第6状態1712のように、methodAメソッドの終了イベント1721及びmainメソッドの終了イベント1722を示すトレース情報117を格納する。
Next, after initializing the
Next, when the loop processing ends, trace
Finally, as in the sixth state 1712, trace
また、バッファサイズに関しても、図17Aのプログラム1701において、ループ内にあるメソッドの数の合計が2、1メソッド分の呼出し情報を取得するのに必要なバッファサイズが2、ループの開始・終了情報が2であることから、バッファサイズは2×2+2=6となる。従って、1712のようにmain1702の開始イベント1713並びに1722及びmethodA1703の開始イベント1714並びに終了イベント1721を除いたバッファ使用量6と一致する。なお、上記の例はループの例のみを例示しているが、再帰がある場合でも、ループの例と同様に取得するトレース情報117の数を算出することができる。
Further, regarding the buffer size, in the
このように、従来では、ループや再帰等の繰り返しを指示する要素がプログラムに含まれている場合、取得するトレース情報の数がループや再帰の繰り返し回数に依存するため、取得するトレース情報の数を算出することはできなかった。それに伴い、そのトレース情報を格納するために必要なバッファサイズを予め把握することができなかった。しかし、本実施形態では、上記のようにループや再帰等の繰り返しを指示する要素が含まれるプログラムから取得するトレース情報の数を算出することができるため、予めトレース情報を格納するためのバッファサイズを算出することもできる。 In this way, conventionally, when an element that indicates repetition such as loop or recursion is included in the program, the number of trace information to be acquired depends on the number of iterations of loop or recursion. Could not be calculated. As a result, the buffer size necessary for storing the trace information could not be grasped in advance. However, in this embodiment, since the number of trace information acquired from a program including an element that indicates repetition such as loop or recursion as described above can be calculated, the buffer size for storing the trace information in advance Can also be calculated.
図18に、トレース情報117の出力例を示す。本実施形態では、図1のトレース情報出力部112が、トレース情報117をファイルとして外部記憶装置118に出力する。なお、図18は、図17Aに示すプログラム1701を実行したトレース情報117の出力結果であり、1〜10の各行がトレース情報117を示している。
トレース情報1801は、mainメソッドの開始を表している。method_entry 1805はメソッドの開始イベント、main 1806はmethod_entry 1805の対象メソッドをそれぞれ表している。
トレース情報1802は、ループIDが1のループが開始されたこと及びそのループが100回繰り返し実行されたことを表している。for_loop_entry 1807はループの開始イベント、1808はループID、1809は繰り返しカウンタをそれぞれ表している。
トレース情報1803は、methodBが終了したことを表しており、method_exit 1810はメソッドの終了イベント、methodB 1811はmethod_exit 1810の対象メソッドをそれぞれ表している。
トレース情報1804は、ループIDが1のループが終了したことを表している。for_loop_exit 1812はループの終了イベント、1813はループIDをそれぞれ表している。
FIG. 18 shows an output example of the
The
最後に、本実施形態によって取得できるトレース情報の利用態様の一例について説明する。計算機101のプログラム実行において、ループ実行中に障害が発生した場合を想定して説明する。図19Aに、計算機101が実行するプログラム113の一例としてプログラム1901を示す。図19Bに、ループ実行中に障害が発生した場合のトレース情報117の出力例を示す。
トレース情報1903より、forループの10回目の繰り返しを実施していたことがわかる。また、トレース情報1904より、methodCが開始されたことがわかる。従って、トレース情報1902の出力例から、forループの10回目の繰り返し中のmethodCで、何らかの障害が発生したことがわかる。
なお、図19Aはループが含まれるプログラム1901を実行した場合のトレース情報117の出力例を示しているが、再帰の場合も同様のトレース情報117の出力が可能である。従って、本実施形態では、ループ・再帰に対してトレース情報117の格納の省略を行っても、障害解析に十分なトレース情報117を残すことが可能である。
Finally, an example of how trace information can be acquired according to the present embodiment will be described. In the program execution of the
It can be seen from the
FIG. 19A shows an output example of the
[第2の実施形態]
次に、本発明を適用した計算機の第2の実施形態について説明する。第2の実施形態は、ユーザの実行頻度が高いプログラム実行経路を構成するプログラム構成要素を選択し、それを基にバッファサイズを算出する実施形態である。
図20に、第2の実施形態における計算機の全体構成を示す。第1の実施形態の全体構成図を示す図1と異なる構成について、以降では説明する。
[Second Embodiment]
Next, a second embodiment of a computer to which the present invention is applied will be described. The second embodiment is an embodiment in which a program component constituting a program execution path having a high user execution frequency is selected, and a buffer size is calculated based on the selected program component.
FIG. 20 shows the overall configuration of the computer in the second embodiment. A configuration different from FIG. 1 showing the overall configuration diagram of the first embodiment will be described below.
まず、本実施形態では、Java仮想マシン104上に、拡張バッファサイズ計算部2001、バッファ再割当部2002及びユーザ実行データ集計部2003の機能部を新たに設ける。また、メモリ103上に、実行履歴データ2004及びユーザ実行データ2005を保持する。
拡張バッファサイズ計算部2001は、プログラム構成要素ツリーから、実行確率の高いプログラム実行経路を抽出し、抽出されたプログラム実行経路に属するノード数からバッファサイズを計算する
バッファ再割当部2002は、割当てたバッファサイズのバッファが不足する場合に、バッファの再割当をする。
ユーザ実行データ集計部2003は、プログラムの実行履歴データ2004をユーザ毎に集計し、ユーザ実行データ2005を生成する。
実行履歴データ2004は、全ユーザのプログラム構成要素ツリーの各ノード(プログラム構成要素)の実行履歴を示すデータである。
ユーザ実行データ2005は、実行履歴データ2004をユーザ毎にプログラム構成要素の各ノードを実行した回数を集計したデータである。
なお、実行履歴データ2004及びユーザ実行データ2005は、メモリ103上ではなく、外部記憶装置118に格納されることもある。
First, in this embodiment, functional units of an extended buffer
The extended buffer
A user execution
The execution history data 2004 is data indicating the execution history of each node (program component) of the program component tree of all users.
The
Note that the execution history data 2004 and the
図21Bは、図21Aのプログラム2101を実行して得られる実行履歴データ2004の一例である。実行履歴データ2004は、ユーザID2102、ノード名2103及びタイムスタンプ2104から構成される。
図22は、図21Bの実行履歴データ2004から生成したユーザ実行データ2005の一例である。図22は、ユーザIDが「1」及び「2」であるユーザのユーザ実行データ2005を示しており、ユーザ実行データ2005は、ノード名2201と各ノードの実行回数の集計値を示す実行回数2202とから構成される。
FIG. 21B is an example of execution history data 2004 obtained by executing the program 2101 of FIG. 21A. The execution history data 2004 includes a
FIG. 22 is an example of
図23に、本発明を適用した第2の実施形態における処理の概要を示す。なお、S2301からS2304までの処理は、図2に示すS201からS204までの処理と同様の処理であるため説明を省略する。
まず、S2305で、拡張バッファサイズ計算部2001が、メモリ103上の実行履歴データ2004を読込み、読込んだ実行履歴データ2004と静的解析データ115からバッファサイズを算出する。そして、算出したサイズのバッファ116をメモリ103上に確保する(拡張バッファサイズ計算処理)。
次に、S2306で、プログラム書換部109が、プログラム書換処理を実行する(プログラム書換処理)。
次に、S2307で、プログラム書換部109が、プログラム実行処理を実行する(プログラム実行処理)。なお、このとき取得したトレース情報に障害が発生しているか否かを確認する。
次に、S2308で、プログラム書換部109が、トレース取得処理を実行する(トレース情報取得処理)。なお、S2306〜S2308は、第1の実施形態と同様の処理である。
次に、S2309で、バッファ再割当部2002が、割り当てたバッファ116が不足しているかを確認する。割り当てたバッファ116が不足している場合(S2309:Yes)、S2310で、バッファ再割当部2002が、バッファ再割当処理を行う(バッファ再割当処理)。バッファ再割当処理は、バッファ再割当部2002が、メモリ103上にあるバッファ116を、プログラム構成要素ツリーのノード数に基づいて計算したバッファサイズのバッファ116に置き換える処理である。そして、バッファ再割当処理の実行後、S2307に戻る。
また、割り当てたバッファ116が不足していない場合(S2309:No)、S2311でトレース情報117を出力し、一連の処理を終了する(トレース情報出力処理)。
FIG. 23 shows an outline of processing in the second embodiment to which the present invention is applied. Note that the processing from S2301 to S2304 is the same as the processing from S201 to S204 shown in FIG.
First, in step S <b> 2305, the extended buffer
Next, in S2306, the
Next, in S2307, the
Next, in S2308, the
In step S <b> 2309, the
If the allocated
以降では、プログラム構成要素のツリーから、実行頻度の高いプログラム実行経路を抽出する方法について説明する。本実施形態では、プログラム構成要素ツリーの各ノードにノードの実行回数を割り当て、割り当てた実行回数から実行確率を求める。そして、求めた実行確率を元に実行頻度が高いノードから構成されるプログラム実行経路を抽出する。なお、実行確率の差は、条件分岐での分岐方向の偏りに起因することが多いため、本実施形態では条件分岐における実行確率を評価する。実行確率は、「条件分岐ノードの子ノードの実行回数÷条件分岐ノードの実行回数」から求めるものとする。 Hereinafter, a method for extracting a program execution path with high execution frequency from a tree of program components will be described. In this embodiment, the node execution count is assigned to each node of the program component tree, and the execution probability is obtained from the assigned execution count. Then, a program execution path composed of nodes having a high execution frequency is extracted based on the obtained execution probability. Since the difference in execution probability is often caused by a deviation in the branch direction in the conditional branch, the execution probability in the conditional branch is evaluated in this embodiment. The execution probability is obtained from “the number of executions of the child node of the conditional branch node ÷ the number of executions of the conditional branch node”.
図24は、拡張バッファサイズ計算部2001が行う拡張バッファサイズ計算処理の流れを示すフローチャートである。拡張バッファサイズ計算処理は、プログラム構成要素ツリーのノード数に基づくバッファサイズと、実行履歴データ2004とから算出したユーザごとに必要とされる効率的なバッファサイズとを求め、求めたバッファサイズのバッファ116をメモリ103上に確保する。
はじめに、S2401で、実行履歴データ2004をメモリ103から読込む。
次に、S2402で、静的解析データ115から総ノード数を取得する。
そして、S2403で、総ノード数に基づいて最大バッファサイズを算出する。
FIG. 24 is a flowchart showing the flow of extended buffer size calculation processing performed by the extended
First, the execution history data 2004 is read from the
Next, in S2402, the total number of nodes is acquired from the
In step S2403, the maximum buffer size is calculated based on the total number of nodes.
次に、S2404で、実行確率によるバッファサイズを算出する。バッファサイズを算出するため、ユーザ実行データ2005に基づき、静的解析データ115から各条件分岐ノード及びその子ノードの実行確率を計算し、実行確率が高いプログラム実行経路を抽出する(実行確率によるバッファサイズ算出処理)。そして、そのプログラム実行経路に属するノード数から、バッファサイズを算出する。なお、S2404では、実行履歴データ2004をユーザごとに集計した上で、現在実行中のユーザに該当するデータを用いて、プログラム構成要素の実行確率を求めるものとする。
次に、S2405で、算出したバッファサイズのバッファ領域をメモリ103上に確保し、処理を終了する。
このように、本実施形態では、プログラムの実行経路について実行確率を評価することで、ユーザ毎に最適なバッファサイズを決定することができる。従って、各ユーザが、実行するプログラムに応じてメモリを使用することができる。
Next, in S2404, the buffer size based on the execution probability is calculated. In order to calculate the buffer size, the execution probability of each conditional branch node and its child node is calculated from the
In step S2405, a buffer area having the calculated buffer size is secured on the
Thus, in this embodiment, the optimal buffer size can be determined for each user by evaluating the execution probability with respect to the execution path of the program. Therefore, each user can use the memory according to the program to be executed.
図25は、拡張バッファサイズ計算部2001が行う実行確率によるバッファサイズ算出処理(図24のS2404)の処理の流れを示すフローチャートである。実行確率によるバッファサイズ算出処理は、プログラム構成要素の始点メソッドのメソッドノードから順次、最近傍の条件分岐ノードをたどってプログラム実行経路を抽出し、抽出したプログラム実行経路に属するノード数からバッファサイズを算出する。
はじめに、S2501で、静的解析データ115中のプログラム構成要素ツリーの各ノードに実行回数データを付与する。なお、ここで付与される実行回数データは、ユーザ実行データ2005の付与対象のノードに対する実行回数である。
次に、S2502で、プログラム構成要素ツリーの始点ノードをカレントノードに設定する。
そして、S2503で、未評価の条件分岐ノードがあるかを確認する。未評価の条件分岐ノードとは、実行確率を評価していない子ノードを持つ条件分岐ノードのことをいう。未評価の条件分岐ノードがある場合(S2503:Yes)、S2504で、カレントノードからたどれる最近傍の条件分岐ノードをカレントノードに設定する。また、未評価の条件分岐ノードがない場合(S2503:No)、S2506に進む。ただし、評価対象のノードはカレントノードから見てプログラム構成要素ツリーの末端方向にあるノードとする。
FIG. 25 is a flowchart showing the flow of the buffer size calculation process (S2404 in FIG. 24) based on the execution probability performed by the extended buffer
First, in S2501, execution frequency data is assigned to each node of the program component tree in the
In step S2502, the starting point node of the program component tree is set as the current node.
In step S2503, it is confirmed whether there is an unevaluated conditional branch node. An unevaluated conditional branch node is a conditional branch node having a child node whose execution probability is not evaluated. If there is an unevaluated conditional branch node (S2503: Yes), the nearest conditional branch node traced from the current node is set as the current node in S2504. If there is no unevaluated conditional branch node (S2503: No), the process proceeds to S2506. However, the node to be evaluated is a node in the end direction of the program component tree as viewed from the current node.
次に、S2505で、条件分岐ノードの子ノードの実行確率を算出する。なお、本実施形態では、子ノードの実行確率は「条件分岐ノードの子ノードの実行回数÷条件分岐ノードの実行回数」により算出するものとする。
次に、S2506で、条件分岐ノードの子ノード間で実行確率を比較し、実行確率が低いノードをバッファサイズの算出対象から除外する。ただし、子ノード間で実行確率を比較するとき、実行確率の差が閾値以下の場合、子ノードを除外対象としなくても良い。なお、この閾値は予め所定の値に設定するのでも、ユーザが指定するのでもよい。そして、S2506終了後、S2503に戻る。ただし、S2506で除外されたノードは、S2503の評価対象とはならないものとする。
最後に、S2507で、プログラム構成要素ツリー中の除外されなかったノードの数を求め、そのノード数からバッファサイズを算出して処理を終了する。なお、プログラム実行経路が複数存在する場合は、ノード数が最大となるプログラム実行経路を元にバッファサイズを算出する。また、バッファサイズの算出方法は、第1の実施形態と同様の方法で行う。
In step S2505, the execution probability of the child node of the conditional branch node is calculated. In this embodiment, the execution probability of the child node is calculated by “the number of executions of the child node of the conditional branch node ÷ the number of executions of the conditional branch node”.
Next, in S2506, the execution probabilities are compared between the child nodes of the conditional branch node, and nodes with a low execution probability are excluded from the buffer size calculation targets. However, when comparing execution probabilities between child nodes, if the difference in execution probabilities is equal to or less than a threshold value, the child nodes may not be excluded. This threshold value may be set in advance to a predetermined value or specified by the user. Then, after S2506 ends, the process returns to S2503. However, it is assumed that the node excluded in S2506 is not an evaluation target in S2503.
Finally, in S2507, the number of nodes not excluded in the program component tree is obtained, the buffer size is calculated from the number of nodes, and the process is terminated. When there are a plurality of program execution paths, the buffer size is calculated based on the program execution path with the maximum number of nodes. The buffer size calculation method is the same as that in the first embodiment.
図26Aに、図21Aに示すプログラム2101の各ノードの実行確率表と、ノードを選択する際に用いる実行確率の差の閾値設定を行う表示画面の一例を示す。各ノードの実行確率表は、ノード名2601、ノードの実行回数2602及びノードの実行確率2603からなる。また、実行確率の差の閾値は2604でユーザが指定できる。ここでは、実行確率の差の閾値を10%に設定した例を示している。これは、条件分岐ノードの実行確率の差が10%以上である場合、その条件分岐に属する子ノードをバッファサイズの算出対象から除外することを意味する。
FIG. 26A shows an example of an execution probability table for each node of the program 2101 shown in FIG. 21A and a display screen for setting a threshold value for a difference in execution probability used when selecting a node. The execution probability table for each node includes a
図26Bは、図26Aに示す各ノードの実行確率を基に選択されたプログラム構成要素ツリーを示す。
はじめに、プログラム構成要素ツリーの最初の条件分岐ノードであるif_1 2606について、子ノードの実行確率を評価する。図26Aの各ノードの実行確率表より、子ノードであるmethodB 2607の実行確率は30%、if_2 2609の条件分岐ノードの実行確率は70%であることがわかる。従って、実行確率の差は、70%−30%=40%であるため、methodB 2607以下のノードである、methodB 2607及びmethodC 2608がバッファサイズの算出対象から除外される。なお、図26Aでは、除外されたノードを点線で描いている。
FIG. 26B shows a program component tree selected based on the execution probability of each node shown in FIG. 26A.
First, the execution probability of the child node is evaluated for
図27は、バッファ再割当部2002が行うバッファ再割当処理(図23のS2310)の処理の概要をフローチャートで示す。バッファ再割当処理は、拡張バッファサイズ計算部2001が確保したバッファ116を、最大バッファサイズまでのバッファ116に割り当て直す。なお、本実施形態では、バッファ再割当処理を行うのは、プログラム113を実行して取得したトレース情報117を格納するために必要なバッファサイズが、確保したバッファサイズでは不足する場合を想定しているが、これに限られず、ユーザが指定した場合等、任意の条件で処理を実行できる。
はじめに、S2701で、拡張バッファサイズ計算部2001で算出した最大バッファサイズのバッファ116をメモリ103上に確保する。
次に、S2702で、既存のバッファ116(実行履歴データ2004に基づいて計算したバッファサイズのバッファ)内に格納してあるトレース情報117を確保したバッファ116にコピーする。
そして、S2703で、既存のバッファ116の領域を解放し、バッファ再割当処理を終了する。本処理により、プログラム中の実行確率の低い経路を実行したことで、トレース取得量がバッファサイズよりも多くなったとしても、トレース情報117の取得漏れを生じさせることなく、トレースを行うことができる。
FIG. 27 is a flowchart showing an outline of the process of the buffer reallocation process (S2310 in FIG. 23) performed by the
First, in step S <b> 2701, the
Next, in S2702, the
In step S2703, the existing
本実施形態では、実行履歴データ2004からシステムのユーザごとに、おおよそ必要なバッファサイズを算出することを考える。そして、バッファ116が不足したとき等、任意の条件で第1の実施形態に示すプログラム構成要素ツリーのノード数に基づいて計算したバッファサイズのバッファ116に割り当て直すことを想定している。従って、実行履歴データ2004に基づいて計算したバッファサイズのバッファ116と、プログラム構成要素ツリーのノード数に基づいて計算したバッファサイズのバッファ116とを併用することにより、トレース情報117を格納するバッファ116をさらに効率的に利用することができる。
In the present embodiment, it is assumed that an approximate required buffer size is calculated for each system user from the execution history data 2004. Then, it is assumed that the
101計算機、102CPU、103メモリ、104Java仮想マシン、105プログラム読込部、106静的解析データ生成部、107静的解析データ読込部、
108バッファサイズ計算部、109プログラム書換部、110プログラム実行部、111トレース情報取得部、112トレース情報出力部、113プログラム、114拡張プログラム、115静的解析データ、116バッファ、117トレース情報、118外部記憶装置、2001拡張バッファサイズ計算部、2002バッファ再割当部、2003ユーザ実行データ集計部、2004実行履歴データ、2005ユーザ実行データ
101 computer, 102 CPU, 103 memory, 104 Java virtual machine, 105 program reading unit, 106 static analysis data generating unit, 107 static analysis data reading unit,
108 buffer size calculator, 109 program rewrite unit, 110 program execution unit, 111 trace information acquisition unit, 112 trace information output unit, 113 program, 114 extended program, 115 static analysis data, 116 buffer, 117 trace information, 118 external Storage device, 2001 extended buffer size calculation unit, 2002 buffer reallocation unit, 2003 user execution data totaling unit, 2004 execution history data, 2005 user execution data
Claims (19)
前記計算機は、プログラムの流れを制御する要素を特定する制御部を有し、前記制御部は、前記プログラムの実行前に前記要素の数を特定し、前記特定した要素の数を基に、取得するトレース情報の数を算出することを特徴とする計算機。 A computer for calculating the number of trace information acquired by the tracer,
The computer has a control unit that identifies an element that controls a flow of a program, the control unit identifies the number of elements before execution of the program, and acquires the number based on the number of identified elements. A computer characterized in that the number of trace information to be calculated is calculated.
前記制御部は、前記取得するトレース情報の数に基づいて、トレース情報を格納するメモリ領域のサイズを決定することを特徴とする計算機。 The computer according to claim 1,
The control unit determines a size of a memory area for storing trace information based on the number of pieces of trace information to be acquired.
前記制御部は、前記特定した要素の数と、前記要素の一つ分のトレース情報を格納するために必要なメモリ領域のサイズとによって、前記実行するプログラムのトレース情報を格納するメモリ領域のサイズを決定することを特徴とする計算機。 The computer according to claim 2,
The control unit determines the size of the memory area for storing the trace information of the program to be executed according to the number of the specified elements and the size of the memory area necessary for storing the trace information for one element. A computer characterized by determining.
前記特定した要素が、処理の繰り返しを指示する要素である場合、前記制御部は、前記処理の繰り返しを指示する要素から取得するトレース情報を削除あるいは上書きしてメモリ領域に格納することを特徴とする計算機。 The computer according to claim 3, wherein
When the specified element is an element that instructs the repetition of the process, the control unit deletes or overwrites the trace information acquired from the element that instructs the repetition of the process, and stores the trace information in a memory area. Calculator to do.
前記制御部は、前記プログラムの流れを制御する要素で構成されたツリーを生成して前記要素の数を特定することを特徴とする計算機。 The computer according to claim 1,
The computer is characterized in that the control unit generates a tree composed of elements that control the flow of the program and specifies the number of the elements.
前記制御部は、さらに前記ツリーを構成するノードを実行した記録である実行頻度をノード毎に管理し、前記実行頻度に応じて所定のプログラム実行経路を特定し、前記特定したプログラム実行経路に含まれるノードの数に基づいて取得するトレース情報の数を算出することを特徴とする計算機。 The computer according to claim 5, wherein
The control unit further manages, for each node, an execution frequency, which is a record of executing nodes constituting the tree, specifies a predetermined program execution path according to the execution frequency, and is included in the specified program execution path A computer that calculates the number of trace information to be acquired based on the number of nodes to be acquired.
前記制御部は、さらに前記ツリーを構成する各ノードを実行した記録である実行頻度をノード毎に管理し、前記実行頻度から実行頻度の高いプログラム実行経路を特定し、前記特定したプログラム実行経路に含まれるノードの数に基づいて取得するトレース情報の数を算出することを特徴とする計算機。 The computer according to claim 5, wherein
The control unit further manages, for each node, an execution frequency that is a record of executing each node constituting the tree, specifies a program execution path having a high execution frequency from the execution frequency, and sets the specified program execution path to the specified program execution path. A computer that calculates the number of trace information to be acquired based on the number of nodes included.
前記制御部は、前記取得するトレース情報の数に基づいて、トレース情報を格納するメモリ領域のサイズを決定することを特徴とする計算機。 The computer according to claim 6 or 7,
The control unit determines a size of a memory area for storing trace information based on the number of pieces of trace information to be acquired.
前記制御部は、前記プログラムを実行し、実行して取得したトレース情報を格納するためのメモリ領域のサイズが、前記決定したメモリ領域のサイズでは不足する場合、前記決定したメモリ領域のサイズから、前記ツリーに含まれる全てのノードの数に基づいて算出されるトレース情報を格納するメモリ領域のサイズまでの大きさのメモリ領域のサイズに変更することを特徴とする計算機。 A computer according to claim 8, wherein
When the size of the memory area for storing the trace information obtained by executing the program and executing the program is insufficient with the size of the determined memory area, the control unit, from the size of the determined memory area, The computer is changed to the size of the memory area up to the size of the memory area for storing the trace information calculated based on the number of all nodes included in the tree.
前記計算機は、プログラムの流れを制御する要素を前記プログラムの実行前に特定し、
前記特定した要素の数を基に、取得するトレース情報の数を算出することを特徴とする方法。 A method for calculating the number of trace information acquired by a computer by a tracer,
The computer identifies an element that controls the flow of the program before the execution of the program,
A method of calculating the number of pieces of trace information to be acquired based on the specified number of elements.
前記計算機は、前記取得したトレース情報の数に基づいて、トレース情報を格納するメモリ領域のサイズを決定することを特徴とする方法。 The method of claim 10, comprising:
It said computer based on the number of the acquired trace information, wherein the determining the size of a memory area for storing trace information.
前記計算機は、前記特定した要素の数と、前記要素の一つ分のトレース情報を格納するために必要なメモリ領域のサイズとによって、前記実行するプログラムのトレース情報を格納するメモリ領域のサイズを決定することを特徴とする方法。 The method of claim 11, comprising:
The computer determines the size of the memory area for storing the trace information of the program to be executed according to the number of the specified elements and the size of the memory area necessary for storing the trace information for one element. A method characterized by determining.
前記特定した要素が、処理の繰り返しを指示する要素である場合、前記計算機は、前記繰り返しを指示する要素から取得するトレース情報を削除あるいは上書きしてメモリ領域に格納することを特徴とする方法。 The method of claim 12, comprising:
When the specified element is an element that instructs repetition of processing, the computer deletes or overwrites trace information acquired from the element that indicates repetition, and stores the trace information in a memory area.
前記計算機は、前記プログラムの流れを制御する要素で構成されたツリーを生成して前記要素の数を特定することを特徴とする方法。 The method of claim 10, comprising:
The computer generates a tree composed of elements that control the flow of the program and specifies the number of elements.
前記計算機に、トレース対象プログラムの流れを制御する要素を前記トレース対象プログラムの実行前に特定させ、前記特定された要素の数を基に、取得するトレース情報の数を算出させることを特徴とするプログラム。 A program for causing a computer to calculate the number of trace information acquired by the tracer,
In said computer, an element for controlling the flow of the trace target program is specified before the execution of the traced program, based on the number of the identified elements, characterized in that to calculate the number of trace information to be obtained program.
前記計算機に、前記取得したトレース情報の数に基づいて、トレース情報を格納するメモリ領域のサイズを決定させることを特徴とするプログラム。 The program according to claim 15,
A program for causing the computer to determine the size of a memory area for storing trace information based on the number of acquired trace information.
前記計算機に、前記特定された要素の数と、前記要素の一つ分のトレース情報を格納するために必要なメモリ領域のサイズとによって、前記実行するトレース対象プログラムのトレース情報を格納するメモリ領域のサイズを決定させることを特徴とするプログラム。 The program according to claim 16, wherein
In said computer, said the number of identified elements, by the size of the memory area required to store the trace information of a single component of the element, a memory area for storing the trace information in the trace target program to the execution A program characterized by determining the size of a program.
前記特定された要素が、処理の繰り返しを指示する要素である場合、前記計算機に、前記繰り返しを指示する要素から取得するトレース情報を削除あるいは上書きしてメモリ領域に格納させることを特徴とするプログラム。 A program according to claim 17,
When the specified element is an element instructing repetition of processing, the computer causes the computer to delete or overwrite the trace information acquired from the element instructing repetition and store it in a memory area. .
前記計算機に、前記トレース対象プログラムの流れを制御する要素で構成されたツリーを生成させて前記要素の数を特定させることを特徴とするプログラム。 The program according to claim 15,
A program that causes the computer to generate a tree composed of elements that control the flow of the trace target program and to specify the number of the elements.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2011264227A JP5572619B2 (en) | 2011-12-02 | 2011-12-02 | Computer for calculating the number of trace information, method for calculating the number of trace information, and program for calculating the number of trace information |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2011264227A JP5572619B2 (en) | 2011-12-02 | 2011-12-02 | Computer for calculating the number of trace information, method for calculating the number of trace information, and program for calculating the number of trace information |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2013117803A JP2013117803A (en) | 2013-06-13 |
JP5572619B2 true JP5572619B2 (en) | 2014-08-13 |
Family
ID=48712344
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2011264227A Expired - Fee Related JP5572619B2 (en) | 2011-12-02 | 2011-12-02 | Computer for calculating the number of trace information, method for calculating the number of trace information, and program for calculating the number of trace information |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP5572619B2 (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP6496640B2 (en) * | 2015-09-14 | 2019-04-03 | 株式会社エクサ | COBOL source code conversion program |
EP3200080B1 (en) * | 2015-12-16 | 2021-12-22 | Tata Consultancy Services Limited | Methods and systems for memory suspect detection |
EP3862873A4 (en) * | 2018-10-03 | 2021-10-13 | Mitsubishi Electric Corporation | Software analysis device, software analysis method, and software analysis program |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH09282173A (en) * | 1996-04-10 | 1997-10-31 | Hitachi Ltd | Static analysis method for program |
JP4914609B2 (en) * | 2005-12-28 | 2012-04-11 | 富士通株式会社 | Source code problem prediction program |
JP2008131278A (en) * | 2006-11-20 | 2008-06-05 | Oki Electric Ind Co Ltd | Tracing device |
-
2011
- 2011-12-02 JP JP2011264227A patent/JP5572619B2/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
JP2013117803A (en) | 2013-06-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20230094191A1 (en) | Scalable execution tracing for large program codebases | |
Sambasivan et al. | Principled workflow-centric tracing of distributed systems | |
US5987250A (en) | Transparent instrumentation for computer program behavior analysis | |
US7213175B2 (en) | Methods and systems for managing an application's relationship to its run-time environment | |
CN104391787B (en) | Monitoring method aiming at target method as well as thermal cutting-in method and device | |
US9355003B2 (en) | Capturing trace information using annotated trace output | |
Sambasivan et al. | So, you want to trace your distributed system? Key design insights from years of practical experience | |
CN106649120A (en) | Data acquisition method, and data analysis method and system | |
US10877873B2 (en) | Using historic execution data to visualize tracepoints | |
JP5572619B2 (en) | Computer for calculating the number of trace information, method for calculating the number of trace information, and program for calculating the number of trace information | |
CN112597064B (en) | Method for simulating program, electronic device and storage medium | |
Sato et al. | Whole program data dependence profiling to unveil parallel regions in the dynamic execution | |
CN111913878A (en) | Program analysis result-based bytecode instrumentation method, device and storage medium | |
CN113778890B (en) | Code testing method and device, electronic equipment and storage medium | |
US7784040B2 (en) | Profiling of performance behaviour of executed loops | |
CN107451038B (en) | Hardware event acquisition method, processor and computing system | |
US8756580B2 (en) | Instance-based field affinity optimization | |
JP7116562B2 (en) | Trace data representation | |
Singh et al. | MG++: Memory graphs for analyzing dynamic data structures | |
US20170123959A1 (en) | Optimized instrumentation based on functional coverage | |
JP2016081126A (en) | Job control language automatic generation program | |
JP5937530B2 (en) | Software error analysis device, error information creation device | |
JP6437396B2 (en) | Trace information management system, method, and program | |
Upp et al. | Using reservoir sampling and parallelization to improve dynamic binary instrumentation | |
CN114385584A (en) | Data writing method and data reading method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20130913 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20140328 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20140408 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20140424 |
|
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: 20140603 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20140630 |
|
LAPS | Cancellation because of no payment of annual fees |