JPH05216717A - Tracing function for debugger - Google Patents

Tracing function for debugger

Info

Publication number
JPH05216717A
JPH05216717A JP4042424A JP4242492A JPH05216717A JP H05216717 A JPH05216717 A JP H05216717A JP 4042424 A JP4042424 A JP 4042424A JP 4242492 A JP4242492 A JP 4242492A JP H05216717 A JPH05216717 A JP H05216717A
Authority
JP
Japan
Prior art keywords
instruction
program
debugged
address
return
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP4042424A
Other languages
Japanese (ja)
Inventor
Yuji Hara
雄司 原
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 JP4042424A priority Critical patent/JPH05216717A/en
Publication of JPH05216717A publication Critical patent/JPH05216717A/en
Pending legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

PURPOSE:To find out failure due to the mis-operation of a stack, etc., by checking return to a call origin with a returning instruction in the subroutine of a program to be debugged as the function of a debugger. CONSTITUTION:When the program 100 to be debugged is executed at a single step processing part 120 by one instruction and a subroutine call instruction is executed, an address when it is returned from the subroutine is preserved in a returning address preservation part 140 in advance. Then, the program 100 is executed by one instruction and when an operation is restored from a subroutine, the address returned actually is compared with the address preserved in advance by a returning address checking part 180. Thereby, it is possible to confirm whether or not the address is going to return to the one to be returned originally.

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、デバッガのトレース機
能に関し、特にサブルーチンのリターンアドレスチェッ
ク機能に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a debugger trace function, and more particularly to a subroutine return address check function.

【0002】[0002]

【従来の技術】従来のトレース機能は、被デバッグプロ
グラムの1命令のみを実行させるシングルステップ機能
や任意の位置で被デバッグプログラムの実行を中断させ
るブレークポイント機能を有している。
2. Description of the Related Art A conventional trace function has a single step function for executing only one instruction of a debugged program and a breakpoint function for interrupting the execution of the debugged program at an arbitrary position.

【0003】[0003]

【発明が解決しようとする課題】この従来のトレース機
能では、単に1命令ずつ実行したり予め実行を中断する
場所を指定し実行を行なうだけの機能であるため、スタ
ッフ操作の誤りによりリターン命令でコール元に制御が
戻らず途中で暴走してしまうようなサブルーチンを含む
プログラムの場合、その誤りの場所を見つけにくいとい
う問題点があった。
Since the conventional trace function is a function that simply executes instructions one by one or specifies a place where the execution is interrupted in advance and executes the instructions, a return instruction is issued due to an error in the staff operation. In the case of a program including a subroutine that does not return control to the caller and goes out of control on the way, there is a problem that it is difficult to find the location of the error.

【0004】[0004]

【課題を解決するための手段】本発明のデバッガのトレ
ース機能は、被デバッグプログラムのトレースを行う範
囲を操作者に指定させる手段と、指定された範囲の被デ
バッグプログラムを1命令ずつ実行させる手段と、被デ
バッグプログラムの次に実行される命令を逆アセンブル
する手段と、被デバッグプログラム内のリターンアドレ
スを保存する手段と、逆アセンブルした命令がルーチン
コール命令・リターン命令・その他の命令のどれである
か判断する手段と、被デバッグプログラムのルーチンコ
ール命令の次の命令のアドレスを出力する手段と、リタ
ーンアドレスを最も新しく保存されたものから順番に読
み出す手段と、被デバッグプログラムを1命令実行させ
た後インストラクションポインタレジスタの値がリター
ンアドレスの保存部より読み出したリターンアドレスと
一致するか判断する手段と、一致しない場合に限ってそ
の旨を操作者に知らせる手段とを備えている。
The trace function of the debugger of the present invention includes means for allowing the operator to specify the range to be traced for the debugged program and means for executing the debugged program in the specified range one instruction at a time. , A means for disassembling the instruction to be executed next to the debugged program, a means for saving the return address in the debugged program, and whether the disassembled instruction is a routine call instruction, a return instruction, or another instruction. There is a means for judging whether there is any, a means for outputting the address of the instruction next to the routine call instruction of the program to be debugged, a means for reading the return address in order from the most recently saved one, and executing one instruction of the program to be debugged. The value of the instruction pointer register after saving the return address Means for determining if it matches more read return address, and a means for notifying to that effect to the operator only if they do not match.

【0005】[0005]

【実施例】次に本発明について図面を参照して説明す
る。
The present invention will be described below with reference to the drawings.

【0006】図1は、本発明の一実施例のブロック図で
ある。
FIG. 1 is a block diagram of an embodiment of the present invention.

【0007】100は、被デバッグプログラムである。
操作者は、トレース範囲指定部110により、デバッガ
のトレースを行なう範囲を指定する。被デバッグプログ
ラム100を1命令ずつ実行させるシングルステップ処
理部120はトレース範囲指定部110によって指定さ
れた範囲の被デバッグプログラムを1命令ずつ実行させ
る。1命令が実行されるたびに次の命令を次命令逆アセ
ンブル部130は逆アセンブルして次の命令が何である
か解析する。命令判断部150は、この解析された命令
がルーチンコール命令・リターン命令・その他の命令の
うちどの命令か判断する。
Reference numeral 100 is a program to be debugged.
The operator uses the trace range specifying unit 110 to specify the range in which the debugger traces. The single-step processing unit 120 that executes the debugged program 100 one instruction at a time causes the debugged program in the range designated by the trace range designating unit 110 to be executed one instruction at a time. Each time one instruction is executed, the next instruction disassembler 130 disassembles the next instruction and analyzes what the next instruction is. The instruction determination unit 150 determines which of the routine call instruction, the return instruction, and the other instructions the analyzed instruction is.

【0008】リターンアドレス出力部160は、ルーチ
ンコール命令のとき実行され被デバッグプログラムのル
ーチンコール命令の次の命令すなわちサブルーチンから
復帰してくるときのアドレスをリターンアドレス保存部
140に出力する。
The return address output unit 160 outputs to the return address storage unit 140 the address at the time of returning from the instruction following the routine call instruction of the program to be debugged, that is, the subroutine, which is executed at the routine call instruction.

【0009】リターンアドレス保存部140には、ルー
チンコール命令が実行されるたびにリターンアドレスが
保存されていく。
The return address storage unit 140 stores return addresses each time a routine call instruction is executed.

【0010】リターンアドレス読み出し部170は、命
令判断部150で逆アセンブルした結果がリターン命令
であると判断された場合実行される。リターンアドレス
読み出し部170は、最も最近に保存されたリターンア
ドレスをリターンアドレス保存部140から読み出す。
The return address reading unit 170 is executed when the instruction determining unit 150 determines that the disassembled result is a return instruction. The return address reading unit 170 reads the most recently stored return address from the return address storage unit 140.

【0011】リターンアドレス保存部140では1回デ
ータが読まれるとそのデータは消去される。リターンア
ドレス読み出し部170で読み出されたリターンアドレ
スはリターンアドレスチェック部180に渡される。
When the data is read once in the return address storage unit 140, the data is erased. The return address read by the return address reading unit 170 is passed to the return address checking unit 180.

【0012】リターンアドレスチェック部180は、シ
ングルステップ処理部120により被デバッグプログラ
ム100を1命令実行させる。この場合は、かならずリ
ターン命令が実行される。そして、実行後のインストラ
クションポインタレジスタの値とリターンアドレス読み
出し部170から渡されたアドレスと比較を行なう。リ
ターン命令で正常に復帰した場合は前述の比較は一致す
る。
The return address check unit 180 causes the debugged program 100 to execute one instruction by the single step processing unit 120. In this case, the return instruction is always executed. Then, the value of the instruction pointer register after execution is compared with the address passed from the return address reading unit 170. If the return instruction returns normally, the above comparisons match.

【0013】もし、サブルーチン内の処理でスタッフ操
作の不具合があるとここでは、不一致となる場合があ
る。このときは、エラー出力部190により、不具合が
発生したことを操作者に通知するとともに被デバッグプ
ログラム100の実行は停止される。
If there is a defect in the staff operation in the processing in the subroutine, there may be a mismatch here. At this time, the error output unit 190 notifies the operator that a failure has occurred and the execution of the debugged program 100 is stopped.

【0014】図2は、スタッフ操作の不具合を含んだ被
プログラムのソースリストの例である。
FIG. 2 is an example of a source list of a program including a malfunction of staff operation.

【0015】メインプログラム200はサブルーチン2
10及びサブルーチン220を呼び出す。サブルーチン
220はRET命令224を実行する前にPOP命令を
実行しておらず不具合を含んでいる。
The main program 200 is the subroutine 2
10 and subroutine 220 is called. The subroutine 220 does not execute the POP command before executing the RET command 224, and thus contains a defect.

【0016】次に、図2のプログラム200を被デバッ
グプログラム100とした場合の動作について詳細に説
明する。操作者は、200のプログラムをトレースの範
囲としてトレース範囲指定部110により入力する。シ
ングルステップ処理部120は、200を先頭から実行
していく。次命令逆アセンブル部130と命令判断部1
50は、次々と被デバッグプログラムを解析していく。
ステップ201に達したとき命令判断部150は、解析
結果がサブルーチンコール命令であると判断して、リタ
ーンアドレス出力部160が実行される。
Next, the operation when the program 200 of FIG. 2 is used as the program to be debugged 100 will be described in detail. The operator inputs 200 programs as a trace range by the trace range designation unit 110. The single-step processing unit 120 executes 200 from the beginning. Next instruction disassembler 130 and instruction determiner 1
50 sequentially analyzes the program to be debugged.
When step 201 is reached, the instruction determination unit 150 determines that the analysis result is a subroutine call instruction, and the return address output unit 160 is executed.

【0017】これにより、ステップ201の次の命令で
あるステップ202のNOP命令のアドレスがリターン
アドレス保存部140に保存される。
As a result, the address of the NOP instruction of step 202, which is the next instruction of step 201, is stored in the return address storage section 140.

【0018】続いて、ステップ211〜214が次々に
実行されていく。
Then, steps 211 to 214 are executed one after another.

【0019】ステップ215に達すると、この命令はリ
ターン命令であるため命令制御部150により、リター
ンアドレス読み出し部170が実行され、先ほど保存し
たリターンアドレスが、リターンアドレス保存部140
より読み出される。そして、リターンアドレスチェック
部180がシングルステップ処理部120を実行させる
ことにより、ステップ215が実行され、ステップ20
2のアドレスがインストラクションポインタレジスタに
ロードされる。そして、140より読み出された値と比
較される。この場合は一致するため続けて処理が続く。
When step 215 is reached, since this instruction is a return instruction, the instruction control unit 150 causes the return address reading unit 170 to execute, and the return address stored earlier is returned to the return address storage unit 140.
Will be read. Then, the return address check unit 180 causes the single-step processing unit 120 to execute, so that Step 215 is executed, and Step 20 is executed.
The address of 2 is loaded into the instruction pointer register. Then, it is compared with the value read from 140. In this case, since they match, the processing continues.

【0020】ステップ203で同様にして、ステップ2
04のアドレスがリターンアドレス保存部140に保存
される。前記と同様な手順によってステップ224に達
したとき同様にリターン命令が実行され後、リターンア
ドレスの比較が行なわれるがPOP命令が実行されてお
らずサブルーチン220に不具合があるため一致せず、
エラー出力部190が実行され、その旨が通知されると
ともにトレースが中止される。
Similarly in step 203, step 2
The address 04 is stored in the return address storage unit 140. When the step 224 is reached in the same procedure as described above, the return instruction is executed in the same manner, and the return addresses are compared, but the POP instruction is not executed and the subroutine 220 has a problem.
The error output unit 190 is executed, the fact is notified, and the trace is stopped.

【0021】[0021]

【発明の効果】以上説明したように本発明は、被デバッ
グプログラム内のサブルーチンでリターン命令が実行さ
れたとき復帰するアドレスがそのサブルーチンをコール
したコール命令の次のアドレスになっているかデバッガ
が自動的にチェックするため、手間をかけずにスタック
操作の不具合を見つけることができる。
As described above, according to the present invention, whether the address to be returned when the return instruction is executed in the subroutine in the program to be debugged is the address next to the call instruction that called the subroutine is automatically determined by the debugger. Since it checks automatically, it is possible to find defects in stack operation without much effort.

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

【図1】本発明の一実施例のブロック図FIG. 1 is a block diagram of an embodiment of the present invention.

【図2】スタッフ操作の不具合を含んだ被プログラムソ
ース例
[Fig.2] Example of program source that includes a defect in staff operation

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

100 被デバッグプログラム 110 トレース範囲指定部 120 シングルステップ処理部 130 次命令逆アセンブル部 140 リターンアドレス保存部 150 命令判断部 160 リターンアドレス出力部 170 リターンアドレス読み出し部 180 リターンアドレスチェック部 190 エラー出力部 200 被デバッグプログラムソースリストの例 210、220 被デバッグプログラムサブルーチンの
例 201〜204、211〜215、221〜224 被
デバッグプログラム各ステップ
100 Debugged program 110 Trace range specification section 120 Single step processing section 130 Next instruction disassemble section 140 Return address storage section 150 Instruction judgment section 160 Return address output section 170 Return address read section 180 Return address check section 190 Error output section 200 Target Example of debug program source list 210, 220 Example of subroutine to be debugged 201 to 204, 211 to 215, 221 to 224 Steps to be debugged program

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 被デバッグプログラムのトレースを行う
範囲を操作者に指定させる手段と、指定された範囲の被
デバッグプログラムを1命令ずつ実行させる手段と、被
デバッグプログラムの次に実行される命令を逆アセンブ
ルする手段と、被デバッグプログラム内のリターンアド
レスを保存する手段と、逆アセンブルした命令がルーチ
ンコール命令・リターン命令・その他の命令のどれであ
るか判断する手段と、被デバッグプログラムのルーチン
コール命令の次の命令のアドレスを出力する手段と、リ
ターンアドレスを最も新しく保存されたものから順番に
読み出す手段と、被デバッグプログラムを1命令実行さ
せた後インストラクションポインタレジスタの値がリタ
ーンアドレスの保存部より読み出したリターンアドレス
と一致するか判断する手段と、一致しない場合に限って
その旨を操作者に知らせる手段を備えることを特徴とす
るデバッガのトレース機能。
1. A means for causing an operator to specify a trace range of a debugged program, a means for executing the debugged program in the specified range one instruction at a time, and an instruction executed next to the debugged program. A means for disassembling, a means for storing the return address in the program to be debugged, a means for determining whether the disassembled instruction is a routine call instruction, a return instruction, or another instruction, and a routine call for the debugged program A means for outputting the address of the instruction next to the instruction, a means for reading the return address in order from the most recently stored one, and a value of the instruction pointer register after executing one instruction of the program to be debugged Judgment whether it matches the read return address Trace function of the debugger, which is provided with means for notifying the operator of the fact that the means does not match.
JP4042424A 1992-01-31 1992-01-31 Tracing function for debugger Pending JPH05216717A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4042424A JPH05216717A (en) 1992-01-31 1992-01-31 Tracing function for debugger

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4042424A JPH05216717A (en) 1992-01-31 1992-01-31 Tracing function for debugger

Publications (1)

Publication Number Publication Date
JPH05216717A true JPH05216717A (en) 1993-08-27

Family

ID=12635681

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4042424A Pending JPH05216717A (en) 1992-01-31 1992-01-31 Tracing function for debugger

Country Status (1)

Country Link
JP (1) JPH05216717A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007148529A (en) * 2005-11-24 2007-06-14 Nippon Telegr & Teleph Corp <Ntt> Buffer overflow detection device, buffer overflow detection method, and buffer overflow detection program
JPWO2005024630A1 (en) * 2003-09-04 2007-11-08 サイエンスパーク株式会社 Method and program for preventing illegal code
JP2008107908A (en) * 2006-10-23 2008-05-08 Nec Electronics Corp Data analysis system

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPWO2005024630A1 (en) * 2003-09-04 2007-11-08 サイエンスパーク株式会社 Method and program for preventing illegal code
JP4518564B2 (en) * 2003-09-04 2010-08-04 サイエンスパーク株式会社 Method for preventing unauthorized code execution, program for preventing unauthorized code execution, and recording medium for program for preventing unauthorized code execution
JP2007148529A (en) * 2005-11-24 2007-06-14 Nippon Telegr & Teleph Corp <Ntt> Buffer overflow detection device, buffer overflow detection method, and buffer overflow detection program
JP2008107908A (en) * 2006-10-23 2008-05-08 Nec Electronics Corp Data analysis system

Similar Documents

Publication Publication Date Title
US7353500B2 (en) Suppressing execution of monitoring measurement program pointed to by inserted branch after threshold number of coverage to reduce instruction testing overhead
KR940003318B1 (en) Processor having cache memory
JPH05216717A (en) Tracing function for debugger
JPH05250221A (en) Simulator execution system
KR950005523B1 (en) Step-run processing method of programmable logic controller
JPH1049401A (en) Method for debugging program
US7627859B2 (en) Method for configuring non-script language library files to be run as scripts
JPH0215340A (en) Control system for state history memory device
JPH03294934A (en) Debugger for high level program lenguage
JPH04149746A (en) Debug device
JPS6240550A (en) Program debug device
JPH05233363A (en) Tracing device for emulator
JPH0573347A (en) Emulation device
JPH06259283A (en) Program development supporting device
JPH0683670A (en) Program test device
JPH05224985A (en) Microprogram controller
JPH03223938A (en) Return address monitoring circuit for debugging device
JPS60147849A (en) System for debugging microprogram
JPH05100898A (en) Program debugging system
JPH01161544A (en) Program tracing system
JPH01106237A (en) Program debugging system
JPH064333A (en) Break point setting device
JPH08241225A (en) Evaluating device
JPH04367902A (en) Programmable controller
JPH01276342A (en) Program debugging method