JP3379675B2 - Reverse execution debugging system - Google Patents
Reverse execution debugging systemInfo
- Publication number
- JP3379675B2 JP3379675B2 JP17829595A JP17829595A JP3379675B2 JP 3379675 B2 JP3379675 B2 JP 3379675B2 JP 17829595 A JP17829595 A JP 17829595A JP 17829595 A JP17829595 A JP 17829595A JP 3379675 B2 JP3379675 B2 JP 3379675B2
- Authority
- JP
- Japan
- Prior art keywords
- instruction
- program
- execution
- trace
- memory
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 238000006243 chemical reaction Methods 0.000 claims description 15
- 238000012545 processing Methods 0.000 claims description 7
- 238000000034 method Methods 0.000 claims description 6
- 230000008569 process Effects 0.000 claims description 3
- 230000007257 malfunction Effects 0.000 description 5
- 238000010586 diagram Methods 0.000 description 3
- 238000011156 evaluation Methods 0.000 description 3
- 230000007704 transition Effects 0.000 description 3
- 238000007796 conventional method Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000005259 measurement Methods 0.000 description 2
- 239000013256 coordination polymer Substances 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000000717 retained effect Effects 0.000 description 1
Landscapes
- Debugging And Monitoring (AREA)
Description
【0001】[0001]
【産業上の利用分野】本発明は、マイクロコンピュータ
上で動作するプログラムのデバッグや評価を行う際に使
用する逆実行デバッグシステムに関するものである。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a reverse execution debug system used when debugging or evaluating a program operating on a microcomputer.
【0002】[0002]
【従来の技術】一般に、プログラムのデバッグや評価の
際は、マイクロコンピュ―タ上で実際にプログラムを動
作させ、その動作のトレースを行う。このような動作ト
レースでは、従来、各種のツール等を使用し、以下のよ
うな作業を行っていた。例えば、プログラムのあるアド
レスにおいて、プログラムの動作を停止させたり、通過
を確認したいときにはプログラムの途中にブレークポイ
ントを設定していた。また、ブレークポイントから数命
令のトレースを行いたい時にはステップ命令を使用し、
1ステップずつ命令を実行していた。これらの機能で確
認できないトレース情報、例えば、特定の命令の実行頻
度の測定、メモリのあるアドレスのアクセス回数の測定
などは、プログラム自身、あるいはデバッグ評価ツール
に、カウンタやフラグなどの仕掛けを組み込むようにし
ていた。2. Description of the Related Art Generally, when a program is debugged or evaluated, the program is actually operated on a microcomputer and the operation is traced. In such operation trace, conventionally, various tools have been used to perform the following work. For example, at a certain address of a program, a breakpoint is set in the middle of the program when it is desired to stop the operation of the program or confirm the passage. If you want to trace a few instructions from a breakpoint, use a step instruction,
The instructions were executed step by step. For trace information that cannot be confirmed by these functions, such as measurement of the execution frequency of a specific instruction or measurement of the number of accesses to an address in memory, install a mechanism such as a counter or flag in the program itself or the debug evaluation tool. I was doing.
【0003】また、ICE(In Circuit Emulator) など
の高機能なデバッグ評価ツールでは、マイクロコンピュ
ータの信号ピンの履歴を一定量トレースメモリに保持し
ておくことができる。そして、これらの信号ピンの履歴
からより多くのトレース情報を得ることができる。この
トレース情報を解析することにより実行命令の履歴、デ
ータアクセスの状況を知ることができた。これらの従来
技術は、いずれも、プログラムをプログラムエントリか
ら実行し、実行時に必要な情報を得るものであった。Further, in a highly functional debug evaluation tool such as ICE (In Circuit Emulator), a certain amount of history of signal pins of a microcomputer can be held in a trace memory. Then, more trace information can be obtained from the history of these signal pins. By analyzing this trace information, it was possible to know the history of execution instructions and the status of data access. In all of these conventional techniques, a program is executed from a program entry to obtain necessary information at the time of execution.
【0004】[0004]
【発明が解決しようとする課題】しかしながら、上述し
た従来の技術には、次のような課題があった。第1に、
プログラムの動作トレースを行う場合に、一度通過して
しまった部分を再現するには、もう一度プログラムエン
トリから実行し直さなければならないので、効率的でな
い。このような状況は、プログラムのデバッグ時に頻繁
に起こる。これは、プログラムのバグが誤動作として表
面に現れるのが、バグ箇所を通過してから一定時間経っ
てからの場合が多いからである。この場合、誤動作した
時点から、少しずつ前の状況を把握していくために何度
もブレークポイントをかけ直して、プログラムをプログ
ラムエントリから再実行する必要があった。However, the above-mentioned conventional techniques have the following problems. First,
In the case of tracing the operation of the program, in order to reproduce the portion that has passed once, it is necessary to execute again from the program entry, which is not efficient. This situation often occurs when debugging a program. This is because a bug in a program appears as a malfunction on the surface in many cases after a certain time has passed after passing through the bug part. In this case, it is necessary to re-execute the breakpoint many times to re-execute the program from the program entry in order to grasp the previous situation little by little after the malfunction.
【0005】第2に、通常、プログラムの実行は、入力
データの内容やその入力タイミングによって異なるもの
であり、一度起きた事象を再現できない場合が多い。従
って、何らかの原因で誤動作が発生した場合に、その誤
動作を再現できず、デバッグできない場合が多いし、評
価する際にも、一度実行したプログラム処理を再現する
ことができない場合が多かった。第3に、ICEを使用
した場合でも、マイクロコンピュータの信号ピンの履歴
を参照して、プログラムの実行を追跡するのは非常に難
しい作業であった。第4に、ICEを使用した場合で
も、実行の特定の箇所でのレジスタやメモリの値を完全
に再現するのは事実上不可能であった。これは、プログ
ラム実行中に上書きされる、レジスタやメモリの値を知
るには、プログラムの実行開始時からの全履歴を保持し
なければならないからである。Secondly, the execution of a program usually differs depending on the contents of input data and the input timing, and it is often impossible to reproduce an event that has occurred once. Therefore, when an erroneous operation occurs for some reason, the erroneous operation cannot be reproduced and debugging cannot be performed in many cases, and often the executed program processing cannot be reproduced in evaluation. Third, even when using ICE, it was a very difficult task to trace the execution of the program by referring to the history of the signal pins of the microcomputer. Fourth, it was virtually impossible to completely recreate the register and memory values at a particular point in execution, even with ICE. This is because in order to know the register and memory values that are overwritten during program execution, the entire history from the start of program execution must be retained.
【0006】[0006]
【課題を解決するための手段】本発明の逆実行デバッグ
システムは、上述した課題を解決するため、以下の点を
特徴とするものである。
(1)1.ユーザソースファイルに格納されたプログラム
を基にして、以下のトレース用プログラムを生成するた
めのコンパイラを備える。即ち、このコンパイラは、ま
ず、プログラム中からレジスタやメモリ等の記憶手段内
のデータを書き換える各書き込み命令を検出する。そし
て、それらの書き込み命令の実行時の直前の記憶手段内
のデータを退避するための退避命令を、当該書き込み命
令の直前に追加する。これらの退避命令は、ストア命
令、又はロード命令とストア命令の組み合わせである。
これらの退避命令を追加したものをトレース用プログラ
ムとする。The reverse execution debug system of the present invention is characterized by the following points in order to solve the above-mentioned problems. (1) 1. A compiler is provided for generating the following trace program based on the program stored in the user source file. That is, this compiler first detects each write instruction that rewrites data in a storage unit such as a register or a memory in a program. Then, a save instruction for saving the data in the storage means immediately before the execution of the write instruction is added immediately before the write instruction. These save instructions are store instructions or a combination of load and store instructions.
A program for trace with these save instructions added is used.
【0007】2.当該コンパイラにより生成されたトレー
ス用プログラムを格納するユーザ実行ファイルを備え
る。
3.当該ユーザ実行ファイルに格納されたトレース用プロ
グラム中の退避命令の実行により退避されるデータ及び
当該トレース用プログラムの実行過程の命令アドレス履
歴をそれぞれ格納するトレースメモリを備える。
4.トレース用プログラムの実行停止時に、ユーザ実行フ
ァイルに格納されたトレース用プログラムを基にして、
以下の逆実行プログラムを生成するための命令変換ツー
ルを備える。即ち、この命令変換ツールは、トレース用
プログラム中の各命令をトレースメモリに格納されてい
る最新の命令アドレスの命令から順次逆のデータ処理を
行う命令に変換し、これを逆実行プログラムとする。2. A user execution file is provided for storing the trace program generated by the compiler. 3. A trace memory for storing data saved by execution of save instructions in the trace program stored in the user execution file and an instruction address history of the execution process of the trace program is provided. 4. When the execution of the trace program is stopped, based on the trace program stored in the user executable file,
An instruction conversion tool for generating the following reverse execution program is provided. That is, this instruction conversion tool converts each instruction in the trace program from the instruction of the latest instruction address stored in the trace memory into an instruction for sequentially performing reverse data processing, and makes this an inverse execution program.
【0008】(2)(1)において、命令変換ツール
は、以下を特徴とする。
1.トレース用プログラム中の各ロード命令をストア命令
に変換する。
2.トレース用プログラム中の各ストア命令をロード命令
に変換する。
3.トレースメモリにデータを退避する際のアドレスを更
新する各命令を1つ前のアドレスに戻す命令に変換す
る。
4.上記以外の命令は無視する。(2) In (1), the instruction conversion tool has the following features. 1. Convert each load instruction in the trace program into a store instruction. 2. Convert each store instruction in the trace program into a load instruction. 3. Convert each instruction that updates the address when saving data to the trace memory into an instruction that returns to the previous address. 4. Instructions other than the above are ignored.
【0009】[0009]
【作用】デバッグの際は、レジスタやメモリへの書き込
み命令の直前に、書き込む領域に格納されているデータ
をトレースメモリに退避する命令を挿入したデバッグ用
プログラムをコンパイラによりコンパイルする。そし
て、このデバッグ用プログラムをユーザ実行ファイルに
格納して実行することにより、デバッグを進める。デバ
ッグ用プログラムを実行すると、バグが存在するときは
その影響により実行が停止する。トレースメモリには、
実行が停止した位置のアドレス及びその時のレジスタ及
びメモリの内容が格納されている。そして、命令変換ツ
ールにより、デバッグ用プログラムをレジスタ及びメモ
リのデータに対し、逆の操作を行う命令列に変換する。
この結果、この命令列を1ステップずつ実行することに
より、実行が停止した位置から逆方向に実行動作を戻す
動作をトレースすることができる。When debugging, a compiler compiles a debugging program in which an instruction to save the data stored in the write area to the trace memory is inserted immediately before the instruction to write to the register or the memory. Then, the debugging program is stored in the user execution file and executed to proceed with the debugging. When a debug program is executed, if a bug exists, its execution will stop due to its effect. Trace memory contains
The address of the position where execution has stopped and the contents of the register and memory at that time are stored. Then, the instruction conversion tool converts the debug program into an instruction sequence for performing the reverse operation on the data in the register and the memory.
As a result, by executing this instruction sequence step by step, it is possible to trace the operation of returning the execution operation in the reverse direction from the position where the execution was stopped.
【0010】[0010]
【実施例】以下、本発明の実施例を図面を参照して詳細
に説明する。図1は、本発明の逆実行デバッグシステム
の一実施例のブロック図である。この図lは、ターゲッ
トシステム上のマイクロプロセッサ(以下、MPUと略
称する)で動作するユーザプログラムをホスト上からデ
バッグするデバッガと、コンパイラおよび命令変換ツー
ルを含むシステムの全体構成を示す。図1において、ホ
スト100では、メモリ103と、ハードディスク10
5と、中央演算装置101(以下、CPUと略称する)
と、CRT106と、ターゲットとのI/F部104と
が内部バス102によって接続されている。また、CP
U101には、ユーザが入力を行うキーボード107
と、マウス108とが接続されている。Embodiments of the present invention will now be described in detail with reference to the drawings. FIG. 1 is a block diagram of an embodiment of a reverse execution debugging system of the present invention. FIG. 1 shows the overall configuration of a system including a debugger for debugging a user program operating on a microprocessor (hereinafter abbreviated as MPU) on a target system from a host, a compiler, and an instruction conversion tool. In FIG. 1, in the host 100, the memory 103 and the hard disk 10
5 and a central processing unit 101 (hereinafter abbreviated as CPU)
The CRT 106 and the target I / F unit 104 are connected by the internal bus 102. Also, CP
The U107 has a keyboard 107 for input by the user.
And the mouse 108 are connected.
【0011】ホスト100上のハードディスク105に
は、ホスト100のCPU101上で動作するプログラ
ムであるコンパイラ1と、デバッガ110と、命令変換
ツール4、およびターゲット上のMPU301上で動作
するユーザプログラムのソースファイル112と、それ
をコンパイラ1でコンパイルして生成されるユーザ実行
ファイル2が格納される。ターゲットシステム300
は、デバッグモニタ309が書き込まれたR0M30
4、メモリ305、ユーザ実行ファイル2を動作させる
MPU301、ユーザ実行ファイル2の実行履歴を格納
するトレースメモリ3aとトレースメモリ3b、および
メモリ管理ユニット310(以下、MMUと略称する)
を搭載する。ターゲットシステム300のI/F部30
3はデバッガインタフェース200を通じてホスト10
0のI/F部104と接続されている。On the hard disk 105 of the host 100, the source files of the compiler 1 which is a program operating on the CPU 101 of the host 100, the debugger 110, the instruction conversion tool 4, and the user program operating on the target MPU 301. 112, and the user execution file 2 generated by compiling it with the compiler 1 are stored. Target system 300
Is the R0M30 to which the debug monitor 309 was written
4, a memory 305, an MPU 301 that operates the user executable file 2, a trace memory 3a and a trace memory 3b that store the execution history of the user executable file 2, and a memory management unit 310 (hereinafter abbreviated as MMU).
Equipped with. I / F unit 30 of target system 300
3 is the host 10 through the debugger interface 200
0 I / F unit 104 is connected.
【0012】MPU301と、ROM304と、メモリ
305と、トレースメモリ3aと、トレースメモリ3b
と、I/F部303とは、ターゲットシステム300の
内部バス302によって接続されている。トレースメモ
リ3bは、命令アドレストレース回路308を通じてM
PU301と接続されている。これにより、命令アドレ
ストレース回路308により、トレースメモリ3bにM
PU301の実行命令アドレス履歴が保持される。MPU 301, ROM 304, memory 305, trace memory 3a, trace memory 3b
And the I / F unit 303 are connected by the internal bus 302 of the target system 300. The trace memory 3b receives M through the instruction address trace circuit 308.
It is connected to the PU 301. As a result, the instruction address trace circuit 308 stores M in the trace memory 3b.
The execution instruction address history of the PU 301 is held.
【0013】この場合、命令アドレストレース回路30
8は、実行命令アドレス履歴を保持するのにトレースメ
モリ3bをループ状に使用する。すなわち、トレースメ
モリ3bの最終番地まで使用してしまったら、再び先頭
番地から履歴を保持する。このようにして、常に、プロ
グラム停止時の前の実行命令アドレス履歴を、トレース
メモリ3bの容量分保持することができる。プログラム
停止時の実行命令アドレスを保持するトレースメモリ3
bのアドレスは、図2に示すように、トレースメモリ3
bのアドレスレジスタ311に保持される。In this case, the instruction address trace circuit 30
8 uses the trace memory 3b in a loop for holding the history of execution instruction addresses. That is, when the last address of the trace memory 3b has been used, the history is held again from the first address. In this way, the execution instruction address history before the program is stopped can be always held for the capacity of the trace memory 3b. Trace memory 3 that holds the execution instruction address when the program is stopped
The address of b is as shown in FIG.
It is held in the address register 311 of b.
【0014】デバッガ110は、キーボード107また
はマウス108からコマンドを入力し、その結果をCR
T106に表示する。また、デバッガ110は、ユーザ
のプログラムロードコマンドによりユーザ実行ファイル
2を読み出し、デバッガインタフェース200を通じて
デバッグモニタ309と通信することにより、ターゲッ
トシステム300上のメモリ305にロードする。そし
て、デバッガインタフェース200を通じてデバッグモ
ニタ309と通信することにより、ユーザコマンドを実
行する。The debugger 110 inputs a command from the keyboard 107 or mouse 108 and CRs the result.
Display at T106. The debugger 110 also loads the user execution file 2 into the memory 305 on the target system 300 by reading the user execution file 2 according to the user's program load command and communicating with the debug monitor 309 through the debugger interface 200. Then, the user command is executed by communicating with the debug monitor 309 through the debugger interface 200.
【0015】次に、上述したシステムの動作を説明す
る。コンパイラ1は、マイクロコンピュータ上で動作す
るユーザ実行ファイル2が実行時に値を書き込む、レジ
スタ、メモリなどの記憶手段の書き込み前の値を退避す
る命令をオペレータの選択により追加することができ
る。以下、この動作の詳細を説明する。例えば、次のよ
うなレジスタ加算命令を定義する。
add %r1,%r2,%r3
この命令は、%r1の値と%r2の値を加えて%r3に
格納する命令である。ここに、%r1などはMPU30
1の内部にあるレジスタを示す。この命令は、レジスタ
への書き込みを伴う命令である。Next, the operation of the above system will be described. The compiler 1 can add an instruction to write a value at the time of execution by the user execution file 2 operating on the microcomputer, and to save a value before writing in a storage unit such as a register or a memory by an operator's selection. The details of this operation will be described below. For example, the following register addition instruction is defined. add% r1,% r2,% r3 This instruction is an instruction to add the value of% r1 and the value of% r2 and store the result in% r3. Here,% r1 is MPU30
1 shows a register inside 1. This instruction is an instruction that involves writing to a register.
【0016】また、次のような命令を定義する。
sw %r1,[%r2]
この命令は、%r1の値を%r2の値のメモリアドレス
へストアする命令であり、メモリ305ヘの書き込みを
伴う命令である。コンパイラ1は、ユーザの選択に応じ
て、このような命令の直前に、書き込まれる記憶手段の
前の値をトレースメモリ3aに退避する命令を追加す
る。例えば、ユーザソースファイル112のコンパイル
時、ユーザが「退避命令の追加」を選択しなかった場合
には、コンパイラ1が、以下の命令列を生成するとす
る。The following instructions are defined. sw% r1, [% r2] This instruction is an instruction to store the value of% r1 in the memory address of the value of% r2, and is an instruction that involves writing to the memory 305. The compiler 1 adds an instruction to save the previous value of the storage means to be written in the trace memory 3a immediately before such an instruction according to the user's selection. For example, when compiling the user source file 112 and the user does not select "add save instruction", the compiler 1 generates the following instruction sequence.
【0017】
(a1) add %r1,%r2,%r3
(a2) sw %r1,[%r2]
一方、ユーザが「退避命令の追加」を選択した場合、コ
ンパイラ1は、「退避命令の追加」を選択しなかった場
合に加えて図3に示す処理を行う。その結果、以下の命
令列を出力する。
(b1) sw %r3,[%wr1]
(b2) add %wr1,4,%wr1
(b3) add %r1,%r2,%r3
(b4) lw [%r2],%wr2
(b5) sw %wr2,[%wr1]
(b6) add %wr1,4,%wr1
(b7) sw %r1,[%r2](A1) add% r1,% r2,% r3 (a2) sw% r1, [% r2] On the other hand, when the user selects “add save instruction”, the compiler 1 selects “add save instruction”. In addition to the case where "" is not selected, the processing shown in FIG. 3 is performed. As a result, the following instruction sequence is output. (B1) sw% r3, [% wr1] (b2) add% wr1, 4,% wr1 (b3) add% r1,% r2,% r3 (b4) 1w [% r2],% wr2 (b5) sw% wr2, [% wr1] (b6) add% wr1, 4,% wr1 (b7) sw% r1, [% r2]
【0018】ここに、%wr1,%wr2は、ユーザプ
ログラムが使用することのないワークレジスタである。
“lw [%r2],%wr2”は、%r2の値の
メモリアドレスの内容を%wr2にロードする命令であ
る。また、%wr1は、常にトレースメモリ3aのアド
レスを指しており、MMU310により、最終番地アド
レスからさらにインクリメントすると先頭番地を指すよ
うにされている。Here,% wr1 and% wr2 are work registers which are not used by the user program.
"Lw [% r2],% wr2" is an instruction to load the contents of the memory address having the value of% r2 into% wr2. In addition,% wr1 always indicates the address of the trace memory 3a, and the MMU 310 indicates the start address when the address is further incremented from the last address.
【0019】上記の場合、コンパイラ1は、(a1)に
当たる(b3)の命令を決定し、この命令がレジスタ%
r3への書き込みを伴う命令なので、書き込まれるレジ
スタ値をトレースメモリ3aに退避する命令(bl)
と、退避するアドレスを更新する命令(b2)を加え
る。同様に、(a2)に当たる(b7)の命令を決定
し、この命令がメモリへの書き込みを伴う命令なので、
書き込まれるメモリ値をトレースメモリ3aに退避する
命令(b4),(b5)と、退避するアドレスを更新す
る命令(b6)を加える。以上のようにして、マイクロ
コンピュータ上で動作するプログラムが実行時に値を書
き込む、レジスタ、メモリなどの記憶手段の書き込み前
の値を退避する命令を選択的に追加することができる。
即ち、ユーザのオプション指定により、退避命令を追加
することができる。In the above case, the compiler 1 determines the instruction (b3) corresponding to (a1), and this instruction is registered in the register%.
Since it is an instruction that involves writing to r3, an instruction that saves the register value to be written to the trace memory 3a (bl)
Then, an instruction (b2) for updating the saved address is added. Similarly, the instruction of (b7) corresponding to (a2) is determined, and since this instruction involves writing to the memory,
Instructions (b4) and (b5) for saving the written memory value in the trace memory 3a and an instruction (b6) for updating the saved address are added. As described above, it is possible to selectively add an instruction to write a value at the time of execution by a program operating on the microcomputer and to save a value before writing in a storage unit such as a register or a memory.
That is, the save instruction can be added by the option designation by the user.
【0020】次に、逆実行によるデバッグ作業について
説明する。命令変換ツール4は、コンパイラ1で、「退
避命令の追加」を選択してコンパイルしたユーザ実行フ
ァイル2とともに使用する。命令変換ツール4は、ユー
ザ実行ファイル2の実行後に、トレースメモリ3bに格
納された実行命令履歴と、トレースメモリ3aに退避さ
れた、レジスタ、メモリなどの記憶手段の書き込み前の
値を使用して、ユーザ実行ファイル2の停止時点から開
始して、ユーザ実行ファイル2の逆動作を実行するユー
ザ実行ファイルを自動的に生成する。以下、この処理の
詳細を説明する。ユーザソースファイル112をコンパ
イラ1によって「退避命令の追加」を行うようにコンパ
イルした結果、以下の命令列を含むユーザ実行ファイル
2が生成されたとする。Next, a debug operation by reverse execution will be described. The instruction conversion tool 4 is used together with the user execution file 2 compiled by selecting "add save instruction" in the compiler 1. After executing the user executable file 2, the instruction conversion tool 4 uses the execution instruction history stored in the trace memory 3b and the value before writing in the storage means such as the register and the memory saved in the trace memory 3a. A user execution file for executing the reverse operation of the user execution file 2 is automatically generated, starting from the time when the user execution file 2 is stopped. The details of this processing will be described below. It is assumed that the user source file 112 is compiled by the compiler 1 so as to "add a save instruction", and as a result, the user executable file 2 including the following instruction sequence is generated.
【0021】 (c1) 0x0fc sw %r1,[%r2] (c2) 0x100 b label ・・・ label: (c3) 0x200 sw %r5,[%wr1] (c4) 0x204 add %wr1,4,%wr1 (c5) 0x208 add %r3,%r4,%r5 (c6) 0x20c lw [%r7],%wr2 (c7) 0x210 sw %wr2,[%wr1] (c8) 0x214 add %wr1,4,%wr1 (c9) 0x218 sw %r6,[%r7][0021] (C1) 0x0fc sw% r1, [% r2] (C2) 0x100 b label ... label: (C3) 0x200 sw% r5, [% wr1] (C4) 0x204 add% wr1,4,% wr1 (C5) 0x208 add% r3,% r4,% r5 (C6) 0x20c lw [% r7],% wr2 (C7) 0x210 sw% wr2, [% wr1] (C8) 0x214 add% wr1,4,% wr1 (C9) 0x218 sw% r6, [% r7]
【0022】ここに、0xfc,0x100などは命令
のアドレスであり、”b label”は、ラベルla
belへの分岐命令である。このユーザ実行ファイル2
を実行した結果、MPU301が命令アドレス0x21
8で停止して、その時点でのターゲットシステム300
のトレースメモリ3a、トレースメモリ3bの内容が以
下のようであったとする。
トレースメモリ3aの内容
(d1) 0x12345678
(d2) 0x98765432Here, 0xfc, 0x100, etc. are the addresses of the instructions, and "b label" is the label la.
This is a branch instruction to bel. This user executable file 2
As a result, the MPU 301 sets the instruction address 0x21.
Stop at 8 and target system 300 at that time
It is assumed that the contents of the trace memory 3a and the trace memory 3b are as follows. Contents of the trace memory 3a (d1) 0x12345678 (d2) 0x98765432
【0023】 トレースメモリ3bの内容 (e1) 0xfc (e2) 0x100 (e3) 0x200 (e4) 0x204 (e5) 0x208 (e6) 0x20c (e7) 0x210 (e8) 0x214 (e9) 0x218[0023] Contents of trace memory 3b (E1) 0xfc (E2) 0x100 (E3) 0x200 (E4) 0x204 (E5) 0x208 (E6) 0x20c (E7) 0x210 (E8) 0x214 (E9) 0x218
【0024】ここに、%wr1は(d2)を指し、トレ
ースメモリ3bのアドレスレジスタ311は(e9)を
指しているとする。トレースメモリ3aとトレースメモ
リ3bの内容はデバッガ110によってハードディスク
105に格納することができる。命令変換ツール4は、
ハードディスク105に格納されたトレースメモリ3a
とトレースメモリ3bの内容、およびユーザ実行ファイ
ル2を使用して、図4のアルゴリズムに従ってユーザ実
行ファイル2の逆実行プログラムを生成する。図4の例
の場合、以下の逆実行プログラムを生成する。ここに、
逆実行プログラムというのは、ユーザプログラムを動作
させた場合のレジスタ、メモリなどの記憶手段の状態遷
移と逆の状態遷移を生じさせるプログラムという意味で
ある。Here, it is assumed that% wr1 indicates (d2) and the address register 311 of the trace memory 3b indicates (e9). The contents of the trace memory 3a and the trace memory 3b can be stored in the hard disk 105 by the debugger 110. Instruction conversion tool 4
Trace memory 3a stored in hard disk 105
Using the contents of the trace memory 3b and the user execution file 2, a reverse execution program of the user execution file 2 is generated according to the algorithm of FIG. In the case of the example of FIG. 4, the following reverse execution program is generated. here,
The reverse execution program means a program that causes a state transition opposite to the state transition of the storage means such as the register and the memory when the user program is operated.
【0025】 (f1) lw [%r7],%r6 (f2) sub %wr1,4,%wr1 (f3) lw [%wr1],%wr2 (f4) sw %wr2,[%r7] (f5) sub %wr1,4,%wr1 (f6) lw [%wr1],%r5 (f7) lw [%r2],%r1[0025] (F1) lw [% r7],% r6 (F2) sub% wr1, 4,% wr1 (F3) lw [% wr1],% wr2 (F4) sw% wr2, [% r7] (F5) sub% wr1, 4,% wr1 (F6) lw [% wr1],% r5 (F7) lw [% r2],% r1
【0026】この生成過程を図4を参照して説明する。
まず、ステップS41で(e9)より(c9)の命令を
読み出すと、これはストア命令なので、その逆のロード
命令(f1)が生成される(ステップS42、S4
3)。次に、ステップS44、S41で(e8)より
(c8)の命令を読み出すと、これは退避するアドレス
を更新する命令なので、退避アドレスを1つ戻す命令
(f2)が生成される(ステップS46)。次に、(e
7)より(c7)の命令を読みだし、これがストア命令
なので、その逆のロード命令(f3)が生成される。こ
のようにして生成されたものが上記の逆実行プログラム
である。この逆実行プログラムにより、メモリ305と
トレースメモリ3aの内容を、ユーザプログラム実行停
止時の状態にしておいて、この逆実行プログラムをロー
ドして動作させれば、レジスタ、メモリなどの記憶手段
の状態遷移を逆に実行させることができる。This generation process will be described with reference to FIG.
First, when the instruction of (c9) is read from (e9) in step S41, since this is a store instruction, the opposite load instruction (f1) is generated (steps S42, S4).
3). Next, when the instruction of (c8) is read from (e8) in steps S44 and S41, since this is an instruction to update the address to be saved, an instruction (f2) for returning the saved address by one is generated (step S46). . Then (e
The instruction of (c7) is read from 7), and since this is a store instruction, a load instruction (f3) of the opposite is generated. The reverse execution program is generated in this way. This reverse execution program causes the contents of the memory 305 and the trace memory 3a to be in a state at the time when the user program execution is stopped, and if this reverse execution program is loaded and operated, the state of the storage means such as a register and a memory is changed. The transition can be reversed.
【0027】以上のようにして、コンパイラ1と、命令
変換ツール4を使用して、ユーザプログラムの停止時か
ら逆動作をする逆実行プログラムを生成することがで
き、この逆実行プログラムを使用して、プログラムの逆
トレースを行うことができる。プログラムの逆トレース
は、従来行われていなかった方法であり、これによって
画期的なデバッグツールが提供される。即ち、一度実行
したプログラムの特定の箇所でのレジスタ、メモリの値
の再現が可能であり、しかも、プログラムの実行、停
止、レジスタ、メモリ値の参照を繰り返して逆トレース
することができる。これにより、バグの原因を捜し出す
ことが容易となり、デバッグが効率的となる。As described above, the compiler 1 and the instruction conversion tool 4 can be used to generate a reverse execution program that performs a reverse operation even when the user program is stopped. , You can do a reverse trace of the program. Reverse tracing of programs is a traditional method, which provides a revolutionary debugging tool. That is, it is possible to reproduce the register and memory values at a specific location of a program that has been executed once, and furthermore, it is possible to carry out reverse tracing by repeatedly executing and stopping the program and referring to the register and memory values. This makes it easier to find the cause of the bug and makes debugging more efficient.
【0028】尚、本発明は上述した実施例に限定される
ものではなく、種々の変形が可能であることはもちろん
である。例えば、上述した実施例では、ハードウェアと
密接な機械命令の場合について説明したが、本発明を高
級言語のプログラムのデバッグに応用することも可能で
ある。The present invention is not limited to the above-mentioned embodiments, and it goes without saying that various modifications can be made. For example, in the above-described embodiment, the case of the machine instruction close to the hardware has been described, but the present invention can be applied to the debugging of a high-level language program.
【0029】[0029]
【発明の効果】以上説明したように、本発明の逆実行デ
バッグシステムによれば、所定の命令変換により逆実行
プログラムを生成して実行するようにしたので、次のよ
うな効果がある。即ち、プログラムの動作トレースを行
う場合に、一度通過してしまった部分を再現する際に、
もう一度プログラムエントリから実行し直す必要がな
く、効率的なデバッグ作業を行うことができる。即ち、
何度もブレークポイントをかけ直さなくても、誤動作し
た時点から、1ステップずつ前の状況を把握していくこ
とができる。また、入力データの内容やその入力タイミ
ングによってプログラムの実行内容が異なるような場合
でも、過去に起きた事象を再現することが可能となる。
従って、何らかの原因で誤動作が発生した場合に、その
誤動作を確実に再現することができる。As described above, according to the reverse execution debug system of the present invention, since the reverse execution program is generated and executed by the predetermined instruction conversion, there are the following effects. That is, when tracing the operation of the program, when reproducing the part that has passed once,
Efficient debugging work can be performed without having to execute again from the program entry. That is,
It is possible to grasp the previous situation step by step from the time when the malfunction occurs, without re-setting the breakpoint many times. Further, even when the execution contents of the program differ depending on the contents of the input data and the input timing, it is possible to reproduce the event that occurred in the past.
Therefore, when a malfunction occurs due to some reason, the malfunction can be reliably reproduced.
【図1】本発明の逆実行デバッグシステムの一実施例の
ブロック図である。FIG. 1 is a block diagram of an embodiment of a reverse execution debugging system of the present invention.
【図2】トレースメモリの構成の説明図である。FIG. 2 is an explanatory diagram of a configuration of a trace memory.
【図3】退避命令を追加する処理手順を説明するフロー
チャートである。FIG. 3 is a flowchart illustrating a processing procedure for adding a save instruction.
【図4】命令変換ツールの処理手順を説明するフローチ
ャートである。FIG. 4 is a flowchart illustrating a processing procedure of an instruction conversion tool.
1 コンパイラ 2 ユーザ実行ファイル 3a、3b トレースメモリ 4 命令変換ツール 1 compiler 2 User executable file 3a, 3b Trace memory 4 Instruction conversion tool
───────────────────────────────────────────────────── フロントページの続き (56)参考文献 特開 平5−108404(JP,A) 特開 平4−342038(JP,A) 特開 平2−213946(JP,A) 特開 平4−540(JP,A) 特開 昭50−137544(JP,A) 特開 平3−127234(JP,A) 特開 平4−153741(JP,A) 特開 昭63−98031(JP,A) 特開 平6−222952(JP,A) 特開 平5−81075(JP,A) 特開 平4−328644(JP,A) (58)調査した分野(Int.Cl.7,DB名) G06F 11/28 - 11/34 ─────────────────────────────────────────────────── ─── Continuation of the front page (56) Reference JP-A-5-108404 (JP, A) JP-A-4-342038 (JP, A) JP-A-2-213946 (JP, A) JP-A-4- 540 (JP, A) JP 50-137544 (JP, A) JP 3-127234 (JP, A) JP 4-153741 (JP, A) JP 63-98031 (JP, A) JP-A-6-222952 (JP, A) JP-A-5-81075 (JP, A) JP-A-4-328644 (JP, A) (58) Fields investigated (Int.Cl. 7 , DB name) G06F 11/28-11/34
Claims (2)
グラム中の各書き込み命令の実行時の直前の記憶手段内
のデータを退避するための退避命令を、当該書き込み命
令の直前に追加したトレース用プログラムを生成するコ
ンパイラと、 当該コンパイラにより生成されたトレース用プログラム
を格納するユーザ実行ファイルと、 当該ユーザ実行ファイルに格納されたトレース用プログ
ラム中の前記退避命令の実行により退避されるデータ及
び当該トレース用プログラムの実行過程の命令アドレス
履歴をそれぞれ格納するトレースメモリと、 前記トレース用プログラムの実行停止時に、前記トレー
ス用プログラム中の各命令を前記トレースメモリに格納
されている最新の命令アドレスの命令から順次逆のデー
タ処理を行う命令に変換した逆実行プログラムを生成す
る命令変換ツールとを備えたことを特徴とする逆実行デ
バッグシステム。1. A trace program in which a save instruction for saving data in a storage means immediately before execution of each write instruction in a program stored in a user source file is added immediately before the write instruction A compiler to generate, a user execution file that stores the trace program generated by the compiler, data saved by the execution of the save instruction in the trace program stored in the user execution file, and the trace program And a trace memory for storing an instruction address history in the execution process of (1), and when the execution of the trace program is stopped, each instruction in the trace program is sequentially reversed from the instruction of the latest instruction address stored in the trace memory. Reverse execution converted to an instruction for data processing A reverse execution debug system comprising an instruction conversion tool for generating a program.
プログラム中の各ロード命令をストア命令に変換し、各
ストア命令をロード命令に変換し、前記トレースメモリ
に退避するアドレスを更新する各命令を1つ前のアドレ
スに戻す命令に変換し、これら以外の命令は無視するこ
とを特徴とする請求項1記載の逆実行デバッグシステ
ム。2. The instruction conversion tool converts each load instruction in the trace program into a store instruction, converts each store instruction into a load instruction, and updates each instruction to save an address saved in the trace memory. 2. The reverse execution debug system according to claim 1, wherein the instruction is converted into an instruction for returning to the previous address and instructions other than these are ignored.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP17829595A JP3379675B2 (en) | 1995-06-21 | 1995-06-21 | Reverse execution debugging system |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP17829595A JP3379675B2 (en) | 1995-06-21 | 1995-06-21 | Reverse execution debugging system |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JPH096647A JPH096647A (en) | 1997-01-10 |
| JP3379675B2 true JP3379675B2 (en) | 2003-02-24 |
Family
ID=16045980
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP17829595A Expired - Fee Related JP3379675B2 (en) | 1995-06-21 | 1995-06-21 | Reverse execution debugging system |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP3379675B2 (en) |
Families Citing this family (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2000235510A (en) * | 1999-02-15 | 2000-08-29 | Hitachi Ltd | Processor and compiled program recording medium therefor |
| JP4107470B2 (en) * | 2001-10-11 | 2008-06-25 | 三菱電機株式会社 | Software failure analysis method and apparatus |
| US7107585B2 (en) * | 2002-07-29 | 2006-09-12 | Arm Limited | Compilation of application code in a data processing apparatus |
| JP4872883B2 (en) * | 2007-10-31 | 2012-02-08 | 日本電気株式会社 | Computer, failure reproduction method and program |
| JP6812637B2 (en) * | 2016-01-20 | 2021-01-13 | 富士電機株式会社 | Programmable controller system, its development support device, target device |
| WO2018071450A1 (en) | 2016-10-11 | 2018-04-19 | Green Hills Software, Inc. | Systems, methods, and devices for vertically integrated instrumentation and trace reconstruction |
| JP7568934B2 (en) * | 2021-03-30 | 2024-10-17 | 富士通株式会社 | Faulty part identifying program, faulty part identifying device, and faulty part identifying method |
-
1995
- 1995-06-21 JP JP17829595A patent/JP3379675B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JPH096647A (en) | 1997-01-10 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US5870607A (en) | Method and apparatus for selective replay of computer programs | |
| US8266608B2 (en) | Post-compile instrumentation of object code for generating execution trace data | |
| US5313387A (en) | Re-execution of edit-compile-run cycles for changed lines of source code, with storage of associated data in buffers | |
| US7533246B2 (en) | Application program execution enhancing instruction set generation for coprocessor and code conversion with marking for function call translation | |
| US6240545B1 (en) | Setting instance breakpoints in object oriented computer programs | |
| CN101446918B (en) | Method for realizing debugging of single function by user state debugger and system thereof | |
| EP0753814B1 (en) | Determining dynamic properties of programs | |
| US8448152B2 (en) | High-level language, architecture-independent probe program compiler | |
| US20080215920A1 (en) | Program code trace signature | |
| US20090037887A1 (en) | Compiler-inserted predicated tracing | |
| JP2004062858A (en) | Compilation of application code in data processor | |
| US20040006760A1 (en) | Generating and using profile information automatically in an integrated development environment | |
| EP1743243A2 (en) | Apparatus and method for improving emulation speed of high-level languages in on-chip emulation systems | |
| US20130125096A1 (en) | Systems and Methods for Dynamic Collection of Probe Call Sites | |
| JP3379675B2 (en) | Reverse execution debugging system | |
| US7676774B2 (en) | System LSI verification system and system LSI verification method | |
| Koju et al. | An efficient and generic reversible debugger using the virtual machine based approach | |
| Magnusson | Partial translation | |
| Demetrescu et al. | A portable virtual machine for program debugging and directing | |
| JP2715988B2 (en) | Program simulator device and program debugging method | |
| Al-Sharif et al. | The use of dynamic temporal assertions for debugging | |
| Mitchell | Porting the UNIX Implementation of Icon | |
| JP2669300B2 (en) | Program trace circuit and program trace method | |
| JPH05108404A (en) | Debugger system | |
| JPH064298A (en) | Program development environment construction system |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20081213 Year of fee payment: 6 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20091213 Year of fee payment: 7 |
|
| LAPS | Cancellation because of no payment of annual fees |