JP2005284542A - Program debugging method, debugging program and program debugging device - Google Patents
Program debugging method, debugging program and program debugging device Download PDFInfo
- Publication number
- JP2005284542A JP2005284542A JP2004095531A JP2004095531A JP2005284542A JP 2005284542 A JP2005284542 A JP 2005284542A JP 2004095531 A JP2004095531 A JP 2004095531A JP 2004095531 A JP2004095531 A JP 2004095531A JP 2005284542 A JP2005284542 A JP 2005284542A
- Authority
- JP
- Japan
- Prior art keywords
- program
- instruction
- breakpoint
- debugging
- debugged
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
- Test And Diagnosis Of Digital Computers (AREA)
Abstract
Description
本発明はマイクロコンピュータのプログラム開発におけるソフトウェアのエミュレーション技術に関し、特にプログラムのブレークポイント設定とプログラム実行に関する。 The present invention relates to a software emulation technique in program development of a microcomputer, and more particularly to program breakpoint setting and program execution.
マイクロコンピュータで動作するプログラムのデバッグを行なう方式として、プログラムをエミュレーションし、ブレークポイントを設定することによって前記プログラムのデバッグを部分的に行なう方式が知られている。このソフトウェアブレークポイントによるデバッグ方式は、ブレークポイントを設定したいプログラム中の命令を、プログラムを制御するための命令、たとえば割り込みを発生させる命令(トラップ命令)に一時的に置き換えるようにしている。このソフトウェアブレークポイントによるデバッグ方式をフラッシュROMに適応することによりROMであってもソフトウェアブレークポイントを設定することが可能となった。 As a method of debugging a program operating on a microcomputer, a method of partially debugging the program by emulating the program and setting a breakpoint is known. In this debugging method using software breakpoints, an instruction in a program for which a breakpoint is to be set is temporarily replaced with an instruction for controlling the program, for example, an instruction for generating an interrupt (trap instruction). By applying this software breakpoint debugging method to flash ROM, software breakpoints can be set even for ROM.
ソフトウェアのエミュレーション環境は、ユーザーが操作するホストマシンと、ホストマシン上で動作するデバッグプログラムと、デバッグ対象であるユーザープログラムを有するマイクロコンピュータと、マイクロコンピュータとホストコンピュータとの間に設けられるエミュレータと、それらを接続するケーブル類とを備えている。エミュレータはホストマシン上のデバッグプログラムと、マイクロコンピュータとの情報の橋渡しの役目をもつ。ユーザーはホストマシンを通してデバッグプログラムを操作し、その命令はデバッグプログラムからエミュレータを介してマイクロコンピュータへ伝達される。マイクロコンピュータの状態はエミュレータによって観察され、エミュレータはその情報をホストマシンへ伝達している。 A software emulation environment includes a host machine operated by a user, a debug program operating on the host machine, a microcomputer having a user program to be debugged, an emulator provided between the microcomputer and the host computer, And cables for connecting them. The emulator serves as a bridge between the debugging program on the host machine and the microcomputer. The user operates the debug program through the host machine, and the instructions are transmitted from the debug program to the microcomputer via the emulator. The state of the microcomputer is observed by the emulator, and the emulator transmits the information to the host machine.
図1にデバッガ7の構成およびエミュレータ1、マイクロコンピュータ4との接続関係を示す。デバッグプログラムであるデバッガ7とエミュレータ1とはホストインターフェースケーブル3によって接続さる。これにより両者間でのデータのやり取りが可能とされる。また、エミュレータ1とマイクロコンピュータ4とはインターフェースケーブル6によって接続される。これによりエミュレータ1において所定のエミュレーション動作が可能とされる。マイクロコンピュータ4は内部にフラッシュROM8を有し、フラッシュROM8にデバッグ対象プログラムが格納されている。
FIG. 1 shows the configuration of the
デバッガ7は実行制御部17、ブレークポイント制御部18、データ転送制御部19、ユーザーインターフェース20およびデバッグ対象情報表示部21を備えており、ユーザーからの操作に基づいてデバッグ作業を行なう。実行制御部17はブレークポイント制御部18、データ転送制御部19、ユーザーインターフェース20およびデバッグ対象情報表示部21の全体的な動作を制御する。
The
ユーザーインターフェース20はブレークポイントの設定や解除、プログラムの実行、停止等の命令をユーザーから受け、それを実行制御部17およびブレークポイント制御部18へ伝える役割を持つ。デバッグ対象情報表示部21はデバッグ対象であるマイクロコンピュータ4の情報を、エミュレータ1の観察に基づいて表示する。
The
ブレークポイント制御部18はユーザーインターフェース20からのブレークポイント設定に基づき、ブレークポイントを設定したプログラムのプログラムカウンターおよびブレーク命令に変更する前の元の命令を記憶しておく役割を持つ。データ転送制御部19はデバッガ7とエミュレータ1の間の情報の伝達をする役割を有し、ホストインターフェースケーブル3を介してエミュレータ1と接続されている。
Based on the breakpoint setting from the
次に、従来のデバッグ方法について図2と図3を用いて説明する。図2はデバッグ対象のプログラムの一例であり、フラッシュROMに記憶されている。ここでは図2に示すように04b6番地にソフトウェアブレークを設定している。図3は具体的なデバッグ手順を表している。まず、デバッガ7から04b6番地にソフトウェアブレークを設定する(S101)。すると、デバッガ7は図2に示すようにブレークポイントを設定した命令をブレーク命令に置き換えたユーザープログラム16をエミュレータ1に送る。エミュレータ1はそのプログラムをデータ転送回路10からフラッシュROM8に書き込む(S102)。そして、デバッガ7がユーザープログラム16を実行する(S103)。ブレークポイントを設定した命令を実行しようとするとプログラム実行が停止する(S104)。
Next, a conventional debugging method will be described with reference to FIGS. FIG. 2 shows an example of a program to be debugged, which is stored in the flash ROM. Here, as shown in FIG. 2, a software break is set at address 04b6. FIG. 3 shows a specific debugging procedure. First, a software break is set at address 04b6 from the debugger 7 (S101). Then, the
ブレークポイントで動作が停止した状態から再びプログラム実行を開始すると、04b6番地の命令がブレーク命令に書き換えられているため、その命令で再度停止してしまう。デバッガ7は04b6番地の命令を元の命令に書き換えたユーザープログラム16をエミュレータ1に送る。エミュレータ1はそのプログラムをデータ転送回路10からフラッシュROM8に書き込む。04b6番地の元の命令をステップ実行、すなわち書き換えられる前の04b6番地の一命令のみを実行する(S105)。その後、デバッガ7は再び04b6番地の命令をブレーク命令に置き換えたユーザープログラム16をフラッシュROM8に書き込む(S106)。
If the program execution is restarted from the state where the operation is stopped at the breakpoint, the instruction at address 04b6 has been rewritten to the break instruction, and the program stops again at that instruction. The
そして、デバッガ7は再度ユーザープログラム16の実行を開始する(S107)。デバッグ作業が終了したら、デバッガ7はブレークポイントの設定を解除する(S108)。するとデバッガ7はブレーク命令に置き換えられていた命令を元の命令に戻したユーザープログラム16をエミュレータ1に送る。エミュレータ1はそのプログラムをデータ転送回路10からフラッシュROM8に書き込む(S109)。図4は上記の従来の動作を含む、デバッグ開始から終了までの流れを表したフローチャートである。太枠のブロックはプログラムの書き換えが行なわれる事を示している。このようなソフトウェアブレークポイントによるデバッグ方法は、例えば特許文献1や特許文献2に記載されている。
Then, the
従来の方法でソフトウェアブレークポイントによるデバッグを実現した場合、ブレークポイントの設定、解除、ブレークポイントからのユーザープログラムの再実行においてフラッシュROMの書き換えが行われることになる。しかしながら、フラッシュROMの書き換えは、一般的に100回程度しか保証されていない。従ってすぐにこの保証回数を超えてしまうおそれがある。そのためフラッシュROMの書き換え回数を出来得る限り少なくすることが求められる。 When debugging with software breakpoints is realized by the conventional method, the flash ROM is rewritten in setting and canceling breakpoints and re-executing the user program from the breakpoints. However, flash ROM rewriting is generally guaranteed only about 100 times. Therefore, there is a risk that this guaranteed number of times will be exceeded immediately. Therefore, it is required to reduce the number of flash ROM rewrites as much as possible.
また、書き換え回数が多いと、フラッシュROMの書き換え制限回数を消費するだけでなく、データ転送およびフラッシュROMの書き換えに時間がかかり、デバッグ作業に時間がかかることになる。さらに、ブレークポイントの設定および解除によるフラッシュROMの書き換えは各々1回しか行なわれないが、ブレークポイントからのユーザープログラムの再実行においては、ブレークポイントを設定する前のプログラムに書き換える動作と、再度ブレーク命令に書き換える動作の計2度行なわれる。 If the number of rewrites is large, not only the flash ROM rewrite limit number is consumed, but also data transfer and flash ROM rewrite take time, and debugging work takes time. In addition, the flash ROM can be rewritten only once each time a breakpoint is set or released. However, when re-executing a user program from a breakpoint, the program is rewritten to the program before the breakpoint is set, and the breakpoint is re-executed. The operation of rewriting to an instruction is performed twice in total.
ここで、プログラムのデバッグ作業において、ブレークポイントからのユーザープログラムの再実行は複数回行なわれることが想定されるので、ブレークポイントからのユーザープログラムの再実行時のプログラムの書き換えはフラッシュROMの書き換え制限回数の消費の面からも、ユーザープログラムの実行に時間がかかりデバッグ効率を悪化させる面からも好ましくないと考えられる。
上述のように、従来のソフトウェアブレークポイントを用いたデバッグ方法では、プログラムの書き換え回数が増加してしまうという問題があった。本発明はこのような問題点を解決するためになされたものであり、デバッグ時における、プログラムの書き換え回数を少なくすることができるデバッグ方法、装置プログラムを提供する事を目的とする。 As described above, the conventional debugging method using software breakpoints has a problem that the number of program rewrites increases. The present invention has been made to solve such problems, and an object of the present invention is to provide a debugging method and an apparatus program that can reduce the number of times of program rewriting during debugging.
本発明にかかわるプログラムデバッグ方法は、デバッグ対象となるプログラムを有する被デバッグ装置をエミュレーションし、前記プログラムのデバッグを行うプログラムのデバッグ方法であって、前記プログラムにブレークポイントを設定するステップと、前記プログラムの前記ブレークポイントに設定された命令を前記プログラムの実行が停止されるブレーク命令に書き換えるステップと、前記ブレークポイントに設定された命令の前の命令まで前記プログラムを実行するステップと、前記ブレークポイントに設定された命令で前記プログラムを停止するステップと、前記ブレークポイントに設定された命令に対して、前記ブレーク命令に書き換えられる前の命令をシミュレーションするステップと、前記シミュレーションの結果に基づく情報を前記被デバッグ装置に書き込むステップと、前記ブレークポイントに設定された命令の次の命令からプログラムを実行するステップと、を備えるプログラムデバッグ方法である。このような構成により、プログラムの書き換え回数を少なくすることができる。 A program debugging method according to the present invention is a program debugging method for emulating a device to be debugged having a program to be debugged and debugging the program, the step of setting a breakpoint in the program, and the program Rewriting the instruction set at the breakpoint to a break instruction at which execution of the program is stopped, executing the program up to the instruction before the instruction set at the breakpoint, and A step of stopping the program at a set instruction; a step of simulating an instruction set to the breakpoint before being rewritten to the break instruction; and a result of the simulation. And writing the information to the debug target device, and executing the program from the next instruction of the set command to the breakpoint, a program debugging method comprising. With this configuration, the number of program rewrites can be reduced.
また、前記ブレークポイントに設定された命令の次の命令からプログラムを実行した後、前記ブレーク命令を前記ブレーク命令に書き込まれる前の命令に書き換えるステップをさらに有してもよい。こうすることにより、再度プログラムを実行してデバッグを行なう必要が無い場合に、プログラムの実行終了後、ブレーク命令の解除を行なう手間が省ける。 The program may further include a step of rewriting the break instruction to an instruction before being written in the break instruction after executing a program from the instruction next to the instruction set at the breakpoint. In this way, when there is no need to execute the program again for debugging, it is possible to save the trouble of releasing the break instruction after the execution of the program is completed.
本発明にかかるデバッグプログラムは、デバッグ対象となるプログラムを有する被デバッグ装置の前記プログラムにブレークポイントを設定して、前記プログラムのデバッグを行う、プログラムであって、(a)前記デバッグ対象プログラムの前記ブレークポイントに設定された命令を前記デバッグ対象プログラムの実行が停止されるブレーク命令に書き換えるステップと、(b)前記ブレークポイントに設定された命令の前の命令まで前記プログラムを実行するステップと、(c)前記ブレークポイントに設定された命令で前記プログラムを停止するステップと、(d)前記ブレークポイントに設定された命令に対して、前記ブレーク命令に書き換えられる前の命令をシミュレーションするステップと、(e)前記シミュレーションの結果に基づく情報を前記被デバッグ装置に書き込むステップと、(f)前記ブレークポイントに設定された命令の次の命令からプログラムを実行するステップと、があり、コンピュータに前記ステップ(a)、(b)、(c)、(d)、(e)、(f)を実行させるためのプログラムである。このような構成により、プログラムの書き換え回数を少なくすることができる。 A debug program according to the present invention is a program for setting a breakpoint in the program of a debugged device having a program to be debugged, and debugging the program, (a) the debug target program Rewriting an instruction set at a breakpoint to a break instruction at which execution of the debug target program is stopped; (b) executing the program up to an instruction before the instruction set at the breakpoint; c) stopping the program at an instruction set at the breakpoint; (d) simulating an instruction before being rewritten to the break instruction with respect to the instruction set at the breakpoint; e) Results of the simulation Writing information to the debugged device; and (f) executing a program from an instruction next to the instruction set at the breakpoint. The computer includes the steps (a), (b), This is a program for executing (c), (d), (e), and (f). With this configuration, the number of program rewrites can be reduced.
また、ステップ(f)の後、前記ブレーク命令を前記ブレーク命令に書き込まれる前の命令に書き換えるステップをさらに有してもよい。こうすることにより、再度プログラムを実行してデバッグを行なう必要が無い場合に、プログラムの実行終了後、ブレーク命令の解除を行なう手間が省ける。 Further, after the step (f), there may be further included a step of rewriting the break instruction to an instruction before being written in the break instruction. In this way, when there is no need to execute the program again for debugging, it is possible to save the trouble of releasing the break instruction after the execution of the program is completed.
本発明にかかわるプログラムデバッグ装置は、デバッグ対象となるプログラムを有する被デバッグ装置をエミュレーションするエミュレータと、前記エミュレータを操作し前記デバッグ対象プログラムに対してブレークポイント設定を行なうデバッグプログラムと、前記デバッグプログラムを動作させるホストマシンと、を有するプログラムデバッグ装置であって、前記プログラムにブレークポイントを設定する手段と、前記プログラムの前記ブレークポイントに設定された命令を前記プログラムの実行が停止されるブレーク命令に書き換える手段と、前記ブレーク命令に書き換えられた命令を有するプログラムを実行する手段と、前記ブレークポイントに設定された命令で前記プログラムを停止する手段と、前記ブレークポイントに設定された命令に対して、前記ブレーク命令に書き換えられる前の命令をシミュレーションする手段と、前記シミュレーションの結果に基づく情報を前記被デバッグ装置に書き込む手段と、前記ブレークポイントに設定された命令の次の命令からプログラムを実行する手段と、を備えるプログラムデバッグ装置である。このような構成により、プログラムの書き換え回数を少なくすることができる。 A program debug apparatus according to the present invention includes an emulator that emulates a debug target apparatus having a program to be debugged, a debug program that operates the emulator and sets a breakpoint for the debug target program, and the debug program. A program debugging apparatus comprising: a host machine that operates; a program that sets a breakpoint in the program; and an instruction that is set at the breakpoint of the program is rewritten to a break instruction that stops execution of the program Means for executing a program having an instruction rewritten to the break instruction; means for stopping the program at an instruction set at the breakpoint; and Means for simulating the instruction before being rewritten to the break instruction, means for writing information based on the result of the simulation to the debugged device, and an instruction next to the instruction set at the breakpoint A program debugging device comprising: With this configuration, the number of program rewrites can be reduced.
また、前記ブレークポイントに設定された命令の次の命令からプログラムを実行した後、前記ブレーク命令を前記ブレーク命令に書き込まれる前の命令に書き換える手段をさらに有してもよい。こうすることにより、再度プログラムを実行してデバッグを行なう必要が無い場合に、プログラムの実行終了後、ブレーク命令の解除を行なう手間が省ける。 The program may further include means for rewriting the break instruction to an instruction before being written in the break instruction after executing a program from an instruction next to the instruction set at the breakpoint. In this way, when there is no need to execute the program again for debugging, it is possible to save the trouble of releasing the break instruction after the execution of the program is completed.
ここで、デバッグ対象プログラムが格納されている記憶媒体はフラッシュROMであってもよい。その場合、プログラムの書き換え回数を低減することにより、フラッシュROMの書き換え制限回数の消費を抑える事ができる。 Here, the storage medium storing the debug target program may be a flash ROM. In that case, by reducing the number of rewrites of the program, consumption of the rewrite limit number of the flash ROM can be suppressed.
本発明によりデバッグ時のプログラムの書き換え回数を低減することができるデバッグ方法、装置、プログラムを提供する事ができる。それによりデバッグ効率を向上させると共に、デバッグ対象プログラムがフラッシュROMに記憶されている場合は、フラッシュROMの書き換え制限回数の消費を抑える事ができる。 According to the present invention, it is possible to provide a debugging method, apparatus, and program that can reduce the number of times of program rewriting during debugging. As a result, debugging efficiency can be improved, and when the program to be debugged is stored in the flash ROM, consumption of the flash ROM rewrite limit number can be suppressed.
以下に、本発明を適用可能な実施の形態が説明される。以下の説明は、本発明の実施形態を説明するものであり、本発明が以下の実施形態に限定されるものではない。また、説明の明確化のため、以下の記載は、適宜、省略及び簡略化がなされている。又、当業者であれば、以下の実施形態の各要素を、本発明の範囲において容易に変更、追加、変換することが可能である。 Hereinafter, embodiments to which the present invention can be applied will be described. The following description is to describe the embodiment of the present invention, and the present invention is not limited to the following embodiment. For the sake of clarity, the following description is omitted and simplified as appropriate. Moreover, those skilled in the art can easily change, add, and convert each element of the following embodiments within the scope of the present invention.
ソフトウェアのエミュレーション環境は図5のように構成されている。すなわちホストマシン2と、エミュレータ1と、マイクロコンピュータ4が実装されたプリント基板5とを備えている。ホストマシン2にはデバッグ用のプログラムが記憶されている。すなわち、ホストマシン2上でデバッガ7が動作する。マイクロコンピュータ4にはデバッグ対象となるユーザープログラムが記憶されている。すなわち、マイクロコンピュータ4はデバッグの対象となる被デバッグ装置である。ホストマシン2とエミュレータ1とはホストインターフェースケーブル3で接続されている。また、エミュレータ1とプリント基板5とはインターフェースケーブル6で接続されている。プリント基板5にはマイクロコンピュータ4とインターフェースケーブル6との間の配線が接続されている。すなわち、インターフェースケーブル6からの信号はプリント基板5を介してマイクロコンピュータ4に入力される。エミュレータ1はホストマシン2からの命令をマイクロコンピュータ4に送信する。また、エミュレータ1はユーザーがホストマシン2上で確認できるよう、マイクロコンピュータの状態をエミュレートする。
The software emulation environment is configured as shown in FIG. That is, it includes a
図5の例では、エミュレータ1はホストインターフェースケーブル3を介してホストマシン2に接続されているがこれに限定されるものではなく、エミュレータ1は例えばPCMCIA(Personal Computer Memory Card International Association)カード、あるいはPCI(Peripheral Component Interconnect)カード等でもよい。この場合ホストマシン2はPCMCIAスロット、あるいはPCIスロット等を搭載したパーソナルコンピュータ等である。
In the example of FIG. 5, the
ホストマシン2は上記の場合も含め、一般的にはパーソナルコンピュータである。以下にホストマシン2の構成例について説明する。図6はホストマシン2のハードウェア構成の概要を示している。中央処理装置(メインCPU)201とメインメモリ204とを含んでいる。メインCPU201とメインメモリ204とは、バスを介して補助記憶装置としてのハードディスク装置と接続される。
The
フレキシビルディスク装置(FDD)220、ハードディスク装置(HDD)213、230、CD−ROMドライブ226、229、MOドライブ228等の記憶媒体駆動装置は、フレキシビルディスク・コントローラ(FDC)219、IDEコントローラ225、SCSIコントローラ227などの各種コントローラを介してバスに接続される。
Storage medium drive devices such as a flexi building disk device (FDD) 220, hard disk devices (HDD) 213 and 230, CD-ROM drives 226 and 229, and MO drive 228 are a flexi building disk controller (FDC) 219 and an
FDD220等の記憶媒体駆動装置には、フレキシビルディスク等の可搬型記憶媒体が挿入される。記憶媒体にはオペレーティングシステムと共同してメインCPU201等に命令を与え、本実施形態を実施するためのコンピュータ・プログラム(デバッガ7)を記憶することができ、メインメモリ204にロードされることによって実行される。コンピュータ・プログラムは圧縮し、又、複数に分割して記憶することができる。
A portable storage medium such as a flexiville disk is inserted into a storage medium driving device such as the
ホストマシン2は、さらに、ユーザ・インターフェース・ハードウェアを備えたシステムとすることができる。ユーザ・インターフェース・ハードウェアとしては、例えば、入力をするためのポインティング・デバイス(マウス207、図示しないジョイスティック等)またはキーボード206や視覚データをユーザーに提示するための表示装置211もしくはCRT212があり、キーボード206、マウス207はキーボードマウスコントローラ205を介してバスに接続され、表示装置211はDAC/LCDC210およびVGA208を介してバスに接続される。又、パラレルポート216を介してプリンタを接続することもできる。
The
ホストマシン2は、シリアルポート215を介してモデムを接続することが可能であり、シリアルポート215、モデムまたはトークンリングや通信用アダプタ218を介してネットワークに接続し、他のコンピュータシステムと通信を行っている。このように、本形態のホストマシン2は、通常のパーソナルコンピュータ(PC)、ワークステーション、汎用機などによって実現可能である。なお、これらの構成は例示であり、そのすべての構成が本実施の形態に必須というものではない。
The
図7にデバッガ7の構成を示す。デバッガ7は実行制御部17、ブレークポイント制御部18、データ転送制御部19、ユーザーインターフェース20、デバッグ対象情報表示部21、命令シミュレーション部22を備えている。実行制御部17は、ブレークポイント制御部18、データ転送制御部19、ユーザーインターフェース20およびデバッグ対象情報表示部21の全体的な動作を制御する。ユーザーインターフェース20はブレークポイントの設定や解除、プログラムの実行、停止等の命令をユーザーから受ける。ユーザーインターフェース20はそれを実行制御部17およびブレークポイント制御部18へ伝える役割を持つ。
FIG. 7 shows the configuration of the
ブレークポイント制御部18はユーザーインターフェース20からのブレークポイント設定に基づき、ブレークポイントを設定したプログラムのプログラムカウンターおよびブレーク命令に変更する前の元の命令を記憶しておく役割を持つ。すなわち、ブレークポイント制御部18はブレークポイントが設定される命令の番地と、その内容を対応づけて記憶する。データ転送制御部19はデバッガ7とエミュレータ1の間の情報の伝達を制御する。デバッグ対象情報表示部21はエミュレータ1により観察されているデバッグ対象であるマイクロコンピュータ4内の情報を表示する。
Based on the breakpoint setting from the
さらに、命令をシミュレーションするために命令シミュレーション部22を導入する。命令シミュレーション部22は実行制御部17から呼び出されて動作し、呼び出されたときのマイクロコンピュータ4のエミュレーション情報に基づいて、ソフト上でマイクロコンピュータ4の動作をシミュレーションする。命令シミュレーション部22はシミュレーションした結果をデータ転送制御部19からエミュレータ1に転送する。
Further, an
また、デバッグ対象であるマイクロコンピュータ4は図8に示すようにフラッシュROM8、プロセッサ9、データ転送回路10、RAM11、外部I/O12および割り込みコントローラ13を備えおり、これらのそれぞれがバス15を介して接続されている。フラッシュROM8は電気的に記憶の消去および書き込みができるROMであり、マイクロコンピュータ4のユーザープログラム16が格納されている。プロセッサ9はフラッシュROM8に格納されたユーザープログラム16を実行する。さらに、プロセッサ9はレジスタ14を含む。書き換え可能なフラッシュROMを用いることにより、上述のとおりROMであってもソフトウェアブレークポイントを設定することが可能となった。このマイクロコンピュータ4に格納されたユーザープログラム16がデバッグ対象のプログラムであり、エミュレータ1を介してデバッガ7によりデバッグされる。
The
データ転送回路10は、エミュレータ1とマイクロコンピュータ4との間で送受信が行なわれるインターフェース回路である。RAM11はフラッシュROM8に格納されているユーザープログラムなどのデータを一時的に格納する。外部I/O12はマイクロコンピュータ4の外部入出力を行なう。割り込みコントローラ13は割り込みが発生した事をプロセッサ9に知らせる役割を持つ。
The
本実施の形態の動作を図2に示すように04b6番地にソフトウェアブレークを設定した場合の例を、図9を用いて説明する。まず、デバッガ7から04b6番地にソフトウェアブレークを設定する(S201)。すると、デバッガ7は図2に示すように04b6番地の命令をブレーク命令に置き換えたユーザープログラム16をエミュレータ1に送る。エミュレータ1はそのプログラムをマイクロコンピュータ4に送信する。エミュレータ1により送信されたプログラムはデータ転送回路により受信される。プロセッサ9はそのプログラムをフラッシュROM8に書き込む(S202)。そして、デバッガ7はエミュレータ1を介してマイクロコンピュータ4のユーザープログラム16を実行する(S203)。0000−04b6番地までの命令が実行される。ブレーク命令である04b6番地でプログラム実行が停止する(S204)。
An example of the operation of the present embodiment when a software break is set at address 04b6 as shown in FIG. 2 will be described with reference to FIG. First, a software break is set at address 04b6 from the debugger 7 (S201). Then, the
ユーザープログラムの実行がソフトウェアブレークポイントで停止した状態で再実行しようとした場合、実行制御部17はブレークポイント制御部18に記憶しておいたブレークポイントを設定した命令を命令シミュレーション部22に通知する。命令シミュレーション部22は受け取った命令をデコードし、エミュレータ1から受け取ったレジスタ、メモリ、I/Oの情報に基づいて書き換える前の命令をシミュレーションする。さらに、シミュレーションしたことによって状態の変化したレジスタ、メモリ、I/Oの情報を、データ転送制御部19からエミュレータ1に転送する。ここで、変化したレジスタ、メモリ、I/Oの情報とはシミュレーション上の情報であり、ホストマシン2すなわちデバッガ7内部の情報である。シミュレーション上の情報は、実際にマイクロコンピュータ4に、書き換えられる前の04b6番地の命令を実行させた場合の情報と対応している。
When execution of the user program is attempted to be re-executed while stopped at the software breakpoint, the
エミュレータ1はその情報をインターフェースケーブル6通してデバッグ対象であるマイクロコンピュータ4に転送する。マイクロコンピュータ4のプロセッサ内部のレジスタ14、RAM11および外部I/O12を変化させる(S205)。すなわちシミュレーションによって変化したレジスタ、メモリ、I/Oの情報に基づいて、レジスタ14、RAM11および外部I/O12の状態が変化する。また、実行制御部17はプロセッサ9内部のプログラムカウンターを次の命令、すなわち04b7番地に移動させる命令をエミュレータ1へ送信し、エミュレータ1はそれをマイクロコンピュータ4へ転送する。データ転送回路10でその命令を受け取り、プロセッサ9はプログラムカウンターを04b7番地に移動させる(S206)。さらに、実行制御部17は移動したプログラムカウンターからプログラム実行を再開させる命令を送信するようデータ転送制御部19を制御する。データ転送制御部19はその情報をエミュレータ1に送信する(S207)。エミュレータ1はその命令を受け取りマイクロコンピュータ4に転送する。プロセッサ9は04b7番地の命令からユーザープログラム16を実行する。
The
デバッグ作業が終了したら、デバッガ7からブレークポイントの設定を解除する(S208)。するとデバッガ7はブレーク命令に置き換えられていた命令を元の命令に戻したユーザープログラム16をエミュレータ1に送る。エミュレータ1はそのプログラムをデータ転送回路10からフラッシュROM8に書き込む(S209)。図10は上記の本実施の形態にかかる動作を含む、デバッグ開始から終了までの流れを表したフローチャートである。太枠のブロックはプログラムの書き換えが行なわれる事を示している。
When the debugging operation is completed, the breakpoint setting is canceled from the debugger 7 (S208). Then, the
すなわち、デバッグ作業が開始されるとユーザーはまずデバッガ7に対してブレークポイントの設定を行なう(S201)。エミュレータ1はブレークポイントの設定に基づき、マイクロコンピュータ4内のユーザープログラムを書き換える(S202)。ブレーク命令への書き換えが終わると、マイクロコンピュータ4においてプロセッサ9によりユーザープログラム16が実行される(S203)。0000番地から04b6番地のブレークポイントにヒットするまでプログラムが実行され、04b6番地のブレーク命令でプログラムが停止する(S204)。デバッガ7がユーザーからプログラムの再実行命令を受け取ると、実行制御部17は命令シミュレーション部22を呼び出す。命令シミュレーション部22はブレークポイント制御部18に記録されている、04b6番地のブレーク命令に書き換えられる前の命令をデコードし実行(シミュレーション)する。このシミュレーションの際、呼び出されたときのマイクロコンピュータ4のエミュレーション情報、すなわちレジスタ14、RAM11、外部I/O12の状態に基づき、命令シミュレーション部22はシミュレーションを行なう。
That is, when the debugging operation is started, the user first sets a breakpoint for the debugger 7 (S201). The
04b6番地の元の命令のシミュレーションが終了すると、実行制御部17がシミュレーションによって変化したレジスタ14、RAM11、外部I/O12の状態をエミュレータ1へ送信するようデータ転送制御部19を制御する。エミュレータ1はその情報をマイクロコンピュータ4へ転送する。データ転送回路10がその情報を受け取り、レジスタ14、RAM11、外部I/O12の状態の変化が書き込まれる(S205)。次に、実行制御部17はプロセッサ9内部のプログラムカウンターを次の命令、すなわち04b7番地に移動させる命令をエミュレータ1へ送信し、エミュレータ1はそれをマイクロコンピュータ4へ転送する。データ転送回路10でその命令を受け取り、プロセッサ9はプログラムカウンターを04b7番地に移動させる(S206)。プログラムがブレーク命令の次の命令から再実行される(S207)。
When the simulation of the original instruction at address 04b6 is completed, the
上記の作業でデバッグ作業が終了しなければ上記の作業を繰り返す。その際、前回の作業と同じブレークポイントで作業するならばS203に、別のブレークポイントを設定するならばS201に戻る。デバッグ作業が終了したならばデバッガ7でブレークポイント解除の命令を出す(S208)。すると、実行制御部17はブレークポイント制御部18に記憶されているブレークポイント情報を参照し、ブレークポイントを設定したプログラムカウンターの命令を元に戻す命令をエミュレータ1に送信する。エミュレータ1はその命令をマイクロコンピュータ4へ転送する。データ転送回路10がその命令を受け取り、プロセッサ9によってフラッシュROM8に格納されているユーザープログラムが書き換えられる(S209)。
If the debugging operation is not completed by the above operation, the above operation is repeated. At this time, if the work is performed at the same breakpoint as the previous work, the process returns to S203, and if another breakpoint is set, the process returns to S201. If the debugging operation is completed, the
以上、説明したように、本実施の形態にかかるプログラムデバッグ方法では、ユーザープログラムの実行がソフトウェアブレークポイントで停止した状態で再実行しようとした場合、ブレークポイントを書き換えるのではなくブレークポイントを設定する前の命令をシミュレーションする。そうすることによってプログラムを書き換えることなく命令を再実行する事ができ、結果的に書き換え回数が低減される。書き換えの回数が低減されることにより、データの書き込み、転送にかかる時間が短縮されるので、ユーザープログラムの実行にかかる時間を短縮する事ができる。 As described above, in the program debugging method according to the present embodiment, when execution of a user program is stopped at a software breakpoint and re-execution is attempted, a breakpoint is set instead of rewriting the breakpoint. Simulate the previous instruction. By doing so, the instruction can be re-executed without rewriting the program, and as a result, the number of rewrites is reduced. Since the number of times of rewriting is reduced, the time required for writing and transferring data is shortened, so that the time required for executing the user program can be shortened.
具体的には、デバッグ作業の中でブレークポイントの設定、ブレークポイントからの再実行、ブレークポイントの解除を各1回行なった場合、図4にも示されるように従来技術では設定、解除で各1回、再実行で2回、書き換えを行なっていたので合計で4回のユーザープログラム書き換えが必要であったが、本実施の形態で行なわれるプログラムの書き換えは図10にも示されるように設定、解除の2回のみなので、ユーザープログラムの書き換え回数が半分に低減される。 Specifically, when setting a breakpoint, re-execution from a breakpoint, and canceling a breakpoint once each time during debugging, the prior art sets and cancels each as shown in FIG. Since the user program was rewritten once and re-executed twice, a total of four user program rewrites were necessary. However, the program rewrite performed in this embodiment is set as shown in FIG. Since the release is only twice, the number of rewrites of the user program is reduced to half.
さらに、実際のデバッグ作業では、ブレークポイントからのユーザープログラムの再実行は複数回行なわれることが想定されるので、ブレークポイントからの再実行を行なう程その効果は倍増する。また、本実施の形態ではユーザープログラムを格納する記憶媒体としてフラッシュROMを用いている。そのような場合、書き換え回数を低減する事によりフラッシュROMの書き換え制限回数の消費を抑えることができる。 Further, in actual debugging work, it is assumed that the re-execution of the user program from the breakpoint is performed a plurality of times, so the effect is doubled as the re-execution from the breakpoint is performed. In this embodiment, a flash ROM is used as a storage medium for storing the user program. In such a case, the consumption of the flash ROM rewrite limit number can be suppressed by reducing the number of rewrite times.
1 エミュレータ、2 ホストマシン、3 ホストインターフェースケーブル、
4 マイクロコンピュータ、5 プリント基板、6 インターフェースケーブル、
7 デバッガ、8 フラッシュROM、9 プロセッサ、10 データ転送回路、
11 RAM、12 外部I/O、13 割り込みコントローラ、14 レジスタ、
15 バス、16 ユーザープログラム、17 実行制御部、
18 ブレークポイント制御部、19 データ転送制御部、
20 ユーザーインターフェース、21 デバッグ対象情報表示部、
22 命令シミュレーション部、201 メインCPU、204 メインメモリ、
205 キーボードマウスコントローラ、206 キーボード、207 マウス、
208 VGA、209 VRAM、210 DAC/LCDC、
211 表示装置、212 CRT、213、230 HDD、
214 ROM、215 シリアルポート、216 パラレルポート、
217 タイマ、218 通信用アダプタカード、219 FDC、
220 FDD、225 IDEコントローラ、226、229 CD−ROMドライブ
227 SCSIコントローラ
1 emulator, 2 host machine, 3 host interface cable,
4 Microcomputer, 5 Printed circuit board, 6 Interface cable,
7 debugger, 8 flash ROM, 9 processor, 10 data transfer circuit,
11 RAM, 12 external I / O, 13 interrupt controller, 14 registers,
15 buses, 16 user programs, 17 execution control units,
18 breakpoint control unit, 19 data transfer control unit,
20 user interface, 21 debug target information display section,
22 instruction simulation unit, 201 main CPU, 204 main memory,
205 keyboard mouse controller, 206 keyboard, 207 mouse,
208 VGA, 209 VRAM, 210 DAC / LCDC,
211 Display device, 212 CRT, 213, 230 HDD,
214 ROM, 215 serial port, 216 parallel port,
217 timer, 218 adapter card for communication, 219 FDC,
220 FDD, 225 IDE controller, 226, 229 CD-
Claims (9)
前記プログラムにブレークポイントを設定するステップと、
前記プログラムの前記ブレークポイントに設定された命令を前記プログラムの実行が停止されるブレーク命令に書き換えるステップと、
前記ブレークポイントに設定された命令の前の命令まで前記プログラムを実行するステップと、
前記ブレークポイントに設定された命令で前記プログラムを停止するステップと、
前記ブレークポイントに設定された命令に対して、前記ブレーク命令に書き換えられる前の命令をシミュレーションするステップと、
前記シミュレーションの結果に基づく情報を前記被デバッグ装置に書き込むステップと、
前記ブレークポイントに設定された命令の次の命令からプログラムを実行するステップと、
を備えるプログラムデバッグ方法。 A program debugging method for emulating a device to be debugged having a program to be debugged and debugging the program,
Setting a breakpoint in the program;
Rewriting the instruction set at the breakpoint of the program to a break instruction that stops execution of the program;
Executing the program up to an instruction before the instruction set at the breakpoint;
Stopping the program with an instruction set at the breakpoint;
Simulating an instruction before being rewritten to the break instruction with respect to the instruction set at the breakpoint;
Writing information based on the result of the simulation to the debugged device;
Executing a program from an instruction next to the instruction set at the breakpoint;
A program debugging method comprising:
(a)前記プログラムの前記ブレークポイントに設定された命令を前記プログラムの実行が停止されるブレーク命令に書き換えるステップと、
(b)前記ブレークポイントに設定された命令の前の命令まで前記プログラムを実行するステップと、
(c)前記ブレークポイントに設定された命令で前記プログラムを停止するステップと、
(d)前記ブレークポイントに設定された命令に対して、前記ブレーク命令に書き換えられる前の命令をシミュレーションするステップと、
(e)前記シミュレーションの結果に基づく情報を前記被デバッグ装置に書き込むステップと、
(f)前記ブレークポイントに設定された命令の次の命令からプログラムを実行するステップと、
があり、コンピュータに前記ステップ(a)、(b)、(c)、(d)、(e)、(f)を実行させるためのプログラム。 A program for setting a breakpoint in the program of the debugged device having a program to be debugged and debugging the program,
(A) rewriting an instruction set at the breakpoint of the program to a break instruction at which execution of the program is stopped;
(B) executing the program up to an instruction before the instruction set at the breakpoint;
(C) stopping the program with an instruction set at the breakpoint;
(D) simulating an instruction set at the breakpoint before the instruction is rewritten to the break instruction;
(E) writing information based on the result of the simulation into the debugged device;
(F) executing a program from an instruction next to the instruction set at the breakpoint;
And a program for causing a computer to execute the steps (a), (b), (c), (d), (e), and (f).
前記プログラムにブレークポイントを設定する手段と、
前記プログラムの前記ブレークポイントに設定された命令を前記プログラムの実行が停止されるブレーク命令に書き換える手段と、
前記ブレーク命令に書き換えられた命令を有するプログラムを実行する手段と、
前記ブレークポイントに設定された命令に対して、前記ブレーク命令に書き換えられる前の命令をシミュレーションする手段と、
前記シミュレーションの結果に基づく情報を前記被デバッグ装置に書き込む手段と、
前記ブレークポイントに設定された命令の次の命令からプログラムを実行する手段と、
を備えるプログラムデバッグ装置。 A program comprising: an emulator for emulating a device to be debugged having a program to be debugged; a debug program for operating the emulator to set a breakpoint for the debug target program; and a host computer for operating the debug program A debugging device,
Means for setting a breakpoint in the program;
Means for rewriting an instruction set at the breakpoint of the program to a break instruction at which execution of the program is stopped;
Means for executing a program having an instruction rewritten to the break instruction;
Means for simulating an instruction before being rewritten to the break instruction with respect to the instruction set at the breakpoint;
Means for writing information based on the result of the simulation to the debugged device;
Means for executing a program from an instruction next to the instruction set at the breakpoint;
A program debugging apparatus comprising:
3. The program debugging apparatus according to claim 1, wherein the program to be debugged is stored in a flash ROM provided in the debugged apparatus.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2004095531A JP2005284542A (en) | 2004-03-29 | 2004-03-29 | Program debugging method, debugging program and program debugging device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2004095531A JP2005284542A (en) | 2004-03-29 | 2004-03-29 | Program debugging method, debugging program and program debugging device |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2005284542A true JP2005284542A (en) | 2005-10-13 |
Family
ID=35182873
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2004095531A Pending JP2005284542A (en) | 2004-03-29 | 2004-03-29 | Program debugging method, debugging program and program debugging device |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2005284542A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0540654A (en) * | 1991-08-05 | 1993-02-19 | Tohoku Nippon Denki Software Kk | Optional instruction tracing system |
JPH1011315A (en) * | 1996-06-27 | 1998-01-16 | Kawasaki Steel Corp | In-circuit emulator device and in-circuit emulation method |
JP2004046716A (en) * | 2002-07-15 | 2004-02-12 | Renesas Technology Corp | Debugging system |
-
2004
- 2004-03-29 JP JP2004095531A patent/JP2005284542A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0540654A (en) * | 1991-08-05 | 1993-02-19 | Tohoku Nippon Denki Software Kk | Optional instruction tracing system |
JPH1011315A (en) * | 1996-06-27 | 1998-01-16 | Kawasaki Steel Corp | In-circuit emulator device and in-circuit emulation method |
JP2004046716A (en) * | 2002-07-15 | 2004-02-12 | Renesas Technology Corp | Debugging system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7171653B2 (en) | Systems and methods for providing communication between a debugger and a hardware simulator | |
JP5270330B2 (en) | Multicore microcomputer system simulation method and simulation apparatus | |
KR20190078681A (en) | System and Method for Artificial Neural Network Learning and Simulation | |
JP2008282308A (en) | Cooperation verification device, cooperation verification method, and cooperation verification program | |
US7043717B2 (en) | Debugging apparatus and method | |
JP2007058813A (en) | Verification device and verification method | |
JP2005284542A (en) | Program debugging method, debugging program and program debugging device | |
JP2005353020A (en) | Simulation system for computer program | |
JPH0477833A (en) | Integrated circuit provided with debugging environment | |
US8914274B1 (en) | Method and system for instruction set simulation with concurrent attachment of multiple debuggers | |
JP2008077176A (en) | Emulation system and emulation method | |
JP4345545B2 (en) | Simulation device | |
JPS63271542A (en) | Rom debugger | |
JPH02186448A (en) | Integrated circuit with debugging environment | |
JPS584461A (en) | Program debugging control system | |
CN117170798A (en) | Loongson 1E300 simulator based on UBQ-SIMTest framework | |
JP2005235047A (en) | Power source intermittent disconnection debugging device and recording medium with program for realizing the method recorded thereon | |
JPH01159743A (en) | Firm soft simulator | |
JP2006139440A (en) | Emulator apparatus and its control method | |
JPH04123235A (en) | Debugging method and system for microprogram | |
JP2013137707A (en) | Processor and debug device using the same | |
JP2000322289A (en) | Method and system for controller emulation and computer readable recording medium for storing program for implementation of controller emulation method by computer | |
Phillips | Enhanced Debugging with Traces: An essential technique used in emulator development is a useful addition to any programmer’s toolbox. | |
JPS61239345A (en) | I/o simulator | |
JPS5968034A (en) | Input and output port simulator for microcomputer developing device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20070110 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20090130 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20091104 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20100104 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20100126 |
|
A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20100525 |