JP2004054807A - Information processing method and apparatus - Google Patents

Information processing method and apparatus Download PDF

Info

Publication number
JP2004054807A
JP2004054807A JP2002214662A JP2002214662A JP2004054807A JP 2004054807 A JP2004054807 A JP 2004054807A JP 2002214662 A JP2002214662 A JP 2002214662A JP 2002214662 A JP2002214662 A JP 2002214662A JP 2004054807 A JP2004054807 A JP 2004054807A
Authority
JP
Japan
Prior art keywords
program
intermediate language
exception
machine language
source
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2002214662A
Other languages
Japanese (ja)
Other versions
JP4192519B2 (en
Inventor
Akira Ioku
井奥 章
Motoaki Satoyama
里山 元章
Yoshiaki Morimoto
森本 義章
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.)
Hitachi Ltd
Original Assignee
Hitachi 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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2002214662A priority Critical patent/JP4192519B2/en
Publication of JP2004054807A publication Critical patent/JP2004054807A/en
Application granted granted Critical
Publication of JP4192519B2 publication Critical patent/JP4192519B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

【課題】実行時にソースプログラムまたは中間語プログラムを機械語プログラムへ翻訳する処理を有する実行系において、デバッグ情報の生成に伴う性能の低下とメモリ消費量の増大を最小限に抑制しつつ、運用者がデバッグ情報を効果的に取得することのできる実行時プログラム翻訳方法および装置を提供する。
【解決手段】複数の電子計算機に共通のソースプログラムまたは中間語プログラムを解釈実行すると共に、計算機固有の機械語プログラムへ翻訳する実行時プログラム翻訳手段を備えるプログラム実行環境において、機械語プログラム実行中に例外発生を監視し、例外を検知した際に実行していた機械語プログラムの翻訳前のソースプログラムまたは中間語プログラムを機械語プログラムにデバッグ情報を生成しながら翻訳しなおすとともに、デバッグ情報をもとにソースプログラムまたは中間語プログラム上での例外発生箇所を特定する。
【選択図】 図1
In an execution system having a process of translating a source program or an intermediate language program into a machine language program at the time of execution, an operator while minimizing a decrease in performance and an increase in memory consumption accompanying generation of debug information are minimized. Provides a method and apparatus for translating a runtime program that can effectively obtain debug information.
In a program execution environment including a runtime program translating means for interpreting and executing a source program or an intermediate language program common to a plurality of computers and translating the source program or intermediate language program into a machine language program unique to the computer, Monitors the occurrence of an exception, re-translates the source program or intermediate language program of the machine language program that was being executed when the exception was detected, while generating debug information in the machine language program, and based on the debug information. Specify the location of the exception in the source program or intermediate language program.
[Selection diagram] Fig. 1

Description

【0001】
【発明の属する技術分野】
本発明は、実行時プログラム翻訳方法および装置に係り、特に、サーバ計算機と複数の機種の異なるクライアント計算機とがネットワークに接続されたネットワーク環境において、複数の計算機に共通に実行できる中間語プログラムをサーバ計算機から読み込んで、インタプリタのような解釈系によって実行する際に、読み込んだ中間語プログラムをクライアント計算機固有の機械語プログラムへ翻訳する実行時プログラム翻訳方法および装置に関する。
【0002】
【従来の技術】
計算機システムにおける複数機種の計算機に共通の中間語プログラムを利用する実行系においては、その性能向上を目的に、実行時に機械語プログラムへ翻訳する方法が採り入れられている。関係する従来技術として、例えば、特開平10−240546号公報等に記載された技術が知られている。
【0003】
このような実行時プログラム翻訳の使用においては、実行時プログラム翻訳におけるコンパイル処理(「実行時コンパイル」などと一般に呼称)によってCPU負荷が大きくなるとともに、中間語プログラムよりも生成する機械語プログラムの方が格納に必要なメモリサイズが大きくなることが知られている。そして、このようなCPU負荷やメモリ使用量を増やす傾向が実行時プログラム翻訳の適用の阻害要因になることが知られている。たとえば、同じくCPU負荷やメモリ使用量を増やす傾向を有する高信頼化機能、たとえばデバッガ向けの情報取得機能との併用が難しい。
【0004】
デバッガとは、コンピュータプログラム実行時のエラーの検出やデバッグに利用されるツールであり、プログラムの実行をトレースしたり、異常終了時の状態からエラー発生地点を検出する機能をもつことが知られている。このような機能の実現に寄与するのが、上述したデバッガ向けの情報(デバッグ情報)であり、一例として、プログラム翻訳して得られた機械語プログラムが翻訳前の中間語プログラムやソースプログラムのどの部分に対応するかを示す情報を含む。
【0005】
デバッグ情報の生成機能を実行時プログラム翻訳機能(実行時コンパイラ)と併用すると、ソースプログラムまたは中間語プログラムを解釈実行中に機械語プログラムへ翻訳する処理を行う際に、機械語プログラムのデバッグ情報を生成する処理が加わる。結果として、CPU負荷やメモリ使用量に対する実行時プログラム翻訳とデバッグ情報生成、双方のオーバーヘッドが累積するため、システム全体の性能低下が顕著になり双方の併用が難しくなるのである。
【0006】
また、デバッグ情報の生成がプログラム翻訳時(コンパイル時)の最適化を難しくすることも、実行時翻訳との同時サポートに不利になる。最適化とは実行時間の短縮などを目的にプログラムに対して行うコンパイル処理中の変換作業であるが、この変換が、最適化コードともとのソースコードとの対応づけに関する正確な把握を困難にするためである。
【0007】
以上の状況は、従来技術において、高速化を追求するとデバッグの支障となることを意味しており、高速化と高信頼性との両立の困難さを示している。Java(R)の実行系においても事情は同様である。
【0008】
Java(R)の実行系においては、デバッガ向けの情報取得のために、Java(R) Virtual Machine Debugger Interface (JVMDI)が存在するが、このJVMDIと、Java(R)の実行時翻訳技術として知られるジャスト・イン・タイム (Just−In−Time, JIT) コンパイラとの、同時併用を認めない仕様になっているのが一般的である。この事例は、実行時コンパイラ利用時にはエラー発生の際に得られるデバッグ情報が少なくなるためにデバッグが困難になること、すなわち、JITコンパイラなどの実行時コンパイラの適用が実行系全体としての信頼性のマイナス要因に働くことを示唆している。
【0009】
【発明が解決しようとする課題】
本発明は、JITコンパイラを伴うJava(R)実行系のように、ソースプログラムまたは中間語プログラムを解釈実行中に機械語プログラムへ翻訳する処理を有する実行系において、前述した従来技術の問題点を解決し、デバッグ情報の生成に伴う性能の低下とメモリ消費量の増大を最小限に抑制しつつ、運用者がデバッグ情報を効果的に取得することのできる実行時プログラム翻訳方法および装置を提供することを目的とする。
【0010】
【発明を解決するための手段】
本発明においては、複数の電子計算機に共通のソースプログラムまたは中間語プログラムを解釈実行すると共に、計算機固有の機械語プログラムへ翻訳する実行時翻訳方法において、ソースプログラムまたは中間語プログラムを解釈実行する解釈実行部と、前記ソースプログラムまたは中間語プログラムをモジュール単位に機械語プログラムに翻訳する実行時翻訳部とを備え、前記実行時翻訳部により解釈された前記機械語プログラム実行中に例外発生を監視する例外監視部、を備えている。前記実行時翻訳部は、デバッグ情報を生成せずに、処理速度の確保とメモリ消費量の抑制を優先させる。
【0011】
さらに、本発明においては、前記例外監視部によって例外を検知した際にその直前に実行していた機械語プログラムに相当するソースプログラムまたは中間語プログラムをモジュール単位でデバッグ情報を生成しながら機械語プログラムに翻訳しなおし、生成したデバッグ情報をもとにソースプログラムまたは中間語プログラム上での例外発生箇所を特定する例外時翻訳部を備える。
【0012】
本発明によれば、通常時はデバッグ情報を持たずに実行し、異常時にのみ必要なデバッグ情報を出力できる。すなわち、デバッグ情報の生成契機を例外発生時に限定することと、性能要求の厳しい通常運用時にはデバッグ情報を生成しないことが特徴的であり、正常運用時の処理遅延を防ぐとともに、デバッグ情報の必要性の高い例外発生時や異常発生時にはデバッグ情報を生成して運用者に現象解析などに必要な情報を提供することができる。
さらに、本発明によれば、デバッグ情報付きの機械語プログラムへの実行時プログラム翻訳を利用可能性の高い例外発生時や異常発生時に限定することによって、生成する機械語に対するデバッグ情報を保持するメモリ領域を削減できるので、メモリ消費量の増大を抑制できる。
【0013】
【発明の実施の形態】
以下、図面を参照して本発明の実施の形態を詳細に説明する。
【0014】
図1は本発明の一実施形態による実行時プログラム翻訳方法を実施する装置の概略構成を示すブロック図である。図1において、110は中央処理装置、120は主記憶装置、121は基本制御部、122は中間語ファイル読み込み部、123は中間語データ解釈実行部、124は実行時翻訳部、125は機械語データ、126はデバッグ情報テーブル、127は中間語データ、128は例外監視部、129は例外時翻訳部、130は入力装置、140は表示装置、150は通信装置、160は外部記憶装置、161は中間語ファイルである。
【0015】
主記憶装置120には、基本制御部121と、中間語ファイル読み込み部122と、中間語解釈実行部123と、実行時翻訳部124とがロードされて格納される。また、主記憶装置120には、中間語ファイル読み込み部によって生成された中間語データ127、中間語解釈実行部123によって生成された実行頻度データ、実行時翻訳部124によって生成された機械語データ125が格納される。また、外部記憶装置160には、中間語ファイル161が格納される。
【0016】
基本制御部121は、本発明による方法を実施する装置全体を制御するプログラムであり、図示装置が立ち上げられたとき、中央処理装置110によって実行され、装置のハードウェアとプログラムとの基本制御を行う。そして、装置の各ハードウェアと各プログラムの例外発生を検出して、例外を検出した場合には例外監視部128に通知することも可能である。
【0017】
中間語ファイル読み込み部122は、通信装置150及びネットワークを介して外部記憶装置160から中間語ファイル161を読み込み、中間語データ127を生成するプログラムである。
【0018】
中間語解釈実行部123は、中間語データ127の解釈実行を行うインタプリタが一例であり、中間語データ127を解釈して直接実行すると共に、中間語データ127の実行途中の例外を検出し例外監視部128に通知することも可能である。
【0019】
実行時翻訳部124は、プログラム翻訳実行部であり、実行頻度データから最も実行頻度の高い中間語データ127のモジュールを選び出し、機械語データ125に変換する。処理速度の確保とメモリ消費量の抑制のために、デバッグ情報を生成しない。
【0020】
機械語データ125は、中央処理装置110に直接実行させることが可能な機械語で表現されたプログラムである。
【0021】
デバッグ情報テーブル126は、デバッグに必要な情報を格納するテーブルであり、ソース・中間語・機械語の対応づけに関わる情報を含む。図2に示すように、デバッグ情報テーブル126は、ソース・中間語・機械語対応テーブル200を含む。ソース・中間語・機械語対応テーブル200は、ソースプログラム内の名前やステートメントから機械語プログラムへの対応づけ(マッピング)を記述するものである。この対応づけの情報の用途の一例として、障害が発生するとその時点での実行位置に対応するソースの場所を決めるために使われる。また、ソースプログラムと機械語プログラムとの間の中間的なデータ構造をアクセスしたほうがソースプログラムへの対応づけが速く確実なケースを想定して、ソース・中間語・機械語対応テーブル200には、中間語プログラムとの対応づけが併記されている。
【0022】
また、ソース・中間語・機械語対応テーブル200は、本発明の一実施の形態において文情報についての情報を記載した文情報テーブル201と変数情報について記載した変数情報テーブル202とから構成される。
【0023】
中間語データ127は、中間語ファイル161を主記憶装置120に読み込んだデータであり、中間語解釈実行部123によって1命令ずつ解釈実行される。
【0024】
中間語ファイル161は、特定の計算機システムに依存しない仮想的な命令(中間語命令)で記述された中間語プログラムが格納されたファイルである。また、この中間語プログラムが或るソースプログラムを変換して得られたものである場合には、中間語プログラムの各部分が変換前のソースプログラムのどの部分に相当するかの対応づけが可能な情報が、このファイルに格納されている。
【0025】
例外監視部128は、例外の発生を検出し、主記憶装置120に存在するが図示しない例外発生フラグをオンにする。例外検出部の検出する例外は、ハードウェア例外、及び基本制御部121から通知されるソフトウェア例外の他に、中間語データ解釈実行部123の処理で発生する例外、例えばJava(R)言語における例外(Exception)クラスのオブジェクトがスローされる事が考えられる。
【0026】
例外時翻訳部129は、本発明を最も特徴付けるものであり、例外監視部128が例外の発生を検知した際に、基本制御部121を通じて起動され、その直前に実行していた機械語データ125のもとになる中間語モジュールから実行時翻訳部124が生成した機械語データ125に対応するデバッグ情報を生成する。そして、このデバッグ情報をもとに、機械語データ125と、機械語に翻訳前のソースプログラムまたは中間語プログラムとを対応づけて、例外発生時に実行していた機械語データ125に対応するソースプログラム情報を特定する。
【0027】
また、中間語ファイル読み込み部122と、中間語解釈実行部123と、実行時翻訳部124とは、基本制御部121によって、外部記憶装置160から通信装置150及びネットワークを介して主記憶装置120に読み込まれて中央処理装置110で実行される。
【0028】
図3は中間語データ127の一例を示す図である。図3において、300は中間語モジュールであり、中間語モジュール300は、中間語モジュール300のモジュール名301、この中間語モジュール300に対応するデバッグ情報テーブル126へのポインタ302、中間語モジュール300を翻訳した結果得られる機械語データ125へのポインタ303、中間語モジュール300の中間語プログラムの命令列を格納する中間語データ領域304により構成される。そして、中間語データ127は、複数の中間語モジュール300から構成される。
【0029】
図4は機械語データ125の一例を示す図である。図4において、400は機械語モジュールであり、この機械語モジュール400は、複数の機械語命令を格納したデータ領域により構成される。そして、機械語データ125は、このような複数の機械語モジュール400から構成される。
【0030】
図5は本発明の一実施の形態による翻訳方法を実行する際の基本制御部121の起動時における処理手順を説明するフローチャートである。図5に示すフローは、基本制御部121が、中間語ファイル161を読み込んだ後、中間語解釈実行部123と、実行時翻訳部124とを起動する処理を示している。このとき、中間語解釈実行部123と、実行時翻訳部124とは並行して実行される。
(1)まず、基本制御部121は、中間語ファイル読み込み部122を起動し、中間語ファイル読み込み部122の処理が完了するのを待つ(ステップ501)。
(2)基本制御部121は、中間語ファイル読み込み部122の処理の完了後、中間語解釈実行部123を起動する(ステップ502)。
(3)次に、基本制御部121は、実行時翻訳部124を起動する(ステップ503)。
(4)次に、基本制御部121は、図1には示していない例外発生フラグがオンの場合には、すなわち、例外が検出されている場合に、例外時翻訳部129を起動する(ステップ504、ステップ505)。
【0031】
図6は中間語ファイル読み込み部122の処理手順を説明するフローチャートである。図6に示すフローは、中間語ファイル読み込み部122が、中間語ファイル161を読み込み、中間語データ127を生成する処理を示している。
(1)中間語ファイル読み込み部122は、図5に説明したステップ501の処理で基本制御部121により起動されると、通信装置150及びネットワークを介して外部記憶装置160から中間語ファイル161を読み込む(ステップ601)。
(2)次に、中間語ファイル読み込み部122は、中間語データ127を生成する。ここで、生成しされた中間語データ127は、図3で説明したように、複数の中間語モジュール300により構成され、中間語ファイル読み込み部122は、各モジュール毎にモジュール名301に読み込んだモジュール名を格納し、デバッグ情報テーブル126へのポインタ302と機械語データ125へのポインタ303とを”0”で初期化し、中間語データ領域304に、読み込んだ中間語ファイル161に格納されている中間語プログラムを書き込む(ステップ602)。
【0032】
図7は中間語解釈実行部123の処理手順を説明するフローチャートである。図7に示すフローは、中間語解釈実行部123が、中間語データ127の解釈実行を繰り返す処理を示している。
(1)中間語解釈実行部123は、図5に説明したステップ502の処理で基本制御部121により起動されると、中間語データ127から1つだけ中間語モジュール300を選択する。初期状態では、”MAIN”をモジュール名301に持つ中間語モジュールを選択する(ステップ701)。
(2)次に、中間語解釈実行部123は、ステップ701で選択した中間語モジュール300が機械語プログラムへ翻訳済みか否かを判定し、翻訳済みであった場合、ステップ701で選択した中間語モジュール300に含まれる機械語データ125へのポインタ303が指し示す機械語モジュール400に格納された機械語プログラムを、基本制御部121に実行させ、実行終了後ステップ701の処理に戻る(ステップ702、703)。
(3)中間語解釈実行部123は、ステップ701で選択した中間語モジュール300に含まれる中間語データ領域304の1命令を読み込み、その命令が終了命令か否かを判定し、終了命令である場合処理を終了する(ステップ705、706)。
(4)ステップ706の判定で読み込んだ命令が終了命令でなかった場合、中間語解釈実行部123は、ステップ705で読み込んだ命令が呼出し命令か否かを判定し、その命令が呼出し命令であった場合処理を終了し、そうでない場合、ステップ705で読み込んだ命令を直接実行した後、ステップ705の処理に戻って、次の命令の処理を続ける(ステップ707、708)。
【0033】
図8は実行時翻訳部124の処理手順を説明するフローチャートである。図8に示すフローは、中間語プログラムを機械語プログラムへ翻訳する処理に相当し、中間語モジュール300から他の中間語モジュールへの呼出し命令がある場合に、呼び出される中間語モジュール300から先に再帰的に機械語プログラムに翻訳し、機械語データ125へのポインタ303が指し示す機械語モジュール400に格納する処理を示している。
(1)実行時翻訳部124は、引数で渡される中間語モジュール300に含まれる中間語データ領域304から中間語命令を1つだけ読み出し、読み出した中間語命令が他のモジュールへの呼出し命令か否かを判定する(ステップ801、802)。
(2)ステップ802の判定で、読み出した中間語命令が他のモジュールへの呼出し命令である場合、呼出し先の中間語モジュールを引数に実行時翻訳部124を再帰的に呼び出して、その中間語モジュールに対して中間語プログラムを機械語プログラムへ翻訳する処理を開始させる(ステップ804)。
(3)ステップ802の判定で、読み出した中間語命令が他のモジュールへの呼出し命令でなかった場合、実行時翻訳部124は、ステップ801で読み出した中間語命令を機械語命令に変換し機械語モジュール400に書き込む(ステップ803)。
(4)次に、実行時翻訳部124は、ステップ801で引数として渡された中間語モジュール300に含まれる中間語モジュール300に未処理の中間語命令が残っているか判定し、残っている場合、ステップ801の処理に戻り、次の中間語命令に対する処理を続ける(ステップ805)。
(5)ステップ805の判定で、未処理の中間語命令が残っていなかった場合、実行時翻訳部124は、機械語モジュール400を指し示すポインタを、機械語データ125へのポインタ303に格納する(ステップ806)。
【0034】
次に例外時翻訳部129の処理手順を説明する。これは例外発生時の処理に相当する。例外監視部128が例外の発生を検出すると図1には示されていない例外発生フラグをオンにする。図5のフローが示すように、例外発生フラグがオンの場合には、基本制御部121が実行時翻訳部124を起動せずに例外時翻訳部129を起動する(ステップ504、ステップ505)。
【0035】
基本制御部121により起動された例外時翻訳部129は、例外発生時に処理していたモジュール名301を含む中間語ファイル161を、ソースプログラムと中間語ファイルとの対応がつくようなデバッグ情報を生成するために、再び読み込む。中間語ファイル161にはソースプログラム上での位置等を示すソース情報が含まれているので、これに基づいてソースプログラムと中間語ファイルとの対応を、ソース・中間語・機械語対応テーブル200に記録する。
【0036】
例外時翻訳部129は、次に、中間語モジュール300と機械語モジュール400との対応がつくようなデバッグ情報を生成するために中間語モジュール300を再び機械語に翻訳する。
【0037】
図9はソース・中間語・機械語対応テーブル200の一例を示した本発明の一実施の形態であり、例外時翻訳部129が生成するデバッグ情報が記録された様子を示すものであり、デバッグ情報テーブル126に含まれる。ソース・中間語・機械語対応テーブル200は、本発明の一実施の形態において(a)文情報テーブル201と(b)変数情報テーブル202とから構成される。
【0038】
図9における本発明の一実施の形態において、文情報テーブル201は、ソースプログラム文番号9011と、中間語プログラム命令アドレス9012と、機械語プログラム命令アドレス9013のフィールドを持つ。例えばエントリ9014は、ソースプログラムの文番号10の文が、中間語プログラムでは、「000060」というアドレスに位置する命令となり、機械語プログラムでは「000040」というアドレスに位置する命令となることを示している。一例として、前記中間語プログラム命令アドレス9012のフィールドには、各中間語モジュール300内の先頭からのオフセットを示す数値が記載されている。また、前記機械語命令アドレス9013のフィールドには、各機械語モジュール400内の先頭からのオフセットを示す数値が記載されている。
【0039】
本発明の一実施の形態において、変数情報テーブル202は、変数名9021と、変数種別9022と、型9023と、文番号9024、および機械語アドレス9025の5つのフィールドを持つ。変数名9026はソースプログラムにおける変数名、変数種別9022は局所変数/大域変数の区別、型9023はその変数のデータ型、文番号9024はその変数が宣言されたソースプログラム上の位置を表す。機械語アドレス9025はその変数の機械語プログラム上でのアドレス情報を示すものである。例えばエントリ9026は、変数iが、局所変数であり、型はintで、ソースプログラムの文番号4に位置し、機械語プログラム上で変数が格納される領域先頭からオフセットが−4であることを示している。なお、変数が格納される領域先頭の先頭アドレス(ベースアドレス)は、一例として、基本制御部121が保持しているフレームポインタ等のレジスタ情報の内容を読み出すことによって可能である。
【0040】
なお、コンパイル時に最適化がなされて機械語内のステートメントの移動や削除がなされた場合などにおいてソースプログラムと中間語プログラムと機械語プログラムの相互の対応づけが困難なことが知られているが、このような場合には変形例として、1対1対応でなく、文番号と複数の命令アドレスとを対応づけて示すことも本発明の趣旨を逸脱せずに実施することが可能である。
【0041】
図10は、例外時翻訳部129が実行中に例外が発生させた中間語モジュール300を対象に、中間語命令の各中間語モジュール300のオフセットとこれを変換して生成した機械語命令の各機械語モジュール400内でのオフセットとを対応づけながら機械語プログラムに翻訳しなおし、ソース・中間語・機械語対応テーブル200にデバッグ情報として記録する処理を、フローチャートにて説明するものである。
【0042】
ここで、中間語モジュール300から他の中間語モジュールへの呼び出し命令がある場合に、呼び出される中間語モジュール300から先に再帰的に機械語プログラムに翻訳する処理は行わない。
(1)例外時翻訳部129は、引数で渡される中間語モジュール300に含まれる中間語データ領域304から中間語命令を1つだけ読み出す(ステップ1001)。
(2)例外時翻訳部129は、ステップ1001で読み出した中間語命令を機械語命令に変換し、中間語モジュール300先頭からのオフセットをデバッグ情報テーブル126内の文情報テーブルの中間語プログラム命令アドレス2012欄に書き込み、機械語モジュール400先頭からのオフセットをデバッグ情報テーブル126内の文情報テーブル201の機械語命令アドレス2013欄に書き込む(ステップ1002〜ステップ1004)。
(3)次に、例外時翻訳部129は、ステップ1001で引数として渡された中間語モジュール300に含まれる中間語モジュール300に未処理の中間語命令が残っているか判定し、残っている場合、ステップ1001の処理に戻り、次の中間語命令に対する処理を続ける(ステップ1005)。
(4)ステップ1005の判定で、未処理の中間語命令が残っていなかった場合、実行時翻訳部124は、ステップ1002〜ステップ1004で生成されたデバッグ情報テーブル126を指し示すポインタを、デバッグ情報テーブル126へのポインタ302に格納する(ステップ1006)。
【0043】
さらに、例外時翻訳部129は、前記デバッグ情報テーブル126の内容を活用して、ダンプを出力したり、警告を発したりする。実行時のダンプとして出力される情報は、プログラムのデバッグに必要な、例えばプログラムカウンタ、変数の値、スタックポインタの値、及び生成スレッド数、日時などの情報で、ソース・中間語・機械語対応テーブル200を用いて取得する。例として、例外発生時にソースプログラムのどの部分(行数(文番号))を実行していたかについての情報、そして当該ソースプログラム内の変数について例外発生時の値を表示する場合を示す。
【0044】
図11に示すフローは、例外時翻訳部129が例外発生時にソースプログラムのどの部分(行数(文番号))を実行していたかについての情報を収集して出力するまでの処理手順を示している。
【0045】
例外時翻訳部129は、はじめに例外発生時に実行していた命令アドレスおよびモジュール名を取り出す(ステップ1101)。これは基本制御部121が保持しているプログラムカウンタ等の内容を読み出すことによって可能である。次に命令アドレスまたはその近傍に存在する単一または複数の機械語を取り出す(ステップ1102)。
【0046】
ついで例外時翻訳部129は、実行時翻訳部124によって生成済みの機械語モジュール400を探索し、例外発生時に実行していた機械語モジュールのなかから前記ステップ1102で取り出した機械語の所在(先頭からのオフセット)を求める(ステップ1103)。そして、求めたオフセットに対応するソース行数(文番号)を例外時翻訳部129が生成した前記デバッグ情報テーブル126の文情報テーブル201から取得する(ステップ1104)。取得した内容は表示装置140に出力する(ステップ1105)。
【0047】
ここで、変形例として、機械語が最適化されていてソースと機械語対応が単一の行(文)に限定できない場合には、代わりにモジュール内の複数の行(文)を例外発生箇所の範囲として報告(出力)してもよい。
【0048】
図12に示すフローは、例外時翻訳部129が例外発生時に実行していたソースプログラム内の変数について例外発生時の値を出力するまでの処理手順を示している。
【0049】
例外時翻訳部129は、はじめにデバッグ情報テーブル126の中間語・機械語対応テーブル200(以降、単に対応テーブルと呼ぶこともある)を参照して、前記モジュールに対応するソースプログラム上での変数を取り出す(ステップ1201)。
【0050】
ついで例外時翻訳部129は、前記変数の内容が格納されている主記憶上のアドレスに変換する(ステップ1202)。そのためには、前記変数について、変数情報テーブル202に記載のオフセットを取得し、変数が格納されている領域のベースアドレスを加算することで主記憶上のアドレスを得る。
【0051】
そして例外時翻訳部129は、ステップ1202で得られたアドレスの内容を主記憶から読み出し(ステップ1203)、読み出した内容を、変数のデータ型に従って変換し、変数命とその値を表示装置140上に出力する(ステップ1204)。
【0052】
以上、本発明の一実施形態について説明したが、本発明は上述した実施形態に限定されるものではない。本発明は、上述した説明から可能な範囲で、また、本発明の実施形態から導かれる範囲で、種々の変形例が可能である。例えば、上述した実施形態は、ソフトウエアを含むものであるが、本発明は、ハードウェアとソフトウェアとの組み合わせ、又はハードウェアのみによって実装され得るものである。本発明は、様々なプログラミング言語によって実装することができる。
【0053】
【発明の効果】
本発明では、異常が発生しプログラムの実行が停止した場合でも容易にデバッグを行え、かつ運用時の処理が高速なプログラム実行環境を提供できる。
【0054】
すなわち、本発明によれば、デバッグ情報の生成契機を例外発生時に限定すること、すなわち、性能要求が厳しくその必要性の低い通常運用時には実行時翻訳に関するデバッグ情報を生成しないことが特徴的であり、正常運用時の処理遅延を防ぎながらその必要性の高い例外発生時や異常発生時にのみ実行時翻訳に関するデバッグ情報を運用者に提供することができる。
【0055】
また、システムの運用管理者などのユーザからみれば、ソースプログラムまたは中間語プログラムを解釈実行中に機械語プログラムへ翻訳する処理を有する実行系において、実行時プログラム翻訳の性能を低下させることなく運用を行えるとともに、運用中のプログラムが異常終了した場合にはその後のデバッグ作業に必要な情報を入手することができる。
【0056】
さらに、本発明によれば、デバッグ情報付きの機械語プログラムへの翻訳を最も利用可能性の高い例外発生時や異常発生時に限定することによって、従来技術では困難であったデバッグ情報付きの実行時翻訳による使用メモリ量の増大を抑制することができ、しかも必要十分な保守性や信頼性を確保できる。
【図面の簡単な説明】
【図1】装置の概略構成を示すブロック図である。
【図2】デバッグ情報テーブルの構成を示す図である。
【図3】中間語データの一例を示す図である。
【図4】機械語データの一例を示す図である。
【図5】基本制御部の処理を示すフローチャートである
【図6】中間語ファイル読み込み部の処理を示すフローチャートである。
【図7】中間語解釈実行部の処理を示すフローチャートである。
【図8】実行時翻訳部の処理を示すフローチャートである。
【図9】ソース・中間語・機械語対応テーブルの構成を示す図である。
【図10】例外時翻訳部によるデバッグ情報生成の処理を示すフローチャートである。
【図11】例外時翻訳部によるソース行数情報取得の処理を示すフローチャートである。
【図12】例外時翻訳部による変数の値の取得処理を示すフローチャートである。
【符号の説明】
110‥中央処理装置、120‥主記憶装置、121‥基本制御部、122‥中間語ファイル読み込み部、123‥中間語解釈実行部、124‥実行時翻訳部、125‥機械語データ、126‥デバッグ情報テーブル、127‥中間語データ、128‥例外監視部、129‥例外時翻訳部、130‥入力装置、140‥表示装置、150‥通信装置、160‥外部記憶装置、161‥中間語ファイル、200‥ソース・中間語・機械語対応テーブル、201‥文情報テーブル、202‥変数情報テーブル、300‥中間語モジュール、301‥モジュール名、302‥デバッグ情報テーブル126へのポインタ、303‥機械語データ125へのポインタ、304‥中間語データ領域、400‥機械語モジュール。
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a runtime program translation method and apparatus, and more particularly to a server program and an intermediate language program that can be commonly executed by a plurality of computers in a network environment in which a server computer and a plurality of different types of client computers are connected to a network. The present invention relates to a runtime program translating method and apparatus for translating a read intermediate language program into a machine language program unique to a client computer when the program is read from a computer and executed by an interpretation system such as an interpreter.
[0002]
[Prior art]
In an execution system that uses an intermediate language program common to a plurality of types of computers in a computer system, a method of translating into a machine language program at the time of execution has been adopted for the purpose of improving the performance. As a related related art, for example, a technology described in Japanese Patent Application Laid-Open No. 10-240546 is known.
[0003]
In the use of such a runtime program translation, a CPU load increases due to a compilation process (generally referred to as “runtime compilation”) in the runtime program translation, and a machine language program generated more than an intermediate language program is used. It is known that the memory size required for storing the data becomes large. It is known that such a tendency to increase the CPU load and the memory usage becomes a hindrance to the application of the runtime program translation. For example, it is difficult to use together with a high reliability function that also tends to increase the CPU load and memory usage, for example, an information acquisition function for a debugger.
[0004]
A debugger is a tool used to detect and debug errors during the execution of a computer program.It is known that a debugger has the function of tracing the execution of a program and detecting the location of an error from the status at the time of abnormal termination. I have. What contributes to the realization of such a function is the above-described information for a debugger (debug information). As an example, a machine language program obtained by translating a program is used in any of an intermediate language program and a source program before translation. Includes information indicating whether it corresponds to the part.
[0005]
When the debug information generation function is used together with the run-time program translation function (run-time compiler), the debug information of the machine language program is translated when the process of translating the source program or intermediate language program into the machine language program is performed. Generate processing is added. As a result, the overhead of both the translation of the runtime program and the generation of debug information with respect to the CPU load and the memory usage is accumulated, so that the performance of the entire system is significantly reduced and it is difficult to use both.
[0006]
Also, the generation of debug information makes it difficult to optimize a program at the time of translation (at the time of compilation), which is disadvantageous for simultaneous support at the time of runtime translation. Optimization is a conversion operation during the compilation process performed on a program for the purpose of shortening the execution time, etc., but this conversion makes it difficult to accurately grasp the correspondence between the optimized code and the original source code. To do that.
[0007]
The above situation means that in the prior art, pursuit of high speed impedes debugging, and indicates difficulty in achieving both high speed and high reliability. The situation is the same in the execution system of Java (R).
[0008]
In the Java (R) execution system, there is a Java (R) Virtual Machine Debugger Interface (JVMDI) for acquiring information for a debugger, and this is known as a runtime translation technology of the Java (R) and Java (R). Generally, the specification is such that simultaneous use with a just-in-time (JIT) compiler is not permitted. In this case, when the runtime compiler is used, debugging becomes difficult because the amount of debug information obtained when an error occurs is small. That is, the application of a runtime compiler such as a JIT compiler makes the reliability of the entire execution system unreliable. It suggests that it works for negative factors.
[0009]
[Problems to be solved by the invention]
The present invention solves the problems of the prior art described above in an execution system having a process of translating a source program or an intermediate language program into a machine language program during interpretation and execution, such as a Java (R) execution system with a JIT compiler. The present invention provides a runtime program translation method and apparatus that enables an operator to effectively acquire debug information while minimizing a decrease in performance and an increase in memory consumption accompanying generation of debug information. The purpose is to:
[0010]
[Means for Solving the Invention]
According to the present invention, in a runtime translation method for interpreting and executing a source program or an intermediate language program common to a plurality of computers and translating the source program or the intermediate language program into a machine language program unique to the computer, an interpretation for interpreting and executing the source program or the intermediate language program An execution unit, and a runtime translation unit that translates the source program or the intermediate language program into a machine language program in a module unit, and monitors an exception during execution of the machine language program interpreted by the runtime translation unit. An exception monitoring unit. The runtime translator gives priority to securing processing speed and suppressing memory consumption without generating debug information.
[0011]
Further, according to the present invention, a source program or an intermediate language program corresponding to a machine language program executed immediately before an exception is detected by the exception monitoring unit while generating debug information on a module basis, And an exception translator for specifying an exception occurrence location in the source program or the intermediate language program based on the generated debug information.
[0012]
According to the present invention, normal execution is performed without debug information, and necessary debug information can be output only when an error occurs. In other words, it is characteristic that the timing of generation of debug information is limited to when an exception occurs, and that debug information is not generated during normal operation where performance requirements are severe. This prevents processing delays during normal operation and the necessity of debug information. When exceptions or abnormalities occur with a high level of error, debug information can be generated and the operator can be provided with information necessary for phenomena analysis and the like.
Further, according to the present invention, a memory for holding debug information for a generated machine language by limiting runtime program translation to a machine language program with debug information at the time of exceptional or abnormal occurrence with high availability Since the area can be reduced, an increase in memory consumption can be suppressed.
[0013]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
[0014]
FIG. 1 is a block diagram showing a schematic configuration of an apparatus for executing a runtime program translation method according to an embodiment of the present invention. In FIG. 1, 110 is a central processing unit, 120 is a main storage device, 121 is a basic control unit, 122 is an intermediate language file reading unit, 123 is an intermediate language data interpretation execution unit, 124 is a runtime translation unit, and 125 is a machine language Data, 126 is a debug information table, 127 is intermediate language data, 128 is an exception monitoring unit, 129 is an exception translation unit, 130 is an input device, 140 is a display device, 150 is a communication device, 160 is an external storage device, and 161 is an external storage device. This is an intermediate language file.
[0015]
In the main storage device 120, a basic control unit 121, an intermediate language file reading unit 122, an intermediate language interpretation execution unit 123, and a runtime translation unit 124 are loaded and stored. In the main storage device 120, the intermediate language data 127 generated by the intermediate language file reading unit, the execution frequency data generated by the intermediate language interpretation execution unit 123, and the machine language data 125 generated by the runtime translation unit 124 are stored. Is stored. The external storage device 160 stores an intermediate language file 161.
[0016]
The basic control unit 121 is a program that controls the entire apparatus that performs the method according to the present invention, and is executed by the central processing unit 110 when the illustrated apparatus is started up, and performs basic control of the hardware and the program of the apparatus. Do. Then, it is also possible to detect the occurrence of an exception in each hardware and each program of the apparatus and notify the exception monitoring unit 128 when the exception is detected.
[0017]
The intermediate language file reading unit 122 is a program that reads the intermediate language file 161 from the external storage device 160 via the communication device 150 and the network, and generates intermediate language data 127.
[0018]
The intermediate language interpretation execution unit 123 is an example of an interpreter that interprets and executes the intermediate language data 127, interprets the intermediate language data 127 and directly executes the intermediate language data 127, detects an exception during the execution of the intermediate language data 127, and monitors the exception. It is also possible to notify the unit 128.
[0019]
The execution time translation unit 124 is a program translation execution unit, selects a module of the intermediate language data 127 having the highest execution frequency from the execution frequency data, and converts it into machine language data 125. No debug information is generated to ensure processing speed and reduce memory consumption.
[0020]
The machine language data 125 is a program expressed in a machine language that can be directly executed by the central processing unit 110.
[0021]
The debug information table 126 is a table for storing information necessary for debugging, and includes information related to correspondence between a source, an intermediate language, and a machine language. As shown in FIG. 2, the debug information table 126 includes a source / intermediate language / machine language correspondence table 200. The source / intermediate language / machine language correspondence table 200 describes correspondence (mapping) from names and statements in the source program to the machine language program. As an example of the use of this association information, when a failure occurs, it is used to determine the location of the source corresponding to the execution position at that time. Also, assuming a case where accessing an intermediate data structure between the source program and the machine language program is faster and more reliable, the source / intermediate / machine language correspondence table 200 includes: The association with the intermediate language program is also described.
[0022]
The source / intermediate language / machine language correspondence table 200 includes a sentence information table 201 in which information on sentence information is described and a variable information table 202 in which variable information is described in one embodiment of the present invention.
[0023]
The intermediate language data 127 is data obtained by reading the intermediate language file 161 into the main storage device 120, and is interpreted and executed one by one by the intermediate language interpretation executing unit 123.
[0024]
The intermediate language file 161 is a file that stores an intermediate language program described by virtual instructions (intermediate language instructions) independent of a specific computer system. When this intermediate language program is obtained by converting a certain source program, it is possible to associate each part of the intermediate language program with which part of the source program before conversion. Information is stored in this file.
[0025]
The exception monitoring unit 128 detects the occurrence of an exception and turns on an exception occurrence flag (not shown) that exists in the main storage device 120. Exceptions detected by the exception detection unit include hardware exceptions, software exceptions notified from the basic control unit 121, and exceptions that occur in the processing of the intermediate language data interpretation execution unit 123, for example, exceptions in the Java (R) language. It is conceivable that an object of the (Exception) class is thrown.
[0026]
The exception-time translating unit 129 is the most characteristic of the present invention. When the exception monitoring unit 128 detects the occurrence of an exception, the exception-time translating unit 129 is activated through the basic control unit 121 and executes the processing of the machine language data 125 executed immediately before. Debug information corresponding to the machine language data 125 generated by the runtime translation unit 124 is generated from the base intermediate language module. Then, based on the debug information, the machine language data 125 is associated with the source program or the intermediate language program before translation to the machine language, and the source program corresponding to the machine language data 125 that was being executed when the exception occurred. Identify information.
[0027]
Further, the intermediate language file reading unit 122, the intermediate language interpretation executing unit 123, and the runtime translating unit 124 are transmitted from the external storage device 160 to the main storage device 120 via the communication device 150 and the network by the basic control unit 121. It is read and executed by the central processing unit 110.
[0028]
FIG. 3 is a diagram showing an example of the intermediate language data 127. In FIG. 3, reference numeral 300 denotes an intermediate language module. The intermediate language module 300 translates the module name 301 of the intermediate language module 300, a pointer 302 to a debug information table 126 corresponding to the intermediate language module 300, and the intermediate language module 300. A pointer 303 to the machine language data 125 obtained as a result, and an intermediate language data area 304 for storing an instruction sequence of an intermediate language program of the intermediate language module 300. The intermediate language data 127 includes a plurality of intermediate language modules 300.
[0029]
FIG. 4 is a diagram illustrating an example of the machine language data 125. In FIG. 4, reference numeral 400 denotes a machine language module. The machine language module 400 includes a data area storing a plurality of machine language instructions. The machine language data 125 is composed of a plurality of such machine language modules 400.
[0030]
FIG. 5 is a flowchart illustrating a processing procedure at the time of starting the basic control unit 121 when executing the translation method according to the embodiment of the present invention. The flow illustrated in FIG. 5 illustrates a process in which the basic control unit 121 reads the intermediate language file 161 and then starts the intermediate language interpretation execution unit 123 and the runtime translation unit 124. At this time, the intermediate language interpretation execution unit 123 and the runtime translation unit 124 are executed in parallel.
(1) First, the basic control unit 121 activates the intermediate language file reading unit 122 and waits for completion of the processing of the intermediate language file reading unit 122 (Step 501).
(2) After the processing of the intermediate language file reading unit 122 is completed, the basic control unit 121 activates the intermediate language interpretation execution unit 123 (Step 502).
(3) Next, the basic control unit 121 activates the runtime translation unit 124 (Step 503).
(4) Next, when an exception occurrence flag not shown in FIG. 1 is turned on, that is, when an exception is detected, the basic control unit 121 activates the exception-time translating unit 129 (step S1). 504, step 505).
[0031]
FIG. 6 is a flowchart illustrating a processing procedure of the intermediate language file reading unit 122. The flow illustrated in FIG. 6 illustrates a process in which the intermediate language file reading unit 122 reads the intermediate language file 161 and generates the intermediate language data 127.
(1) The intermediate language file reading unit 122 reads the intermediate language file 161 from the external storage device 160 via the communication device 150 and the network when activated by the basic control unit 121 in the processing of step 501 described in FIG. (Step 601).
(2) Next, the intermediate language file reading unit 122 generates intermediate language data 127. Here, the generated intermediate language data 127 is composed of a plurality of intermediate language modules 300, as described with reference to FIG. 3, and the intermediate language file reading unit 122 reads the module name read into the module name 301 for each module. The intermediate name stored in the intermediate language file 161 is stored in the intermediate language data area 304 by initializing the pointer 302 to the debug information table 126 and the pointer 303 to the machine language data 125 with “0”. A word program is written (step 602).
[0032]
FIG. 7 is a flowchart illustrating a processing procedure of the intermediate language interpretation execution unit 123. The flow illustrated in FIG. 7 illustrates a process in which the intermediate language interpretation execution unit 123 repeats the execution of the interpretation of the intermediate language data 127.
(1) When activated by the basic control unit 121 in the process of step 502 described in FIG. 5, the intermediate language interpretation execution unit 123 selects only one intermediate language module 300 from the intermediate language data 127. In the initial state, an intermediate language module having "MAIN" as the module name 301 is selected (step 701).
(2) Next, the intermediate language interpretation execution unit 123 determines whether or not the intermediate language module 300 selected in step 701 has been translated into a machine language program, and if it has been translated, the intermediate language module selected in step 701 The basic control unit 121 executes the machine language program stored in the machine language module 400 pointed to by the pointer 303 to the machine language data 125 included in the language module 300, and returns to the processing of step 701 after the execution is completed (step 702, 703).
(3) The intermediate language interpretation execution unit 123 reads one instruction in the intermediate language data area 304 included in the intermediate language module 300 selected in step 701, determines whether the instruction is an end instruction, and determines that the instruction is an end instruction. In the case, the process is terminated (steps 705 and 706).
(4) If the command read in step 706 is not an end command, the intermediate language interpretation execution unit 123 determines whether the command read in step 705 is a call command, and determines that the command is a call command. If not, the process is terminated; otherwise, the instruction read in step 705 is directly executed, and the process returns to step 705 to continue the processing of the next instruction (steps 707 and 708).
[0033]
FIG. 8 is a flowchart illustrating a processing procedure of the runtime translator 124. The flow illustrated in FIG. 8 corresponds to a process of translating an intermediate language program into a machine language program. When there is a call instruction from the intermediate language module 300 to another intermediate language module, the intermediate language module 300 to be called is first transmitted. A process of recursively translating into a machine language program and storing in a machine language module 400 indicated by a pointer 303 to machine language data 125 is shown.
(1) The runtime translator 124 reads out only one intermediate language instruction from the intermediate language data area 304 included in the intermediate language module 300 passed as an argument, and determines whether the read intermediate language instruction is a call instruction to another module. It is determined whether or not it is (steps 801 and 802).
(2) If it is determined in step 802 that the read intermediate language instruction is a call instruction to another module, the runtime translation unit 124 is recursively called with the intermediate language module to be called as an argument, and the intermediate language The module starts the process of translating the intermediate language program into the machine language program (step 804).
(3) If it is determined in step 802 that the read intermediate language instruction is not a call instruction to another module, the runtime translation unit 124 converts the intermediate language instruction read in step 801 into a machine language instruction, Write into the word module 400 (step 803).
(4) Next, the runtime translator 124 determines whether an unprocessed intermediate language instruction remains in the intermediate language module 300 included in the intermediate language module 300 passed as an argument in step 801. , The process returns to step 801 to continue the process for the next intermediate language instruction (step 805).
(5) If no unprocessed intermediate language instruction remains in the determination in step 805, the runtime translator 124 stores the pointer pointing to the machine language module 400 in the pointer 303 to the machine language data 125 ( Step 806).
[0034]
Next, the processing procedure of the exception-time translator 129 will be described. This corresponds to the processing when an exception occurs. When the exception monitoring unit 128 detects the occurrence of an exception, it turns on an exception flag not shown in FIG. As shown in the flow of FIG. 5, when the exception occurrence flag is ON, the basic control unit 121 activates the exception-time translator 129 without activating the runtime translator 124 (steps 504 and 505).
[0035]
The exception-time translating unit 129 activated by the basic control unit 121 generates the intermediate language file 161 including the module name 301 being processed at the time of occurrence of the exception, and generates debug information for associating the source program with the intermediate language file. Read again to make it. Since the intermediate language file 161 includes source information indicating a position on the source program and the like, the correspondence between the source program and the intermediate language file is stored in the source / intermediate language / machine language correspondence table 200 based on the source information. Record.
[0036]
Next, the exception-time translating unit 129 translates the intermediate language module 300 again into a machine language in order to generate debug information that allows the correspondence between the intermediate language module 300 and the machine language module 400.
[0037]
FIG. 9 shows an embodiment of the present invention showing an example of the source / intermediate language / machine language correspondence table 200. FIG. 9 shows a state where debug information generated by the exception-time translator 129 is recorded. It is included in the information table 126. The source / intermediate language / machine language correspondence table 200 includes an (a) sentence information table 201 and (b) a variable information table 202 in one embodiment of the present invention.
[0038]
In the embodiment of the present invention shown in FIG. 9, the statement information table 201 has fields of a source program statement number 9011, an intermediate language program instruction address 9012, and a machine language program instruction address 9013. For example, entry 9014 indicates that the statement with statement number 10 of the source program is an instruction located at the address “0000060” in the intermediate language program and an instruction located at the address “0000040” in the machine language program. I have. As an example, in the field of the intermediate language program instruction address 9012, a numerical value indicating an offset from the head in each intermediate language module 300 is described. In the field of the machine language instruction address 9013, a numerical value indicating an offset from the head in each machine language module 400 is described.
[0039]
In one embodiment of the present invention, the variable information table 202 has five fields: a variable name 9021, a variable type 9022, a type 9023, a statement number 9024, and a machine language address 9025. A variable name 9026 indicates a variable name in the source program, a variable type 9022 indicates a distinction between a local variable and a global variable, a type 9023 indicates a data type of the variable, and a statement number 9024 indicates a position in the source program where the variable is declared. The machine language address 9025 indicates address information of the variable on the machine language program. For example, entry 9026 states that variable i is a local variable, of type int, located at statement number 4 of the source program, and having an offset of -4 from the beginning of the area where the variable is stored in the machine language program. Is shown. The head address (base address) at the head of the area where the variables are stored can be obtained by reading the contents of register information such as a frame pointer held by the basic control unit 121, for example.
[0040]
It is known that it is difficult to correlate a source program, an intermediate language program, and a machine language program in cases such as when statements in a machine language are moved or deleted due to optimization during compilation. In such a case, as a modified example, instead of a one-to-one correspondence, a statement number and a plurality of instruction addresses may be shown in association with each other without departing from the gist of the present invention.
[0041]
FIG. 10 shows the offset of each intermediate language module 300 of the intermediate language instruction and the machine language instruction generated by converting the offset of the intermediate language module 300 for the intermediate language module 300 in which an exception has occurred during execution of the exception-time translating unit 129. A process for translating the offset into the machine language program while associating the offset with the offset in the machine language module 400 and recording it as debug information in the source / intermediate language / machine language correspondence table 200 will be described with reference to a flowchart.
[0042]
Here, if there is a call instruction from the intermediate language module 300 to another intermediate language module, the process of recursively translating the intermediate language module 300 to the machine language program first is not performed.
(1) The exception-time translation unit 129 reads only one intermediate language instruction from the intermediate language data area 304 included in the intermediate language module 300 passed as an argument (step 1001).
(2) The exception-time translator 129 converts the intermediate language instruction read in step 1001 into a machine language instruction, and sets the offset from the head of the intermediate language module 300 as the intermediate language program instruction address of the statement information table in the debug information table 126. Write into the 2012 column, and write the offset from the top of the machine language module 400 into the machine language instruction address 2013 column of the statement information table 201 in the debug information table 126 (steps 1002 to 1004).
(3) Next, the exception-time translating unit 129 determines whether an unprocessed intermediate language instruction remains in the intermediate language module 300 included in the intermediate language module 300 passed as an argument in step 1001. , The process returns to step 1001, and the process for the next intermediate language instruction is continued (step 1005).
(4) If no unprocessed intermediate language instruction remains in the determination in step 1005, the runtime translating unit 124 sets the pointer pointing to the debug information table 126 generated in steps 1002 to 1004 to the debug information table. It is stored in the pointer 302 to the pointer 126 (step 1006).
[0043]
Further, the exception-time translating unit 129 outputs a dump or issues a warning using the contents of the debug information table 126. The information output as a dump at the time of execution is the information necessary for debugging the program, such as the program counter, the value of variables, the value of the stack pointer, the number of threads created, the date and time, etc. It is acquired using the table 200. As an example, a case is shown in which information on which part (line number (statement number)) of the source program was being executed at the time of occurrence of an exception and a value at the time of occurrence of an exception are displayed for variables in the source program.
[0044]
The flow shown in FIG. 11 shows a processing procedure until the exceptional translator 129 collects and outputs information on which part (line number (sentence number)) of the source program was being executed when the exception occurred. I have.
[0045]
The exception-time translator 129 first extracts the instruction address and module name that were being executed when the exception occurred (step 1101). This can be achieved by reading the contents of the program counter and the like held by the basic control unit 121. Next, one or a plurality of machine words existing at or near the instruction address are extracted (step 1102).
[0046]
Next, the exception-time translating unit 129 searches for the machine language module 400 that has been generated by the runtime translating unit 124, and finds the location of the machine language extracted in step 1102 from among the machine language modules that were being executed at the time of occurrence of the exception (top Is obtained (step 1103). Then, the number of source lines (sentence number) corresponding to the obtained offset is acquired from the sentence information table 201 of the debug information table 126 generated by the exception-time translating unit 129 (step 1104). The acquired content is output to the display device 140 (step 1105).
[0047]
Here, as a modified example, when the machine language is optimized and the correspondence between the source and the machine language cannot be limited to a single line (sentence), a plurality of lines (sentences) in the module are replaced with the exception occurrence location. May be reported (output) as a range.
[0048]
The flow illustrated in FIG. 12 illustrates a processing procedure until the exception-time translating unit 129 outputs the value at the time of occurrence of an exception for a variable in the source program that was being executed when the exception occurred.
[0049]
First, the exception-time translator 129 refers to the intermediate language / machine language correspondence table 200 (hereinafter, sometimes simply referred to as a correspondence table) in the debug information table 126 to determine a variable in the source program corresponding to the module. It is taken out (step 1201).
[0050]
Next, the exception-time translator 129 converts the variable into an address on the main memory where the content of the variable is stored (step 1202). For this purpose, an offset in the variable information table 202 is obtained for the variable, and the base address of the area where the variable is stored is added to obtain an address on the main memory.
[0051]
Then, the exception-time translator 129 reads the content of the address obtained in step 1202 from the main memory (step 1203), converts the read content according to the data type of the variable, and displays the variable order and its value on the display device 140. (Step 1204).
[0052]
As described above, one embodiment of the present invention has been described, but the present invention is not limited to the above-described embodiment. Various modifications of the present invention are possible within the range possible from the above description and the range derived from the embodiment of the present invention. For example, the above-described embodiments include software, but the present invention can be implemented by a combination of hardware and software, or only by hardware. The invention can be implemented by various programming languages.
[0053]
【The invention's effect】
According to the present invention, it is possible to provide a program execution environment in which debugging can be easily performed even when an error occurs and execution of a program is stopped, and processing at the time of operation is fast.
[0054]
That is, according to the present invention, it is characteristic that the timing of generation of debug information is limited to the time of occurrence of an exception, that is, debug information relating to runtime translation is not generated during normal operation when performance requirements are severe and the need is low. In addition, debug information relating to runtime translation can be provided to the operator only at the time of exception occurrence or abnormal occurrence, which is highly necessary, while preventing processing delay during normal operation.
[0055]
Also, from the viewpoint of a system administrator or the like, in an execution system having a process of translating a source program or an intermediate language program into a machine language program while interpreting and executing, it is possible to operate the system without degrading the performance of runtime program translation. In addition to the above, when the running program terminates abnormally, it is possible to obtain information necessary for subsequent debugging work.
[0056]
Furthermore, according to the present invention, the translation into a machine language program with debug information is limited to the most-usable exception occurrence or abnormality occurrence, so that it is difficult to execute with debug information with the prior art. An increase in the amount of used memory due to translation can be suppressed, and necessary and sufficient maintainability and reliability can be secured.
[Brief description of the drawings]
FIG. 1 is a block diagram showing a schematic configuration of an apparatus.
FIG. 2 is a diagram showing a configuration of a debug information table.
FIG. 3 is a diagram illustrating an example of intermediate language data.
FIG. 4 is a diagram illustrating an example of machine language data.
FIG. 5 is a flowchart illustrating processing of a basic control unit.
FIG. 6 is a flowchart illustrating processing of an intermediate language file reading unit.
FIG. 7 is a flowchart illustrating processing of an intermediate language interpretation execution unit.
FIG. 8 is a flowchart showing a process of a runtime translation unit.
FIG. 9 is a diagram showing a configuration of a source / intermediate language / machine language correspondence table.
FIG. 10 is a flowchart illustrating a process of generating debug information by an exception-time translating unit.
FIG. 11 is a flowchart illustrating a process of acquiring source line number information by an exception-time translating unit.
FIG. 12 is a flowchart illustrating a process of acquiring a value of a variable by an exception-time translating unit.
[Explanation of symbols]
110 central processing unit, 120 main storage unit, 121 basic control unit, 122 intermediate file reading unit, 123 intermediate language interpreting execution unit, 124 runtime translation unit, 125 machine language data, 126 debugging Information table, 127 intermediate data, 128 exception monitoring unit, 129 exception translation unit, 130 input device, 140 display device, 150 communication device, 160 external storage device, 161 intermediate language file, 200 {Source / intermediate language / machine language correspondence table, 201} sentence information table, 202} variable information table, 300 {intermediate language module, 301} module name, 302 {pointer to debug information table 126, 303} machine language data 125 Pointer to, 304 $ intermediate data area, 400 $ machine language module.

Claims (2)

複数の電子計算機に共通のソースプログラムまたは中間語プログラムを解釈実行すると共に、計算機固有の機械語プログラムへ翻訳する実行時プログラム翻訳手段を備えるプログラム実行環境において、前記機械語プログラム実行中に例外発生を監視する例外監視手段と、前記例外監視手段によって例外を検知した際に実行していた機械語プログラムの翻訳前のソースプログラムまたは中間語プログラムを機械語プログラムにデバッグ情報を生成しながら翻訳しなおすとともに、前記デバッグ情報をもとにソースプログラムまたは中間語プログラム上での例外発生箇所を特定する例外時プログラム翻訳手段とを備えることを特徴とする情報処理装置。In a program execution environment which interprets and executes a source program or an intermediate language program common to a plurality of computers and translates it into a computer-specific machine language program, in a program execution environment, occurrence of an exception during execution of the machine language program Exception monitoring means for monitoring, and re-translating the source program or intermediate language program before translation of the machine language program that was being executed when the exception monitoring means detected the exception while generating debug information in the machine language program And an exception-time program translating means for specifying an exception occurrence location in a source program or an intermediate language program based on the debug information. 複数の電子計算機に共通のソースプログラムまたは中間語プログラムを解釈実行すると共に、計算機固有の機械語プログラムへ翻訳する実行時プログラム翻訳工程を備えるプログラム実行方法において、前記実行時プログラム翻訳工程により解釈された前記機械語プログラム実行中に例外発生を監視する例外監視工程と、前記例外監視工程によって例外を検知した際に実行していた機械語プログラムの翻訳前のソースプログラムまたは中間語プログラムをデバッグ情報を生成しながら機械語プログラムに翻訳しなおすとともに、生成したデバッグ情報をもとにソースプログラムまたは中間語プログラム上での例外発生箇所を特定する例外時プログラム翻訳工程とを備えることを特徴とする情報処理方法。In a program execution method, which includes a runtime program translation step of interpreting and executing a source program or an intermediate language program common to a plurality of computers, and translating into a computer-specific machine language program, the program is interpreted by the runtime program translation step. An exception monitoring step of monitoring the occurrence of an exception during execution of the machine language program; and generating debug information of a source program or an intermediate language program before translation of the machine language program that was being executed when the exception was detected by the exception monitoring step. While translating the program into a machine language program while specifying the location of an exception in the source program or the intermediate language program based on the generated debug information. .
JP2002214662A 2002-07-24 2002-07-24 Information processing method and apparatus Expired - Fee Related JP4192519B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002214662A JP4192519B2 (en) 2002-07-24 2002-07-24 Information processing method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2002214662A JP4192519B2 (en) 2002-07-24 2002-07-24 Information processing method and apparatus

Publications (2)

Publication Number Publication Date
JP2004054807A true JP2004054807A (en) 2004-02-19
JP4192519B2 JP4192519B2 (en) 2008-12-10

Family

ID=31936892

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002214662A Expired - Fee Related JP4192519B2 (en) 2002-07-24 2002-07-24 Information processing method and apparatus

Country Status (1)

Country Link
JP (1) JP4192519B2 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011107883A (en) * 2009-11-16 2011-06-02 Renesas Electronics Corp Debugging device
KR20110060822A (en) * 2009-11-30 2011-06-08 인터내셔널 비지네스 머신즈 코포레이션 Memory optimization of virtual machine code by segmenting foreign information

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011107883A (en) * 2009-11-16 2011-06-02 Renesas Electronics Corp Debugging device
KR20110060822A (en) * 2009-11-30 2011-06-08 인터내셔널 비지네스 머신즈 코포레이션 Memory optimization of virtual machine code by segmenting foreign information
JP2011118901A (en) * 2009-11-30 2011-06-16 Internatl Business Mach Corp <Ibm> Method for memory optimization of virtual machine code by partitioning extraneous information, computer program, and system
KR101699981B1 (en) * 2009-11-30 2017-01-26 인터내셔널 비지네스 머신즈 코포레이션 Memory optimization of virtual machine code by partitioning extraneous information

Also Published As

Publication number Publication date
JP4192519B2 (en) 2008-12-10

Similar Documents

Publication Publication Date Title
EP2359247B1 (en) Transforming user script code for debugging
US9766911B2 (en) Support for a non-native application
JP4094724B2 (en) Apparatus and method for identifying exceptions when debugging software
US20030074650A1 (en) Debugger operating system for embedded systems
US20080127113A1 (en) Method and system for implementing watchpoints
CN101482845B (en) Method and system for calling instant debugger
US8458681B1 (en) Method and system for optimizing the object code of a program
US20120331449A1 (en) Device, method and computer program product for evaluating a debugger script
US20080270840A1 (en) Device and method for testing embedded software using emulator
KR102025078B1 (en) Diagnosing code using single step execution
US8429632B1 (en) Method and system for debugging merged functions within a program
CN101446918A (en) Method for realizing debugging of single function by user state debugger and system thereof
US8533683B2 (en) Stack walking enhancements using sensorpoints
CN101241444A (en) Debug method for dynamic binary translation
US20090044040A1 (en) Modification of array access checking in aix
US20020073359A1 (en) System and method for high priority machine check analysis
US7523446B2 (en) User-space return probes
US7526756B2 (en) Address watch breakpoints with basing pointers
JP4192519B2 (en) Information processing method and apparatus
US20080127118A1 (en) Method and system for dynamic patching of software
US7073096B2 (en) File path resolving debugger
US5903719A (en) Emulator apparatus and emulation method for efficiently analyzing program faults
US20070150866A1 (en) Displaying parameters associated with call statements
JP2659366B2 (en) Debugging method and device
CN118672811A (en) Program abnormality analysis method, device, electronic device and storage medium

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20040330

RD01 Notification of change of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7421

Effective date: 20060419

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20070605

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20070803

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20070918

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20071114

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20080603

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20080731

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

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20080908

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111003

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121003

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20131003

Year of fee payment: 5

LAPS Cancellation because of no payment of annual fees