JPH0695921A - Simulation method and program debugging system - Google Patents

Simulation method and program debugging system

Info

Publication number
JPH0695921A
JPH0695921A JP4272422A JP27242292A JPH0695921A JP H0695921 A JPH0695921 A JP H0695921A JP 4272422 A JP4272422 A JP 4272422A JP 27242292 A JP27242292 A JP 27242292A JP H0695921 A JPH0695921 A JP H0695921A
Authority
JP
Japan
Prior art keywords
instruction
host computer
instruction sequence
program
computer
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.)
Withdrawn
Application number
JP4272422A
Other languages
Japanese (ja)
Inventor
Yuugo Kashiwagi
有吾 柏木
Tsutomu Hayashi
努 林
Yoshihiro Shinoda
佳博 篠田
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 JP4272422A priority Critical patent/JPH0695921A/en
Publication of JPH0695921A publication Critical patent/JPH0695921A/en
Withdrawn legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

PURPOSE:To speed up processing in the case of simulating or debugging the execution of a program for a target computer by a host computer. CONSTITUTION:A compiler 2 generates an object information program 6 from a source program 1 for the target computer. The program 6 is obtained by translating instruction strings (including no jump instruction, branch instruction, or restoring instruction from a subroutine on the way) for the target computer which can be sequentially executed into instruction strings for the host computer 3. Since simulation is executed in each translated instruction string, the convensional overhead of instruction interpretation as data for the execution of one step can be reduced and the speed-up of simulation can be attained.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は、シミュレーション方
法、更にはプログラムデバッグシステムに係り、例えば
ホスト計算機上でターゲット計算機のプログラムをデバ
ッグするシミュレータデバッガなどに適用して有効な技
術に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a simulation method and a program debug system, and more particularly to a technique effectively applied to a simulator debugger for debugging a program of a target computer on a host computer.

【0002】[0002]

【従来の技術】従来のシミュレータデバッガ若しくはシ
ミュレータは、ターゲット計算機の命令をデータとして
持ち、それを一命令ごとに解釈実行(1ステップ実行)
することによってシミュレーションの目的を達してい
た。すなわち、ターゲット計算機とホスト計算機の実行
環境はCPU(中央処理装置)を含めて大きく異なるた
め、シミュレータは、ソフトウェアでターゲット計算機
の実行環境を表現し、そのターゲット計算機の機械語を
データとして受け取って命令単位に解釈し、対応する動
作を擬似的に実現する。このような手法を以下インタプ
リタ方式という。また、シミュレータデバッガを用いて
高級言語レベルでデバッグを行うには、高級言語で指定
された変数やソース行番号の情報と、オブジェクトプロ
グラムのアドレス、サイズなどの対応情報とをデータと
して持ち、このデータを解釈すなわち検索して参照する
ことによってデバッグのために必要な操作を行ってい
た。例えばこの操作としては、デバッグ時の参照のため
に必要なソースプログラムの変数アドレスの取得、ソー
スプログラムの行番号からターゲットプログラムのアド
レス取得などの操作である。なお、シミュレーションに
ついて記載された文献の例としては昭和59年11月3
0日にオーム社から発行された「LSIハンドブック」
第561頁がある。
2. Description of the Related Art A conventional simulator debugger or simulator has instructions of a target computer as data, and interprets and executes each instruction (one step execution).
The goal of the simulation was achieved by doing. That is, since the execution environments of the target computer and the host computer are significantly different, including the CPU (Central Processing Unit), the simulator expresses the execution environment of the target computer by software, receives the machine language of the target computer as data, and gives instructions. Interpret in units and realize the corresponding operation in a pseudo manner. Such a method is hereinafter referred to as an interpreter method. In addition, in order to perform debugging at a high-level language level using the simulator debugger, the variables and source line numbers specified in the high-level language and corresponding information such as the address and size of the object program are stored as data. The necessary operation for debugging was performed by interpreting, that is, searching and referencing. For example, this operation is an operation such as acquisition of the variable address of the source program necessary for reference at the time of debugging, acquisition of the address of the target program from the line number of the source program, and the like. In addition, as an example of the document describing the simulation, November 3, 1984.
"LSI Handbook" issued by Ohmsha on the 0th
There is page 561.

【0003】[0003]

【発明が解決しようとする課題】しかしながら、インタ
プリタ方式のシミュレーションでは、ターゲット計算機
の命令コードをデータとして受け取って命令単位に解釈
して対応する動作を模擬するため、命令コードの解釈実
行のオーバヘッドによってターゲット計算機上での実行
に比べて著しく低速になるという問題点がある。また、
高級言語レベルでのデバッグ機能は、各言語ごとにデバ
ッグ情報の規約を設け、該デバッグ情報を解釈実行する
ことによってデバッグを行なっていた。この方式では、
デバッグ情報に関するデータのテーブル検索のような処
理が必要になるため実行速度が低下するだけでなく、タ
ーゲット計算機のソースプログラムを記述するための高
級言語毎にデバッグ情報の規約を設ける必要があり、そ
のための処理を予めシミュレータデバッガに組み込む必
要があった。これはシミュレータデバッガの汎用性を著
しく損なっている。
However, in the interpreter type simulation, since the instruction code of the target computer is received as data and is interpreted in the instruction unit to simulate the corresponding operation, the overhead of the interpretation execution of the instruction code causes the target. There is a problem that it becomes significantly slower than execution on a computer. Also,
The debugging function at the high-level language level has been designed by providing a rule for debugging information for each language and interpreting and executing the debugging information for debugging. With this method,
Not only does the execution speed decrease because processing such as a table search of data related to debug information is required, but it is also necessary to establish a debug information convention for each high-level language for writing the source program of the target computer. It was necessary to incorporate the above process into the simulator debugger in advance. This significantly impairs the versatility of the simulator debugger.

【0004】本発明の目的はターゲット計算機のための
プログラムの実行をホスト計算機でシミュレーション、
更にはデバッグするときの処理の高速化を図ることにあ
る。本発明の別の目的は、デバッグ対象プログラムを記
述した高級言語の種類に係らず同一のシミュレータデバ
ッガでデバッグできる機能を実現することにある。
An object of the present invention is to simulate execution of a program for a target computer on a host computer,
Furthermore, it is intended to speed up the processing when debugging. Another object of the present invention is to realize a function capable of being debugged by the same simulator debugger regardless of the type of high-level language that describes the program to be debugged.

【0005】本発明の前記並びにその他の目的と新規な
特徴は本明細書の記述及び添付図面から明らかになるで
あろう。
The above and other objects and novel features of the present invention will be apparent from the description of this specification and the accompanying drawings.

【0006】[0006]

【課題を解決するための手段】本願において開示される
発明のうち代表的なものの概要を簡単に説明すれば下記
の通りである。
The outline of the representative one of the inventions disclosed in the present application will be briefly described as follows.

【0007】すなわち、従来方式では、ターゲット計算
機の命令をデータとして受け取ってシミュレーション時
に一命令づつ解釈して実行していたが、本発明において
は、逐次的に順次実行できるターゲット計算機の命令列
すなわち途中にジャンプ命令若しくはブランチ命令更に
はサブルーチンからの復帰命令を含まず、また、これら
の命令の分岐先命令も含まない命令列を、シュミレーシ
ョン前に予めホスト計算機の命令列に翻訳し、この翻訳
された命令列を単位としてシミュレーションを行う。こ
れによって、各命令のシミュレートに伴う従来の命令解
釈のオーバヘッドを削減するものである。また、同様の
オーバヘッド削減の手法は、ターゲット計算機用プログ
ラムのデバッグのためのデバッグ情報の解釈にも適用す
る。すなわち、ソースプログラム上の概念に対応する情
報と、ターゲット計算機上のハードウェア資源上の概念
に対応する情報との対応を、ホスト計算機の命令で表現
されたデバッグ用操作手続としてコンパイラにて用意
し、このデバッグ用操作手続を必要に応じて呼び出すこ
とによって高級言語レベルでデバッグを可能にする。こ
のとき、解釈並びに実行のための特殊なインタフェース
を要せず、直接ホスト計算機の機械語で実行すべき操作
を記述することから、特にデバッグのための操作におい
て、ターゲット計算機の高級言語の仕様に依存しないで
高級言語レベルでのデバッグを実現する。ここで、本明
細書で称するターゲット計算機は、いわゆる計算機に限
るものではなく、設定、変更が可能で、その状態をホス
ト計算機のハードウェアで表現可能なハードウェア資源
と、当該資源に対する基本操作を持った装置であればよ
い。
That is, in the conventional method, the instruction of the target computer is received as data, and the instruction is interpreted and executed one by one during the simulation. However, in the present invention, the instruction sequence of the target computer that can be sequentially and sequentially executed, that is, in the middle. An instruction sequence that does not include a jump instruction or branch instruction, or a return instruction from a subroutine, and does not include a branch destination instruction of these instructions is translated into the instruction sequence of the host computer in advance before the simulation, and this translated Simulation is performed with the instruction sequence as a unit. This reduces the overhead of the conventional instruction interpretation accompanying the simulation of each instruction. The same overhead reduction method is also applied to the interpretation of debug information for debugging the target computer program. In other words, the compiler prepares the correspondence between the information corresponding to the concept on the source program and the information corresponding to the concept on the hardware resource on the target computer as a debug operation procedure expressed by the instruction of the host computer. , It enables debugging at a high-level language level by calling this debugging operation procedure as needed. At this time, since the operation to be executed is directly described in the machine language of the host computer without requiring a special interface for interpretation and execution, the high-level language specifications of the target computer can be specified especially in the operation for debugging. It realizes debugging at a high-level language level without depending on it. Here, the target computer referred to in this specification is not limited to a so-called computer, but can be set and changed, and a hardware resource whose state can be expressed by the hardware of the host computer and a basic operation for the resource are described. Any device you have will do.

【0008】次に上記手段の詳細を項目毎に個々に説明
する。
Next, the details of the above means will be individually described for each item.

【0009】(1) シミュレーションの高速化 シミュレーションの高速化は以下の手段によって実現す
る。 (a)ターゲット計算機のメモリ,レジスタ,フラグ等
のハードウェア資源に対して、ホスト計算機のメモリ,
レジスタ,フラグを対応させ、ターゲット計算機の内部
状態をホスト計算機の内部状態によって忠実に表現でき
るようにする。すなわち、ホスト計算機の資源とソフト
ウェアによってターゲット計算機の実行環境を表現す
る。 (b)ターゲット計算機の各命令に対して、該命令の作
用を、ターゲット計算機のハードウェア資源に対応付け
られたホスト計算機の上でシミュレーションするホスト
計算機の命令列を対応させる。 (c)ターゲット計算機のプログラムのベーシックブロ
ック(必ず逐次実行される命令列、すなわち、途中にジ
ャンプ命令やサブルーチン命令更にはサブルーチンから
の復帰命令を含まず、また、前記命令の分岐先を含まな
い命令列)を切り出し、対応するホスト計算機の命令列
の並びを生成する。これと上記項目(b)により、逐次
的に順次実行可能なターゲット計算機の命令列が翻訳さ
れて成るホスト計算機の命令列を取得する。 (d)生成したホスト計算機の命令列のデータフローを
解析し、最適化を施す。 (e)ターゲット計算機のベーシックブロックの先頭ア
ドレスを、ベーシックブロックに対応するホスト計算機
の命令列に対応付ける表を作成する。 (f)ターゲット計算機の基本ブロックの実行を、対応
するホスト計算機の命令列を実行することによってシミ
ュレートする。 (g)ターゲット計算機のジャンプ命令又はブランチ命
令の実行を、ジャンプ又はブランチ先のアドレスに対応
するホスト計算機の命令列に制御を移行することによっ
てシミュレートする。
(1) Acceleration of Simulation Acceleration of simulation is realized by the following means. (A) For the hardware resources such as the memory, registers and flags of the target computer, the memory of the host computer,
Registers and flags are associated with each other so that the internal state of the target computer can be faithfully represented by the internal state of the host computer. That is, the execution environment of the target computer is expressed by the resources and software of the host computer. (B) For each instruction of the target computer, the instruction sequence of the host computer that simulates the action of the instruction on the host computer associated with the hardware resource of the target computer is associated. (C) A basic block of the program of the target computer (an instruction sequence that is always executed sequentially, that is, an instruction that does not include a jump instruction, a subroutine instruction, or a return instruction from a subroutine in the middle, and does not include a branch destination of the instruction. Column) is cut out, and a sequence of instruction sequences of the corresponding host computer is generated. By this and the above item (b), the instruction sequence of the host computer obtained by translating the instruction sequence of the target computer that can be executed sequentially is acquired. (D) The data flow of the generated instruction sequence of the host computer is analyzed and optimized. (E) A table is created in which the start address of the basic block of the target computer is associated with the instruction string of the host computer corresponding to the basic block. (F) The execution of the basic block of the target computer is simulated by executing the instruction sequence of the corresponding host computer. (G) The execution of the jump instruction or the branch instruction of the target computer is simulated by transferring control to the instruction sequence of the host computer corresponding to the address of the jump or branch destination.

【0010】(2) シミュレーション機能の切り替え 上記方式で全てのシミュレーションを行うと、基本的な
シミュレーション機能の一部であるブレークポイント機
能、命令の書き替え機能、デバッグ時にベーシックブロ
ックの途中に飛び込む機能を犠牲にすることになる。こ
れを避けるために、上記方式と従来のインタプリタ方式
若しくは1ステップ実行方式を併用し、シミュレーショ
ン機能を縮小することなく高速化できる切り替え方式を
以下の手段で実現する。 (a)各ベーシックブロックに対して、ブレークポイン
トの指定を示すフラグを設け、そのベーシックブロック
内でブレークポイントが指定されている場合は、対応す
るホスト計算機の命令列に制御を移すことなく、ターゲ
ット計算機を一命令ずつ解釈して実行するように切り替
える。 (b)デバッグ時に命令の書換えが生じた場合は、その
命令を含むベーシックブロックを再び翻訳して、ターゲ
ット計算機とホスト計算機の命令の対応を更新する。ま
た、命令の書換えによってベーシックブロックが分割さ
れる場合(ベーシックブロックに飛び込む命令への変更
等)は、分割された新しいベーシックブロックに対して
もそれぞれ翻訳を行う。 (c)デバッグ時の実行開始アドレス指定により、ベー
シックブロックの先頭以外のアドレスが指定された場合
は、当該ベーシックブロックは命令ごとに従来方式でシ
ミュレーションを行ない、それ以降のベーシックブロッ
クは上記方式でシミュレーションする。
(2) Switching of simulation function When all simulations are performed by the above method, a breakpoint function, an instruction rewriting function, which is a part of the basic simulation function, and a function of jumping into a basic block during debugging are performed. It will be a sacrifice. In order to avoid this, the above method and the conventional interpreter method or the one-step execution method are used together, and a switching method that can speed up the simulation function without reducing the size is realized by the following means. (A) A flag indicating the designation of a breakpoint is provided for each basic block, and if the breakpoint is designated in that basic block, the target is transferred without transferring control to the instruction sequence of the corresponding host computer. Switch to interpret and execute the computer one instruction at a time. (B) When an instruction is rewritten during debugging, the basic block including the instruction is translated again to update the correspondence between the instructions of the target computer and the host computer. In addition, when the basic block is divided by rewriting the instruction (change to the instruction jumping into the basic block, etc.), the new divided basic block is also translated. (C) When an address other than the start of the basic block is specified by the execution start address specification during debugging, the basic block is simulated for each instruction by the conventional method, and the subsequent basic blocks are simulated by the above method. To do.

【0011】(3) 高級言語レベルでのデバッグ機能
をホスト計算機の命令で実現 高級言語レベルでのデバッグ機能は、ソースプログラム
上の概念に対応する情報(変数名、行番号等)に、ター
ゲット計算機上のハードウェア資源上の概念に対応する
情報(アドレス値、レジスタ名等)を対応させる。これ
らの対応を、ホスト計算機の命令で表現された手続きと
して実現する。これは以下の手段によって行う。 (a)ソースプログラムのコンパイル時に、ホスト計算
機のデバッグ用手続きを生成する。例えば、変数の名前
から割付けアドレス値を求めるのであれば、変数名と現
在のプログラムカウンタ値を入力とし、プログラムカウ
ンタに対応するプログラム点における変数の割付けアド
レスを結果として返す手続きを、ホスト計算機の命令と
して生成する。 (b)シミュレータデバッガは、上記デバッグ用手続き
を、ターゲット計算機のプログラムをロードするとき
に、ホスト計算機のプログラムとしてロードし、デバッ
グ用手続きを直接呼びだすことによってデバッグ機能を
実現する。
(3) High-level language level debug function realized by host computer instructions The high-level language level debug function uses the information (variable name, line number, etc.) corresponding to the concept on the source program in the target computer. Corresponds information (address value, register name, etc.) corresponding to the above concept of hardware resources. These correspondences are realized as a procedure expressed by a command of the host computer. This is done by the following means. (A) When the source program is compiled, a procedure for debugging the host computer is generated. For example, if you want to obtain the allocation address value from the variable name, enter the variable name and the current program counter value, and return the variable allocation address at the program point corresponding to the program counter as a result Generate as. (B) The simulator debugger realizes the debug function by loading the above-mentioned debug procedure as a program of the host computer when loading the program of the target computer and directly calling the debug procedure.

【0012】[0012]

【作用】上記した手段によれば、ターゲット計算機のベ
ーシックブロックに対応して予め翻訳したホスト計算機
の命令列を用いてシミュレーションを行い、また、ホス
ト計算機の命令で表現されたデバッグ用操作手続を利用
してデバッグを行うことは、従来のようにデータとして
与えられるオブジェクトコードの解釈や、デバッグ操作
手続のためのデータテーブルの検索参照といったデータ
解釈のためのオーバヘッドをなくし、シミュレーション
並びにデバッグの高速化を実現する。
According to the above means, the simulation is performed using the instruction sequence of the host computer translated in advance corresponding to the basic block of the target computer, and the debugging operation procedure expressed by the instruction of the host computer is used. Performing debugging by eliminating the overhead of data interpretation such as the conventional interpretation of object code given as data and the search reference of the data table for the debug operation procedure speeds up simulation and debugging. To be realized.

【0013】また、前記ホスト計算機の命令で表現され
たデバッグ用操作手続を利用してデバッグを行うこと
は、高級言語デバッグ機能を、高級言語に依存すること
なくシミュレータデバッガに容易に組み込むことを可能
にする。
Further, by performing the debugging by using the debugging operation procedure expressed by the instruction of the host computer, the high-level language debugging function can be easily incorporated in the simulator debugger without depending on the high-level language. To

【0014】[0014]

【実施例】図1には本発明の一実施例に係るシミュレー
タデバッガのブロック図が示される。同図において1は
ターゲット計算機のための、高級言語で記述されたソー
スプログラムである。このソースプログラム1がシミュ
レーション並びにデバッグの対象とれる。ソースプログ
ラム1はコンパイラ2にてコンパイルされる。このコン
パイラ2は、ソースプログラム1をオブジェクトコード
4に変換する。従来はこのオブジェクトコード4をデー
タとしてホスト計算機3に与えて1命令単位でシミュレ
ーションを行っていた。本実施例において前記コンパイ
ラ2は、デバッグ情報プログラム5とオブジェクト情報
プログラム6を生成する。
1 is a block diagram of a simulator debugger according to an embodiment of the present invention. In the figure, reference numeral 1 is a source program written in a high-level language for the target computer. This source program 1 is a target for simulation and debugging. The source program 1 is compiled by the compiler 2. The compiler 2 converts the source program 1 into an object code 4. Conventionally, the object code 4 is given to the host computer 3 as data and the simulation is performed in units of one instruction. In this embodiment, the compiler 2 generates a debug information program 5 and an object information program 6.

【0015】その詳細は後述するが、前記オブジェクト
情報プログラム6は、逐次的に順次実行可能なターゲッ
ト計算機の命令列をホスト計算機3の命令列に翻訳して
成る、ブロック化された命令列の集合である。したがっ
て、サブルーチンへのジャンプ命令(JMP命令)やサ
ブルーチンからの復帰命令(RTS命令)など、命令実
行フロー若しくは実行すべき命令の順序を変化させる命
令は、前記翻訳された命令列の途中には含まれない。前
記デバッグ情報プログラム5は、ソースプログラム1上
の概念に対応する情報と、図示しないターゲット計算機
上のハードウェア資源上の概念に対応する情報との対応
を、ホスト計算機3の命令で表現されたデバッグ用操作
手続としてコンパイルされたものである。デバッグ情報
プログラム5及びオブジェクト情報プログラム6は、ホ
スト計算機3に適合する命令記述によって構成され、シ
ミュレータの核として位置付けられるシミュレータシス
テムプログラム7と必要に応じてリンクされてホスト計
算機3にロードされる。ホスト計算機3は、コマンドに
したがってそのロードされたプログラムを実行すること
によってソースプログラムのシミュレーションを行うと
共にデバッグをサポートする。
As will be described in detail later, the object information program 6 is a set of blocked instruction sequences formed by translating the instruction sequences of the target computer that can be executed sequentially into the instruction sequences of the host computer 3. Is. Therefore, an instruction that changes the instruction execution flow or the order of instructions to be executed, such as a jump instruction (JMP instruction) to a subroutine or a return instruction (RTS instruction) from a subroutine, is included in the middle of the translated instruction sequence. I can't. The debug information program 5 debugs the correspondence between the information corresponding to the concept on the source program 1 and the information corresponding to the concept on the hardware resource on the target computer (not shown) expressed by the instruction of the host computer 3. It was compiled as a user operation procedure. The debug information program 5 and the object information program 6 are composed of instruction descriptions suitable for the host computer 3, and are linked to the simulator system program 7 positioned as the core of the simulator as required and loaded into the host computer 3. The host computer 3 simulates the source program by executing the loaded program in accordance with the command and supports debugging.

【0016】以下、本実施例に係るシミュレータデバッ
ガによる処理手順を項目順に具体例を交えて詳述する。
シミュレータの部分の具体例に関しては、説明を簡単に
するために、ホスト計算機とターゲット計算機が同一の
命令仕様を持つものと仮定して記述するが、実際に有用
なのはホスト計算機とターゲット計算機が異なる場合で
ある。いずれの場合も、動作原理として異なるところは
ない。また、ホスト計算機の命令に直接依存しない処理
の説明においては、高級言語としてC言語を用いて説明
する。
The processing procedure by the simulator debugger according to the present embodiment will be described in detail in the order of items with specific examples.
For the purpose of simplifying the explanation, a concrete example of the simulator part will be described assuming that the host computer and the target computer have the same instruction specifications, but it is actually useful when the host computer and the target computer are different. Is. In any case, there is no difference in operation principle. In the description of the processing that does not directly depend on the instruction of the host computer, the C language is used as the high-level language.

【0017】(1) ハードウェア資源の対応 ホスト計算機3及び図示しないターゲット計算機の夫々
は、8本の汎用レジスタ(R0〜R7)、ステータスレ
ジスタ(SR)、プログラムカウンタ(PC)を持つと
仮定する。また、ワードサイズは4バイト、アドレシン
グはバイト単位に行うものとする。本実施例では、ター
ゲット計算機上の汎用レジスタ、ステータスレジスタ、
プログラムカウンタをホスト計算機3のメモリ上に対応
付けるものとする。ターゲット計算機のハードウェア資
源に対して、ホスト計算機3において以下のメモリ領域
を割り付ける。 unsigned long general_reg[8]; 汎用レジスタの
領域 unsigned long status_reg; ステータスレジ
スタの領域 unsigned long program counter; プログラムカウ
ンタの領域 unsigned long memory[MEMORY_SIZE]; メモリの領域 ここでターゲット計算機のレジスタをホスト計算機3の
メモリに割り付けているのは、以下の説明をより明快に
提示するのが目的であり、もちろんターゲット計算機の
レジスタをホスト計算機のレジスタに割り付けることに
よって、より高速なシミュレーションが可能になる。こ
の場合、シミュレータコマンド受付け時とシミュレーシ
ョン時でレジスタの退避、回復を行う必要がある。
(1) Correspondence of hardware resources It is assumed that each of the host computer 3 and the target computer (not shown) has eight general-purpose registers (R0 to R7), a status register (SR), and a program counter (PC). . The word size is 4 bytes, and the addressing is performed in byte units. In this embodiment, general-purpose registers, status registers, and
The program counter is associated with the memory of the host computer 3. The following memory areas are allocated in the host computer 3 to the hardware resources of the target computer. unsigned long general_reg [8]; General register area unsigned long status_reg; Status register area unsigned long program counter; Program counter area unsigned long memory [MEMORY_SIZE]; Memory area Here, the target computer register is the memory of the host computer 3. The purpose of the assignment is to more clearly present the following explanation, and of course, by allocating the register of the target computer to the register of the host computer, faster simulation becomes possible. In this case, it is necessary to save and restore the register at the time of accepting the simulator command and at the time of simulation.

【0018】(2)ターゲット計算機の命令の翻訳 ターゲット計算機の命令を、ホスト計算機3の命令に一
対一に翻訳する例を示す。 例1:命令“MOV R0,R1”の翻訳例を示す。本
命令は、レジスタR0の内容をレジスタR1に転送し、
プログラムカウンタに命令サイズ(本例では4バイトと
する)を加算するものである。したがって、以下のホス
ト計算機の命令が対応する。 MOV @general_reg,@(general_reg+4) ADD #4,@program_counter 例2:命令“ADD R0,R1”の翻訳例を示す。本
命令は、レジスタR0の内容をレジスタR1に転送し、
演算結果をステータスレジスタに反映し、プログラムカ
ウンタに命令サイズ(本例では4バイトとする)を加算
するものである。したがって、以下のホスト計算機の命
令が対応する。 ADD @general_reg,@(general_reg+4) MOV SR,@status_reg ADD #4,@program_counter 例3:命令“BRA 10”の翻訳例を示す。このよう
な分岐命令は、ベーシックブロックの最後の命令にな
る。本命令は、プログラムカウンタの値を10に設定す
るものである。この場合には下に示すホスト計算機3の
命令が対応される。 MOV #10,@program_counter 同様に各命令に対して翻訳する規則を決定し、その規則
に従ってターゲット計算機の各ベーシックブロックに対
してホスト計算機の命令列を生成する。
(2) Translation of Target Computer Instructions An example is shown in which target computer instructions are translated into host computer 3 instructions one-to-one. Example 1: An example of translation of the instruction "MOV R0, R1" is shown. This instruction transfers the contents of register R0 to register R1,
The instruction size (4 bytes in this example) is added to the program counter. Therefore, the following host computer instructions correspond. MOV @general_reg, @ (general_reg + 4) ADD # 4, @ program_counter Example 2: A translation example of the instruction "ADD R0, R1" is shown. This instruction transfers the contents of register R0 to register R1,
The calculation result is reflected in the status register, and the instruction size (4 bytes in this example) is added to the program counter. Therefore, the following host computer instructions correspond. ADD @general_reg, @ (general_reg + 4) MOV SR, @ status_reg ADD # 4, @ program_counter Example 3: A translation example of the instruction "BRA 10" is shown. Such a branch instruction becomes the last instruction of the basic block. This instruction sets the value of the program counter to 10. In this case, the command of the host computer 3 shown below is supported. MOV # 10, @ program_counter Similarly, the rules for translating each instruction are determined, and the instruction sequence of the host computer is generated for each basic block of the target computer according to the rule.

【0019】(3)ホスト命令列の最適化 ホスト計算機3の上記翻訳された命令列は、制御の移行
がないため(途中にジャンプ命令やブランチ命令のよう
な命令を含まないため)、データの移動を追跡すること
によって最適化できる。これは、コンパイラ技術におい
て複写伝播と呼ばれる一般的な技法を応用したものであ
るが、シミュレーションをするためのホスト計算機の翻
訳された命令列に本最適化の手法を施すことについては
新規である。 例1: ターゲット計算機の命令列: MOV R0,R1 MOV R0,R2 を考える。これは、上記項目(2)の規則にしたがえ
ば、以下の命令列に翻訳される。 MOV @general_reg,@(general_reg+4) ADD #4,@program_counter MOV @general_reg,@(general_reg+8) ADD #4,@program_counter 上記命令列は、最適化によって同じ機能を果たす以下の
命令列に置き換えが可能である。最適化内容としては、
ターゲット計算機のレジスタR0の内容をホスト計算機
3のレジスタR0に割り付けたこと、プログラムカウン
タの2回の更新を1回に纏めたことである。 MOV @general_reg,R0 MOV R0,@(general_reg+4) MOV R0,@(general_reg+8) ADD #8,@program_counter 例2: ターゲット計算機の命令列 ADD R0,R1 ADD R0,R2 を考える。これは前記項目(2)の規則にしたがえば、
以下の命令列に翻訳される。 ADD @general_reg,@(general_reg+4) MOV SR,@status_reg ADD #4,@program_counter ADD @general_reg,@(general_reg+8) MOV SR,@status_reg ADD #4,@program_counter 上記命令列は以下のように最適化できる。ここでは、上
記例1の最適化の内容に加えて、ステータスレジスタの
2回の更新を1回の更新に最適化したものである。 MOV @general_reg,R0 ADD R0,@(general_reg+4) ADD R0,@(general_reg+8) MOV SR,@status_reg ADD #8,@program_counter
(3) Optimization of host instruction sequence Since the translated instruction sequence of the host computer 3 has no control transfer (because it does not include an instruction such as a jump instruction or a branch instruction on the way), It can be optimized by tracking movements. This is an application of a general technique called copy propagation in compiler technology, but it is new to apply this optimization technique to the translated instruction sequence of the host computer for simulation. Example 1: Consider the target computer instruction sequence: MOV R0, R1 MOV R0, R2. According to the rule of the above item (2), this is translated into the following instruction sequence. MOV @general_reg, @ (general_reg + 4) ADD # 4, @ program_counter MOV @general_reg, @ (general_reg + 8) ADD # 4, @ program_counter The above instruction sequence is replaced with the following instruction sequence that performs the same function by optimization. Is possible. As the optimization contents,
The contents of the register R0 of the target computer are assigned to the register R0 of the host computer 3, and the two updates of the program counter are combined into one. MOV @ general_reg, R0 MOV R0, @ (general_reg + 4) MOV R0, @ (general_reg + 8) ADD # 8, @ program_counter Example 2: Consider the target computer instruction sequence ADD R0, R1 ADD R0, R2. According to the rule of item (2) above, this is
It is translated into the following command sequence. ADD @general_reg, @ (general_reg + 4) MOV SR, @ status_reg ADD # 4, @ program_counter ADD @general_reg, @ (general_reg + 8) MOV SR, @ status_reg ADD # 4, @ program_counter The above instruction sequence is as follows: Can be optimized. Here, in addition to the optimization contents of the above-mentioned example 1, two updates of the status register are optimized to one update. MOV @ general_reg, R0 ADD R0, @ (general_reg + 4) ADD R0, @ (general_reg + 8) MOV SR, @ status_reg ADD # 8, @ program_counter

【0020】(4)ホスト命令列のシミュレータへのロ
ード 上記項目(3)の最適化で生成した命令列をシミュレー
ション時にロードする。ロードは、ターゲット計算機の
デバッグ対象プログラム(オブジェクトコード4)をデ
ータとしてシミュレータデバッガのホスト計算機3にロ
ードする際に行なう。ロードされた複数のホスト命令列
において最後に実行されるべき命令列の最後には、サブ
ルーチン復帰命令(RTS)を付加することができる。
これにより、ターゲット計算機のプログラムのベーシッ
クブロックをホスト計算機3におけるサブルーチンの起
動によってシミュレーションできるようになる。
(4) Loading the host instruction sequence into the simulator The instruction sequence generated by the optimization in item (3) above is loaded during simulation. The loading is performed when the debug target program (object code 4) of the target computer is loaded as data into the host computer 3 of the simulator debugger. A subroutine return instruction (RTS) can be added to the end of the instruction sequence to be executed last in the loaded plurality of host instruction sequences.
As a result, the basic block of the program of the target computer can be simulated by starting the subroutine in the host computer 3.

【0021】(5)ホスト命令列によるシミュレーショ
ンの実行 ホスト命令列によるシミュレーションの実行は以下の手
続きで行う。 simulate() { for (; ; ) simulate_block(); ベーシックブロックのシミュレーション } simulate_block() { void (*f)(); f=get_host_action(program_counter); ホスト命令列の開始アドレスの取得 (*f)(); ホスト命令列の実行 } 図2にはその実行手順のフローチャートが示される。図
2に従えば、夫々のベーシックブロックに対するシミュ
レーションは、PC値の取得ステップ(S1)、翻訳さ
れたコードの検索ステップ(S2)、及び翻訳されたコ
ードの実行ステップ(S3)に大別される。PC値の取
得ステップにおけるPC値とは、ターゲット計算機のプ
ログラムにおける(ソースプログラム上における)ベー
シックブロックの先頭アドレスであり、例えば、コマン
ドのパラメータ若しくはホスト計算機3のシミュレータ
システムプログラム中におけるジャンプ命令のジャンプ
先アドレスとして与えられる。前記翻訳されたコードの
検索ステップでは、ベーシックブロックの先頭アドレス
とこれに対応する翻訳命令列の先頭アドレスとの対応テ
ーブルを検索して、前記ステップS1で取得されたPC
値に対応するホスト計算機3上の翻訳命令列の先頭アド
レスを取得する。前記ステップS3では、先頭アドレス
が検索された翻訳命令列を順次最後まで実行する。各命
令に対する処理は、命令フェッチ、命令解釈、及び命令
実行とされ、途中でジャンプ命令やブランチ命令が実行
されることはない。尚、図2においてAは、ターゲット
計算機のリソースとしてホスト計算機3が持っているP
C(プログラムカウンタ)の値を示し、Bは、それに対
応する翻訳命令列ブロックの先頭アドレスを意味するも
のである。図3にはJMP命令実行における処理の移行
を摸式的に示してある。同図において61〜67は夫々
ベーシックブロックに対応する翻訳命令列のブロックで
ある。図3に従えば、翻訳命令列のブロック62の最後
にはJMP命令を翻訳した結果として、PCにブランチ
先のアドレス100を設定する命令と、翻訳命令列から
復帰するためのRTS命令が配置されている。シミュレ
ーションにおいてホスト計算機3が翻訳命令列ブロック
62の最後でRTS命令を実行すると、そのジャンプ先
は前記PC値の取得ステップS1によって処理され、次
いで、前記翻訳されたコードの検索ステップS2で対応
する翻訳命令列ブロック例えば66の先頭アドレスが取
得され、これによって、そのJMP命令によって指示さ
れる処理ルーチンは翻訳命令列ブロック66の実行によ
ってシミュレートされる。翻訳される命令列ブロックの
最後にRTS命令が配置されている場合の処理も上記同
様である。
(5) Execution of simulation by host instruction sequence The simulation is executed by the host instruction sequence by the following procedure. simulate () {for (;;) simulate_block (); Basic block simulation} simulate_block () {void (* f) (); f = get_host_action (program_counter); Get start address of host instruction string (* f) ( ); Execution of host instruction sequence} FIG. 2 shows a flowchart of the execution procedure. According to FIG. 2, the simulation for each basic block is roughly divided into a PC value acquisition step (S1), a translated code retrieval step (S2), and a translated code execution step (S3). . The PC value in the PC value acquisition step is the start address of the basic block in the program of the target computer (on the source program), for example, the parameter of the command or the jump destination of the jump instruction in the simulator system program of the host computer 3. Given as an address. In the step of searching the translated code, the correspondence table between the start address of the basic block and the start address of the corresponding translation instruction string is searched, and the PC obtained in step S1 is searched.
The start address of the translation instruction sequence on the host computer 3 corresponding to the value is acquired. In step S3, the translation instruction string whose start address has been searched is sequentially executed to the end. The processing for each instruction is instruction fetch, instruction interpretation, and instruction execution, and jump instructions and branch instructions are not executed in the middle. Incidentally, in FIG. 2, A is P which the host computer 3 has as a resource of the target computer.
The value of C (program counter) is shown, and B means the start address of the corresponding translation instruction string block. FIG. 3 schematically shows a process transition in executing the JMP instruction. In the figure, 61 to 67 are blocks of a translation instruction string corresponding to basic blocks, respectively. According to FIG. 3, at the end of the block 62 of the translation instruction sequence, an instruction for setting the branch destination address 100 in the PC and an RTS instruction for returning from the translation instruction sequence are arranged as a result of translating the JMP instruction. ing. When the host computer 3 executes the RTS instruction at the end of the translation instruction sequence block 62 in the simulation, the jump destination is processed by the PC value acquisition step S1, and then the corresponding translation is performed in the translated code retrieval step S2. The start address of the instruction string block, for example 66, is obtained, whereby the processing routine instructed by the JMP instruction is simulated by executing the translation instruction string block 66. The processing when the RTS instruction is arranged at the end of the instruction string block to be translated is similar to the above.

【0022】(6)デバッグ機能の実現 ベーシックブロックに対するホスト計算機3の翻訳命令
列単位でのシミュレーションでは、デバッグ対象プログ
ラムのベーシックブロックの内部に対する操作はできな
い。そこで、従来の命令毎に解釈実行する1ステップ実
行方式を本実施例方式に併用し、きめ細かなデバッグ機
能を以下のように実現する。
(6) Realization of Debug Function In the simulation of the translation instruction string unit of the host computer 3 for the basic block, the inside of the basic block of the program to be debugged cannot be operated. Therefore, the conventional one-step execution method for interpreting and executing each instruction is used in combination with the method of the present embodiment, and a detailed debug function is realized as follows.

【0023】(7)ブレークポイントの実現 ブレークポイントがベーシックブロックの内部に対して
指定された場合、当該ベーシックブロックに対応したフ
ラグを立て、そのフラグが立っているときは当該ベーシ
ックブロックを従来の1ステップ実行方式で命令ごとに
解釈実行する処理を行う。これは以下の手続きによって
実現される。 simulate_block() { void (*f)(); if (get_flag(program_counter)) フラグの判定 simulate_step_by_step(); 従来方式のシミュレーション else{ f=get_host_action(program_counter); 新方式のシミュレーション (*f)(); } 図4にはその実行方式のフローチャートが示される。同
図に従えば、ブレークポイントの有無を判定し、指定さ
れている場合には1ステップ実行でシミュレーションを
行い、指定されていない場合には図2に基づいて説明し
たような翻訳コードによる実行形式でシミュレーション
を行う。
(7) Realization of Breakpoint When a breakpoint is specified inside the basic block, a flag corresponding to the basic block is set, and when the flag is set, the basic block is set to the conventional 1 Interpretation is executed for each instruction in the step execution method. This is achieved by the following procedure. simulate_block () {void (* f) (); if (get_flag (program_counter)) Judge the flag simulate_step_by_step (); Conventional simulation else {f = get_host_action (program_counter); New simulation (* f) (); } FIG. 4 shows a flowchart of the execution method. According to the figure, the presence / absence of a breakpoint is determined, and if it is specified, the simulation is performed in one step execution. If it is not specified, the execution form by the translated code as described with reference to FIG. 2 is executed. Simulate with.

【0024】(8)ベーシックブロックの途中からの実
行 ベーシックブロックの途中からの実行も、上記項目
(7)の場合と同様、当該ベーシックブロックは従来方
式でシミュレーションし、次に実行するベーシックブロ
ックから新方式のシミュレーションに切り替える。
(8) Execution from the middle of the basic block Even in the middle of the basic block, similar to the case of the item (7), the basic block is simulated by the conventional method, and the basic block to be executed next is updated. Switch to method simulation.

【0025】(9)デバッグ時の命令の変更 デバッグ時に命令を書き替えた場合、当該ベーシックブ
ロックを再びホスト命令列に翻訳し、新たなホスト命令
列をベーシックブロックの先頭アドレスに対して再登録
する。
(9) Change of instruction during debugging When an instruction is rewritten during debugging, the basic block is translated into a host instruction sequence again, and a new host instruction sequence is reregistered with the start address of the basic block. .

【0026】(10)デバッグ時のベーシックブロック
構成の変更 デバッグ時に命令を分岐命令に書き替えた場合、新たな
ベーシックブロックが生じる。この場合、書き替えた命
令を含むベーシックブロックだけでなく、書き替えた分
岐命令の飛び先を含むベーシックブロックも必要であれ
ば再翻訳、再登録する。
(10) Change of basic block configuration at the time of debugging When an instruction is rewritten to a branch instruction at the time of debugging, a new basic block is generated. In this case, not only the basic block including the rewritten instruction but also the basic block including the jump destination of the rewritten branch instruction are retranslated and reregistered if necessary.

【0027】(11)高級言語デバッグ機能のホスト計
算機命令語による実現 高級言語レベルでのデバッグ機能をホスト計算機命令語
で実現する例を以下に示す。以下、これら機能を表現す
るためにC言語を用いるが、実際には、C言語で記述さ
れた手続きに対応する機械語のホスト計算機命令列をコ
ンパイラ2で生成して利用する。
(11) Realization of high-level language debug function by host computer command word An example of realizing a high-level language debug function by a host computer command word is shown below. Hereinafter, the C language is used to express these functions, but in reality, a machine language host computer instruction sequence corresponding to a procedure described in the C language is generated and used by the compiler 2.

【0028】(12)変数のアドレスの取得 高級言語での変数をデバッグ時に設定したり、参照する
ために、変数のアドレスを取得する必要が有る。このア
ドレスは、コンパイル時に決定できるので、コンパイラ
2がデバッグ対象プログラムをコンパイルする時に、同
時に以下の手続きをホスト計算機3の命令として生成
し、デバッグ時に動的にロードする。 void *get_address(char *var) { if (strcmp(var, "a")==0) 変数名のチェック if (program_counter>=100 && program_counter<200) プログラムカウンタの値のチェック return &memory[200]; : : else return NULL; : : else return NULL; } 上に示されるような手続きは、図5に示されるように、
コンパイル時に判明している変数名と、デバッグ時に与
えられる変数名を比較し、変数名が同一であれば、各変
数の割付けが一定であるプログラムカウンタの範囲と、
現在のプログラムカウンタの値を比較し、現在のシミュ
レーションの状況における変数のアドレスを得る手続き
である。この手続において、パラメタとして与えられた
もの以外は全てコンパイル時に決定可能である。したが
って、本手続きをコンパイラ2が生成することは可能で
ある。デバッガは、これらのホスト計算機3用の手続き
をロードし、呼び出すことによってシミュレーション時
の変数の値の設定や参照を、デバッグ情報の特殊な規約
を設けることなく高級言語レベルで行うことができる。
従来のデバッガにおけるデバッグ情報の特殊な規約は、
ターゲット計算機のソースプログラムの言語に依存し
た、データ検索並びに参照のようなデータ解釈のための
規約とされる。同様の手続きを、行番号から当該行に対
応するプログラム点のプログラムカウンタ値の取得等の
高級言語レベルデバッグの基本操作に対して設けること
により、高級言語レベルデバッグ機能を言語と独立に実
現することができる。斯る手続は、その外に、ソースプ
ログラムの行番号からターゲットプログラムのアドレス
を取得したり、その逆を行ったりする手続がある。
(12) Acquisition of Variable Address It is necessary to acquire the address of the variable in order to set or refer to the variable in the high-level language during debugging. Since this address can be determined at the time of compiling, when the compiler 2 compiles the debug target program, at the same time, the following procedure is generated as an instruction of the host computer 3 and dynamically loaded at the time of debugging. void * get_address (char * var) {if (strcmp (var, "a") == 0) Check variable name if (program_counter> = 100 && program_counter <200) Check program counter value return & memory [200]; :: else return NULL;:: else return NULL;} The procedure as shown above, as shown in FIG.
The variable name known at compile time is compared with the variable name given at debugging, and if the variable names are the same, the range of the program counter in which the allocation of each variable is constant,
This is a procedure for comparing the current program counter value and obtaining the address of the variable in the current simulation situation. In this procedure, anything other than those given as parameters can be determined at compile time. Therefore, it is possible for the compiler 2 to generate this procedure. By loading and calling these procedures for the host computer 3, the debugger can set or reference the value of the variable at the time of simulation at a high level language level without providing a special convention for debug information.
The special convention for debug information in traditional debuggers is
It is a convention for data interpretation such as data retrieval and reference, depending on the language of the source program of the target computer. A similar procedure is provided for basic operations of high-level language level debugging, such as the acquisition of the program counter value of the program point corresponding to the line from the line number, to realize the high-level language level debug function independently of the language. You can In addition to this procedure, there is a procedure for obtaining the address of the target program from the line number of the source program and vice versa.

【0029】(13)複数モジュ−ルをリンクした場合
の高級言語レベルデバッグ 複数モジュ−ルをリンクした場合、デバッグ用手続きが
複数できる。これは、各モジュ−ルに対して高級言語レ
ベルでバッグの基本操作の手続きのエントリアドレスを
保持するテーブルをそれぞれ設けることによって実現で
きる。斯るリンクの処理により、所望のシミュレーショ
ン更にはデバッグのための特有なホスト計算機命令列と
してのプログラムを得ることができる。
(13) High-level language level debugging when multiple modules are linked When multiple modules are linked, multiple debugging procedures can be performed. This can be realized by providing each module with a table holding the entry address of the procedure of the basic bag operation at the high level language level. By the processing of such a link, a program as a unique host computer instruction sequence for desired simulation and further debugging can be obtained.

【0030】以上本発明者によってなされた発明を実施
例に基づいて具体的に説明したが、本発明はそれに限定
されるものではなく、その要旨を逸脱しない範囲におい
て種々変更可能であることは言うまでもない。以上の説
明では主として本発明者によってなされた発明をその背
景となった利用分野であるシミュレータデバッガーに適
用した場合について説明したが、シミュレータはもとよ
り、未完成なマイクロコンピュータ応用システムのシス
テムデバッグやそのシステムのためのターゲットプログ
ラムのデバッグをエミュレーションするためのシステム
や手法にも適用することができる。本発明は、少なくと
もターゲット計算機の命令やデバッグのための手続情報
をホスト計算機のネイティブコードにコンパイルして利
用する条件のものに広く適用することができる。
Although the invention made by the present inventor has been specifically described based on the embodiments, the present invention is not limited thereto, and it goes without saying that various modifications can be made without departing from the scope of the invention. Yes. In the above description, the case where the invention made by the present inventor is mainly applied to the simulator debugger which is the field of application which is the background has been described. However, not only the simulator but also the system debug of an unfinished microcomputer application system and the system thereof are described. It can also be applied to systems and methods for emulating the debugging of target programs for. The present invention can be widely applied to the condition that at least the instruction of the target computer and the procedure information for debugging are compiled into the native code of the host computer and used.

【0031】[0031]

【発明の効果】本願において開示される発明のうち代表
的なものによって得られる効果を簡単に説明すれば下記
の通りである。
The effects obtained by the typical ones of the inventions disclosed in the present application will be briefly described as follows.

【0032】(1)ターゲット計算機のベーシックブロ
ックに対応して予め翻訳したホスト計算機の命令列を用
いてシミュレーションを行い、また、ホスト計算機の命
令で表現されたデバッグ用操作手続を利用してデバッグ
を行うことにより、従来のようにデータとして与えられ
るオブジェクトコードの解釈や、デバッグ操作手続のた
めのデータテーブルの検索参照といったデータ解釈のた
めのオーバヘッドをなくし、シミュレーション並びにデ
バッグの高速化を実現することができる。 (2)上記により、デバッグ対象にするプログラムの範
囲を大幅に拡大できる。したがって、従来の方式では難
しかった大規模なシステムのシミュレータによるデバッ
グが可能になる。 (3)上記シミュレーション方式と従来のインタプリタ
方式(1ステップ実行方式)を併用して、シミュレーシ
ョン方式を切り替えることにより、ブレークポイント機
能、命令の書き替え機能、デバッグ時にベーシックブロ
ックの途中に飛び込む機能などを犠牲にすることなく、
換言すれば、シミュレーション機能を縮小することな
く、シミュレーションを高速化することができる。 (4)ホスト計算機の命令で表現されたデバッグ用操作
手続を利用してデバッグを行うことにより、高級言語の
種類に依存しないシミュレータ若しくはシミュレータデ
バッガを実現できる。 (5)上記(4)により、新しい言語が出現してもシミ
ュレータを変更することなくデバッグ機能を実現でき
る。 (6)それらにより、デバッグコマンド実行の高速化
と、高級言語の言語仕様に依存しないプログラムデバッ
グシステムを実現できる。
(1) A simulation is performed by using the instruction sequence of the host computer translated in advance corresponding to the basic block of the target computer, and the debugging is performed by using the debug operation procedure expressed by the instruction of the host computer. By doing so, it is possible to eliminate the overhead for data interpretation such as the interpretation of the object code given as data and the search reference of the data table for the debug operation procedure as in the past, and to realize the speedup of simulation and debugging. it can. (2) With the above, the range of programs to be debugged can be greatly expanded. Therefore, it becomes possible to debug a large-scale system using a simulator, which was difficult with the conventional method. (3) By combining the simulation method and the conventional interpreter method (one-step execution method) and switching the simulation method, a breakpoint function, an instruction rewriting function, a function to jump into a basic block during debugging, etc. Without sacrificing
In other words, the simulation can be sped up without reducing the simulation function. (4) A simulator or a simulator debugger that does not depend on the type of high-level language can be realized by performing debugging using the debugging operation procedure expressed by the instruction of the host computer. (5) By the above (4), the debug function can be realized without changing the simulator even when a new language appears. (6) With these, it is possible to realize high-speed debug command execution and a program debug system that does not depend on the language specifications of high-level languages.

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

【図1】本発明の一実施例に係るシミュレータデバッガ
ーのブロック図である。
FIG. 1 is a block diagram of a simulator debugger according to an embodiment of the present invention.

【図2】高速シミュレーション実行方式のフローチャー
トである。
FIG. 2 is a flowchart of a high-speed simulation execution method.

【図3】JMP命令実行における処理の移行を摸式的に
示す説明図である。
FIG. 3 is an explanatory diagram schematically showing a process transition in JMP instruction execution.

【図4】ブレークポイント実現手法を説明するためのフ
ローチャートである。
FIG. 4 is a flowchart for explaining a breakpoint realization method.

【図5】変数アドレス取得を一例としたデバッグ情報プ
ログラムによる処理の一例フローチャートである。
FIG. 5 is a flowchart illustrating an example of processing by a debug information program, which is an example of variable address acquisition.

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

1 ソースプログラム 2 コンパイラ 3 ホスト計算機 4 オブジェクトコード 5 デバッグ情報プログラム 6 オブジェクト情報プログラム 61〜67 翻訳命令列ブロック 7 シミュレータシステムプログラム 1 Source Program 2 Compiler 3 Host Computer 4 Object Code 5 Debug Information Program 6 Object Information Program 61-67 Translation Instruction Sequence Block 7 Simulator System Program

Claims (6)

【特許請求の範囲】[Claims] 【請求項1】 ターゲット計算機の命令をホスト計算機
の命令に翻訳し、これをホスト計算機にロードして実行
するシミュレーション方法であって、 逐次的に順次実行可能なターゲット計算機の命令列をホ
スト計算機の命令列に翻訳する翻訳ステップと、 前記ターゲット計算機の命令列における先頭アドレス
と、これに対応するホスト計算機の前記翻訳された命令
列における先頭アドレスとを対応付ける対応付けステッ
プと、 前記対応付けステップで得られた対応に基づいて、ター
ゲット計算機の前記命令列の実行を、これに対応するホ
スト計算機の前記命令列を実行することによってシミュ
レートするステップと、 を含むことを特徴とするシミュレーション方法。
1. A simulation method of translating an instruction of a target computer into an instruction of a host computer, loading the instruction into a host computer and executing the instruction, wherein an instruction sequence of a target computer that can be sequentially and sequentially executed is stored in the host computer. A translation step of translating into an instruction sequence, a correspondence step of associating a start address in the instruction sequence of the target computer with a start address in the translated instruction sequence of the corresponding host computer, and Simulating the execution of the instruction sequence of the target computer by executing the instruction sequence of the corresponding host computer based on the determined correspondence.
【請求項2】 前記シミュレートするステップは、ター
ゲット計算機の所定の前記命令列の先頭アドレスを取得
するステップと、これによって取得された先頭アドレス
に基づいて対応するホスト計算機の命令列における先頭
アドレスを検索するステップと、検索されたこの先頭ア
ドレスからホスト計算機の命令列を逐次実行するステッ
プと、を含むことを特徴とする請求項1記載のシミュレ
ーション方法。
2. The simulating step includes a step of acquiring a start address of a predetermined instruction sequence of a target computer, and a start address in an instruction sequence of a corresponding host computer based on the start address obtained thereby. 2. The simulation method according to claim 1, further comprising: a step of searching and a step of sequentially executing an instruction string of the host computer from the searched start address.
【請求項3】 ターゲット計算機の前記命令列の最後に
含まれるジャンプ又はブランチ命令に対して、前記ジャ
ンプ又はブランチ先アドレスに対応するホスト計算機の
前記命令列に実行を移行することによってシミュレート
することを特徴とする請求項1又は2記載のシミュレー
ション方法。
3. A jump or branch instruction included at the end of the instruction sequence of the target computer is simulated by shifting execution to the instruction sequence of the host computer corresponding to the jump or branch destination address. The simulation method according to claim 1 or 2, characterized in that.
【請求項4】 ブレークポイントの指定の有無を判定す
るステップを含み、ブレークポイントの指示があるとき
は前記ホスト計算機の命令列を実行せずに、ターゲット
計算機の命令をデータとして逐次解釈しながら1ステッ
プ実行でシミュレーションを行い、ブレークポイントの
指示が無いときは前記ホスト計算機の命令列を実行して
シミュレーションを行うことを特徴とする請求項1乃至
3の何れか1項記載のシミュレーション方法。
4. A step of determining whether or not a breakpoint is designated, wherein when a breakpoint is designated, the instruction sequence of the host computer is not executed and the instruction of the target computer is sequentially interpreted as data 1 4. The simulation method according to claim 1, wherein the simulation is performed by step execution, and when there is no instruction of a breakpoint, the instruction sequence of the host computer is executed to perform the simulation.
【請求項5】 ソースプログラム上の概念に対応する情
報と、ターゲット計算機上のハードウェア資源上の概念
に対応する情報との対応を、ホスト計算機の命令で表現
されたデバッグ用操作手続として生成するコンパイラ
と、 前記デバッグ用操作手続きがロードされ、ロードされた
デバッグ用操作手続を必要に応じて呼び出すことによっ
て高級言語レベルでデバッグを可能とするシミュレータ
デバッガと、 を備えて成るものであることを特徴とするプログラムデ
バッグシステム。
5. A correspondence between information corresponding to the concept on the source program and information corresponding to the concept on the hardware resource on the target computer is generated as a debugging operation procedure expressed by an instruction of the host computer. A compiler, and a simulator debugger that loads the debug operation procedure and enables debugging at a high-level language level by calling the loaded debug operation procedure as needed. And a program debugging system.
【請求項6】 前記シミュレータデバッガは、逐次的に
順次実行可能なターゲット計算機の命令列をホスト計算
機の命令列に翻訳された結果、及び前記ターゲット計算
機の命令列における先頭アドレスと、これに対応するホ
スト計算機の前記翻訳された命令列における先頭アドレ
スとを対応付けに基づいて、前記ターゲット計算機の前
記命令列の実行を、これに対応するホスト計算機の前記
命令列を実行することによってシミュレーションを行う
ものであることを特徴とする請求項5記載のプログラム
デバッグシステム。
6. The simulator debugger sequentially translates an instruction sequence of a target computer that can be sequentially executed into an instruction sequence of a host computer, a start address in the instruction sequence of the target computer, and the corresponding addresses. A simulation is performed by executing the instruction sequence of the target computer based on the correspondence between the head address in the translated instruction sequence of the host computer and the instruction sequence of the corresponding host computer. 6. The program debug system according to claim 5, wherein:
JP4272422A 1992-09-16 1992-09-16 Simulation method and program debugging system Withdrawn JPH0695921A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4272422A JPH0695921A (en) 1992-09-16 1992-09-16 Simulation method and program debugging system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4272422A JPH0695921A (en) 1992-09-16 1992-09-16 Simulation method and program debugging system

Publications (1)

Publication Number Publication Date
JPH0695921A true JPH0695921A (en) 1994-04-08

Family

ID=17513694

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4272422A Withdrawn JPH0695921A (en) 1992-09-16 1992-09-16 Simulation method and program debugging system

Country Status (1)

Country Link
JP (1) JPH0695921A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH10177487A (en) * 1996-12-16 1998-06-30 Fujitsu Ltd Instruction simulation method and instruction simulation system of processor

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH10177487A (en) * 1996-12-16 1998-06-30 Fujitsu Ltd Instruction simulation method and instruction simulation system of processor

Similar Documents

Publication Publication Date Title
EP0327195B1 (en) Processor simulation
EP0327196B1 (en) Processor simulation
US7568189B2 (en) Code translation and pipeline optimization
EP0926592B1 (en) Software emulation system
JP4766540B2 (en) Method and apparatus for performing verification of program code conversion
US6467082B1 (en) Methods and apparatus for simulating external linkage points and control transfers in source translation systems
JPH01166141A (en) Debugging system
JP5050019B2 (en) Source code analysis system
US20060026584A1 (en) Explicit linking of dynamic link libraries
JPH09237202A (en) Method for executing debugging processing
Mitchell et al. A workbench for computer architects
Sadolewski et al. Compiler and virtual machine of a multiplatform control environment
EP0327198B1 (en) Processor simulation
Smith et al. POPLOG's Two-level virtual machine support for interactive languages
JPH0695921A (en) Simulation method and program debugging system
JPH096646A (en) Program simulation device
JPH08286896A (en) Software development method and software development system
JPH02176938A (en) Machine language instruction optimizing system
KR20130088285A (en) Data processing system and method of data simulation
WO2007131089A2 (en) Code translation and pipeline optimization
EP1943589A2 (en) Method for generating a simulation program which can be executed on a host computer
JP3137094B2 (en) Simulation method, simulation device, and recording medium therefor
JP2000207226A (en) Code optimizing device, language processor, and code optimization method
Mitchell Porting the UNIX Implementation of Icon
JP2990882B2 (en) Functional simulation device

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 19991130