JP2743889B2 - Method and apparatus for program evaluation - Google Patents

Method and apparatus for program evaluation

Info

Publication number
JP2743889B2
JP2743889B2 JP7299880A JP29988095A JP2743889B2 JP 2743889 B2 JP2743889 B2 JP 2743889B2 JP 7299880 A JP7299880 A JP 7299880A JP 29988095 A JP29988095 A JP 29988095A JP 2743889 B2 JP2743889 B2 JP 2743889B2
Authority
JP
Japan
Prior art keywords
program
address value
instruction
stack pointer
execution
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
Application number
JP7299880A
Other languages
Japanese (ja)
Other versions
JPH09146793A (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.)
NEC Corp
Original Assignee
NEC Corp
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 NEC Corp filed Critical NEC Corp
Priority to JP7299880A priority Critical patent/JP2743889B2/en
Priority to EP96118360A priority patent/EP0778524A1/en
Priority to US08/751,619 priority patent/US6185700B1/en
Publication of JPH09146793A publication Critical patent/JPH09146793A/en
Application granted granted Critical
Publication of JP2743889B2 publication Critical patent/JP2743889B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)

Description

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

【発明の属する技術分野】本発明は、プログラム評価装
置の機械語命令を1命令だけステップ実行する機能に関
し、特に呼び出されるサブプログラムを一度に実行する
プロシージャステップ実行に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a function for step-executing only one machine language instruction of a program evaluation device, and more particularly to a procedure step execution for executing a subprogram to be called at a time.

【0001】プログラム開発を行う場合、通常、1つの
大きなプログラムは多くの小さなサブプログラム(また
はサブルーチン)に分割して開発を行う。サブプログラ
ムの大半はその中でさらに別のサブプログラムを呼び出
して処理を行う場合も多く、何重もの入れ子関係をつく
る。このようなプログラムのデバッグは最初から大きな
プログラムの全体をデバッグするのではなく、サブプロ
グラムの入れ子関係の下層にあるサブプログラムから、
順次上層のサブプログラムに向かってデバッグしていく
ことが多い。この場合、デバッグが完了した下層のサブ
プログラムには不具合が存在しないため、より上層のサ
ブプログラムをデバッグするときにはブラックボックス
として扱っても問題ない。
When developing a program, one large program is usually divided into many small subprograms (or subroutines) for development. Most of the subprograms often call other subprograms for processing, and create multiple nesting relationships. Debugging such a program does not debug the entire large program from the beginning, but rather from the subprograms underneath the nesting of subprograms,
In many cases, debugging is performed sequentially toward the upper subprogram. In this case, since there is no defect in the lower subprogram after the completion of the debugging, there is no problem if the upper subprogram is treated as a black box when debugging the upper subprogram.

【0002】プログラムのデバッグ作業は、プログラム
を1命令ずつ実行してレジスタやメモリの変化を調べて
いくステップ実行がよく用いられるが、この場合デバッ
グが完了したサブプログラムに対しては、サブプログラ
ム内をステップ実行して変化を確認する必要はなく、サ
ブプログラムを一度に実行した後で変化を確認すればよ
い。このためプログラムのデバッグ作業を行うほとんど
のプログラム評価装置には、ステップ実行しようとして
いる命令がサブプログラムの呼び出し命令であった場
合、そのサブプログラム内を一度に実行してしまうプロ
シージャステップ実行と呼ばれる機能をもっている。
[0002] A program is often debugged by executing a program one instruction at a time and examining changes in registers and memory. In this case, a subprogram for which debugging has been completed is not included in the subprogram. Does not need to be executed step by step to check the change, and the change may be checked after executing the subprogram at once. For this reason, most program evaluation devices that perform program debugging work have a function called procedure step execution that executes the subprogram at once if the instruction to be stepped is a subprogram call instruction. Have.

【0003】[0003]

【従来の技術】従来のプロシージャステップ実行機能に
おいてデバッグが完了したサブプログラムを一度に実行
するためには、図9に示すようにサブプログラム呼び出
し命令(以下CALL命令とする)の実行回数とサブプ
ログラムからの復帰命令(以下RET命令とする)の実
行回数を数え、それぞれの値が一致したときにサブプロ
グラムの実行が終了したものと判定していた。つまり、
図9では(1)で実行すべき命令がCALL命令かRE
T命令かそれ以外の命令かを判定し、例えばCALL命
令であった場合は(2)でCALL命令を実行して
(3)へ進みCALL命令の実行回数をカウントする。
同様に(1)でRET命令と判定した場合は、(5)、
(6)でRET命令を実行してその回数をカウントす
る。また(1)でCALLおよびRET命令でないと判
定した場合は、(4)でその命令を実行し、次の命令実
行のために(1)に戻る。さらに、実行した命令がCA
LLおよびRET命令であった場合は、(7)でCAL
L命令とRET命令の実行回数を比較し、その実行回数
が一致した場合は最初に呼び出したサブプログラムの実
行が終了したものと判定するが、実行回数が不一致の場
合、最初に呼び出したサブプログラムの実行がまだ終了
していないものとし、次の命令実行のために(1)に戻
る。
2. Description of the Related Art In order to execute at once a subprogram that has been debugged by a conventional procedure step execution function, the number of executions of a subprogram call instruction (hereinafter referred to as a CALL instruction) and the The number of executions of a return instruction (hereinafter, referred to as a RET instruction) from the server was counted, and when the respective values matched, it was determined that the execution of the subprogram was terminated. That is,
In FIG. 9, the instruction to be executed in (1) is a CALL instruction or a RE instruction.
It is determined whether the instruction is a T instruction or another instruction. If the instruction is a CALL instruction, for example, the CALL instruction is executed in (2) and the process proceeds to (3) to count the number of times the CALL instruction is executed.
Similarly, if it is determined that the instruction is a RET instruction in (1), (5)
At (6), the RET instruction is executed and the number of times is counted. If it is determined in (1) that the instruction is not the CALL or RET instruction, the instruction is executed in (4), and the process returns to (1) for executing the next instruction. Further, if the executed instruction is CA
If the instruction is an LL or RET instruction, the CAL is executed in (7).
The number of executions of the L instruction and the RET instruction are compared. If the number of executions matches, it is determined that the execution of the first subprogram called has been completed. Is not finished yet, and the process returns to (1) to execute the next instruction.

【0004】次に、従来のサブプログラム終了判定方法
の一例を、図10のプログラムを例にとり詳細に説明す
る。以下に説明をするサブプログラム終了判定方法は、
上述した図9の終了判定方法とは若干異なり、CALL
命令の実行回数をCOUNTという変数に代入するが、
CALL命令実行でCOUNT変数をインクリメント
し、RET命令の実行でCOUNT変数をデクリメント
して、COUNT変数が0となったときにサブプログラ
ム終了判定を行うものである。図10は、MAINのプ
ログラムの中で、サブプログラムSUB1およびSUB
2を呼び出して処理を行うプログラムの例であり、図1
1にこの処理の模式図とCOUNT変数の変化を示し
た。図11において、(1)〜(5)のCALLおよび
RET命令は、図10の(1)〜(5)に対応している
が、まず(A)のCALL命令が実行されるとCOUN
T変数がインクリメントされ1となり、(B)のCAL
L命令でCOUNT変数=2、(C)のRET命令でC
OUNT変数=1、(D)のCALL命令でCOUNT
変数=2、(E)のRET命令でCOUNT変数=1、
そして(F)のRET命令でCOUNT変数=0とな
り、サブプログラムの終了判定がなされる。
Next, an example of a conventional subprogram end determination method will be described in detail with reference to a program shown in FIG. The subprogram end determination method described below
Slightly different from the end determination method of FIG.
The execution count of the instruction is assigned to a variable called COUNT.
The COUNT variable is incremented by the execution of the CALL instruction, the COUNT variable is decremented by the execution of the RET instruction, and when the COUNT variable becomes 0, the subprogram termination judgment is performed. FIG. 10 shows that the subprograms SUB1 and SUB are included in the MAIN program.
FIG. 1 shows an example of a program that calls and performs processing.
FIG. 1 shows a schematic diagram of this process and changes in the COUNT variable. In FIG. 11, the CALL and RET instructions of (1) to (5) correspond to (1) to (5) of FIG. 10, but first, when the CALL instruction of (A) is executed,
The T variable is incremented to 1 and the CAL in (B)
COUNT variable = 2 by L instruction, C by RET instruction of (C)
COUNT variable = 1, COUNT by CALL instruction of (D)
Variable = 2, COUNT variable = 1 by RET instruction in (E),
Then, by the RET instruction in (F), the COUNT variable = 0, and the end of the subprogram is determined.

【0005】上述のCOUNT変数を変化させるサブプ
ログラム終了判定方法を実行する回路を図12に示す。
ここで図2にプログラム評価装置の全体図を示すが、図
12は図2中の201に位置するものである。以下図2
および図12を用いて従来例を説明する。図2におい
て、200はプログラム評価装置、201はサブプログ
ラム終了判定回路、202はプログラム評価装置の各部
の制御を行う制御プログラムを実行する中央処理装置、
203、204は制御プログラム用のRAMおよびRO
M、205は被デバッグプログラムおよび被デバッグプ
ログラムの実行を制御するスーパバイザプログラムを実
行する評価用プロセッサ、206、207はスーパバイ
ザプログラム用のRAMおよびROM、208、209
は被デバッグプログラム用のRAMおよびROM、21
0〜212は各部を接続するアドレスバス、データバ
ス、コントロールバス等の各種バス、213はサブプロ
グラム終了判定回路201中のフリップフロップ等のリ
セットを行うリセット信号、214は評価用プロセッサ
205のステップ実行制御信号、215は評価用プロセ
ッサ205とサブプログラム終了判定回路201の間の
各種制御信号、216は被デバッグプログラムが制御す
るためのターゲットシステム、217は評価用プロセッ
サ205とターゲットシステム216の間の各種バス、
218はプログラム評価装置200を制御するホストコ
ンピュータ、219〜222はI/Oポートである。以
下評価用プロセッサ205において、被デバッグプログ
ラムが実行されるときをユーザモード、スーパバイザプ
ログラムが実行されるときをスーパバイザモードと呼
ぶ。次に図12において、1はフリップフロップ回路、
2はOR回路、9はスーパバイザ割込要求端子(以下S
VIRQ端子)、10はステップ実行制御端子、11は
CALLストローブ端子、12はRETストローブ端
子、14は8入力OR回路、15はインバータ、16は
アップダウンカウンタであり、図2に対応するものは同
番号を付している。
FIG. 12 shows a circuit for executing the above-described subprogram end determination method for changing the COUNT variable.
Here, FIG. 2 shows an overall view of the program evaluation apparatus, and FIG. 12 is located at 201 in FIG. Figure 2 below
A conventional example will be described with reference to FIG. In FIG. 2, reference numeral 200 denotes a program evaluation device, 201 denotes a subprogram end determination circuit, 202 denotes a central processing unit that executes a control program for controlling each unit of the program evaluation device,
203 and 204 are RAMs and ROs for control programs.
M and 205 are evaluation processors for executing a debugged program and a supervisor program for controlling execution of the debugged program, and 206 and 207 are RAM and ROM for the supervisor program, and 208 and 209.
Are RAM and ROM for the program to be debugged, 21
Reference numerals 0 to 212 denote various buses such as an address bus, a data bus, and a control bus for connecting each unit. 213, a reset signal for resetting a flip-flop in the subprogram end determination circuit 201; Control signals 215 are various control signals between the evaluation processor 205 and the sub-program end determination circuit 201, 216 is a target system controlled by the program to be debugged, and 217 is a various system between the evaluation processor 205 and the target system 216. bus,
218 is a host computer that controls the program evaluation device 200, and 219 to 222 are I / O ports. Hereinafter, when the debugged program is executed in the evaluation processor 205, it is called a user mode, and when the supervisor program is executed, it is called a supervisor mode. Next, in FIG. 12, 1 is a flip-flop circuit,
2 is an OR circuit, 9 is a supervisor interrupt request terminal (hereinafter S
VIRQ terminal), 10 is a step execution control terminal, 11 is a CALL strobe terminal, 12 is a RET strobe terminal, 14 is an 8-input OR circuit, 15 is an inverter, 16 is an up / down counter, and those corresponding to FIG. Numbered.

【0006】プログラムの評価を行うにあたり、ホスト
コンピュータ218は、制御プログラムをROM204
に、スーパバイザプログラムをROM207に、被デバ
ッグプログラムをROM209にそれぞれあらかじめ格
納する。この場合、ROMを用いず、RAM203、2
06、208に各プログラムを格納してもよい。次に、
制御プログラムは評価用プロセッサ205にスーパバイ
ザプログラムを起動させ、プログラム評価の準備をす
る。評価用プロセッサ205がスーパバイザモードのと
きは、被デバッグプログラムが格納されたROM209
やRAM208、被デバッグプログラムの実行結果によ
る評価用プロセッサ205の内部レジスタの値、また場
合によりターゲットシステム216内の状態をモニタ
し、ホストコンピュータ218から確認することができ
る。ただし本従来例の場合ではターゲットシステム21
6に実際に載せるプロセッサはシングルチップマイコン
を想定しており、ターゲットシステム216内には特に
メモリ等を持たない構成となっている。
In evaluating the program, the host computer 218 stores the control program in the ROM 204
Then, the supervisor program is stored in the ROM 207 and the program to be debugged is stored in the ROM 209 in advance. In this case, without using the ROM, the RAM 203, 2
06, 208 may store each program. next,
The control program causes the evaluation processor 205 to start the supervisor program and prepare for the program evaluation. When the evaluation processor 205 is in the supervisor mode, the ROM 209 storing the program to be debugged is stored.
And the value of the internal register of the evaluation processor 205 based on the execution result of the debugged program, the RAM 208, and the state of the target system 216 as the case may be. However, in the case of this conventional example, the target system 21
6 is assumed to be a single-chip microcomputer, and the target system 216 does not particularly have a memory or the like.

【0007】プログラムの評価を開始すると、評価用プ
ロセッサ205はスーパバイザモードにおいて中央処理
装置202にリセット信号213を発生させ、フリップ
フロップ1およびアップダウンカウンタ16を初期化す
る。そしてROM209を参照して被デバッグプログラ
ムの実行すべき命令がCALL命令かその他の命令かを
判定する。CALL命令以外の命令であった場合、中央
処理装置202によりステップ実行制御信号214をア
クティブとする。評価用プロセッサ205はステップ実
行制御端子10がアクティブになると、ユーザモードに
おいて被デバッグプログラムの命令を一つ実行し、スー
パバイザモードに再び戻る。ただしステップ実行制御信
号214はI/Oポート222でラッチされているの
で、評価用プロセッサ205はスーパバイザモードに戻
ったとき、中央処理装置202にステップ実行制御信号
214をインアクティブにさせる。次に被デバッグプロ
グラムがCALL命令であった場合は、ステップ実行制
御信号214はアクティブとせず、ユーザモードにおい
てCALL命令を実行する。この場合、CALL命令実
行後も続けて被デバッグプログラムが実行される。評価
用プロセッサ205は、通常CALLストローブ端子1
1およびRETストローブ端子12に1レベルを出力し
ているが、実行する命令がCALLまたはRET命令で
ある場合、CALL命令実行時にCALLストローブ端
子11に0レベルを出力し、RET命令実行時にRET
ストローブ端子12に0レベルを出力する。これはあら
かじめ評価用プロセッサ205に内蔵されたCALLお
よびRET命令のマイクロプログラムに組み込まれた処
理で行う。ここで図12のCALLストローブ、RET
ストローブ、およびSVIRQの各信号は、図2の制御
信号215にあたる。フリップフロップ1は、上述のよ
うにあらかじめリセットされているので、SVIRQ端
子9に1レベルを出力している。アップダウンカウンタ
16はCALLストローブの立ち上がりでアップカウン
トし、RETストローブの立ち上がりでダウンカウント
する。すなわち、CALL命令の実行終了時にアップカ
ウントし、RET命令の実行終了時にダウンカウントす
る。インバータ回路15は、アップダウンカウンタ16
のD0ビットの出力を反転する。8入力OR回路14
は、インバータ回路15の出力とアップダウンカウンタ
16のD1〜D7ビットの出力が全て0のとき、すなわ
ち、アップダウンカウンタ16の値が1のときに、S1
ラインに0レベルを出力する。OR回路2は、S1ライ
ンが0レベルのときにRETストローブが0レベルにな
ると、S2ラインに0レベルを出力する。フリップフロ
ップ1は、S2ラインが0レベルになるとセットされ、
それ以後、SVIRQ端子9に0レベルを出力する。評
価用プロセッサ205は、SVIRQ端子9が0レベル
になったとき被デバッグプログラムの実行を停止し、ス
ーパバイザモードに戻る。
When the evaluation of the program is started, the evaluation processor 205 generates a reset signal 213 to the central processing unit 202 in the supervisor mode to initialize the flip-flop 1 and the up / down counter 16. Then, referring to the ROM 209, it is determined whether the instruction to be executed by the debug target program is the CALL instruction or another instruction. If the instruction is other than the CALL instruction, the central processing unit 202 activates the step execution control signal 214. When the step execution control terminal 10 becomes active, the evaluation processor 205 executes one instruction of the program to be debugged in the user mode, and returns to the supervisor mode again. However, since the step execution control signal 214 is latched at the I / O port 222, the evaluation processor 205 causes the central processing unit 202 to make the step execution control signal 214 inactive when returning to the supervisor mode. Next, when the program to be debugged is a CALL instruction, the step execution control signal 214 is not activated, and the CALL instruction is executed in the user mode. In this case, the debugged program is continuously executed even after the execution of the CALL instruction. The evaluation processor 205 normally has the CALL strobe terminal 1
1 and 1 level are output to the RET strobe terminal 12, but when the instruction to be executed is a CALL or RET instruction, a 0 level is output to the CALL strobe terminal 11 when the CALL instruction is executed, and RET is executed when the RET instruction is executed.
It outputs 0 level to the strobe terminal 12. This is performed by processing incorporated in the microprogram of the CALL and RET instructions built in the evaluation processor 205 in advance. Here, the CALL strobe, RET in FIG.
The strobe and SVIRQ signals correspond to the control signal 215 in FIG. Since the flip-flop 1 has been reset in advance as described above, it outputs 1 level to the SVIRQ terminal 9. The up / down counter 16 counts up at the rising edge of the CALL strobe and counts down at the rising edge of the RET strobe. That is, it counts up when the execution of the CALL instruction is completed and counts down when the execution of the RET instruction is completed. The inverter circuit 15 includes an up-down counter 16
Is inverted. 8-input OR circuit 14
When the output of the inverter circuit 15 and the output of the D1 to D7 bits of the up / down counter 16 are all 0, that is, when the value of the up / down counter 16 is 1, S1
Output 0 level to the line. When the RET strobe goes to the 0 level when the S1 line is at the 0 level, the OR circuit 2 outputs the 0 level to the S2 line. The flip-flop 1 is set when the S2 line becomes 0 level,
Thereafter, 0 level is output to the SVIRQ terminal 9. When the SVIRQ terminal 9 becomes 0 level, the evaluation processor 205 stops executing the debugged program and returns to the supervisor mode.

【0008】以上をまとめると、アップダウンカウンタ
16のカウント値が1となったときにRET命令を実行
すると、サブプログラムの実行が終了したものと判定す
ることになる。
In summary, when the RET instruction is executed when the count value of the up / down counter 16 becomes 1, it is determined that the execution of the subprogram has been completed.

【0009】図13に、図12のサブプログラム終了判
定回路の動作を示すタイミングチャートを示す。図13
中、各符号は図12と共通である。図13の時刻t1、
t5、t13のCALLストローブと、時刻t9、t1
7、t21のRETストローブは、図11の(A)、
(B)、(D)のCALL命令、(C)、(E)、
(F)のRET命令にそれぞれ対応する。アップダウン
カウンタ16の出力であるD0、D1は、CALLスト
ローブの立ち上がりでアップカウントされ、RETスト
ローブの立ち上がりでダウンカウントされている。アッ
プダウンカウンタ16のカウント値は、時刻t2〜t
5、t10〜t13、t18〜t21で1となり、S1
ラインが0レベルとなる。さらに時刻t21ではアップ
ダウンカウンタ16のカウント値が1であり、かつRE
Tストローブが発生するのでS1ラインとS2ラインが
同時に0レベルとなり、それ以降のSVIRQが0レベ
ルとなる。
FIG. 13 is a timing chart showing the operation of the subprogram end determination circuit of FIG. FIG.
In the figure, each symbol is common to FIG. At time t1 in FIG.
CALL strobe at t5 and t13 and time t9 and t1
7, the RET strobe at t21 is (A) in FIG.
(B), (D) CALL instruction, (C), (E),
(F) corresponds to the RET instruction. The outputs D0 and D1 of the up / down counter 16 are counted up at the rise of the CALL strobe and down counted at the rise of the RET strobe. The count value of the up / down counter 16 is set between time t2 and time t2.
5, it becomes 1 at t10 to t13 and t18 to t21, and S1
The line goes to the 0 level. Further, at time t21, the count value of the up / down counter 16 is 1 and RE
Since the T strobe is generated, the S1 line and the S2 line are simultaneously at the 0 level, and the subsequent SVIRQ is at the 0 level.

【0010】以上に説明したようなサブプログラムの終
了判定方法を用いたプログラム評価装置は、被デバッグ
プログラムのOSが従来のように複数のプログラムが並
行して動作しないOSでは問題ないが、OSとしてリア
ルタイムOSを用いた場合、正常に動作しないことがあ
る。
The program evaluation apparatus using the above-described subprogram termination determination method has no problem if the OS of the program to be debugged is an OS in which a plurality of programs do not operate in parallel as in the prior art. When a real-time OS is used, it may not operate normally.

【0011】[0011]

【発明が解決しようとする課題】以下に、リアルタイム
OSで従来のサブプログラムの終了判定方法を行った場
合の問題点を述べる。リアルタイムOSとは、タスクと
いう単位に分割された複数のプログラムを状況により切
り換えながら動作させるOSであり、OSに対するシス
テムコールの発行や、割り込みによるイベントの発生に
より、実行中のタスクが切り替わる。よってリアルタイ
ムOSは、その特色からプログラムの構成上いくつかの
並列的に行われる処理や、時間経過の管理を伴うような
処理を必要とする場合に使用されることがある。また、
タスクは通常のプログラムと同様に幾つかのサブプログ
ラムに分割されて開発される。
The following describes problems when a conventional subprogram end determination method is performed on a real-time OS. The real-time OS is an OS that operates while switching a plurality of programs divided into units called tasks according to circumstances, and issues a system call to the OS or generates an event due to an interrupt, and the task being executed is switched. Therefore, the real-time OS may be used when it is necessary to perform some parallel processing or processing involving management of the passage of time due to its characteristics. Also,
A task is developed by being divided into several subprograms as in a normal program.

【0012】リアルタイムOSでは、タスクが切り替わ
ることが原因となってCALL命令とRET命令の実行
回数が一致しないことがある。以下に図14に示したプ
ログラムを例にとって、リアルタイムOSを使用した場
合のCALL命令とRET命令の実行回数について説明
する。図14のプログラムは、MAIN_A、SUB1
_A、およびSUB2_AがTASK_Aのプログラム
群、MAIN_BおよびSUB1_BがTASK_Bの
プログラム群である。このTASK_AとTASK_B
は互いに独立したプログラム群であり、TASK_Aが
TASK_Bを呼び出したりするわけではない。図14
中の「CALL SYS_CALL」がリアルタイムO
Sに対してシステムコールを発行している箇所である。
図15は、図14のプログラムを実行したときの処理の
模式図であり、時間の流れに対して実行する処理がTA
SK_A、TASK_B、およびリアルタイムOSに切
り替わる様子を表す。この場合、TIME3からTIM
E4にかけて、実行するタスクはTASK_Bに切り替
わっている。図16にTASK_Aの、図17にTAS
K_Bの詳細な処理の流れをそれぞれ示す。図16、図
17の(2)〜(11)のCALLおよびRET命令
は、図14の(2)〜(11)の各命令に対応してい
る。また、図16、図17には処理の流れに応じて
(A)〜(M)の符号をつけたが、図16の(A)、
(E)、(H)はリアルタイムOSがTASK_Aに戻
るときのRET命令であり、図17の(K)はリアルタ
イムOSがTASK_Bに戻るときのRET命令であ
る。なお、リアルタイムOSからタスクへ戻る動作は、
OS自身が管理して行う。図18、図19は、図16、
図17の(A)〜(M)に対応した、CALLおよびR
ET命令実行後のスタックポインタのアドレス値とスタ
ックの内容である。リアルタイムOSでは各タスク毎に
別々のスタック領域を割り当てるようになっており、タ
スクが切り替わったときにスタック領域も一緒に切り替
わる。この例ではTASK_Aのスタック領域は0F7
40H〜0F77FHに、TASK_Bのスタック領域
は0F700H〜0F73FHとするが、図18、図1
9には変化する範囲のスタックしか示していない。リア
ルタイムOSでは図18、図19の様に各タスク毎にサ
ブプログラムの戻りアドレスを管理できるので、各タス
ク毎に独自にサブプログラムの呼び出しができる。
In the real-time OS, the number of executions of the CALL instruction and the RET instruction may not match due to the task switching. Hereinafter, the number of executions of the CALL instruction and the RET instruction when the real-time OS is used will be described using the program shown in FIG. 14 as an example. The program in FIG. 14 includes MAIN_A, SUB1
_A and SUB2_A are TASK_A programs, and MAIN_B and SUB1_B are TASK_B programs. This TASK_A and TASK_B
Are a group of programs independent of each other, and TASK_A does not call TASK_B. FIG.
"CALL SYS_CALL" in the real-time O
This is where a system call is issued to S.
FIG. 15 is a schematic diagram of the processing when the program of FIG. 14 is executed.
It shows a state of switching to SK_A, TASK_B, and real-time OS. In this case, TIME3 to TIM
From E4, the task to be executed has been switched to TASK_B. FIG. 16 shows TASK_A, and FIG. 17 shows TAS.
A detailed process flow of K_B will be shown. The CALL and RET instructions in (2) to (11) in FIGS. 16 and 17 correspond to the instructions in (2) to (11) in FIG. Although FIGS. 16 and 17 are denoted by reference numerals (A) to (M) in accordance with the flow of the processing, FIGS.
(E) and (H) are RET instructions when the real-time OS returns to TASK_A, and (K) in FIG. 17 are RET instructions when the real-time OS returns to TASK_B. The operation to return to the task from the real-time OS is
It is managed by the OS itself. FIG. 18 and FIG.
CALL and R corresponding to (A) to (M) of FIG.
These are the address value of the stack pointer and the contents of the stack after the execution of the ET instruction. In the real-time OS, a separate stack area is assigned to each task, and when a task is switched, the stack area is switched together. In this example, the stack area of TASK_A is 0F7
40H to 0F77FH and the stack area of TASK_B is 0F700H to 0F73FH.
In FIG. 9, only the stack in the changing range is shown. In the real-time OS, since the return address of the subprogram can be managed for each task as shown in FIGS. 18 and 19, the subprogram can be independently called for each task.

【0013】ここで、図14の(4)のサブプログラム
呼び出し命令についてCALL命令とRET命令の実行
回数を説明すると、サブプログラムSUB1_Aで呼び
出されたサブプログラムSUB2_Aの実行が完了する
のは、(8)のRET命令、すなわち図16の(F)の
RET命令を実行したときである。この間には、TIM
E3〜TIME4にかけてTASK_Bが実行されてい
るため、TASK_Aでは図16の(C)、(D)のC
ALL命令と(E)、(F)のRET命令が、TASK
_Bでは図17の(L)、(M)のCALL命令と
(K)のRET命令が実行される。つまり、全部で4回
のCALL命令と3回のRET命令が実行されるので、
CALL命令とRET命令の実行回数が異なる。ゆえに
従来のようなサブプログラム終了判定方法を用いた場合
は、図16の(F)のRET命令の実行後もサブプログ
ラムが終了していないという判定をするという問題が生
じる。
The number of times the CALL instruction and the RET instruction are executed with respect to the subprogram call instruction (4) in FIG. 14 will be described. The execution of the subprogram SUB2_A called by the subprogram SUB1_A is completed in (8) ), That is, when the RET instruction of FIG. 16F is executed. During this time, TIM
Since TASK_B is executed from E3 to TIME4, TASK_A indicates C in FIGS. 16C and 16D.
ALL instruction and RET instruction of (E) and (F) are TASK
In _B, the CALL instruction in (L) and (M) of FIG. 17 and the RET instruction in (K) are executed. In other words, a total of four CALL instructions and three RET instructions are executed,
The number of times the CALL instruction and the RET instruction are executed is different. Therefore, when the conventional subprogram end determination method is used, there is a problem that it is determined that the subprogram has not ended even after the execution of the RET instruction of FIG.

【0014】[0014]

【課題を解決するための手段】上述したようなリアルタ
イムOSに対して、本発明はプログラムの処理がメイン
プログラムからサブプログラムに分岐するときに変化す
るスタックポインタのアドレス値を利用することによ
り、サブプログラムの実行の終了判定を行うものであ
る。具体的には、被デバッグプログラムにサブプログラ
ムを呼び出す命令が存在する場合に、被デバッグプログ
ラムにおいてサブプログラムを呼び出す命令を最初に実
行した時のスタックポインタのアドレス値を保持し、こ
の保持されたスタックポインタのアドレス値とサブプロ
グラムの実行において変化した現在のスタックポインタ
のアドレス値とを比較して、両者が一致した場合に被デ
バッグプログラムから呼び出されたサブプログラムの実
行が終了したことを検出する。
SUMMARY OF THE INVENTION In contrast to the real-time OS as described above, the present invention uses a stack pointer address value that changes when the processing of a program branches from a main program to a subprogram. This is for determining the end of the execution of the program. Specifically, when an instruction for calling a subprogram is present in the debugged program, the address value of the stack pointer when the instruction for calling the subprogram is first executed in the debugged program is held. The address value of the pointer and the current address value of the stack pointer changed during execution of the subprogram are compared, and when they match, it is detected that the execution of the subprogram called from the debugged program has ended.

【0015】[0015]

【発明の実施の形態】以下、本発明の実施の形態につい
て説明する。第1の実施の形態として本発明の基本とな
る処理説明図を図1に示す。図1において、100は被
デバッグプログラム、101は被デバッグプログラムが
その処理において呼び出すサブプログラム、102はサ
ブプログラム101が呼び出すサブプログラム、103
はスタックポインタのアドレス値保持手段、104はス
タックポインタのアドレス値比較手段、105はスタッ
クポインタのアドレス値出力信号、106は一致信号、
107は被デバッグプログラム100のCALL命令、
108はサブプログラム101および102の命令、1
09は被デバッグプログラム100のCALLおよびR
ET命令以外の命令、110は評価用プロセッサ、11
1はステップ実行制御手段、112は命令実行処理、1
13はステップ実行制御手段111のフラグ状態を調べ
る処理、114は被デバッグプログラム100の命令実
行結果の状態を調べる処理(プログラム評価)である。
本実施の形態では、サブプログラム101、102のデ
バッグは既に完了しているとする。
Embodiments of the present invention will be described below. FIG. 1 is an explanatory diagram of a basic process of the present invention as a first embodiment. In FIG. 1, reference numeral 100 denotes a program to be debugged; 101, a subprogram called by the program to be debugged in its processing; 102, a subprogram called by the subprogram 101;
Is a stack pointer address value holding means, 104 is a stack pointer address value comparing means, 105 is a stack pointer address value output signal, 106 is a match signal,
107 is a CALL instruction of the debugged program 100;
108 is an instruction of the subprograms 101 and 102, 1
09 is CALL and R of the program to be debugged 100.
Instructions other than the ET instruction, 110 is an evaluation processor, 11
1 is step execution control means, 112 is instruction execution processing, 1
13 is a process for checking the flag state of the step execution control means 111, and 114 is a process for checking the state of the instruction execution result of the debugged program 100 (program evaluation).
In the present embodiment, it is assumed that debugging of the subprograms 101 and 102 has already been completed.

【0016】プログラムの評価を開始し、被デバッグプ
ログラム100中のCALLおよびRET命令以外の命
令を実行した場合、ステップ実行制御手段111におい
て命令のステップ実行を行うためのフラグを立て、11
2の命令実行処理を行う。そして113のフラグ状態を
調べる処理でフラグが立っていることを判定するので、
114の命令実行結果を調べる処理が実行される。つま
り、1命令の実行毎に実行結果を調べる。
When the evaluation of the program is started and an instruction other than the CALL and RET instructions in the debugged program 100 is executed, the step execution control means 111 sets a flag for executing the execution of the instruction.
2 is executed. Then, since it is determined that the flag is set in the process of checking the flag state of 113,
A process of checking the instruction execution result at 114 is executed. That is, the execution result is checked every time one instruction is executed.

【0017】上述のように被デバッグプログラム100
を実行する過程で、実行すべき命令がCALL命令であ
る場合、例えば被デバッグプログラム100中の(1)
のCALL命令の実行時には、アドレス値保持手段10
3にスタックポインタのアドレス値を保持し、アドレス
値比較手段104に出力する。そしてステップ実行制御
手段111のフラグを立てずにCALL命令を実行し、
サブプログラム101を呼び出す。CALL命令実行
後、113のフラグ状態を調べる処理ではフラグが立っ
ていないことを判定するので、サブプログラム101が
続けて実行される。ここでサブプログラム101中に
(2)の様にCALL命令があった場合、その実行時の
スタックポインタのアドレス値をアドレス値比較手段1
04に出力する。また同様にRET命令の実行時にも、
スタックポインタのアドレス値をアドレス値比較手段1
04に出力し、アドレス値保持手段103から出力され
る(1)のCALL命令実行時のスタックポインタのア
ドレス値と逐次比較を行う。サブプログラムの実行を続
けていくと、サブプログラム101の(4)のRET命
令を実行するが、このRET命令はサブプログラム10
1が被デバッグプログラム100に戻る命令である。よ
って、アドレス値比較手段104では(1)のCALL
命令実行時のスタックポインタのアドレス値との一致を
判定し、一致信号106がステップ実行制御手段111
に対して発生され、ステップ実行制御のフラグが立つ。
そして113のフラグ状態を調べる処理でフラグが立っ
ていることを判定するのでサブプログラムの実行が終了
したと判定し、114の命令実行結果を調べる処理に移
る。
As described above, the program to be debugged 100
If the instruction to be executed is a CALL instruction in the process of executing
When the CALL instruction is executed, the address value holding means 10
3 holds the address value of the stack pointer and outputs it to the address value comparing means 104. Then, the CALL instruction is executed without setting the flag of the step execution control means 111,
Call the subprogram 101. After the CALL instruction is executed, in the processing for checking the flag state of 113, it is determined that the flag is not set, so that the subprogram 101 is continuously executed. If there is a CALL instruction in the subprogram 101 as shown in (2), the address value of the stack pointer at the time of execution is compared with the address value comparing means 1.
04. Similarly, when the RET instruction is executed,
Address value comparing means 1 for comparing the address value of the stack pointer
04, and is sequentially compared with the address value of the stack pointer at the time of execution of the CALL instruction (1) output from the address value holding means 103. As the execution of the subprogram is continued, the RET instruction of (4) of the subprogram 101 is executed.
1 is an instruction to return to the program to be debugged 100. Therefore, in the address value comparing means 104, (1) CALL
A match with the address value of the stack pointer at the time of execution of the instruction is determined, and the match signal
And the step execution control flag is set.
Then, it is determined that the flag has been set in the flag state check processing in step 113, so that it is determined that the execution of the subprogram has been completed, and the processing proceeds to step 114 in which the instruction execution result is checked.

【0018】以上の説明をまとめると、プログラムの実
行において最初に実行すべきCALL命令の実行時のス
タックポインタのアドレス値、つまりCALL命令の実
行においてプログラムの戻り番地が保持されるスタック
ポインタのアドレス値を保持し、サブプログラムの実行
に移る。しかし、サブプログラム中にCALL命令があ
ったときはスタックポインタのアドレス値は保持せず、
CALLおよびRET命令で変化するスタックポインタ
のアドレス値と、はじめに保持されたスタックポインタ
のアドレス値を比較し、両者が一致したときにサブプロ
グラムの実行が終了したものとみなすことになる。
In summary, the address value of the stack pointer at the time of execution of the CALL instruction to be executed first in the execution of the program, that is, the address value of the stack pointer at which the return address of the program is held in the execution of the CALL instruction And proceed to execution of the subprogram. However, when the CALL instruction is included in the subprogram, the address value of the stack pointer is not held, and
The address value of the stack pointer changed by the CALL and RET instructions is compared with the address value of the stack pointer held first, and when they match, it is considered that the execution of the subprogram has been completed.

【0019】次に図14のリアルタイムOSのプログラ
ムの実行過程におけるスタックポインタを示した図1
8、図19を用いてスタックポインタのアドレス値の比
較の説明をする。図14のTASK_Aのメインプログ
ラムであるMAIN_Aにおいて、(1)の「CALL
SYS_CALL」はリアルタイムOSに分岐して戻
ってくるだけであるので、(2)の「CALL SUB
1_A」の実行について説明する。図18において、図
14の(2)は(B)に対応するので、スタックポイン
タのアドレス値の保持手段には「0F780H」が保持
される。その後(B)〜(D)のCALL命令が実行さ
れ、スタックポインタのアドレス値は変化していくが、
その値は保持されない。時間の流れにおいて、TIME
3〜4でTASK_Bに移っているが、上述したように
各タスク用のスタック領域に切り替わるため、TASK
_Aに戻ったとき、スタックポインタのアドレス値はT
ASK_Bに移る前の値となる。以下処理が実行され、
結局(I)のRET命令を実行するとスタックポインタ
のアドレス値は「0F780H]になるため、保持され
ていたアドレス値と等しくなり、図14の(2)で呼び
出されたサブプログラムの実行が終了する。よって、サ
ブプログラムの終了判定が正しく行われる。またこの方
法では、再帰呼び出しと呼ばれる、あるプログラムが自
分自身を呼び出すようなサブプログラムの分岐処理にも
対応できる。
FIG. 1 shows a stack pointer in the process of executing the program of the real-time OS shown in FIG.
8, the comparison of the address value of the stack pointer will be described with reference to FIG. In MAIN_A which is the main program of TASK_A in FIG. 14, (1) "CALL
“SYS_CALL” simply branches back to the real-time OS and returns, so “(2) CALL SUB”
1_A ”will be described. In FIG. 18, since (2) in FIG. 14 corresponds to (B), “0F780H” is held in the holding unit for the address value of the stack pointer. Thereafter, the CALL instructions (B) to (D) are executed, and the address value of the stack pointer changes,
Its value is not retained. In the flow of time, TIME
Although the process has shifted to TASK_B in steps 3 and 4, the stack area is switched to the stack area for each task as described above.
_A, the address value of the stack pointer is T
This is the value before shifting to ASK_B. The following processing is executed,
After all, when the RET instruction of (I) is executed, the address value of the stack pointer becomes “0F780H”, so that it becomes equal to the held address value, and the execution of the subprogram called in (2) of FIG. 14 ends. Thus, the termination of the subprogram is correctly determined, and this method can cope with a subprogram branching process called a recursive call in which a certain program calls itself.

【0020】第2の実施の形態として、本発明を回路
(ハードウェア)により実現したものを図3に示す。こ
こでプログラム評価装置の全体の構成は従来例で説明し
た図2のものと同様である。図3において、1、6、お
よび8はフリップフロップ回路、2はOR回路、3は1
6入力NAND回路、4は16個のEXNOR回路、5
は16ビットラッチ回路、7はNOR回路、9はスーパ
バイザ割込要求端子、10はステップ実行制御端子、1
1はCALLストローブ端子、12はRETストローブ
端子、13はスタックポインタ出力端子であり、図2お
よび図12に対応するものは同番号を付している。ただ
し、図2の各種制御信号215は従来例と同様のCAL
Lストローブ、RETストローブ、SVIRQに加え
て、スタックポインタ出力信号も表す。なお図4は図3
の16入力NAND回路3およびEXNOR回路4の詳
細な接続図であり、図3における16本のビット線であ
るL1およびL2ラインの、対応するビット線同志を1
6個のEXNOR回路で比較し、全てのEXNOR回路
で一致を判定して1レベルを出力すると、16入力NA
ND回路3が0レベルを出力するものである。
FIG. 3 shows a second embodiment in which the present invention is realized by a circuit (hardware). Here, the overall configuration of the program evaluation device is the same as that of FIG. 2 described in the conventional example. In FIG. 3, 1, 6, and 8 are flip-flop circuits, 2 is an OR circuit, and 3 is 1
6-input NAND circuit, 4 are 16 EXNOR circuits, 5
Is a 16-bit latch circuit, 7 is a NOR circuit, 9 is a supervisor interrupt request terminal, 10 is a step execution control terminal, 1
1 is a CALL strobe terminal, 12 is a RET strobe terminal, 13 is a stack pointer output terminal, and those corresponding to FIG. 2 and FIG. However, the various control signals 215 in FIG.
In addition to the L strobe, RET strobe, and SVIRQ, it also indicates a stack pointer output signal. FIG. 4 is FIG.
FIG. 4 is a detailed connection diagram of the 16-input NAND circuit 3 and the EXNOR circuit 4 of FIG. 3, where the corresponding bit lines of the 16 bit lines L1 and L2 in FIG.
When six EXNOR circuits compare, and all EXNOR circuits determine a match and output one level, a 16-input NA
The ND circuit 3 outputs 0 level.

【0021】以下に図3の回路の動作を説明する。第2
の実施の形態において評価用プロセッサ205は、スタ
ックポインタのアドレス値をスタックポインタ出力端子
13に出力していることとOSがリアルタイムOSであ
る以外は、スーパバイザモードおよびユーザモードにお
いても従来例のものと同様の動作を行うのでサブプログ
ラムの終了判定以外の動作は省略する。フリップフロッ
プ1、6、および8は、従来例と同様あらかじめリセッ
ト信号213によりリセットされる。フリップフロップ
8、NAND回路7、およびフリップフロップ6は、最
初のCALL命令の実行終了時(CALLストローブの
最初の立ち上がり)に、F3ラインを0レベルから1レ
ベルに変化させ、それ以後CALLストローブが発生し
てもF3ラインが1レベルのままになるようにしてい
る。16ビットラッチ5は、F3ラインの立ち上がりで
L2ラインの値をラッチし、L1ラインに出力する。す
なわち、16ビットラッチ5は最初のCALL命令の実
行終了時におけるスタックポインタのアドレス値をラッ
チし、以後その値を保持するようになっている。EXN
OR回路4と16入力NAND回路3は、16ビットラ
ッチ5の出力とスタックポインタ出力端子13の出力を
比較し、両者の値が一致したとき、S1ラインに0レベ
ルを出力する。OR回路2は、S1ラインが0レベルの
ときにRETストローブが0レベルになると、0レベル
をS2ラインに出力する。そしてフリップフロップ1
は、S2ラインの0レベルによりセットされ、それ以後
0レベルをSVIRQ端子9に出力し、評価用プロセッ
サ205がスーパバイザモードに移行する。
The operation of the circuit shown in FIG. 3 will be described below. Second
In the embodiment, the evaluation processor 205 outputs the address value of the stack pointer to the stack pointer output terminal 13 and operates in the same manner as the conventional example in the supervisor mode and the user mode except that the OS is a real-time OS. Since the same operation is performed, operations other than the subprogram end determination are omitted. The flip-flops 1, 6, and 8 are reset by a reset signal 213 in advance as in the conventional example. The flip-flop 8, the NAND circuit 7, and the flip-flop 6 change the F3 line from the 0 level to the 1 level at the end of the execution of the first CALL instruction (the first rising of the CALL strobe), and thereafter, the CALL strobe is generated. Even so, the F3 line is kept at one level. The 16-bit latch 5 latches the value of the L2 line at the rise of the F3 line and outputs the value to the L1 line. That is, the 16-bit latch 5 latches the address value of the stack pointer at the end of the execution of the first CALL instruction, and holds the value thereafter. EXN
The OR circuit 4 and the 16-input NAND circuit 3 compare the output of the 16-bit latch 5 with the output of the stack pointer output terminal 13, and output a 0 level to the S1 line when the values match. When the RET strobe goes to the 0 level when the S1 line is at the 0 level, the OR circuit 2 outputs the 0 level to the S2 line. And flip-flop 1
Is set by the 0 level of the S2 line, and thereafter the 0 level is output to the SVIRQ terminal 9, and the evaluation processor 205 shifts to the supervisor mode.

【0022】図5に、図3のサブプログラム終了判定回
路の動作を示すタイミングチャートを示す。図5中、各
符号は図3と共通である。また、時刻t8〜t21まで
の間にはタスクの切換えなどがあるとする。なお、評価
用プロセッサ205は、本実施の形態の場合CALL命
令の実行によりスタックポインタのアドレス値を2減算
し、RET命令の実行により2加算する。すなわち、ス
タックポインタのアドレス値SPはCALLストローブ
の立ち下がりで2が減算され、RETストローブの立ち
上がりで2が加算される。スタックポインタのアドレス
値SPは、最初のCALL命令の実行前はaであるとす
ると、時刻t1にある最初のCALL命令開始時にa−
2となる。そして、時刻t1のCALL命令終了時に対
応してF2ラインが0レベルとなり、さらにF3ライン
が1レベルとなる。16ビットラッチ5はF3ラインの
1レベルに対応してスタックポインタのアドレス値SP
の値をラッチするので時刻t1の終わりでL1ラインは
a−2となる。その後、時刻t5のCALL命令開始時
にCALLストローブによりF2ラインが1レベルとな
るがF3ラインは変化しないのでL1ラインも変化しな
い。ただし、スタックポインタのアドレス値SPはa−
4となる。時刻t25ではRET命令終了時にスタック
ポインタのアドレス値SPがa−2に戻る。つまり時刻
t26〜t29では、スタックポインタのアドレス値S
Pの値が最初のCALL命令の実行終了時の値に戻るた
め、S1ラインが0レベルになる。さらに時刻t29で
はS1ラインとRETストローブが同時に0レベルにな
るため、S2ラインが0レベルとなるので、時刻t29
以降、SVIRQは0レベルになり、評価用チップ20
5がスーパバイザモードに移行する。
FIG. 5 is a timing chart showing the operation of the subprogram end determination circuit of FIG. In FIG. 5, each reference numeral is common to FIG. Further, it is assumed that there is a task switching or the like between time t8 and t21. Note that, in the case of the present embodiment, the evaluation processor 205 subtracts 2 from the address value of the stack pointer by executing the CALL instruction, and adds 2 by executing the RET instruction. That is, 2 is subtracted from the address value SP of the stack pointer at the fall of the CALL strobe, and 2 is added at the rise of the RET strobe. Assuming that the address value SP of the stack pointer is a before execution of the first CALL instruction, a- at the start of the first CALL instruction at time t1.
It becomes 2. Then, in response to the end of the CALL instruction at time t1, the F2 line goes to the 0 level, and the F3 line goes to the 1 level. The 16-bit latch 5 stores the address value SP of the stack pointer corresponding to one level of the F3 line.
At the end of time t1, the L1 line becomes a-2. Thereafter, at the start of the CALL instruction at time t5, the F2 line becomes 1 level due to the CALL strobe, but the F3 line does not change, so the L1 line does not change either. However, the address value SP of the stack pointer is a-
It becomes 4. At time t25, at the end of the RET instruction, the address value SP of the stack pointer returns to a-2. That is, from time t26 to t29, the stack pointer address value S
Since the value of P returns to the value at the end of the execution of the first CALL instruction, the S1 line goes to the 0 level. Further, at time t29, the S1 line and the RET strobe go to the 0 level at the same time, and the S2 line goes to the 0 level.
Thereafter, SVIRQ goes to the 0 level, and the evaluation chip 20
5 shifts to the supervisor mode.

【0023】以上のように本発明の第2の実施の形態
は、最初のCALL命令の実行過程におけるスタックポ
インタが変化した後のアドレス値を記憶し、その後変化
するスタックポインタのアドレス値と逐次比較を行い、
メインプログラムに戻るRET命令の実行過程における
スタックポインタが変化する前のアドレス値と比較する
ことにより、サブプログラムの終了判定を正しく行うこ
とができる。
As described above, according to the second embodiment of the present invention, the address value after the stack pointer is changed during the execution of the first CALL instruction is stored, and the address value of the stack pointer that changes after that is successively compared. Do
By comparing with the address value before the stack pointer changes in the execution process of the RET instruction returning to the main program, it is possible to correctly determine the end of the subprogram.

【0024】第3の実施の形態として、本発明をソフト
ウェアにより実現したものを図6〜8に示す。本実施の
形態の場合第2の実施の形態とは異なり、図2のプログ
ラム評価装置の全体図からは、リセット信号213、各
種制御信号およびスタックポインタ出力信号215、サ
ブプログラム終了判定回路201が無くなる。そして代
わりにサブプログラムの終了判定を実現するソフトウェ
アがスーパバイザプログラムの一部としてROM207
に格納される。
As a third embodiment, the present invention realized by software is shown in FIGS. In the case of the present embodiment, unlike the second embodiment, the reset signal 213, various control signals and the stack pointer output signal 215, and the subprogram end determination circuit 201 are eliminated from the overall view of the program evaluation device of FIG. . Instead, software that realizes the end determination of the subprogram is stored in the ROM 207 as a part of the supervisor program.
Is stored in

【0025】プログラムの評価を開始するまでの準備は
従来例および第2の実施の形態と同一であるので説明を
省略する。プログラムの評価を開始すると、評価用プロ
セッサ205はスーパバイザモードにおいて中央処理装
置202によりステップ実行制御信号214をアクティ
ブとする。そして図6に示すフローチャートが開始され
る。つまり従来例や第2の実施の形態とは異なり、命令
の種類に係わりなくステップ実行制御信号214をアク
ティブとする。なお、図6、図7のフローチャートでは
省略したが、被デバッグプログラムの命令を実行する場
合、スーパバイザプログラムはスーパバイザリターン命
令(RETSVI命令)を発行する。このRETSVI
命令は評価用プロセッサ205をユーザモードに移行さ
せ、被デバッグプログラムの命令を1命令実行した後、
再びスーパバイザモードに戻る命令であり、ステップ実
行制御信号214がアクティブのときのみ有効となる。
以下に、図6〜8のフローチャートの説明をする。まず
(1)ではROM209を参照して被デバッグプログラ
ムの実行すべき命令の命令コードを調べRAM206に
確保されたDATAという変数に格納する。(2)では
該命令コードがCALL命令かその他の命令かを判定す
る。本実施の形態の場合、CALL命令を表す命令コー
ドの1バイト目は「01H」であり、RET命令を表す
命令コードの1バイト目は「02H」であるとする。よ
って命令コードの1バイト目を調べることにより命令コ
ードを判定するが、これはどのような情報処理装置であ
っても命令コードを解析することにより行うことができ
る。(2)で命令がCALL命令以外の命令であった場
合、(3)に分岐して1命令実行し、(11)へ進む。
また(2)で命令がCALL命令であった場合は、図7
に示すサブプログラムの終了判定を行うフローチャート
に分岐する。次に図7の(4)では、RAM206に確
保されたVALUEという変数にスタックポインタのア
ドレス値を格納する。そして評価用プロセッサ205が
ユーザモードに移行して(5)のCALL命令を実行
し、再びスーパバイザモードに戻って図8の(6)に進
む。(6)および(7)では、(1)および(2)と同
様の処理を行い、(5)のCALL命令によって呼び出
されたサブプログラム中の命令がRET命令か、CAL
L命令を含むその他の命令かを判定する。(7)でRE
T命令以外の命令であった場合、図7の(10)に分岐
して1命令実行し、(6)に戻る。また(7)で命令が
RET命令であった場合、(8)へ分岐してRET命令
を実行し、(9)へ進む。(9)では(4)で保持され
たスタックポインタのアドレス値であるVALUE変数
と現在のスタックポインタのアドレス値を比較するが、
両者が不一致だった場合は(6)へ戻る。また両者が一
致した場合は、サブプログラムの実行が終了したものと
判定し、図6の(11)へ進む。(11)は、従来例や
第2の実施の形態のスーパバイザモードと同様のもので
あり、ステップ実行制御信号214をインアクティブと
し、被デバッグプログラムの実行結果をモニタする処理
が起動される。
The preparation up to the start of the evaluation of the program is the same as in the conventional example and the second embodiment, so that the description is omitted. When the evaluation of the program is started, the evaluation processor 205 activates the step execution control signal 214 by the central processing unit 202 in the supervisor mode. Then, the flowchart shown in FIG. 6 is started. That is, unlike the conventional example and the second embodiment, the step execution control signal 214 is activated irrespective of the type of instruction. Although not shown in the flowcharts of FIGS. 6 and 7, when executing the instruction of the program to be debugged, the supervisor program issues a supervisor return instruction (RETSVI instruction). This RETSVI
The instruction shifts the evaluation processor 205 to the user mode, executes one instruction of the debugged program, and then executes
This is a command to return to the supervisor mode again, and is valid only when the step execution control signal 214 is active.
The flowcharts of FIGS. 6 to 8 are described below. First, in (1), the instruction code of the instruction to be executed by the program to be debugged is checked with reference to the ROM 209 and stored in a variable called DATA secured in the RAM 206. In (2), it is determined whether the instruction code is a CALL instruction or another instruction. In the case of the present embodiment, the first byte of the instruction code representing the CALL instruction is “01H”, and the first byte of the instruction code representing the RET instruction is “02H”. Therefore, the instruction code is determined by examining the first byte of the instruction code. This can be performed by analyzing the instruction code in any information processing apparatus. If the instruction is an instruction other than the CALL instruction in (2), branch to (3), execute one instruction, and proceed to (11).
If the instruction is a CALL instruction in (2),
The flow branches to a flowchart for determining the end of the subprogram shown in FIG. Next, in (4) of FIG. 7, the address value of the stack pointer is stored in a variable called VALUE secured in the RAM 206. Then, the evaluation processor 205 shifts to the user mode, executes the CALL instruction of (5), returns to the supervisor mode again, and proceeds to (6) of FIG. In (6) and (7), the same processing as in (1) and (2) is performed, and the instruction in the subprogram called by the CALL instruction in (5) is a RET instruction or a CAL instruction.
It is determined whether the instruction is another instruction including the L instruction. RE at (7)
If the instruction is other than the T instruction, the process branches to (10) in FIG. 7 to execute one instruction and returns to (6). If the instruction is a RET instruction in (7), the process branches to (8), executes the RET instruction, and proceeds to (9). In (9), the VALUE variable which is the address value of the stack pointer held in (4) is compared with the current address value of the stack pointer.
If they do not match, the procedure returns to (6). If they match, it is determined that the execution of the subprogram has been completed, and the process proceeds to (11) in FIG. (11) is similar to the supervisor mode of the conventional example or the second embodiment, in which the step execution control signal 214 is made inactive, and the process of monitoring the execution result of the program to be debugged is started.

【0026】以上のように本発明の第3の実施の形態
は、最初のCALL命令の実行過程におけるスタックポ
インタが変化する前のアドレス値を記憶し、その後変化
するスタックポインタのアドレス値と逐次比較を行い、
メインプログラムに戻るRET命令の実行過程における
スタックポインタが変化した後のアドレス値と比較する
ことにより、サブプログラムの終了判定を正しく行うこ
とができる。
As described above, the third embodiment of the present invention stores the address value before the stack pointer changes during the execution of the first CALL instruction, and successively compares the address value with the changing stack pointer address value. Do
By comparing with the address value after the change of the stack pointer in the process of executing the RET instruction returning to the main program, it is possible to correctly determine the end of the subprogram.

【0027】[0027]

【発明の効果】本発明は、リアルタイムOSを用いたプ
ログラム評価装置のプロシージャステップ実行におい
て、従来のようなサブプログラムの呼び出し命令および
戻り命令の実行数を数える方法ではサブプログラムの実
行終了を正しく判定できない場合があったものを、一般
的に情報処理装置に備わっているサブプログラムの呼び
出し命令および戻り命令の実行により変化するスタック
ポインタを利用し、そのアドレス値の変化を見ることで
サブプログラムの実行終了を正しく判定できる効果を奏
する。
According to the present invention, in the procedure step execution of the program evaluation apparatus using the real-time OS, the conventional method for counting the number of executions of the call instruction and the return instruction of the subprogram correctly judges the execution end of the subprogram. What could not be done is executed using the stack pointer, which is generally changed by execution of a subprogram call instruction and return instruction provided in the information processing device, and observing a change in the address value of the subprogram. This has the effect of correctly determining the end.

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

【図1】 第1の実施の形態の説明図FIG. 1 is an explanatory diagram of a first embodiment.

【図2】 評価装置全体図FIG. 2 is an overall view of an evaluation device.

【図3】 第2の実施の形態のサブプログラム終了判
定回路図
FIG. 3 is a circuit diagram of a subprogram end determination circuit according to a second embodiment;

【図4】 図3の補足図FIG. 4 is a supplementary diagram of FIG. 3;

【図5】 図3の回路のタイミングチャートFIG. 5 is a timing chart of the circuit of FIG. 3;

【図6】 第3の実施の形態の全体フローチャートFIG. 6 is an overall flowchart of a third embodiment.

【図7】 第3の実施の形態のサブプログラム終了判
定フローチャート
FIG. 7 is a flowchart of a subprogram end determination according to the third embodiment;

【図8】 第3の実施の形態のRET命令判定フロー
チャート
FIG. 8 is a flowchart for determining a RET instruction according to the third embodiment;

【図9】 従来の技術の基本処理説明図FIG. 9 is an explanatory diagram of basic processing of a conventional technique.

【図10】 リアルタイムOSを使用しない場合のプロ
グラム例
FIG. 10 shows a program example when a real-time OS is not used.

【図11】 図10のプログラムによるサブプログラム
呼出処理の模式図
11 is a schematic diagram of a subprogram calling process by the program of FIG.

【図12】 従来の技術のサブプログラム終了判定回路
And FIG. 12 is a circuit diagram of a sub-program end determination circuit according to the related art.

【図13】 図12の回路のタイミングチャート13 is a timing chart of the circuit in FIG.

【図14】 リアルタイムOSを使用した場合のプログ
ラム例
FIG. 14 shows an example of a program when a real-time OS is used.

【図15】 図14のプログラムによるタスクの切り替
わりの模式図
FIG. 15 is a schematic diagram of task switching by the program of FIG. 14;

【図16】 図14のプログラムのTASK_Aの処理
の流れ図
FIG. 16 is a flowchart of TASK_A processing of the program in FIG. 14;

【図17】 図14のプログラムのTASK_Bの処理
の流れ図
FIG. 17 is a flowchart of TASK_B processing of the program in FIG. 14;

【図18】 図14のプログラムのTASK_Aのスタ
ックの変化
FIG. 18 shows a change in the stack of TASK_A in the program of FIG.

【図19】 図14のプログラムのTASK_Bのスタ
ックの変化
FIG. 19 shows a change in the stack of TASK_B in the program of FIG.

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

1、6、8、フリップフロップ回路 2、OR回路 3、16入力NAND回路 4、EXNOR回路 5、16ビットラッチ回路 7、NOR回路 9、スーパバイザ割込要求端子 10、ステップ実行制御端子 11、CALLストローブ端子 12、RETストローブ端子 13、スタックポインタ出力端子 14、8入力OR回路 15、インバータ 16、アップダウンカウンタ 100、被デバッグプログラム 101、102、サブプログラム 103、スタックポインタのアドレス値保持手段 104、スタックポインタのアドレス値比較手段 105、スタックポインタのアドレス値出力信号 106、一致信号 107、被デバッグプログラムのCALL命令 108、サブプログラムの命令 109、被デバッグプログラムのCALLおよびRET
命令以外の命令 110、評価用プロセッサ 111、ステップ実行制御手段 112、命令実行処理 113、ステップ実行制御手段のフラグ状態を調べる処
理 114、命令実行結果の状態を調べる処理 200、プログラム評価装置 201、サブプログラム終了判定回路 202、中央処理装置、 203、制御プログラム用RAM 204、制御プログラム用ROM 205、評価用プロセッサ 206、スーパバイザプログラム用RAM 207、スーパバイザプログラム用ROM 208、被デバッグプログラム用RAM 209、被デバッグプログラム用ROM 210〜212、各種バス 213、リセット信号 214、ステップ実行制御信号 215、各種制御信号 216、ターゲットシステム 217、評価用プロセッサとターゲットシステム間の各
種バス 218、ホストコンピュータ 219〜222、I/Oポート
1, 6, 8, flip-flop circuit 2, OR circuit 3, 16-input NAND circuit 4, EXNOR circuit 5, 16-bit latch circuit 7, NOR circuit 9, supervisor interrupt request terminal 10, step execution control terminal 11, CALL strobe Terminal 12, RET strobe terminal 13, stack pointer output terminal 14, 8-input OR circuit 15, inverter 16, up / down counter 100, debugged programs 101, 102, subprogram 103, stack pointer address value holding means 104, stack pointer Value comparison means 105, stack pointer address value output signal 106, match signal 107, CALL instruction 108 of the program to be debugged, instruction 109 of the subprogram, CALL and RET of the program to be debugged
Non-instruction instruction 110, evaluation processor 111, step execution control means 112, instruction execution processing 113, processing of checking flag state of step execution control means 114, processing of checking instruction execution result state 200, program evaluation device 201, sub Program end determination circuit 202, central processing unit, 203, control program RAM 204, control program ROM 205, evaluation processor 206, supervisor program RAM 207, supervisor program ROM 208, debug program RAM 209, debug program Program ROM 210-212, various buses 213, reset signal 214, step execution control signal 215, various control signals 216, target system 217, evaluation processor and target system Of various bus 218, host computer 219~222, I / O port

Claims (5)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】第1のプログラムによる命令処理フローの
中に第2のプログラムが挿入されたプログラムの評価方
法において、前記第2のプログラムを呼び出すための命
令を実行したときのスタックポインタのアドレス値を保
持し、当該保持されたスタックポインタのアドレス値と
その後の命令実行におけるスタックポインタのアドレス
値とを比較して、両者が一致した場合に前記第2のプロ
グラムの実行終了を検出するプログラム評価方法。
1. An evaluation method of a program in which a second program is inserted in an instruction processing flow by a first program, wherein an address value of a stack pointer when an instruction for calling the second program is executed. A program evaluation method for comparing the stored address value of the stack pointer with the address value of the stack pointer in subsequent instruction execution, and detecting the end of the execution of the second program when the two match. .
【請求項2】第1および第2のプログラムを有し、前記
第1のプログラムの中に前記第2のプログラムを呼び出
す呼び出し命令を有するプログラムの評価方法におい
て、前記第1のプログラム中の前記呼び出し命令を検知
して、当該呼び出し命令の実行過程においてその時点の
スタックポインタのアドレス値を保持し、前記第2のプ
ログラムの実行において、さらに第3のプログラムを呼
び出す命令を実行する場合においてはスタックポインタ
のアドレス値を保持せず、前記第3のプログラムの呼び
出し命令を含む前記第2および第3のプログラムの命令
の実行におけるスタックポインタのアドレス値と前記保
持されたスタックポインタのアドレス値と比較し、両者
が一致した場合に前記第2のプログラムの実行終了を判
定するプログラム評価方法。
2. A method for evaluating a program having first and second programs, wherein the first program has a call instruction for calling the second program, wherein the call in the first program is performed. When the instruction is detected, the address value of the stack pointer at that time is held in the execution process of the call instruction, and when executing the instruction to call the third program further in the execution of the second program, the stack pointer And comparing the address value of the stack pointer with the address value of the held stack pointer in executing the instructions of the second and third programs including the call instruction of the third program, A program evaluation for judging the end of the execution of the second program when both match. Method.
【請求項3】複数のプログラムで構成されるプログラム
であり、第1のプログラムが第2のプログラムを呼び出
す処理を有するプログラムと、前記プログラムの実行に
より変化するスタックポインタのアドレス値を出力する
アドレス値出力手段と、前記アドレス値出力手段から出
力されたスタックポインタのアドレス値を保持するアド
レス値保持手段と、前記アドレス値保持手段に保持され
たスタックポインタのアドレス値と前記第2のプログラ
ムの実行において変化したスタックポインタのアドレス
値とを比較するアドレス値比較手段とを備えるプログラ
ム評価装置であって、前記アドレス値保持手段には前記
第1のプログラムにおいて前記第2のプログラムを呼び
出すときのスタックポインタのアドレス値が保持され、
前記アドレス値比較手段において前記保持されたスタッ
クポインタのアドレス値と前記変化したスタックポイン
タのアドレス値が一致した場合に前記第2のプログラム
の実行終了を検出するプログラム評価装置。
3. A program comprising a plurality of programs, wherein a first program has a process for calling a second program, and an address value for outputting an address value of a stack pointer which is changed by execution of the program. An output unit, an address value holding unit that holds an address value of a stack pointer output from the address value output unit, and an address value of the stack pointer held by the address value holding unit and the execution of the second program. An address value comparing means for comparing the changed address value of the stack pointer with an address value of the changed stack pointer, wherein the address value holding means stores a stack pointer at the time of calling the second program in the first program. Address value is retained,
A program evaluation device for detecting the end of execution of the second program when the address value of the stored stack pointer matches the address value of the changed stack pointer in the address value comparing means.
【請求項4】評価の対象である被デバッグプログラム
と、前記被デバッグプログラムが記憶される記憶手段
と、前記被デバッグプログラムを実行する評価用プロセ
ッサとを有するプログラム評価装置において、前記被デ
バッグプログラムは複数のサブプログラムから構成さ
れ、前記評価用プロセッサは前記被デバッグプログラム
のサブプログラム呼び出し命令の実行を示す制御信号
と、前記被デバッグプログラムの命令実行時に変化する
スタックポインタのアドレス値を示すアドレス値情報と
を出力する手段を有し、さらに前記制御信号によってセ
ットされるフリップフロップと、前記フリップフロップ
のセット信号が最初に発生したときの前記アドレス値情
報を保持し出力するアドレス値保持回路と、前記変化す
るアドレス値情報と前記アドレス値保持回路の出力とを
比較し、両者が一致したときに一致信号を発生するアド
レス値比較回路を備え、前記一致信号の発生により前記
サブプログラムの実行終了を検出することを特徴とする
プログラム評価装置。
4. A program evaluation apparatus comprising: a debugged program to be evaluated; storage means for storing the debugged program; and an evaluation processor for executing the debugged program. The evaluation processor comprises a plurality of subprograms, wherein the evaluation processor includes a control signal indicating execution of a subprogram call instruction of the debugged program, and address value information indicating an address value of a stack pointer that changes when the debugged program instruction is executed. A flip-flop set by the control signal; an address value holding circuit for holding and outputting the address value information when the flip-flop set signal is first generated; The changing address value information and the address Compares the output of less value holding circuit, an address value comparison circuit for generating a No. one match signal when they match, said the generation of said coincidence signal
A program evaluation device for detecting the end of execution of a subprogram.
【請求項5】前記アドレス値保持回路が、前記フリップ
フロップを第1のフリップフロップとすると、前記制御
信号と前記第1のフリップフロップのセット信号との論
理積をとる第1の論理積回路と、前記第1の論理積回路
の出力によりセットされる第2のフリップフロップと、
前記第2のフリップフロップのセット信号に応じて前記
アドレス値情報をラッチし出力するラッチ回路から構成
され、前記アドレス値比較回路が、前記アドレス値情報
と前記ラッチ回路の出力との対応するビット同志が入力
される、スタックポインタのアドレス値のビット数と同
数の排他的論理和回路と、前記排他的論理和回路の出力
の論理積をとる第2の論理積回路から構成されることを
特徴とする請求項4記載のプログラム評価装置
5. The flip-flop according to claim 1, wherein the address value holding circuit comprises a flip-flop.
If the flop is a first flip-flop, the control
Between signal and set signal of the first flip-flop
A first logical product circuit for calculating logical product, and the first logical product circuit
A second flip-flop set by the output of
According to the set signal of the second flip-flop,
Consists of a latch circuit that latches and outputs address value information
The address value comparison circuit is configured to store the address value information
And the corresponding bit between the output of the latch circuit and
The number of bits of the address value of the stack pointer
EXCLUSIVE-OR circuit and output of said exclusive-OR circuit
And a second AND circuit that takes the logical product of
5. The program evaluation device according to claim 4, wherein:
JP7299880A 1995-11-17 1995-11-17 Method and apparatus for program evaluation Expired - Fee Related JP2743889B2 (en)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP7299880A JP2743889B2 (en) 1995-11-17 1995-11-17 Method and apparatus for program evaluation
EP96118360A EP0778524A1 (en) 1995-11-17 1996-11-15 Method and device for evaluating a program
US08/751,619 US6185700B1 (en) 1995-11-17 1996-11-18 Method and device for evaluating a program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP7299880A JP2743889B2 (en) 1995-11-17 1995-11-17 Method and apparatus for program evaluation

Publications (2)

Publication Number Publication Date
JPH09146793A JPH09146793A (en) 1997-06-06
JP2743889B2 true JP2743889B2 (en) 1998-04-22

Family

ID=17878070

Family Applications (1)

Application Number Title Priority Date Filing Date
JP7299880A Expired - Fee Related JP2743889B2 (en) 1995-11-17 1995-11-17 Method and apparatus for program evaluation

Country Status (1)

Country Link
JP (1) JP2743889B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2018158032A (en) * 2017-03-23 2018-10-11 株式会社平和 Game machine

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS5914058A (en) * 1982-07-15 1984-01-24 Matsushita Electric Works Ltd Debugging device of program
JPS59121678A (en) * 1982-12-27 1984-07-13 Fujitsu Ltd Controlling method of write/read in/from stack
JPS61160146A (en) * 1984-12-31 1986-07-19 Fujitsu Ltd Control system of address stack pointer device
JPS63150732A (en) * 1986-12-16 1988-06-23 Fujitsu Ltd Program running supervisory equipment
JPH036618A (en) * 1989-06-02 1991-01-14 Fuji Electric Co Ltd Abnormality detecting circuit for stack pointer
JPH0348933A (en) * 1989-07-17 1991-03-01 Nec Corp Stack control circuit for return address

Also Published As

Publication number Publication date
JPH09146793A (en) 1997-06-06

Similar Documents

Publication Publication Date Title
US7840842B2 (en) Method for debugging reconfigurable architectures
JP4094724B2 (en) Apparatus and method for identifying exceptions when debugging software
JPH06100976B2 (en) Break point recognition device
JP2005317023A (en) Breakpoint logic unit, debug logic, and breakpoint method for data processing apparatus
JP2743889B2 (en) Method and apparatus for program evaluation
US20210357312A1 (en) Method and device for testing robustness and stability of smm, and storage medium
EP0829048B1 (en) Programmable instruction trap system and method
EP0778524A1 (en) Method and device for evaluating a program
EP0448127B1 (en) Microprogram sequence controller
JPH08171504A (en) Emulation device
JPS6385942A (en) Supporting device for debugging of parallel program
US11152076B2 (en) Apparatus and method for executing debug instructions
JP2990800B2 (en) Interrupt processing device
JPH0581087A (en) Processor monitoring system
JPS6270947A (en) Control system for debug interruption
JP3159155B2 (en) Method and apparatus for debugging program
KR100257772B1 (en) An apparatus for generating breakpoint in superscalar microprocessor
JPH0736735A (en) Debugging device
JPS5977553A (en) Data gathering system
JPH11167500A (en) Event circuit and debug system for emulator device
JPH0342734A (en) Automatic debugging system for hardware
JPH06282353A (en) Timer device having time shortening function
JPS6075945A (en) Program control type data processor provided with trigger timing function
JPH02118740A (en) Interruption generation circuit for debug
JPH04160650A (en) Microprocessor

Legal Events

Date Code Title Description
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 19980106

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

Free format text: PAYMENT UNTIL: 20080206

Year of fee payment: 10

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

Free format text: PAYMENT UNTIL: 20090206

Year of fee payment: 11

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

Free format text: PAYMENT UNTIL: 20100206

Year of fee payment: 12

LAPS Cancellation because of no payment of annual fees