JP2004287869A - Program execution monitoring device and method - Google Patents
Program execution monitoring device and method Download PDFInfo
- Publication number
- JP2004287869A JP2004287869A JP2003079340A JP2003079340A JP2004287869A JP 2004287869 A JP2004287869 A JP 2004287869A JP 2003079340 A JP2003079340 A JP 2003079340A JP 2003079340 A JP2003079340 A JP 2003079340A JP 2004287869 A JP2004287869 A JP 2004287869A
- Authority
- JP
- Japan
- Prior art keywords
- monitoring
- function
- program
- code
- execution
- 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.)
- Pending
Links
Images
Abstract
Description
【0001】
【発明の属する技術分野】
本発明はコンピュータのプログラム実行に際してプログラム実行を効率良く監視する方法に関する。
【0002】
【従来の技術】
コンピュータで実行するプログラムの実行監視としては、例えばプログラムのソースに、ログの出力コードを埋め込んでコンパイルし、これを実行することで実行ログを得る方法は非常に一般的で、プログラム開発の基本手法である(特許文献1等)。
【0003】
また現在存在する殆どのデバッガはプログラムにデバッグ用コードを挿入することでその機能を実現している。例えばソフトウェア割り込みを発生させる命令をプログラム中に埋め込むことで、そのコードが実行されると割り込みが発生し、プログラムの実行を容易に検出することが可能となっている(特許文献2等)プログラム実行のボトルネックを検出するために、プログラムのどの部分でどれだけ時間がかかっているか等を計測するためのプロフアイリングを行うツールも存在し、これらもプログラムの最適化工程ではしばしば利用されている。これらは、プログラムの読み込み時にプログラムに監視用のコードを挿入し、その監視用のコードが実行されることでプログラムの実行状態を監視する。
【0004】
【特許文献1】
特開平6−314221号公報
【特許文献2】
特開平11−184727号公報
【0005】
【発明が解決しようとする課題】
上記ログの出力コードを埋め込む方式は、実施にプログラムソースとこのコンパイル環境が必要であり、いずれかが欠けても実現不可能である。デバッガはプログラム開発時に利用することを念頭に開発されており、実行時に少ない負荷で利用することが難しい上、インタプリタのプログラム実行環境では使用できない。
【0006】
また、プロフアイリングを行うツールでは、監視コードをプログラムの動作に影響を極力与えずに挿入するには、複雑な処理が必要となる(例えば、引数の監視を行うためにはスタックの操作が必要となる等)。本発明では、システムの運用時においても利用可能な低負荷で、容易に適用可能なプログラムヘの監視用コードの挿入方法を提案する。
【0007】
【発明を解決するための手段】
上記の課題を解決するために、複数の関数を含むプログラムを格納するプログラム記憶部と、該記憶部からプログラムを読み出して実行するプログラム実行部とを備えるコンピュータでプログラムを実行するに際し、記憶部から読み出したプログラムの関数が監視対象の関数であるかを判定し、監視対象の関数に対して監視処理が施されるように当該プログラムに監視コードを挿入する。
【0008】
このときに、監視コードを、監視する関数の先頭と、関数からの復帰をおこなう命令の直前に挿入しておく。監視コードを挿入された関数を、プログラムの実行部が実行することにより監視コードが実行されて関数実行の状況がわかるようになる。
【0009】
また、監視対象の関数を呼び出すためのアドレスあるいは関数の名称を変更し、名称の変更された関数を呼び出す命令を含む監視用関数と前述した監視コードとからなる監視用関数を生成し、プログラムに前記監視用関数を挿入するようにしてもよい。
【0010】
この場合にユーザが任意に作成した監視コードを、一旦コンパイラでコンパイルし、これを変形して監視用関数とすれば、ユーザの作成した任意のコードを監視コードとして使用することが出来るため、自由度の高い実行監視を実現できる。さらに、この監視用関数の開発を支援するために、監視されるプログラムを元に監視コードのソースを生成し、ユーザに提示して必要ならこれを修正して、コンパイルすることでさらに利用を容易化できる。
【0011】
【発明の実施の形態】
以下、図面を用いて本発明の実施例を説明する。なお、本発明が実施例に限定されるものではない。
【0012】
図1は本発明の一実施例の全体構成を示す。本発明は、コンピュータ上で動作するプログラム実行部10が、プログラム格納部20に格納されたプログラムファイル50を読込み実行する一般的なプログラム実行装置に、監視コード挿入部11と監視コード挿入制御ファイル30、監視プログラム60、監視コード生成部70を更に備える構成からなる。
【0013】
プログラム実行部10は、インタプリタ実行系と機械語を実行する通常の実行系とが考えられるいずれもCPUが実行主体となる。プログラム格納部20は、ディスク装置、メモリカード、磁気テープなどプログラムを記録可能な全ての装置である。監視コード挿入制御ファイル30は実行するプログラム中の関数が監視対象の関数であるかどうかを決める情報を格納する。単純なファイルで構成されてもよいが、他あるいは同一のコンピュータ上で動作する別のプログラムであってもよい。
【0014】
監視コード生成部70は、プログラムファイル解析部71、監視コード配置部72、監視コード制止部73、コンパイラ75、及びエディタ74からなる。監視コード生成部73は監視コードテンプレート80を参照する。
【0015】
プログラム実行装置は、プログラム実行部10、プログラム格納部20のほかに、プログラム実行部10が実行するプログラム格納部等から読み出したプログラムやデータを一時格納するワークメモリ12、プログラムの実行等の指示を操作者が装置へ入力するための入力装置13、プログラムの実行経過、実行結果等を可視出力するためのディスプレイ14、通信路を介した他の装置との通信を制御する通信制御部15、監視プログラム、監視コード挿入制御ファイル等のデータがCD−ROM等の記憶媒体に格納されて取引される場合に、記憶媒体の内容を読み取ってプログラム格納部20ヘインストールするための媒体読み取り装置1
6を備え、それぞれが内部バスブリッジ17で接続される。なお、図中のバスブリッジ17はワークメモリ、入力装置、ディスプレイ等とのインターフェースコントローラも兼ねている。
【0016】
図2はプログラムファイル50の構成を示す。プログラムファイル50は任意個の関数510を持つ。関数は1つあるいは複数の実行コード520で構成される。実行コード520としては、通常のプログラム実行系では機械語が考えられ、インタブリタ実行系では中間コード(バイトコードとも呼ばれる)が考えられる。プログラムファイル50には関数テーブル530を持つ。関数テーブル530は関数がプログラムファイルのうちどの部分を構成しているか、どのような属性を持っているか等の関数に関する情報を持つ。なお、図2では、関数テーブル530をプログラムファイル50の中に持たせる構造としているが、例えば一般的なコンパイラで出力されるMAPファイルのように別のファイルとして存在させてもよい。
【0017】
図3は関数テーブルの構造の一例を示す。関数テーブル530は、インデックス531、関数名532、開始アドレス533、終了アドレス534、および属性535からなる。プログラムファイル内の関数の情報が格納される。
【0018】
図4は本発明のプログラム実行部10がプログラムファイル50を読み込みつつ監視コードを挿入する処理を示したフローチャートである。まずプログラム実行部10はプログラムファイル50から関数を1つ読み込み監視コード挿入部11に処理を譲る(ステップ1000)。監視コード挿入部11は監視コード挿入制御ファイル30の情報を元に、それが監視対象の関数かどうかを判定し(ステップ1010)、監視対象であればその関数に監視コードを挿入し(ステップ1020)、挿入したコードの長さだけ挿入部以降の実行コードのアドレス情報および、
関数テーブル530を変更し(ステップ1030)、注目している監視対象向けの監視コードを全て挿入するまでステップ1020と1030を繰り返した後、その関数をプログラム実行部10に渡す(ステップ1040)。これを全ての関数について行う(ステップ1050)。プログラム実行部10はステップ1040で監視コード挿入部11から渡された関数を並行して実行する。
【0019】
図5は図4で示した監視コードの挿入方法によって監視コードが挿入された関数の構成を示した図である。図の上側が先に実行され、順番に下の命令が実行される。本方式ではまず関数の先頭部分に監視コード530を埋め込み、次に実行コードのうち関数終了のコード、つまりこのコードを実行することで関数を呼び出した箇所に戻るコード521、の直前に監視コード531を挿入する。
【0020】
プログラム実行部10は監視コード挿入部11によって監視コードが上記の通り挿入されたプログラムファイルを順次実行するので、関数に実行が移った直後と終了直前に監視コードを実行することになり、当該関数の実行時間、実行回数および呼出時に渡された引数などを監視することが可能となる。
【0021】
なお、監視コードは、それ自体が複数の実行コードで実装されたモジュールであってもよいし、他の監視コードライブラリを呼び出す関数呼出コードであってもよいし、機械語実行の場合ではソフトウェア割り込みを発生させるようなコードでもよい。監視コードの動作としては、外部のハードウェアの制御、ログの出力、変数の値の変更等が例として考えられる。また、監視コードは関数実行時のみ、あるいは関数実行終了前のいずれかに挿入するだけでも良い。
【0022】
次に図6を用いて監視コード挿入方式の他の例を説明する。この方法では、まず監視する関数(例えばここでは関数A)(610)をプログラム実行上において別の関数に見えるように変更する(615)。これは例えば関数をアドレスで呼び出す実行方式であれば、関数テーブルを(620)を参照して、利用可能な別のアドレスに関数を移動する方式が考えられる。インタブリタ言語で多く採用されている、関数テーブル(620)へのインデックスを指定して関数を呼び出す実行方式であれば、関数テーブル(620)に新たにエントリを追加して、別の名前を付け、その他の情報については元の情報をコピーすることで実現できる。次に、従来の関数Aとして呼び出した場合に呼び出されるスタブ関数(611)を挿入する。このスタプ関数(611)には改名された関数Aを呼び出すコード(613)を記述する。これにより、関数A(610)の呼出は、一旦スタブ関数(611)を経由してから「改名された関数A」(620)を呼び出すことになる。この際に、スタブ関数(611)の改名された関数Aの呼出コード(613)の前に監視コード(612)が存在すれば、改名された関数A(615)に先だって監視コード(612)の内容が実行され、同様に後ろの監視コード(614)は改名された関数A(615)の実行の後で呼び出されることになる。この監視コード中で、関数Aに渡されるはずである引数の値の監視や変更をしたり、関数Aからの戻り値を監視及び変更することも可能となる。
【0023】
図7は図6で示した方式の監視コード挿入処理のフローチャートである。図4で説明した処理と異なるのはステップ1015の部分だけであるので、その部分だけを抜き出して説明する。本フローではプログラム実行部10の関数の呼出方式が、関数テーブル530のインデックス531を使用して関数を実行する場合について説明する。読み込んだ関数を別名の関数にするために、ます関数テーブルにエントリを新規に作成する(ステップ2000)。次にその新規作成したエントリに図4のステップ1000で読み込んだ関数を、プログラム中で別の関数として見えるように登録する(ステップ2010)。次に、監視用のスタブ関数を挿入し(ステップ2020)、このスタプ関数からステップ2010で操作した監視対象の関数の呼出をするコードを挿入し(ステップ2030)、監視コードも挿入する(ステップ2040)。最後に、ステップ2020で挿入したスタブ関数が監視対象として機能するように関数テーブルを変更する。
【0024】
このような処理を行うことで、ステップ2020で挿入したスタブ関数を経由して監視対象の関数の実行を監視することが可能となる。
【0025】
図7のステップ2020から2040ではスタブ関数をプログラム的に生成した.この場合、利用者が監視コードの振る舞いを細かく制御するためには監視コード挿入部11にこれに対応する機能を実装する必要がある。一方、監視対象のスタブ関数に利用者が記述したコードを利用すればこれを変形して挿入するだけでよい。任意の監視コード挿入を容易に実現できる。
【0026】
この手順について図8のフローを用いて説明する。図7で示した処理と異なるのはステップ2015の部分だけであるので、その部分だけを抜き出して説明する。まず、監視対象の関数の呼出規約を取得する(ステップ3000)。呼出規約とは、関数がどのような引数、返値を持つかなど、関数を呼び出す際に必要な規約である。次に得られた呼出規約を元に、スタブ関数のソースコードを生成する(ステップ3010)。これはファイルに出力しても良いし、GUI上にウィンドウを生成して出力しても良い。使用者はこのソースを必要に応じて修正し(ステップ3020)、ソースをコンパイルする(ステップ3030)。コンパイルのタイミングは、監視コード挿入部11が使用者による変更を検出して行っても良いし、使用者が行っても良い。コンパイルが終了したらコンパイルされたコードからスタブ関数として作成、コンパイルして部分を抽出しこれをスタブ関数として挿入する(ステップ3040)。最後に挿入したスタブ関数ゐ内容がプログラム実行に矛盾しないかをチェックして、必要なら修正する(ステップ3050)
前述した手順ではスタブのソース出力(ステップ3010)からソースのコンパイル(ステップ3030)を挿入時に行うように記したが、この処理を利用者がプログラム実行の前にあらかじめ行っておき、どの監視コードを挿入するかという情報を監視コード挿入制御部30から取得して、挿入時にはステップ3040,3050の処理だけを行うことで、高速化する方法も考えられる。あるいは、ステップ3000から3030までの処理を行う部分だけを別のプログラムとして実装することも可能である。
【0027】
また、前述の実施例では、1つの監視対象の関数に対して様々な種類の監視操作を行う場合に、1つのスタブ関数にそれらの複数の処理を既述するように既述した。次に一つの監視対象関数に対して、複数の監視コードを挿入する方式について説明する。
【0028】
図9にこの方式の概要を示した。図6に監視コードの挿入方法を図示したが、これは、スタブ関数を1つ使用する方式し、その中に監視コードを実装する方式である。一方、図9で示したのは、複数のスタブ関数としてスタブ関数Bと、スタブ関数Cの複数の関数を挿入する方法である(図9では2つの関数を挿入する例を示した)。この状態ではAに改名されたスタブ関数C(700)を呼び出すと、まず監視コードZ(612)が実行され、スタブ関数Bの呼出(704)が起こる。さらに、スタブ関数B(701)は改名された関数Aを呼び出し(705)、終了後に監視コードY(703)を実行する。このような構成でスタブ関数を入れ子で呼び出すことで複数の監視コードを1つの呼出で実行できる。
【0029】
図10にはこの関数Aに対して、どのスタブ関数を挿入するかを監視コード挿入制御部30に入力するテーブルの例である。この図では、監視対象の関数(801)と、挿入する関数の対応(802)が一行になっており、同一の監視対象関数に対して、複数の関数を挿入することが可能である。図では、関数Aに対して、スタブ関数Bとスタブ関数Cを挿入する場合の例を示した。この行の既述順序が挿入順、呼出順に反映するように実装することで、監視の精度を高めることが出来る。例えば、関数の実行時間の測定は出来るだけ監視対象の直前で行う必要があり、このような利用者の意図を反映できることで、監視の精度を高めることが可能となる。
【0030】
挿入処理は、一旦、監視対象の関数名に改名されたスタブを次の処理では監視対象と見なすことで、図4と図8のフローチャートがそのまま適用可能である。
【0031】
実施例では、ソースを生成してコンパイルする方法を示したが、より容易な方法として、例えばアセンブラ言語を使用してアセンブラで実行可能形式に変換してもよい。また、機械語あるいはインタブリタのバイトコードをユーザが入力し、このコードで監視実行する方式も考えられる。
【0032】
次に監視コードを監視対象のプログラムから自動生成する方法について記す。これまでの実施例では、監視コードと監視コード挿入制御ファイルを使用者が作製するという前提で説明したが、これをある程度自動化することでし、本発明自体の操作性を向上することが可能となる。図1の監視コード生成部70がこの機能を提供する。
【0033】
図11に基本的な動作のフローを示した。最初にプログラム解析部71が、プログラムファイル50を解析し、プログラム情報の取得、関数の抽出、関数の情報取得を行う(ステップ4010)。次にこれで取得したプログラム情報と、関数に適用できる監視コードテンプレート80を利用者に提示する(ステップ4020)。使用者は関数と利用する監視コードテンプレート80を指定する(ステップ4030)。この際に、後で編集する旨、指定しておくと(ステップ4040)、一旦エディタ74に監視コード、つまり監視関数のソースプログラムが出力されるので(ステップ4050)、出力メッセージなどを任意に編集して(ステップ4060)、これをコンパイラ75でコンパイルする(ステップ4070)。編集が必要なければ、ステップ4030から直接コンパイルを行う。コンパイルを行った監視コードと、監視コード生成部73が生成した監視コード挿入制御ファイル30、を監視コード配置部72が適切な位置に配置する。ステップ4010で読み込むプログラムはファイルからだけでなく、ネットワークや、メモリから読み出す場合でも以降の処理に何ら違いはない。
【0034】
図12に監視コードテンプレート80の構成について示す。監視コードテンプレート80は監視コード出力部81、動作設定部82、適合検査部83、および詳細情報出力部84からなる。監視コード出力部81は、監視コードのプログラムソースを生成する。例えば、関数実行の実行時間を測定する機能を提供する監視コードテンプレートであれば、実行時間を測定するプログラムを、監視コードとして使用できる形式で出力する。もし、ソースの編集が必要なければ直接監視コードを出力しても良い。
【0035】
動作設定部82は、監視コード出力部81が出力する監視コードの内容を変更するなどの、オプション的な指定を外部から行うためのものである。これは監視コード出力部81が直接オプションの設定を受け付けられれば、必須の構成要素ではない。適合検査部83は監視対象の関数に、当該監視コードテンプレートが出力するコードが利用できるかどうかを判断する。詳細情報出力部84は、監視コードテンプレートの説明などを出力する。
【0036】
監視コードテンプレートは例えばプログラムモジュールとして実装され、その場合には当該機能は関数として実装すると利用が容易である。または、監視コードテンプレートをデータベースに登録したデータとし、このデータベースを解析して監視コードを出力するものも考えられる。
【0037】
図13に、ステップ4020のプログラム内容と、適応できる監視コードテンプレートを利用者に提示する画面の一例を示す。モジュール名表示域901はプログラムの中のモジュール名やクラス名などを表示する。関数名表示域902には当該モジュール中の関数名を表示する。呼出方法表示域903には当該関数の呼出時の引数の型を表示する。戻り値表示域904には当該関数の戻り値の型を表示する。適用監視コード指定域905には、当該関数に使用できる監視コードが出力される。例えば、この図の場合、関数名method1にはログ取得と9051と実行時間測定9052の監視コードの挿入が指定されている。また関数method2は呼出の引数として文字列を取ることからmethod1の場合に加えて引数文字数チェック9053の監視コードの利用が選択できる。またオプションの指定として何文字であるかをチェックするかを設定するGUI9054が表示される。
【0038】
図13に示したGUIを表示するためのフローを図14に示した。最初に、プログラムファイル解析部71は、プログラムファイル50からプログラムモジュールを抽出し(ステップ5010)、さらにその中から関数510を取得する(ステップ5020)。監視コードテンプレート80を取得し(ステップ5030)、取得した関数に対して、当該監視コードテンプレートを適用できるかを判定する(ステップ5040)。適用できる場合は、さらに詳細情報を取得して(ステップ5050)、これを利用者に提示する情報に追加する(ステップ5060)。この処理を全てのテンプレートに対して行い(ステップ5070)、これらの処理を全ての関数に対して行い(ステップ5080)、さらにこれらの処理を全てのプログラムモジュールに対して行うことで(ステップ5090)、図13のような情報を利用者に提示することが可能となる。この例では全てのプログラムモジュール、関数、及び監視コードテンプレートを検索したが、予め、検索対象を利用者が正規表現などで指定して、検索対象を絞り込むことで、検索時間を短くしたり、必要のない情報が提示されることを制限することも可能である。
【0039】
監視コード生成部73は、監視コード挿入ファイルも併せて生成するが、これは、利用者が、どのモジュールのどの関数に対して、どの監視コードテンプレートを適用したかの情報から生成することが可能である。
【0040】
【発明の効果】
本発明によれば、監視するプログラムのソースコードやコンパイル作業をすることなくプログラム中の特定のあるいは全ての関数の実行を監視することができる。本発明を用いて(監視の必要な)特定の関数にだけ監視コードを挿入する場合には他の関数実行に負荷をかけずに監視を行うことができる。スタブ関数を挿入する方式を採用した場合には利用者の記述した任意の監視コードを挿入することができ、自由度の高い実行監視が可能となる。
【0041】
また、監視コードのテンプレートを利用することで利用者が監視コードを記述しなくても関数実行の詳細な監視が可能となる。
【図面の簡単な説明】
【図1】本発明の一実施例における全体構成を示すブロック図。
【図2】プログラムファイルの構成を示す図。
【図3】関数テーブルの構成を示す図。
【図4】監視コード挿入の手順を示したフローチャート。
【図5】監視コードが挿入された関数の構成を示す図。
【図6】監視コード挿入の他の例を説明する図。
【図7】スタブ関数挿入方式による監視コード導入の手順を示すフローチャート。
【図8】スタブ関数挿入方式による他の例の手順を示すフローチャート。
【図9】複数のスタブ関数を使用する場合の構成を示す図。
【図10】複数のスタブ関数を使用する場合の挿入順序指定方式を示す図。
【図11】監視コードを、監視コードテンプレートから生成する手順を示すフローチャート。
【図12】監視コードテンプレートの構成を示す図。
【図13】監視コードテンプレートを利用する際の画面例を示す図。
【図14】監視コードテンプレートを利用する際に利用者に提示する内容を取得する手順を示したフローチャート。
【符号の説明】
10…プログラム実行部、11…監視コード挿入部、20…プログラム格納部、30…監視コード挿入制御部、60…監視コード、50…プログラムファイル、70…監視コード生成部、510…関数、520…実行コード、530…関数テーブル。[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a method for efficiently monitoring program execution when a computer executes a program.
[0002]
[Prior art]
For monitoring the execution of a program executed by a computer, for example, a method of embedding a log output code in a program source and compiling the program to obtain an execution log is very common. (
[0003]
Most of the existing debuggers realize their functions by inserting debugging code into a program. For example, by embedding an instruction for generating a software interrupt in a program, an interrupt is generated when the code is executed, and it is possible to easily detect the execution of the program (for example, Patent Document 2) There are also profiling tools that measure how much time is spent in which parts of a program to detect bottlenecks, and these are often used in the program optimization process. . In these, when a program is read, a monitoring code is inserted into the program, and the execution state of the program is monitored by executing the monitoring code.
[0004]
[Patent Document 1]
JP-A-6-314221 [Patent Document 2]
JP-A-11-184727
[Problems to be solved by the invention]
The method of embedding the log output code requires a program source and this compilation environment for implementation, and it is not feasible if any of them is missing. The debugger has been developed with the intention of using it at the time of program development. It is difficult to use the debugger with a small load at the time of execution, and it cannot be used in the interpreter program execution environment.
[0006]
In addition, profiling tools require complex processing to insert monitoring code without affecting the operation of the program as much as possible (for example, stack operations are required to monitor arguments). Etc.) The present invention proposes a method of inserting a monitoring code into a program that can be easily used with a low load that can be used even during operation of the system.
[0007]
[Means for Solving the Invention]
In order to solve the above problem, when executing a program on a computer including a program storage unit that stores a program including a plurality of functions and a program execution unit that reads and executes the program from the storage unit, It is determined whether the read function of the program is a function to be monitored, and a monitoring code is inserted into the program so that monitoring processing is performed on the function to be monitored.
[0008]
At this time, the monitoring code is inserted at the beginning of the function to be monitored and immediately before the instruction for returning from the function. When the execution part of the program executes the function in which the monitoring code is inserted, the monitoring code is executed and the status of the function execution can be understood.
[0009]
Also, an address for calling the function to be monitored or the name of the function is changed, and a monitoring function including an instruction for calling the function whose name has been changed and a monitoring function including the above-described monitoring code are generated. The monitoring function may be inserted.
[0010]
In this case, if the monitoring code arbitrarily created by the user is compiled by the compiler once and transformed into a monitoring function, any code created by the user can be used as the monitoring code. A high degree of execution monitoring can be realized. Furthermore, in order to support the development of this monitoring function, the source of the monitoring code is generated based on the program to be monitored, presented to the user, modified if necessary, and compiled, making it even easier to use. Can be
[0011]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments of the present invention will be described with reference to the drawings. Note that the present invention is not limited to the embodiments.
[0012]
FIG. 1 shows the overall configuration of one embodiment of the present invention. According to the present invention, the monitoring
[0013]
The program execution unit 10 is mainly executed by a CPU, which may be an interpreter execution system or a normal execution system that executes a machine language. The
[0014]
The monitoring
[0015]
The program execution device includes, in addition to the program execution unit 10 and the
6 are connected by an
[0016]
FIG. 2 shows the configuration of the
[0017]
FIG. 3 shows an example of the structure of the function table. The function table 530 includes an
[0018]
FIG. 4 is a flowchart showing a process in which the program execution unit 10 of the present invention inserts a monitoring code while reading the
The function table 530 is changed (Step 1030), and
[0019]
FIG. 5 is a diagram showing a configuration of a function in which a monitoring code is inserted by the monitoring code insertion method shown in FIG. The upper part of the figure is executed first, and the lower instructions are executed in order. In this method, the
[0020]
Since the program execution unit 10 sequentially executes the program file in which the monitoring code is inserted by the monitoring
[0021]
The monitoring code itself may be a module implemented by a plurality of execution codes, a function call code that calls another monitoring code library, or a software interrupt in the case of machine language execution. May be generated. Examples of the operation of the monitoring code include control of external hardware, output of a log, change of a value of a variable, and the like. Further, the monitoring code may be inserted only at the time of executing the function or just before the end of the function execution.
[0022]
Next, another example of the monitoring code insertion method will be described with reference to FIG. In this method, first, a function to be monitored (for example, function A in this case) (610) is changed so that it looks like another function in program execution (615). For example, if the execution method calls a function by an address, the function table may be referred to (620) to move the function to another available address. In the case of an execution method that calls an function by designating an index to the function table (620), which is often adopted in the interpreter language, a new entry is added to the function table (620), and another name is given. Other information can be realized by copying the original information. Next, a stub function (611) called when called as the conventional function A is inserted. In this stap function (611), a code (613) for calling the function A, which has been renamed, is described. As a result, the call of the function A (610) calls the “renamed function A” (620) once via the stub function (611). At this time, if the monitoring code (612) exists before the call code (613) of the function A whose name has been changed of the stub function (611), the monitoring code (612) is prior to the function A (615). The content is executed, and similarly the subsequent monitoring code (614) will be called after the execution of the renamed function A (615). In this monitoring code, it becomes possible to monitor and change the value of the argument that should be passed to the function A, and to monitor and change the return value from the function A.
[0023]
FIG. 7 is a flowchart of the monitoring code insertion processing of the method shown in FIG. The only difference from the process described with reference to FIG. 4 is the
[0024]
By performing such processing, it becomes possible to monitor the execution of the function to be monitored via the stub function inserted in
[0025]
In
[0026]
This procedure will be described with reference to the flow of FIG. The only difference from the processing shown in FIG. 7 is the
In the above-described procedure, the source compilation of the stub (step 3010) and the compilation of the source (step 3030) are described as being performed at the time of insertion. However, this processing is performed in advance by the user before executing the program, and which monitoring code A method of increasing the speed by obtaining information on whether or not to insert from the monitoring code
[0027]
Further, in the above-described embodiment, when performing various types of monitoring operations on one function to be monitored, a plurality of processes are already described for one stub function. Next, a method of inserting a plurality of monitoring codes into one monitoring target function will be described.
[0028]
FIG. 9 shows an outline of this method. FIG. 6 shows a method of inserting a monitoring code. This is a method of using one stub function and mounting a monitoring code therein. On the other hand, FIG. 9 shows a method of inserting a plurality of stub functions B and C as a plurality of stub functions (FIG. 9 shows an example in which two functions are inserted). In this state, when the stub function C (700) renamed to A is called, first the monitoring code Z (612) is executed, and the stub function B is called (704). Further, the stub function B (701) calls the renamed function A (705), and executes the monitoring code Y (703) after the termination. By nesting stub functions in such a configuration, a plurality of monitoring codes can be executed by one call.
[0029]
FIG. 10 shows an example of a table for inputting which stub function is to be inserted into the function A to the monitoring code
[0030]
In the insertion processing, the stub renamed once to the function name of the monitoring target is regarded as the monitoring target in the next processing, so that the flowcharts of FIGS. 4 and 8 can be applied as it is.
[0031]
In the embodiment, the method of generating and compiling the source has been described. However, as an easier method, the source may be converted into an executable form by using an assembler language. In addition, a system is also conceivable in which a user inputs a machine language or a byte code of an interpreter, and performs monitoring with this code.
[0032]
Next, a method of automatically generating a monitoring code from a program to be monitored will be described. In the embodiments described so far, the description has been made on the assumption that the user creates the monitoring code and the monitoring code insertion control file.However, it is possible to improve the operability of the present invention itself by automating this to some extent. Become. The monitoring
[0033]
FIG. 11 shows a basic operation flow. First, the program analysis unit 71 analyzes the
[0034]
FIG. 12 shows the configuration of the
[0035]
The
[0036]
The monitoring code template is implemented, for example, as a program module, and in that case, the function is easy to use if implemented as a function. Alternatively, a monitoring code template may be used as data registered in a database, and the database may be analyzed to output a monitoring code.
[0037]
FIG. 13 shows an example of a screen for presenting the contents of the program in
[0038]
FIG. 14 shows a flow for displaying the GUI shown in FIG. First, the program file analysis unit 71 extracts a program module from the program file 50 (Step 5010), and further obtains a
[0039]
The monitoring
[0040]
【The invention's effect】
According to the present invention, it is possible to monitor the execution of a specific or all functions in a program without performing the source code of the program to be monitored or compiling. When the monitoring code is inserted only into a specific function (needing monitoring) using the present invention, monitoring can be performed without imposing a load on execution of other functions. When the method of inserting a stub function is adopted, an arbitrary monitoring code described by a user can be inserted, and execution monitoring with a high degree of freedom can be performed.
[0041]
Further, by using the monitoring code template, detailed monitoring of function execution is possible without the user writing a monitoring code.
[Brief description of the drawings]
FIG. 1 is a block diagram showing an overall configuration according to an embodiment of the present invention.
FIG. 2 is a diagram showing a configuration of a program file.
FIG. 3 is a diagram showing a configuration of a function table.
FIG. 4 is a flowchart showing a procedure for inserting a monitoring code.
FIG. 5 is a diagram showing a configuration of a function into which a monitoring code is inserted.
FIG. 6 is a view for explaining another example of insertion of a monitoring code.
FIG. 7 is a flowchart showing a procedure of introducing a monitoring code by a stub function insertion method.
FIG. 8 is a flowchart showing the procedure of another example using the stub function insertion method.
FIG. 9 is a diagram showing a configuration when a plurality of stub functions are used.
FIG. 10 is a diagram showing an insertion order designation method when a plurality of stub functions are used.
FIG. 11 is a flowchart showing a procedure for generating a monitoring code from a monitoring code template.
FIG. 12 is a diagram showing a configuration of a monitoring code template.
FIG. 13 is a view showing an example of a screen when a monitoring code template is used.
FIG. 14 is a flowchart showing a procedure for acquiring contents to be presented to a user when using a monitoring code template.
[Explanation of symbols]
Reference Signs List 10: program execution unit, 11: monitoring code insertion unit, 20: program storage unit, 30: monitoring code insertion control unit, 60: monitoring code, 50: program file, 70: monitoring code generation unit, 510: function, 520: Execution code, 530: Function table.
Claims (14)
上記記憶部から読み出したプログラムの関数が監視対象の関数であるかを判達する手段と、
監視対象の関数に対して監視処理が施されるようにプログラムに監視コードを挿入する監視コード挿入手段と、
監視コードが挿入された関数を実行して当該関数及び当該関数に対する監視処理を実行するプログラム実行手段とを備えたプログラム実行監視装置。Program storage means for storing a program including a plurality of functions;
Means for determining whether the function of the program read from the storage unit is a function to be monitored,
Monitoring code insertion means for inserting a monitoring code into a program so that a monitoring process is performed on a function to be monitored;
A program execution monitoring device comprising: a function in which a monitoring code is inserted; and a program execution unit that executes the function and a monitoring process for the function.
記憶部から読み出したプログラムの関数が監視対象の関数であるかを判定し、監視対象の関数に対して監視処理が施されるように当該プログラムに監視コードを挿入することを特徴とするプログラムの実行監視方法。A program execution monitoring method in a computer, comprising: a program storage unit that stores a program including a plurality of functions; and a program execution unit that reads and executes the program from the storage unit.
Determining whether the function of the program read from the storage unit is a function to be monitored, and inserting a monitoring code into the program so as to perform monitoring processing on the function to be monitored; Execution monitoring method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003079340A JP2004287869A (en) | 2003-03-24 | 2003-03-24 | Program execution monitoring device and method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003079340A JP2004287869A (en) | 2003-03-24 | 2003-03-24 | Program execution monitoring device and method |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2004287869A true JP2004287869A (en) | 2004-10-14 |
Family
ID=33293472
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2003079340A Pending JP2004287869A (en) | 2003-03-24 | 2003-03-24 | Program execution monitoring device and method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2004287869A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2007265190A (en) * | 2006-03-29 | 2007-10-11 | Fujitsu Ltd | Module embedding program, module embedding device and module embedding method |
JP2009015734A (en) * | 2007-07-06 | 2009-01-22 | Ntt Data Corp | Program profiling device, program profiling method and program |
JP2010033170A (en) * | 2008-07-25 | 2010-02-12 | Ntt Docomo Inc | Debugging support device |
JP2011070533A (en) * | 2009-09-28 | 2011-04-07 | Bank Of Tokyo-Mitsubishi Ufj Ltd | Code editing program and code editing apparatus |
JP5460928B1 (en) * | 2013-03-06 | 2014-04-02 | 三菱電機株式会社 | Programmable controller, programmable controller system, and execution error information creation method |
-
2003
- 2003-03-24 JP JP2003079340A patent/JP2004287869A/en active Pending
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2007265190A (en) * | 2006-03-29 | 2007-10-11 | Fujitsu Ltd | Module embedding program, module embedding device and module embedding method |
JP2009015734A (en) * | 2007-07-06 | 2009-01-22 | Ntt Data Corp | Program profiling device, program profiling method and program |
JP2010033170A (en) * | 2008-07-25 | 2010-02-12 | Ntt Docomo Inc | Debugging support device |
JP2011070533A (en) * | 2009-09-28 | 2011-04-07 | Bank Of Tokyo-Mitsubishi Ufj Ltd | Code editing program and code editing apparatus |
US8473903B2 (en) | 2009-09-28 | 2013-06-25 | The Bank Of Tokyo-Mitsubishi Ufj, Ltd. | Code edit apparatus and recording medium |
JP5460928B1 (en) * | 2013-03-06 | 2014-04-02 | 三菱電機株式会社 | Programmable controller, programmable controller system, and execution error information creation method |
WO2014136228A1 (en) * | 2013-03-06 | 2014-09-12 | 三菱電機株式会社 | Programmable controller, programmable controller system, and execute error information creation method |
CN105009006A (en) * | 2013-03-06 | 2015-10-28 | 三菱电机株式会社 | Programmable controller, programmable controller system, and execute error information creation method |
CN105009006B (en) * | 2013-03-06 | 2017-04-05 | 三菱电机株式会社 | Programmable Logic Controller, programable controller system and execution error message generation method |
US9753444B2 (en) | 2013-03-06 | 2017-09-05 | Mitsubishi Electric Corporation | Programmable controller, programmable controller system, and method of creating execution error information |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US5987250A (en) | Transparent instrumentation for computer program behavior analysis | |
JP2004164554A (en) | Device and method for executing and monitoring program | |
US8924937B1 (en) | Method and system for generating verification information and tests for software | |
US9514026B2 (en) | Debugging analysis in running multi-user systems | |
US5926638A (en) | Program debugging system for debugging a program having graphical user interface | |
US8752020B2 (en) | System and process for debugging object-oriented programming code leveraging runtime metadata | |
US6874140B1 (en) | Debug annotations | |
US7426717B1 (en) | System and method for debugging files in a runtime environment | |
Valente et al. | A semi-automatic approach for extracting software product lines | |
US20090013312A1 (en) | Executable High-Level Trace File Generation System and Method | |
JPH11316696A (en) | Relocatable measuring tag for testing and debugging of computer program | |
JP5208635B2 (en) | Information processing apparatus, information processing system, programming support method and program for supporting programming | |
US7624381B1 (en) | Portable detection of start and completion of object construction | |
Samuel et al. | A novel test case design technique using dynamic slicing of UML sequence diagrams | |
JP2004287869A (en) | Program execution monitoring device and method | |
JPH08314760A (en) | Program development supporting device | |
JP4055197B2 (en) | Device for analyzing procedures included in the program | |
JP2010287101A (en) | Software debugging device and method | |
JP3745968B2 (en) | Test system, test method, test program, and computer-readable recording medium recording the test program | |
JP2007004516A (en) | Program debugging method of built-in system | |
CN117785160B (en) | Behavior logic development and debugging method, system and device for low-code application | |
JP2672968B2 (en) | Source list output processing method for debugging | |
JP3077627B2 (en) | Debugging method and recording medium for recording debug program | |
JPH1165885A (en) | Device and method for debugging software | |
JPH04307630A (en) | Compiler with simple debugging option |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20050916 |
|
RD01 | Notification of change of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7421 Effective date: 20060420 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20080410 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20080415 |
|
A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20080902 |