JP2653411B2 - How to set breakpoints - Google Patents

How to set breakpoints

Info

Publication number
JP2653411B2
JP2653411B2 JP4069815A JP6981592A JP2653411B2 JP 2653411 B2 JP2653411 B2 JP 2653411B2 JP 4069815 A JP4069815 A JP 4069815A JP 6981592 A JP6981592 A JP 6981592A JP 2653411 B2 JP2653411 B2 JP 2653411B2
Authority
JP
Japan
Prior art keywords
breakpoint
execution
address
program
instruction
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 - Lifetime
Application number
JP4069815A
Other languages
Japanese (ja)
Other versions
JPH05233364A (en
Inventor
浩一 武田
裕一 吉田
輝彦 大原
修 山下
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.)
National Institute of Advanced Industrial Science and Technology AIST
Original Assignee
Agency of Industrial Science and Technology
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 Agency of Industrial Science and Technology filed Critical Agency of Industrial Science and Technology
Priority to JP4069815A priority Critical patent/JP2653411B2/en
Publication of JPH05233364A publication Critical patent/JPH05233364A/en
Application granted granted Critical
Publication of JP2653411B2 publication Critical patent/JP2653411B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【産業上の利用分野】本発明は、いわゆるデバッガ等の
プログラムデバッグ支援ツールにおける、命令の実行を
途中で停止するためのブレークポイント設定方法に関す
るものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a method for setting a breakpoint for stopping execution of an instruction in a program debugging support tool such as a so-called debugger.

【0002】[0002]

【従来の技術】従来、多くのデバッグ支援システムにお
いて、命令実行のブレークポイント機能が備えられてい
る。プログラムのデバッグにおいて、命令実行のブレー
クポイント機能は、有効であり、多くのデバッグ支援シ
ステムに組み込まれている。この機能は、デバッグ対象
プログラムにおいて、指定した命令で実行を停止させる
ものである。このような機能は、プログラムのデバッグ
において、有用である。この機能を用いる場合、ユーザ
は、予め実行を停止させたい命令を指定しておいてか
ら、デバッグ対象プログラムを実行させる。これによ
り、デバッグ対象プログラムは、指定された命令で実行
が停止する。その際、オペレータは、必要ならば、その
停止した時点でのレジスタやメモリの値を調べたり変更
したりすることができる。その後、また、その停止した
時点からプログラムの実行を再開することができる(例
えば、「情報科学辞典」岩波書店 第1刷、1990年p.65
5 “ブレークポイント”参照)。ブレークポイント機能
の実現方法として、次の (1)〜(3) のような方法があ
る。
2. Description of the Related Art Conventionally, many debug support systems have a breakpoint function for instruction execution. In program debugging, the breakpoint function of instruction execution is effective and is incorporated in many debug support systems. This function stops execution at a designated instruction in a program to be debugged. Such a function is useful in debugging a program. When using this function, the user specifies an instruction whose execution is to be stopped in advance, and then executes the program to be debugged. Thus, the execution of the debug target program stops at the designated instruction. At that time, the operator can check or change the values of the registers and memories at the time of the stop, if necessary. After that, the program can be resumed from the point at which it was stopped (for example, "Information Science Dictionary," Iwanami Shoten, First Edition, 1990, p.65
5 See “Breakpoints”). There are the following methods (1) to (3) for realizing the breakpoint function.

【0003】(1)指定された命令をトラップ命令で置き
換える。即ち、トラップ命令が検出されると、トラップ
が発生し、トラップ処理ルーチンを経由してデバッグ支
援プログラムに制御が渡り、ユーザにその旨が通知され
る。実行の再開が指示されると、置き換えられた元の命
令の実行をシミュレートした後、制御を元に戻す(例え
ば、飯塚、田中「ソフトウェア指向アーキテクチャ」
オーム社 第1版1985年p,212 “命令の実行に関する割
出し”参照)。この方法には、複数のブレークポイント
を設定できるという特徴がある。
(1) Replace a specified instruction with a trap instruction. That is, when a trap instruction is detected, a trap is generated, control is passed to the debug support program via the trap processing routine, and the user is notified of the fact. When execution restart is instructed, the execution of the replaced original instruction is simulated, and then control is returned to the original (for example, Iizuka, Tanaka "Software Oriented Architecture")
Ohmsha, 1st Edition, 1985, p.212, "Indexing for Instruction Execution"). This method has a feature that a plurality of breakpoints can be set.

【0004】(2)ハードウェアにブレークポイントレジ
スタを設ける。ブレークポイントレジスタ(BPR)
は、実行を停止させたい命令のアドレスを保持するレジ
スタである。このレジスタで指定される命令が検出され
ると、トラップが発生し、トラップ処理ルーチンを経由
してデバッグ支援プログラムに制御が渡り、ユーザにそ
の旨が通知される。実行の再開が指示されると、制御が
元に戻される(例えば、「32ビット・マイクロプロセ
ッサ」日経マグロウヒル社p.178 参照)。この方法は、
以下の(a)、(b) の特徴を持つ。 (a)デバッグ対象プログラムを変更する必要がない。 (b)命令の実行をシミュレートする必要がない。
(2) A breakpoint register is provided in hardware. Breakpoint register (BPR)
Is a register that holds the address of the instruction whose execution is to be stopped. When the instruction specified by this register is detected, a trap is generated, control is passed to the debug support program via the trap processing routine, and the user is notified of the fact. When execution resume is instructed, the control is returned (for example, see “32-bit microprocessor”, Nikkei McGraw-Hill, p. 178). This method
It has the following features (a) and (b). (a) There is no need to change the program to be debugged. (b) There is no need to simulate instruction execution.

【0005】(3)命令毎にブレークポイントを制御する
フラグを用意する。このフラグがセットされている命令
が検出されると、トラップが発生し、トラップ処理を経
由してデバッグ支援プログラムに制御が渡り、ユーザに
その旨が通知される。実行の再開が指示されると、制御
が元に戻される(例えば、「MC68020 ユーザーズ・マニ
ュアル 2nd Edition」Motorola Inc., 1989 CQ出版p.
80参照)。この方法は、以下の(a)、(b) の特徴を持つ。 (a)複数のブレークポイントを設定できる。 (b)命令の実行をシミュレートする必要がない。
(3) A flag for controlling a breakpoint is prepared for each instruction. When an instruction in which this flag is set is detected, a trap is generated, control is passed to the debug support program via the trap processing, and the user is notified of that. When the execution is instructed to resume, the control is returned (for example, “MC68020 User's Manual 2nd Edition”, Motorola Inc., 1989, CQ Publication p.
80). This method has the following features (a) and (b). (a) Multiple breakpoints can be set. (b) There is no need to simulate instruction execution.

【0006】[0006]

【発明が解決しようとする課題】しかしながら、上述し
た (1)〜(3) の従来の技術には、次のような問題があっ
た。即ち、(1)には、次の(a)、(b) のような問題があっ
た。 (a)ブレークポイントを設定するために元のプログラム
を書き直す必要がある。従って、プログラムが読み出し
専用メモリなどに書き込まれていて、プログラムの書き
換えができない場合、ブレークポイントの設定ができな
い。 (b)ブレークポイントからプログラムの実行を再開する
ためには、書き換えられた元の命令の実行をシミュレー
トする必要がある。このため、以下の(ア)、(イ)の問題が
あった。
However, the above-mentioned conventional techniques (1) to (3) have the following problems. That is, (1) has the following problems (a) and (b). (a) The original program needs to be rewritten to set breakpoints. Therefore, when the program is written in a read-only memory or the like and the program cannot be rewritten, a breakpoint cannot be set. (b) To resume the execution of the program from the breakpoint, it is necessary to simulate the execution of the rewritten original instruction. Therefore, there are the following problems (A) and (B).

【0007】(ア)プログラムカウンタ相対アドレッシン
グモード等を使う命令の場合、プログラムカウンタの値
が元のプログラムの実行状態とは異なるため、正しくシ
ミュレートするには多くの命令を必要とする。 (イ)特権モードなどのプロセッサの状態が、元のプログ
ラムの実行状態と異なることがある場合、元のプログラ
ムの状態ではその命令の実行が許可されていないときで
もそれが検出できない。
(A) In the case of an instruction using the program counter relative addressing mode or the like, since the value of the program counter is different from the execution state of the original program, many instructions are required to correctly simulate. (B) If the state of the processor such as the privileged mode is different from the execution state of the original program, it cannot be detected in the original program state even if execution of the instruction is not permitted.

【0008】また、(2)には、次のような問題があった。
ハードウェアで用意できるブレークポイントレジスタの
数には限りがあるため、その数を超えるブレークポイン
トを設定できない。例えば、ブレークポイントレジスタ
の数が4つの場合は、最大4つのブレークポイントしか
同時に監視できない。そして、(3)には、次の(a)、(b) の
ような問題があった。 (a)ブレークポイントを設定するために元のプログラム
中の命令のフラグを書き直す必要がある。従って、(1)
(a)と同様に、プログラムが読み出し専用メモリなどに
書き込まれていて、プログラムの書き換えができない場
合、ブレークポイントの設定ができない。 (b)命令にブレークポイントを制御するフラグが備わっ
ている特殊なプロセッサ以外のプロセッサには適用でき
ない。
[0008] In addition, (2) has the following problem.
Since the number of breakpoint registers that can be prepared by hardware is limited, it is not possible to set more breakpoints. For example, when the number of breakpoint registers is four, only four breakpoints can be monitored at the same time. And (3) had the following problems (a) and (b). (a) It is necessary to rewrite the flag of the instruction in the original program to set a breakpoint. Therefore, (1)
As in (a), when the program is written in a read-only memory or the like and the program cannot be rewritten, a breakpoint cannot be set. (b) It cannot be applied to processors other than special processors having a flag for controlling a breakpoint in an instruction.

【0009】本発明は、以上の点に着目してなされたも
ので、従来の(1)〜(3)の各方法の問題点を解決
し、以下の(A)〜(D)の特徴を保ちつつ、デバッグ
支援システムが命令実行のブレークポイントを実現でき
るブレークポイント設定方法を提供することを目的とす
るものである。 (A)任意の複数個数のブレークポイントを設定でき
る。 (B)デバッグ対象プログラムを書き換える必要がな
い。 (C)命令の実行をシミュレートする必要がない。 (D)命令自身に特別な機構を設ける必要がない。
The present invention has been made in view of the above points, and solves the problems of the conventional methods (1) to (3) and has the following features (A) to (D). It is an object of the present invention to provide a breakpoint setting method in which a debug support system can realize a breakpoint of instruction execution while keeping the same. (A) Any number of breakpoints can be set. (B) There is no need to rewrite the debug target program. (C) There is no need to simulate instruction execution. (D) There is no need to provide a special mechanism in the instruction itself.

【0010】[0010]

【課題を解決するための手段】本発明のブレークポイン
ト設定方法は、複数の命令から成るプログラム中で、指
定された各命令で当該プログラムの実行をそれぞれ停止
させる複数のブレークポイントを用意し、当該ブレーク
ポントのアドレスのうちのいずれかを保持する複数のレ
ジスタの中から任意に選択した1つのレジスタと、当該
レジスタに保持されたアドレスに存在する命令の実行に
対応して割込みを要求するブレークポイント検出機構と
を用意するとともに、前記プログラム中の連続したアド
レスに存在する命令を順次実行する途中で、不連続な他
のアドレスに分岐する分岐命令が出現した場合に、当該
分岐命令の実行後に割込みを要求する分岐トレース機構
を用意し、前記プログラムのデバッグのため、当該プロ
グラムの実行を開始する場合には、実行開始アドレス以
上で、且つ、当該実行開始アドレスに最も近いブレーク
ポイントのアドレスを前記レジスタに設定し、前記プロ
グラムのブレークポイントでの停止後、当該プログラム
の実行を再開する場合には、実行再開アドレスより大き
く、且つ、当該実行再開アドレスに最も近いブレークポ
イントのアドレスを前記レジスタに設定し、前記プログ
ラムの実行の途中で前記分岐トレース機構により分岐が
検出された場合には、分岐先アドレス以上で、且つ、当
該分岐先アドレスに最も近いブレークポイントのアドレ
スを前記レジスタに設定することにより、前記プログラ
ムの実行の途中で、実行される先の命令を順次前記レジ
スタに設定することを特徴とするものである。
According to the present invention, there is provided a method for setting a breakpoint, comprising preparing a plurality of breakpoints in a program comprising a plurality of instructions for stopping execution of the program at each designated instruction. One register arbitrarily selected from a plurality of registers holding any of the addresses of the breakpoints, and a breakpoint for requesting an interrupt in response to execution of an instruction at an address held in the register In addition to providing a detection mechanism, if a branch instruction that branches to another discontinuous address appears during the sequential execution of instructions existing at consecutive addresses in the program, an interrupt occurs after the execution of the branch instruction. A branch trace mechanism that requests the execution of the program is provided for debugging the program. In this case, when the address of the break point that is equal to or more than the execution start address and is closest to the execution start address is set in the register, and after the program is stopped at the break point, execution of the program is resumed. Sets an address of a breakpoint that is greater than the execution resuming address and is closest to the execution resuming address in the register. If a branch is detected by the branch tracing mechanism during the execution of the program, By setting the address of a breakpoint that is equal to or greater than the destination address and closest to the branch destination address in the register, it is possible to sequentially set instructions to be executed in the register during the execution of the program. It is a feature.

【0011】[0011]

【作用】本発明のブレークポイント設定方法において
は、まず、ブレークポイント設定ルーチンは、指定され
た複数のブレークポイントのうち、プログラムの実行の
特定のタイミングで、次に検出されるブレークポイント
を予測し、そのアドレスをブレークポイントレジスタに
設定する。即ち、プログラムの実行に従って次に現われ
るであろうブレークポイントを予測し、そのアドレスを
ブレークポイントレジスタに入換える。これにより、1
個のブレークポイントレジスタで複数のブレークポイン
トを支援する。ここに、ブレークポイントを予測し、ブ
レークポイントレジスタの設定を行なうタイミングは、
デバッグ対象プログラムの実行開始直前、ブレークポイ
ント検出時及び分岐時に行なう。分岐の検出は分岐トレ
ース機構による。
In the breakpoint setting method of the present invention, first, the breakpoint setting routine predicts a breakpoint to be detected next at a specific timing of program execution among a plurality of designated breakpoints. , And set the address in the breakpoint register. That is, a breakpoint that will appear next is predicted according to the execution of the program, and its address is replaced with a breakpoint register. This gives 1
Support multiple breakpoints with one breakpoint register. Here, the timing of predicting the breakpoint and setting the breakpoint register is as follows.
This is performed immediately before the execution of the debug target program starts, when a breakpoint is detected, and when a branch is made. The branch is detected by a branch trace mechanism.

【0012】また、ブレークポイントの予測は、次の性
質を利用することにより、行なう。即ち、分岐が起きな
い限りは、実行される命令のアドレスは、順次増加す
る。従って、次のブレークポイントのアドレスは、現在
の命令実行アドレスより大きいブレークポイントアドレ
スのうち、最小のアドレスを持つものである。この予測
は、プログラムの実行開始直前及びブレークポイント検
出時に適用する。分岐が起きたときは、分岐先の命令ア
ドレス以上のブレークポイントアドレスのうちで最小の
アドレスを持つものを次のブレークポイントと予測す
る。
The prediction of a breakpoint is performed by utilizing the following properties. That is, unless a branch occurs, the address of the instruction to be executed increases sequentially. Therefore, the address of the next breakpoint has the smallest address among the breakpoint addresses larger than the current instruction execution address. This prediction is applied immediately before the start of program execution and when a breakpoint is detected. When a branch occurs, the one having the smallest breakpoint address among the breakpoint addresses higher than the instruction address of the branch destination is predicted as the next breakpoint.

【0013】[0013]

【実施例】以下、本発明の実施例を図面を参照して詳細
に説明する。図1は、本発明の方法を適用した装置の実
施例のブロック図である。本発明の方法を実現するため
の装置は、ブレークポイントレジスタ1と、ブレークポ
イント検出機構2と、分岐トレース機構3と、ブレーク
ポイント設定ルーチンBとから構成される。ブレークポ
イントレジスタ1は、1個設けられている。尚、このブ
レークポイントレジスタ1は、複数のレジスタの中から
任意に選択した1つのレジスタであり、候補となるレジ
スタはハードウェアの資源が許す限り、2個以上いくつ
あってもよい。ブレークポイント検出機構2は、ブレー
クポイントレジスタ1により指定された命令が検出され
たとき、又は実行されたときに割込みを要求する。分岐
トレース機構3は、分岐が起きたときに割込みを要求す
る機構である。ブレークポイント設定ルーチンBは、ブ
レークポイントレジスタ1にブレークポイントのアドレ
スを設定するためのルーチンである。
Embodiments of the present invention will be described below in detail with reference to the drawings. FIG. 1 is a block diagram of an embodiment of an apparatus to which the method of the present invention is applied. An apparatus for implementing the method of the present invention includes a breakpoint register 1, a breakpoint detection mechanism 2, a branch tracing mechanism 3, and a breakpoint setting routine B. One breakpoint register 1 is provided. The breakpoint register 1 is one register arbitrarily selected from a plurality of registers, and there may be any two or more candidate registers as long as hardware resources permit. The breakpoint detection mechanism 2 requests an interrupt when the instruction specified by the breakpoint register 1 is detected or executed. The branch trace mechanism 3 is a mechanism that requests an interrupt when a branch occurs. The breakpoint setting routine B is a routine for setting a breakpoint address in the breakpoint register 1.

【0014】図において、割込み処理ルーチンTは、デ
バッグ支援プログラムDによって対象プログラムPのデ
バッグを行なう。対象プログラムPは、デバッグの対象
となるプログラムであり、ブレークポイントBP1、B
P2、BP3を有する。ブレークポイントBP1、BP
2、BP3は、デバッグを途中で停止させるアドレスを
示す。これらのアドレスは、所定の記憶領域に格納され
ている。
In FIG. 1, an interrupt processing routine T debugs a target program P by a debug support program D. The target program P is a program to be debugged, and includes breakpoints BP1 and BP1.
It has P2 and BP3. Breakpoint BP1, BP
2, BP3 indicates an address at which debugging is stopped halfway. These addresses are stored in a predetermined storage area.

【0015】一方、デバッグ支援プログラムDは、デバ
ッグのための各種ルーチンの集合体である。この中に
は、ブレークポイント設定ルーチンが含まれている。ブ
レークポイント設定ルーチンBは、対象プログラムP上
のブレークポイントBP1、BP2、BP3を設定する
ためのルーチンである。このブレークポイント設定ルー
チンは、デバッグ支援プログラムD内で実行されるサブ
ルーチンから成る。
On the other hand, the debug support program D is a set of various routines for debugging. This includes a breakpoint setting routine. The breakpoint setting routine B is a routine for setting breakpoints BP1, BP2, and BP3 on the target program P. This breakpoint setting routine includes a subroutine executed in the debug support program D.

【0016】上述したブレークポイントBP1、BP
2、BP3は、デバッグ支援プログラムDを使って対象
プログラムPのデバッグを行なっているユーザが指定す
る。指定されたすべてのブレークポイントBP1、BP
2、BP3のアドレスは、デバッグ支援プログラムDの
使用する記憶領域に蓄えられているものとする。例え
ば、3個のブレークポイントBP1、BP2、BP3が
設定されていて、アドレスは、この順に大きくなってい
るものとする。次に、上述した装置の動作を説明する。
まず、ユーザが、ブレークポイントBP1、BP2、B
P3を設定してから、デバッグ支援プログラムDに対象
プログラムPの実行を指示する。すると、ブレークポイ
ントレジスタ1に設定されたブレークポイントによる割
込み及び分岐トレース機能を有効にして、デバッグ支援
プログラムDから割込み処理ルーチンTを経由して対象
プログラムPへ制御が移される。
The above-mentioned break points BP1, BP
2, BP3 is specified by a user who is debugging the target program P using the debug support program D. All specified breakpoints BP1, BP
2. It is assumed that the address of BP3 is stored in a storage area used by the debug support program D. For example, it is assumed that three breakpoints BP1, BP2, and BP3 are set, and the addresses increase in this order. Next, the operation of the above-described device will be described.
First, the user inputs breakpoints BP1, BP2, B
After setting P3, the debug support program D is instructed to execute the target program P. Then, the interrupt and branch trace function by the breakpoint set in the breakpoint register 1 is enabled, and the control is transferred from the debug support program D to the target program P via the interrupt processing routine T.

【0017】ブレークポイントレジスタ1で指定される
ブレークポイントBP1、BP2又はBP3が検出され
たときは、割込み処理ルーチンTを経由してデバッグ支
援プログラムDに制御が渡される。ユーザがデバッグ支
援プログラムDに対象プログラムPの実行再開を指示し
たときは、ブレークポイント設定ルーチンBを実行して
から割込み処理ルーチンTを経由して対象プログラムP
に制御が渡される。分岐トレース機構3により分岐が検
出されたときは、割込み処理ルーチンTを経由してブレ
ークポイント設定ルーチンBに制御が渡され、その実行
後、割込み処理ルーチンTを経由して対象プログラムP
に制御が戻される。
When the breakpoint BP1, BP2 or BP3 specified by the breakpoint register 1 is detected, the control is passed to the debug support program D via the interrupt processing routine T. When the user instructs the debug support program D to resume execution of the target program P, the breakpoint setting routine B is executed, and then the target program P is passed through the interrupt processing routine T.
Is passed to. When a branch is detected by the branch tracing mechanism 3, control is passed to the breakpoint setting routine B via the interrupt processing routine T, and after execution, the target program P is transmitted via the interrupt processing routine T.
Is returned to

【0018】ここでは、ブレークポイントレジスタ1で
指定されるブレークポイントが検出された場合、その命
令を実行する前に割込み処理ルーチンTに制御が移るも
のとする。従って、ブレークポイントの命令から実行が
再開される。また、分岐トレース機構3により分岐が検
出された場合は、その分岐を引き起こした命令の実行が
完了した後に割込み処理ルーチンTに制御が移るものと
する。従って、分岐先の命令から実行が再開される。ブ
レークポイントレジスタ1で指定される命令が分岐を引
き起こす場合は、ブレークポイントが優先される。割込
み処理ルーチンTから戻ってくるときの実行再開アドレ
スは、特別なレジスタ又はスタックに格納されていて、
デバッグ支援プログラムDから知ることができるものと
する。次に、ブレークポイント設定ルーチンにおける処
理手順について説明する。
Here, when a breakpoint specified by the breakpoint register 1 is detected, control is transferred to the interrupt processing routine T before executing the instruction. Therefore, execution is resumed from the instruction at the breakpoint. When a branch is detected by the branch tracing mechanism 3, control is transferred to the interrupt processing routine T after the execution of the instruction that caused the branch is completed. Therefore, execution is restarted from the instruction at the branch destination. If the instruction specified by breakpoint register 1 causes a branch, the breakpoint has priority. The execution resume address when returning from the interrupt processing routine T is stored in a special register or stack.
It can be known from the debug support program D. Next, a processing procedure in the breakpoint setting routine will be described.

【0019】図2は、対象プログラムPの実行を再開す
る場合の処理手順を説明するフローチャートである。ま
ず、ブレークポイントの個数を調べる(ステップS1、
S2)。そして、ブレークポイントの個数が“0”でな
く、“1”でもないときは、ブレークポイントレジスタ
による割込み、分岐トレース機能が、プログラムの実行
が開始されるとき([1]-(1)) に有効になるようにする
(ステップS3、[1]-(1)) 。次に、ブレークポイントレ
ジスタに実行開始アドレス以上で、且つ当該実行開始ア
ドレスに最も近いブレークポイントを探す(ステップS
4)。図1の場合は、これは、ブレークポイントBP1
である。従って、ブレークポイントレジスタには、ブレ
ークポイントBP1のアドレスを設定する(ステップS
5、[2]-(1)、(2))。
FIG. 2 is a flowchart for explaining a processing procedure when the execution of the target program P is resumed. First, the number of breakpoints is checked (step S1,
S2). If the number of breakpoints is neither "0" nor "1", the interrupt and branch trace function by the breakpoint register is activated when program execution is started ([1]-(1)). It is made valid (step S3, [1]-(1)). Next, a breakpoint that is equal to or more than the execution start address and is closest to the execution start address is searched for in the breakpoint register (step S).
4). In the case of FIG. 1, this is the breakpoint BP1
It is. Therefore, the address of the breakpoint BP1 is set in the breakpoint register (step S1).
5, [2]-(1), (2)).

【0020】一方、ブレークポイントが指定されていな
いときは、ブレークポイントレジスタによる割込み、及
び、分岐トレース機能が無効になるようにしておく(ス
テップS8)。また、ブレークポイントが1つだけ指定
されているときは、ブレークポイントレジスタによる割
込みのみを有効にし、従って、分岐トレースを無効にす
る(ステップS6)。そして、ブレークポイントレジス
タには、そのブレークポイントを設定する(ステップS
7)。
On the other hand, when a breakpoint is not specified, the interruption by the breakpoint register and the branch trace function are disabled (step S8). If only one breakpoint is specified, only the interrupt by the breakpoint register is enabled, and the branch trace is disabled (step S6). Then, the break point is set in the break point register (step S
7).

【0021】図3は、ブレークポイントで中断された実
行を再開する場合の処理手順を説明するフローチャート
である。まず、実行再開アドレスを得る(ステップS1
1、[2]-(3)、(4)、(5))。次に、実行再開アドレスより大
きく、且つ、それに最も近いブレークポイントを探す
(ステップS12)。その次に、該当するブレークポイ
ントがあるかどうかを調べる(ステップS13)。そし
て、そのブレークポイントのアドレスをブレークポイン
トレジスタに設定する(ステップS14)。例えば、ブ
レークポイントBP1から実行を再開する場合は、ブレ
ークポイントBP2を設定する。該当するブレークポイ
ントが見つからなかった場合は、ブレークポイントレジ
スタの変更は行なわない。
FIG. 3 is a flowchart for explaining a processing procedure when the execution suspended at the breakpoint is resumed. First, an execution restart address is obtained (step S1).
1, [2]-(3), (4), (5)). Next, a breakpoint larger than the execution resuming address and closest to the address is searched (step S12). Next, it is checked whether there is a corresponding breakpoint (step S13). Then, the address of the break point is set in the break point register (step S14). For example, when resuming execution from the breakpoint BP1, a breakpoint BP2 is set. If the corresponding breakpoint is not found, the breakpoint register is not changed.

【0022】図4は、分岐が検出された場合の処理手順
を説明するフローチャートである。まず、実行再開アド
レスを得る(ステップS21、[2]-(3)、(4)、(5))。そし
て、この場合、実行再開アドレスが分岐先アドレスにな
っているので、実行再開アドレス以上で、且つ当該実行
再開アドレスに最も近いブレークポイントを探す(ステ
ップS22、[3]-(1)、(2)、(3)、(4))。次に、該当するブ
レークポイントがあるかどうかを調べる(ステップS2
3)。そして、そのブレークポイントのアドレスをブレ
ークポイントレジスタに設定する(ステップS24)。
例えば、図1に示すように、ブレークポイントBP1と
BP2との間で分岐命令を実行し、ブレークポイントB
P2とBP3との間にあるアドレスLに分岐したとする
と、このときはブレークポイントBP3を設定する。一
方、該当するブレークポイントが見つからなかった場合
は、ブレークポイントレジスタの変更は行なわない。
FIG. 4 is a flowchart for explaining a processing procedure when a branch is detected. First, an execution resuming address is obtained (step S21, [2]-(3), (4), (5)). In this case, since the execution resuming address is the branch destination address, a breakpoint that is equal to or larger than the execution resuming address and closest to the execution resuming address is searched (step S22, [3]-(1), (2) ), (3), (4)). Next, it is checked whether there is a corresponding breakpoint (step S2).
3). Then, the address of the break point is set in the break point register (step S24).
For example, as shown in FIG. 1, a branch instruction is executed between breakpoints BP1 and BP2, and breakpoint B is executed.
Assuming that the process branches to an address L located between P2 and BP3, a breakpoint BP3 is set at this time. On the other hand, if the corresponding breakpoint is not found, the breakpoint register is not changed.

【0023】[0023]

【発明の効果】以上説明したように、本発明のブレーク
ポイント設定方法によれば、複数のレジスタの中から任
意に選択した1つのレジスタに、複数のブレークポイン
トアドレスを順次設定していくようにしたので、次のよ
うな効果がある。 (A)デバッグ対象プログラムを書き直す必要がないた
め、読み出し専用メモリ上のプログラムに対してもブレ
ークポイントが設定できる。 (B)ブレークポイントの命令をシミュレートする必要
がないため、命令シミュレートのためのルーチン及びデ
ータ領域を不要とすることができる。 (C)任意の複数個数のブレークポイントを設定するこ
とができる。 (D)プログロムの実行状態が通常の動作時と同じにで
きる。従って、命令自身に特別なフラグ等の機構を設け
る必要がない。
As described above, according to the breakpoint setting method of the present invention, a plurality of breakpoint addresses are sequentially set in one register arbitrarily selected from a plurality of registers. Therefore, the following effects are obtained. (A) Since it is not necessary to rewrite the program to be debugged, a breakpoint can be set for a program on a read-only memory. (B) Since it is not necessary to simulate the instruction at the breakpoint, a routine and a data area for simulating the instruction can be eliminated. (C) Any number of breakpoints can be set. (D) The execution state of the program can be made the same as in the normal operation. Therefore, there is no need to provide a mechanism such as a special flag in the instruction itself.

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

【図1】本発明のブレークポイント設定方式の実施例の
説明図である。
FIG. 1 is an explanatory diagram of an embodiment of a breakpoint setting method according to the present invention.

【図2】対象プログラムPの実行を開始する場合の処理
手順を説明するフローチャートである。
FIG. 2 is a flowchart illustrating a processing procedure when starting execution of a target program P;

【図3】中断された実行を再開する場合の処理手順を説
明するフローチャートである。
FIG. 3 is a flowchart illustrating a processing procedure when resuming suspended execution.

【図4】中断された実行を再開する場合の処理手順を説
明するフローチャートである。
FIG. 4 is a flowchart illustrating a processing procedure when resuming suspended execution.

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

1 ブレークポイントレジスタ 2 ブレークポイント検出機構 3 分岐トレース機構 P 対象プログラム T 割込み処理ルーチン D デバッグ支援プログラム BP1、BP2、BP3 ブレークポイント 1 Breakpoint register 2 Breakpoint detection mechanism 3 Branch tracing mechanism P Target program T Interrupt handling routine D Debugging support program BP1, BP2, BP3 Breakpoint

───────────────────────────────────────────────────── フロントページの続き (72)発明者 山下 修 東京都港区虎ノ門1丁目7番12号 沖電 気工業株式会社内 (56)参考文献 特開 平1−211129(JP,A) ──────────────────────────────────────────────────続 き Continuation of the front page (72) Inventor Osamu Yamashita 1-7-12 Toranomon, Minato-ku, Tokyo Oki Electric Industry Co., Ltd. (56) References JP-A 1-211129 (JP, A)

Claims (1)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 複数の命令から成るプログラムの中
で、指定された各命令で当該プログラムの実行をそれぞ
れ停止させる複数のブレークポイントを用意し、当該ブ
レークポイントのアドレスのうちのいずれかを保持する
複数のレジスタの中から任意に選択した1つのレジスタ
と、当該レジスタに保持されたアドレスに存在する命令
の実行に対応して割込みを要求するブレークポイント検
出機構とを用意するとともに、 前記プログラム中の連続したアドレスに存在する命令を
順次実行する途中で、不連続な他のアドレスに分岐する
分岐命令が出現した場合に、当該分岐命令の実行後に割
込みを要求する分岐トレース機構を用意し、 前記プログラムのデバッグのため、当該プログラムの実
行を開始する場合には、実行開始アドレス以上で、且
つ、当該実行開始アドレスに最も近いブレークポイント
のアドレスを前記レジスタに設定し、 前記プログラムのブレークポイントでの停止後、当該プ
ログラムの実行を再開する場合には、実行再開アドレス
より大きく、且つ、当該実行再開アドレスに最も近いブ
レークポイントのアドレスを前記レジスタに設定し、 前記プログラムの実行の途中で前記分岐トレース機構に
より分岐が検出された場合には、分岐先アドレス以上
で、且つ、当該分岐先アドレスに最も近いブレークポイ
ントのアドレスを前記レジスタに設定することにより、 前記プログラムの実行の途中で、次にブレークポイント
が検出される可能性のある命令アドレスを順次前記レジ
スタに設定することを特徴とするブレークポイント設定
方法
In a program including a plurality of instructions, a plurality of breakpoints for stopping execution of the program at each designated instruction are prepared, and one of the addresses of the breakpoint is held.
One register arbitrarily selected from a plurality of registers and a breakpoint detection mechanism for requesting an interrupt in response to execution of an instruction at an address held in the register are provided. When a branch instruction that branches to another discontinuous address appears during the sequential execution of instructions existing at consecutive addresses, a branch trace mechanism that requests an interrupt after execution of the branch instruction is provided, and the program When the execution of the program is started for debugging, the address of the breakpoint that is equal to or higher than the execution start address and closest to the execution start address is set in the register, and the program is stopped at the breakpoint. Later, when the execution of the program is resumed, it is larger than the execution resume address and Setting the address of the breakpoint closest to the execution resuming address in the register, and if a branch is detected by the branch tracing mechanism during the execution of the program, the address is equal to or higher than the branch destination address and by setting the address of the nearest break point before address in the register, in the course of execution of the program, then the breakpoint
Instruction addresses that may be detected
Breakpoint setting characterized by setting
Method
JP4069815A 1992-02-19 1992-02-19 How to set breakpoints Expired - Lifetime JP2653411B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4069815A JP2653411B2 (en) 1992-02-19 1992-02-19 How to set breakpoints

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4069815A JP2653411B2 (en) 1992-02-19 1992-02-19 How to set breakpoints

Publications (2)

Publication Number Publication Date
JPH05233364A JPH05233364A (en) 1993-09-10
JP2653411B2 true JP2653411B2 (en) 1997-09-17

Family

ID=13413639

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4069815A Expired - Lifetime JP2653411B2 (en) 1992-02-19 1992-02-19 How to set breakpoints

Country Status (1)

Country Link
JP (1) JP2653411B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7401323B2 (en) * 2003-04-21 2008-07-15 Microsoft Corporation Just-My-Code debugging

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63303440A (en) * 1987-06-03 1988-12-12 Mitsubishi Electric Corp Measuring instrument
JPH01211129A (en) * 1988-02-19 1989-08-24 Nec Corp Information processor

Also Published As

Publication number Publication date
JPH05233364A (en) 1993-09-10

Similar Documents

Publication Publication Date Title
EP0638864B1 (en) Development support system for microcomputer with internal cache
JP2653411B2 (en) How to set breakpoints
JP2653412B2 (en) How to set breakpoints
JPH0581070A (en) Programmable controller and user program execution method in programmable controller
JPH0588933A (en) Parallel processing system with debugging function
JP3029355B2 (en) Single-step instruction execution method
JP3102381B2 (en) Task debugging device, task debugging method, and recording medium therefor
JPS6270947A (en) Control system for debug interruption
JP3449812B2 (en) Control electronics
JPH0581068A (en) Debugging support device
JPS5842891B2 (en) Meirei Seigiyohoushiki
JP2998299B2 (en) Processor control unit
JPH04140851A (en) Diagnostic system for information processor
JPH0772874B2 (en) Interrupt receiving device
JPS638946A (en) Program debug supporting system
JPS59202546A (en) Debugging device
JPH0375832A (en) Virtual machine control system
JPH0259829A (en) Microcomputer
JPH04157537A (en) Address trap system
JPH02191046A (en) Tracing system for program
JPH04288634A (en) One-chip microcomputer
JPH04167032A (en) Program debugging system
JPH07134665A (en) Information processor
JP2001051873A (en) Debugging device
JPH02103636A (en) Additional arithmetic unit

Legal Events

Date Code Title Description
EXPY Cancellation because of completion of term