JP3309792B2 - Stack pointer trace device, stack pointer trace method, and recording medium - Google Patents

Stack pointer trace device, stack pointer trace method, and recording medium

Info

Publication number
JP3309792B2
JP3309792B2 JP00761498A JP761498A JP3309792B2 JP 3309792 B2 JP3309792 B2 JP 3309792B2 JP 00761498 A JP00761498 A JP 00761498A JP 761498 A JP761498 A JP 761498A JP 3309792 B2 JP3309792 B2 JP 3309792B2
Authority
JP
Japan
Prior art keywords
instruction
program
code
stack pointer
stack
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
JP00761498A
Other languages
Japanese (ja)
Other versions
JPH11203166A (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 JP00761498A priority Critical patent/JP3309792B2/en
Publication of JPH11203166A publication Critical patent/JPH11203166A/en
Application granted granted Critical
Publication of JP3309792B2 publication Critical patent/JP3309792B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Executing Machine-Instructions (AREA)
  • Debugging And Monitoring (AREA)

Description

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

【0001】[0001]

【発明の属する技術分野】この発明は、プログラムの実
行中におけるスタック領域の使用状況を検証する装置及
び方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to an apparatus and a method for verifying the use status of a stack area during execution of a program.

【0002】[0002]

【従来の技術】コンピュータ等が実行するプログラムを
開発する上では、生成したプログラムのプログラムコー
ドに含まれる誤りを発見して修正する過程、すなわちデ
バッグが不可欠である。そして、デバッグにおいては、
通常、プログラムがデータを記憶するために確保する領
域であるスタック領域が正しく使用されているか否かを
検証する過程が必要である。また、プログラムが使用す
るメモリ容量を節約するためには、スタック領域のサイ
ズを必要最小限に抑えることが必要である。そして、ス
タック領域の必要最小限のサイズを知るためには、スタ
ック領域の使用状況を検証することが必要である。
2. Description of the Related Art In developing a program to be executed by a computer or the like, a process of finding and correcting an error contained in a program code of a generated program, that is, debugging is indispensable. And for debugging,
In general, it is necessary to perform a process of verifying whether or not a stack area, which is an area secured by a program for storing data, is correctly used. Also, in order to save the memory capacity used by the program, it is necessary to minimize the size of the stack area. Then, in order to know the minimum required size of the stack area, it is necessary to verify the usage status of the stack area.

【0003】スタックの使用状況を取得する手法として
は、プログラムが実行される前にスタック領域に任意の
値を埋め込んでおき、一定程度プログラムが実行されて
からスタック領域を参照し、埋め込まれた値が変更され
ているか否かを判別することによってスタックの使用状
況を確認する手法が考えられる。
[0003] As a method of acquiring the usage status of the stack, an arbitrary value is embedded in the stack area before the program is executed, and after the program is executed to a certain extent, the stack area is referred to and the embedded value is read. There is a method of confirming the use state of the stack by determining whether or not the stack has been changed.

【0004】[0004]

【発明が解決しようとする課題】しかし、この手法で
は、プログラムが一定程度実行された後のスタックの使
用結果が把握されるに過ぎず、正確な使用状況を把握す
ることができないという問題が生じる。また、この手法
では、スタック領域外など不当なアドレスへのアクセス
を行っているか否かの情報が得られないという問題もあ
る。
However, in this method, the use result of the stack after the program has been executed to a certain extent is merely ascertained, and there is a problem that it is not possible to ascertain an accurate use state. . In addition, this method has a problem in that it is not possible to obtain information as to whether an illegal address such as outside the stack area is accessed.

【0005】これらの問題を解決する手法としては、例
えば、特開平4−131937に開示されているもの
や、特開平5−113902に開示されているものが考
えられる。
As a method for solving these problems, for example, a method disclosed in JP-A-4-131937 and a method disclosed in JP-A-5-113902 can be considered.

【0006】特開平4−131937に開示されている
手法においては、スタック領域の使用状況を検証する対
象の実行プログラムが実行される前に、そのスタック領
域(結果退避情報格納部)に、その実行プログラムが正
常に実行された場合に読み出されるべき値(正解退避情
報)が予め埋め込まれる。そして、その実行プログラム
の処理が一定程度進行してから、その実行プログラムが
結果退避情報格納部に退避したデータの内容を確認する
ことにより、結果退避情報格納部の使用状況を検証す
る。
In the technique disclosed in Japanese Patent Application Laid-Open No. 4-131937, the execution program to be used for verifying the usage status of the stack area is stored in the stack area (result save information storage unit) before the execution program is executed. A value (correct answer save information) to be read out when the program is executed normally is embedded in advance. Then, after the processing of the execution program has progressed to a certain extent, the execution program checks the contents of the data saved in the result saving information storage unit, thereby verifying the use status of the result saving information storage unit.

【0007】特開平5−113902に開示されている
手法においては、マイクロプログラムを実行するマイク
ロプロセッサがサブルーチンをコールすると、スタック
ファイルにマイクロプログラムアドレスがプシュダウン
され、さらに、マイクロプログラムアドレスと、該マイ
クロプログラムアドレスの格納位置を示すスタックポイ
ンタがトレーサに格納される。そして、サブルーチンか
ら元のルーチンにリターンするときは、スタックファイ
ルからマイクロプログラムアドレスがポップアップさ
れ、ポップアップされた当該マイクロプログラムアドレ
スは、該マイクロプログラムアドレスが格納されていた
位置を示すスタックポインタと共に、トレーサに格納さ
れる。
In the method disclosed in Japanese Patent Application Laid-Open No. 5-113902, when a microprocessor executing a microprogram calls a subroutine, a microprogram address is pushed down to a stack file, and a microprogram address and the microprogram address are further reduced. A stack pointer indicating the storage location of the program address is stored in the tracer. Then, when returning from the subroutine to the original routine, the microprogram address is popped up from the stack file, and the popped up microprogram address is stored in the tracer together with the stack pointer indicating the position where the microprogram address was stored. Is stored.

【0008】しかし、特開平4−131937の手法に
よった場合、予め正解退避情報が明らかになっている必
要がある。このため、予め正解退避情報を知ることが困
難な処理の場合は、この手法を用いることが困難であ
る。また、プログラムが、本来読み出すべきアドレスか
ら正解退避情報を読み出さないというバグを含む場合、
正解退避情報は正しく読み出されないので、そのプログ
ラムによる処理は所期の通りに進行しないこととなる。
However, according to the method disclosed in Japanese Patent Laid-Open No. 4-131937, it is necessary that the correct answer evacuation information has been clarified in advance. For this reason, it is difficult to use this method in the case of a process in which it is difficult to know correct answer evacuation information in advance. Also, if the program contains a bug that the correct answer save information is not read from the address that should be read,
Since the correct answer save information is not correctly read, the processing by the program does not proceed as expected.

【0009】また、特開平5−113902の手法で
は、プシュダウン及びポップアップされたデータのスタ
ックファイル内における配置が明らかとなるに過ぎず、
それらのデータが、どのマイクロプログラムのいかなる
処理の結果プシュダウン及びポップアップされたもので
あるかを知ることができない。
In the method disclosed in Japanese Patent Laid-Open No. 5-113902, only the arrangement of push-down and pop-up data in a stack file becomes clear.
It is impossible to know which data has been pushed down and popped up as a result of what processing of which microprogram.

【0010】この発明は上記実状に鑑みてなされたもの
で、プログラムを実行中に、そのプログラムによるスタ
ックの使用状況が正確に把握できるスタックポインタト
レース装置及びスタックポインタトレース方法を提供す
ることを目的とする。
The present invention has been made in view of the above circumstances, and has as its object to provide a stack pointer tracing device and a stack pointer tracing method that can accurately grasp the state of use of a stack by a program during execution of the program. I do.

【0011】[0011]

【課題を解決するための手段】上記目的を達成するた
め、この発明の第1の観点にかかるスタックポインタト
レース装置は、スタック領域にアクセスしてデータを読
み書きするプログラムが実行される間に、前記データを
読み書きする位置を指示するスタックポインタの指示先
を示すアドレスを記録するためのスタックポインタトレ
ース装置であって、前記プログラムのプログラムコード
を記憶するプログラム記憶手段と、前記プログラム記憶
手段が記憶する前記プログラムコード上における、前記
スタックポインタの指示先を変更する命令を表す命令コ
ードが記述されている位置を特定し、該命令コードを所
定のマーカに置換する命令変更手段と、前記命令変更手
段により前記マーカに置換された前記命令コードと、
換された該命令コードが記述されていた前記プログラム
コード上の位置を示す情報とを、互いに対応付けて記憶
する被置換命令記憶手段と、前記命令変更手段により
置を特定された前記命令コードが前記マーカに置換され
た前記プログラムコードに含まれる命令コードを逐次実
行しつつマーカを検出するプログラム実行手段と、前
記プログラム実行手段が検出したマーカの位置を特定
て、前記被置換命令記憶手段に記憶されている前記命令
コードのうち、位置を特定したマーカの位置に記述さ
れていたものを特定する被置換命令特定手段と、前記ス
タックポインタが現に指示している箇所と、前記被置換
命令特定手段により特定された前記命令コードとに基づ
いて、特定された該命令コードが実行された場合におい
て前記スタックポインタが指示すべき箇所を特定し、特
定された前記箇所を示すアドレスを記録する解析手段と
を備え、前記プログラム実行手段は、前記被置換命令特
定手段により特定された前記命令コードを前記被置換命
令特定手段より取得して実行し、該命令コードに続いて
実行されるべき命令コードを逐次実行する手段を備え
る、ことを特徴とする。
In order to achieve the above object, a stack pointer tracing device according to a first aspect of the present invention provides a stack pointer tracing device that executes a program for accessing a stack area and reading and writing data. What is claimed is: 1. A stack pointer trace device for recording an address indicating a point indicated by a stack pointer indicating a position at which data is read / written, wherein: a program storage means for storing a program code of the program; and An instruction code representing an instruction on the program code for changing a destination indicated by the stack pointer.
To locate where over de is described, an instruction changing means for replacing the instruction code to a predetermined marker, and the instruction code is substituted into the marker by the instruction changing means, location
And information indicating a position on said program code conversion has been instruction code has been written, and the replaced instruction storage means for storing in association with each other, position by the instruction changing means
And program executing means for detecting the marker while executing the instruction code the instruction code identifying the location is included in the program code is replaced with the marker sequentially specifies the position of the marker in which the program executing means detects to the one of the instruction codes stored in the replacement instruction storage means, and the replacement instruction specifying means for specifying what was described on the position of the marker identifying the location, the stack pointer is currently indicated And specifying the location to be indicated by the stack pointer when the specified instruction code is executed, based on the location where the instruction code is specified and the instruction code specified by the replaced instruction specifying means. Analyzing means for recording an address indicating the location, wherein the program executing means is specified by the replaced instruction specifying means. Executing the instruction code acquired from the object to be substituted command specifying means comprises means for sequentially executing the instruction code to be executed following the instruction code, and wherein the.

【0012】このようなスタックポインタトレース装置
によれば、スタックポインタの指示先のアドレスが変更
される度に、該アドレスが前記解析手段により蓄積され
る。また、スタックポインタの指示先のアドレスを変更
する命令を示す命令コードは、前記被置換命令特定手段
により特定されるので、スタックポインタの指示先のア
ドレスが変更された原因も特定される。
According to such a stack pointer tracing device, the address is accumulated by the analyzing means each time the address indicated by the stack pointer is changed. Further, since the instruction code indicating the instruction for changing the address of the stack pointer is specified by the replaced instruction specifying means, the cause of the change of the address of the stack pointer is also specified.

【0013】前記プログラム実行手段は、前記スタック
領域のうち自らが実行している前記プログラムが使用す
る対象である部分を識別する識別情報を記憶する手段を
備え、前記解析手段は、前記スタック領域のうちの特定
の部分を識別する識別情報を記憶する手段と、前記プロ
グラム実行手段より、前記プログラム実行手段が記憶し
ている前記識別情報を取得して、取得した該識別情報
が、前記解析手段自身が記憶する前記識別情報と実質的
に同一の部分を示すか否かを判別し、示すと判別された
とき、前記被置換命令特定手段により特定された命令コ
ードが実行された場合においてスタックポインタが指示
すべきアドレスを特定する手段とを備えるものであって
もよい。これにより、スタックポインタの指示先のアド
レスの変更のうち、特定のプログラムにより行われた分
が特定されるので、スタックポインタの指示先のアドレ
スがどのプログラムによりどのように変更されたかを示
す情報が得られる。
[0013] The program execution means may include the stack
And means for storing identification information identifying the portion is a subject that the program itself is running using in the region, said analysis means, certain of the stack area
Means for storing identification information for identifying the parts, from the program execution unit obtains the identification information the program execution unit is stored, acquired identification information, said analysis means itself stores It is determined whether or not the identification information indicates a substantially same part. When it is determined that the identification information indicates the same part , the stack pointer should indicate when the instruction code specified by the replaced instruction specifying means is executed. Means for specifying an address. As a result, of the change of the address of the pointer indicated by the stack pointer, the portion performed by the specific program is specified, and information indicating how and by which program the address of the stack pointer is changed is specified. can get.

【0014】前記解析手段は、前記スタック領域のうち
前記プログラムが使用し得る部分の範囲を特定するスタ
ック領域情報を記憶するスタック領域記憶手段と、該解
析手段自身により特定された前記アドレスが、前記スタ
ック領域情報が示す範囲内にあるか否かを判別し、ない
と判別された場合に判別結果を外部に通知する異常アク
セス通知手段とを備えるものであってもよい。これによ
り、プログラムが使用し得ないアドレスをスタックポイ
ンタが指示した場合、該プログラムの異常が通知され
る。このため、この通知を受けた操作者等により前記プ
ログラムの強制終了などの措置が講じられれば、他のプ
ログラムの処理の混乱などが回避される。
[0014] The analyzing means includes a stack area storage means for storing a stack area information specifying a range of <br/> the part program may be used among the stack area, said specified by the analysis unit itself An abnormal access notifying unit that determines whether the address is within the range indicated by the stack area information and notifies the outside of the determination result when it is determined that the address is not present may be provided. Thus, when the stack pointer points to an address that cannot be used by the program, an abnormality of the program is notified. For this reason, if measures such as forced termination of the program are taken by the operator or the like who has received this notification, confusion in the processing of other programs is avoided.

【0015】前記異常アクセス通知手段は、前記解析手
段により特定された前記アドレスが前記スタック領域情
報が示す範囲内にないと判別された場合に、前記プログ
ラム実行手段が実行している前記プログラムの処理を停
止する手段を備えるものであってもよい。これにより、
プログラムが使用し得ないアドレスをスタックポインタ
が指示した場合、該プログラムは強制終了されるので、
他のプログラムの処理の混乱などが回避される。
[0015] The abnormal access notifying means, when it is determined that the address specified by the analyzing means is not within the range indicated by the stack area information, processes the program executed by the program executing means. May be provided. This allows
If the stack pointer points to an address that cannot be used by the program, the program is forcibly terminated.
Confusion of the processing of other programs is avoided.

【0016】前記プログラム実行手段は、前記スタック
領域のうちの前記プログラムが使用し得る部分の範囲
変更するための前記命令コードを検知するスタック変更
命令検知手段と、前記スタック変更命令検知手段が検知
した前記命令コードを実行したとき、変更後の前記範囲
を特定する前記スタック領域情報を新たに作成し、前記
スタック領域記憶手段に記憶されている変更前の前記ス
タック領域情報を、新たに作成された前記スタック領域
情報に更新する手段とを備えるものであってもよい。こ
れにより、前記プログラムにより前記スタック領域が変
更された場合も、変更後のスタック領域からスタックポ
インタの指示先が逸脱するか否かが監視される。
[0016] The program executing means may include the stack
And the stack change instruction detecting means for detecting the instruction codes to change the range of the portion where the program can be used out of the region, when the stack change instruction detecting means executes the instruction code is detected, the changed The stack area information that specifies the range is newly created, and the stack area information before the change stored in the stack area storage unit is updated to the newly created stack area information. And means for performing the same. Thus, even when the stack area is changed by the program, it is monitored whether or not the point indicated by the stack pointer deviates from the changed stack area.

【0017】また、この発明の第2の観点にかかるスタ
ックポインタトレース方法は、スタック領域にアクセス
してデータを読み書きするプログラムが実行される間
に、前記データを読み書きする位置を指示するスタック
ポインタの指示先を示すアドレスを記録するためのスタ
ックポインタトレース方法であって、前記プログラムの
プログラムコードを記憶するプログラム記憶ステップ
と、前記プログラム記憶ステップが記憶する前記プログ
ラムコード上における、前記スタックポインタの指示先
を変更する命令を表す命令コードが記述されている位置
を特定し、該命令コードを所定のマーカに置換する命令
変更ステップと、前記命令変更ステップにより前記マー
カに置換された前記命令コードと、置換された該命令コ
ードが記述されていた前記プログラムコード上の位置を
示す情報とを、互いに対応付けて記憶する被置換命令記
憶ステップと、前記命令変更ステップにより位置を特定
された前記命令コードが前記マーカに置換された前記プ
ログラムコードに含まれる前記命令コードを逐次実行し
つつマーカを検出するプログラム実行ステップと、前
記プログラム実行ステップが検出したマーカの位置を
して、前記被置換命令記憶ステップに記憶されている
前記命令コードのうち、位置を特定したマーカの位置
に記述されていたものを特定する被置換命令特定ステッ
プと、前記スタックポインタが現に指示している箇所
と、前記被置換命令特定ステップにより特定された前記
命令コードとに基づいて、特定された該命令コードが実
行された場合において前記スタックポインタが指示すべ
き箇所を特定し、特定された前記箇所を示すアドレスを
記録する解析ステップとを備え、前記プログラム実行ス
テップは、前記被置換命令特定ステップにより特定され
た前記命令コードを前記被置換命令特定ステップより取
得して実行し、該命令コードに続いて実行されるべき命
令コードを逐次実行するステップを備える、ことを特徴
とする。
Further, in a stack pointer tracing method according to a second aspect of the present invention, during execution of a program for accessing a stack area and reading and writing data, a stack pointer for indicating a position at which the data is read and written is read. A stack pointer tracing method for recording an address indicating an instruction destination, comprising: a program storage step for storing a program code of the program; and an instruction destination of the stack pointer on the program code stored in the program storage step. identify positions are described instruction code representing the instruction to change the instruction changing step of replacing the instruction code to a predetermined marker, and the instruction code is substituted into the marker by the instruction changing step, replacing has been the instruction code has been written Identifying information indicating the position on the serial program code, and the replaced instruction storage step of storing in association with each other, the position by the instruction changing step
A program execution step of detecting the marker while executing the instruction code is the instruction code is included in the program code is replaced with the marker sequentially Japanese positions of marker the program execution step detects
Constant to, among the instruction codes the stored in the replaced instruction storage step, and the replaced command specifying step <br/> flop to identify what was described on the position of the marker identifying the location, Based on the location currently indicated by the stack pointer and the instruction code identified by the instruction to be replaced identification step, a location to be indicated by the stack pointer when the identified instruction code is executed. And an analysis step of recording an address indicating the identified location, wherein the program execution step acquires the instruction code identified by the replaced instruction identification step from the replaced instruction identification step. And sequentially executing an instruction code to be executed following the instruction code.

【0018】このようなスタックポインタトレース方法
によれば、スタックポインタの指示先のアドレスが変更
される度に、該アドレスが前記解析ステップにより蓄積
される。また、スタックポインタの指示先のアドレスを
変更する命令を示す命令コードは、前記被置換命令特定
ステップにより特定されるので、スタックポインタの指
示先のアドレスが変更された原因も特定される。
According to such a stack pointer tracing method, every time the address indicated by the stack pointer is changed, the address is accumulated in the analysis step. Further, since the instruction code indicating the instruction to change the address of the stack pointer is specified in the instruction to be replaced specifying step, the cause of the change in the address of the stack pointer is also specified. You.

【0019】また、この発明の第3の観点にかかるコン
ピュータ読み取り可能な記録媒体は、コンピュータを、
スタック領域にアクセスしてデータを読み書きするプロ
グラムのプログラムコードを記憶するプログラム記憶手
段と、前記プログラム記憶手段が記憶する前記プログラ
ムコード上における、前記データを読み書きする位置を
指示するスタックポインタの指示先を変更する命令を表
す命令コードが記述されている位置を特定し、該命令
ードを所定のマーカに置換する命令変更手段と、前記命
令変更手段により前記マーカに置換された前記命令コー
ドと、置換された該命令コードが記述されていた前記プ
ログラムコード上の位置を示す情報とを、互いに対応付
けて記憶する被置換命令記憶手段と、前記命令変更手段
により位置を特定された前記命令コードが前記マーカに
置換された前記プログラムコードに含まれる前記命令コ
ードを逐次実行しつつマーカを検出するプログラム実
行手段と、前記プログラム実行手段が検出したマーカの
位置を特定して、前記被置換命令記憶手段に記憶されて
いる前記命令コードのうち、位置を特定したマーカの
位置に記述されていたものを特定する被置換命令特定
段と、前記スタックポインタが現に指示している箇所
と、前記被置換命令特定手段により特定された前記命令
コードとに基づいて、特定された該命令コードが実行さ
れた場合において前記スタックポインタが指示すべき箇
所を特定し、特定された前記箇所を示すアドレスを記録
する解析手段として機能させ、前記プログラム実行手段
を、前記被置換命令特定手段により特定された前記命令
コードを前記被置換命令特定手段より取得して実行し、
該命令コードに続いて実行されるべき命令コードを逐次
実行する手段として機能させる、ためのプログラムを記
録したことを特徴とする。
A computer-readable recording medium according to a third aspect of the present invention includes a computer
A program storage means for storing a program code of a program for accessing the stack area to read and write data, and a position on the program code stored in the program storage means for reading and writing the data.
Table instructions to change the indication destination of the stack pointer to
To locate where to instruction code is written, the instruction code
Information indicating an instruction changing means for replacing the over de in a predetermined marker, and the instruction code is substituted into the marker by the instruction changing means, the position on said program code instruction code replacement has been described And the replaced instruction storage means for storing the instruction code in the program code in which the position of the instruction code specified by the instruction changing means is replaced with the marker while sequentially executing the instruction code included in the program code. and program executing means for detecting the marker, to identify the position of the marker in which the program executing unit detects, among the instruction codes the stored in the replacement instruction storage means, the position of the marker identifying the location identifying what was described in the the replacement instruction particular hand <br/> stage, a portion of the stack pointer is pointing fact, the object to be substituted Based on said instruction code specified by decree specifying means, the stack pointer identifies the location to be indicated when the instruction code specified is executed, records the address indicating the specified ibid Function as an analysis means, the program execution means, the instruction code specified by the replaced instruction identification means is obtained from the replaced instruction identification means and executed,
A program for functioning as a means for sequentially executing an instruction code to be executed following the instruction code is recorded.

【0020】このような記録媒体に記録された前記プロ
グラムを実行する前記コンピュータは、スタックポイン
タの指示先のアドレスが変更される度に、該アドレスを
前記解析手段により蓄積するスタックポインタトレース
装置として機能する。また、前記コンピュータは、スタ
ックポインタの指示先のアドレスを変更する命令を示す
命令コードを、前記被置換命令特定手段の機能を行うこ
とにより特定するので、スタックポインタの指示先のア
ドレスが変更された原因も特定される。
The computer which executes the program recorded on such a recording medium functions as a stack pointer trace device for accumulating the address indicated by the stack pointer by the analysis means each time the address is changed. I do. Further, the computer specifies an instruction code indicating an instruction to change the address of the stack pointer, by performing the function of the replaced instruction specifying unit, so that the address of the stack pointer is changed. The cause is also identified.

【0021】[0021]

【発明の実施の形態】以下、この発明の実施の形態にか
かるスタックポインタトレース装置及びスタックポイン
タトレース方法を説明する。 (第1の実施の形態)図1は、この発明の第1の実施の
形態にかかるスタックポインタトレース装置の物理的構
成を示す。図示するように、このスタックポインタトレ
ース装置は、プログラム記憶装置1と、入力装置2と、
トレース装置3と、出力装置4と、情報を記録する記憶
装置5とを含む。
DESCRIPTION OF THE PREFERRED EMBODIMENTS A stack pointer tracing device and a stack pointer tracing method according to an embodiment of the present invention will be described below. (First Embodiment) FIG. 1 shows a physical configuration of a stack pointer trace device according to a first embodiment of the present invention. As shown, the stack pointer trace device includes a program storage device 1, an input device 2,
It includes a tracing device 3, an output device 4, and a storage device 5 for recording information.

【0022】入力装置2は、キーボードやフロッピーデ
ィスクドライブ等からなり、スタックの使用状況を解析
する対象となるプログラムを入力してプログラム記憶装
置1に供給する。プログラム記憶装置1はRAM(ラン
ダムアクセスメモリ)等からなり、入力装置2から供給
されたプログラムを記憶する記憶領域を備える。また、
プログラム記憶装置1は、プログラムが処理において用
いるデータを格納するスタック領域を確保するための記
憶領域を備える。
The input device 2 includes a keyboard, a floppy disk drive, and the like. The input device 2 inputs a program for which the usage status of the stack is analyzed and supplies the program to the program storage device 1. The program storage device 1 includes a RAM (random access memory) or the like, and includes a storage area for storing a program supplied from the input device 2. Also,
The program storage device 1 includes a storage area for securing a stack area for storing data used in processing by a program.

【0023】記憶装置5は、命令記憶部51と、解析デ
ータ記憶部52と、トレースデータ記憶部53とを備え
ている。
The storage device 5 includes an instruction storage unit 51, an analysis data storage unit 52, and a trace data storage unit 53.

【0024】命令記憶部51は、スタック領域のうち、
次に読み書きが行われるべき部分のアドレスを指すポイ
ンタ(スタックポインタ)を変更する命令を表す命令コ
ードと、解析する対象のプログラム上で当該命令コード
が存在した位置(アドレス)とを対応づける対応表を記
憶する。
The instruction storage unit 51 stores, in the stack area,
A correspondence table that associates an instruction code indicating an instruction for changing a pointer (stack pointer) indicating an address of a portion to be read / written next with a position (address) where the instruction code exists in a program to be analyzed. Is stored.

【0025】解析データ記憶部52は、解析する対象の
プログラムが使用するスタック領域を識別する情報から
なる所有者識別子と、当該スタック領域が、プログラム
記憶装置1が備える記憶領域中において占める範囲(ア
ドレス範囲)を示す情報とを互いに対応付ける対応表を
記憶する。
The analysis data storage unit 52 stores an owner identifier including information for identifying a stack area used by a program to be analyzed, and a range (address) occupied by the stack area in the storage area of the program storage device 1. And a correspondence table for associating information indicating the range with each other.

【0026】トレースデータ記憶部53は、このスタッ
クポインタトレース装置が実行した各プログラムが過去
に使用したスタック領域を識別する上述の所有者識別子
と、該スタック領域のうち、各プログラムが読み書きを
行った部分のアドレスを指すスタックポインタの値と、
各プログラムに割り当てられているスタック領域のアド
レス範囲とを、これらが互いに対応づけられた対応表の
形をとって記録する。
The trace data storage unit 53 stores the above-mentioned owner identifier for identifying a stack area used in the past by each program executed by the stack pointer tracing device, and reads and writes by each program in the stack area. The value of the stack pointer to the address of the part,
The address range of the stack area assigned to each program is recorded in the form of a correspondence table in which these are associated with each other.

【0027】トレース装置3は、命令変更手段31と、
解析データ記憶手段32と、解析手段33とを備えてい
る。
The tracing device 3 comprises: an instruction changing means 31;
An analysis data storage unit 32 and an analysis unit 33 are provided.

【0028】命令変更手段31は、スタックポインタを
変更するための命令コードが解析する対象のプログラム
に含まれている場合、その命令コードを命令記憶部51
に記録する。そして、解析する対象のプログラムが記憶
されているプログラム記憶装置1上の記憶領域のうち、
その命令コードが格納されている位置に、その命令コー
ドが命令記憶部51に書き移されたことを示すコード
(ブレーク例外コード)を上書きする。
When the instruction code for changing the stack pointer is included in the program to be analyzed, the instruction changing means 31 stores the instruction code in the instruction storage unit 51.
To record. Then, in the storage area on the program storage device 1 in which the program to be analyzed is stored,
A code (break exception code) indicating that the instruction code has been transferred to the instruction storage unit 51 is overwritten at the position where the instruction code is stored.

【0029】解析データ記憶手段32は、解析する対象
のプログラムが使用するスタック領域の新規割り当てや
変更があるとき、割り当てられたスタック領域や変更後
のスタック領域のアドレス範囲等を調べ、調べた結果
を、上述の対応表の形式をとって解析データ記憶部52
に記録する。
When there is a new allocation or change of a stack area used by the program to be analyzed, the analysis data storage means 32 checks the allocated stack area, the address range of the changed stack area, and the like. In the form of the above-mentioned correspondence table,
To record.

【0030】解析手段33は、命令記憶部51に記憶さ
れているデータに基づいて、解析する対象のプログラム
により変更されるスタックポインタの変更後の値を計算
し、解析データ記憶部52に記録されているスタック領
域のアドレス範囲のデータと共に、トレースデータ記憶
部53に記録する。解析手段33は、スタックポインタ
の値の計算結果が、解析データ記憶部52に記録されて
いるスタック領域のアドレス範囲に含まれない値である
とき、トレースデータ記憶部53に記憶されている内容
を出力装置4に出力する。
The analysis means 33 calculates the changed value of the stack pointer changed by the program to be analyzed based on the data stored in the instruction storage section 51 and records the value in the analysis data storage section 52. The data is recorded in the trace data storage unit 53 together with the data in the address range of the stack area. When the calculation result of the value of the stack pointer is a value that is not included in the address range of the stack area recorded in the analysis data storage unit 52, the analysis unit 33 deletes the content stored in the trace data storage unit 53. Output to the output device 4.

【0031】出力装置4は、ディスプレイ装置や印刷装
置等からなり、トレースデータ記憶部53に記憶されて
いる内容を解析手段33から取得して、取得した内容を
表示、印字等する。
The output device 4 is composed of a display device, a printing device, or the like, acquires the contents stored in the trace data storage unit 53 from the analysis unit 33, and displays and prints the acquired contents.

【0032】次に、図1および図2を参照してこのスタ
ックポインタトレース装置の動作を説明する。図2のス
テップA1からA3までは、解析対象のプログラムを実
行する前に行う処理を示す。図2のステップA4からA
6は、解析対象のプログラムを実行中の処理を示す。図
2のステップA7からA12は、ブレーク例外発生後の
処理を示す。
Next, the operation of the stack pointer tracing device will be described with reference to FIGS. Steps A1 to A3 in FIG. 2 show processing performed before executing the program to be analyzed. Steps A4 to A in FIG.
6 shows a process during execution of the analysis target program. Steps A7 to A12 in FIG. 2 show processing after a break exception occurs.

【0033】(解析対象のプログラムを実行する前の処
理)まず、入力装置2から、スタックポインタを変更す
る命令を含んだ解析対象のプログラムが供給され、プロ
グラム記憶装置1に格納される。次に、命令変更手段3
1は、プログラム記憶装置1から該プログラムを順次読
み取って解析することにより、スタックポインタを変更
する命令を表す命令コードがある該プログラム上のアド
レスを特定する。そして、該アドレスと、該アドレスに
あった命令コードとを対応づける対応表を作成して命令
記憶部51に格納する(ステップA1)。次に、命令変
更手段31は、ステップA1で特定されたアドレスにブ
レーク例外コードを上書きする(ステップA2)。そし
て、該プログラムにスタック領域を新規に割り当て、該
スタック領域を識別する所有者識別子を作成し、割り当
てられたスタック領域のアドレス範囲と、作成された所
有者識別子とを互いに対応づける対応表を作成して解析
データ記憶部52に格納した後、解析対象のプログラム
を実行する(ステップA3)。
(Processing Before Execution of Program to be Analyzed) First, a program to be analyzed including an instruction to change the stack pointer is supplied from the input device 2 and stored in the program storage device 1. Next, instruction changing means 3
1 sequentially reads and analyzes the program from the program storage device 1 to specify an address on the program where an instruction code representing an instruction to change a stack pointer is located. Then, a correspondence table that associates the address with the instruction code corresponding to the address is created and stored in the instruction storage unit 51 (step A1). Next, the instruction changing means 31 overwrites the address specified in step A1 with the break exception code (step A2). Then, a stack area is newly assigned to the program, an owner identifier for identifying the stack area is created, and a correspondence table for associating the address range of the assigned stack area with the created owner identifier is created. After that, the analysis target program is stored in the analysis data storage unit 52, and then the program to be analyzed is executed (step A3).

【0034】(解析対象のプログラム実行中の処理)解
析対象のプログラムを実行中、該プログラム自身が使用
するスタック領域を変更する処理が行われた場合(ステ
ップA4)、解析データ記憶部52に格納されている対
応表を更新するため、解析対象のプログラムから解析デ
ータ記憶手段32が呼ばれる。解析データ記憶手段32
は、解析データ記憶部52が格納している対応表のう
ち、解析対象のプログラムが使用するスタック領域を識
別する所有者識別子を含むものを特定し、その所有者識
別子に対応づけられているアドレス範囲を、ステップA
4の処理で変更された後のアドレス範囲に更新する(ス
テップA5)。
(Processing during execution of analysis target program) During execution of the analysis target program, if processing for changing the stack area used by the program itself is performed (step A4), the analysis target storage is stored in the analysis data storage unit 52. In order to update the correspondence table, the analysis data storage unit 32 is called from the analysis target program. Analysis data storage means 32
Specifies, from the correspondence table stored in the analysis data storage unit 52, a table including an owner identifier for identifying a stack area used by a program to be analyzed, and an address associated with the owner identifier. Range, step A
The address range is updated to the address range changed in the process 4 (step A5).

【0035】(ブレーク例外発生後の処理)実行中にブ
レーク例外が発生すると(ステップA7)、解析手段3
3が、ステップA8以降の処理を実行する。解析手段3
3は、ブレーク例外が発生したアドレスを特定し、命令
記憶部51に格納されている対応表を検索することによ
り、特定されたアドレスに存在していた元の命令コード
を特定する(ステップA8)。そして、特定された命令
コード(スタックポインタの値を変更する命令を示す命
令コード)と、ブレーク例外が発生した時点におけるス
タックポインタの値とに基づき、解析対象のプログラム
が設定しようとしていたスタックポインタの値を求める
(ステップA9)。例えば、特定された命令コードが、
変更前のスタックポインタが示すアドレスにデータをプ
ッシュする(書き込む)命令を示すものである場合、解
析手段33は、ブレーク例外が発生した時点におけるス
タックポインタの値に1を加算し、得られた値を、解析
対象のプログラムが設定しようとしていたスタックポイ
ンタの値とする。
(Processing after Break Exception Occurrence) When a break exception occurs during execution (step A7), the analyzing means 3
3 executes the processing after step A8. Analysis means 3
No. 3 specifies the address where the break exception has occurred, and specifies the original instruction code existing at the specified address by searching the correspondence table stored in the instruction storage unit 51 (step A8). . Then, based on the specified instruction code (the instruction code indicating the instruction to change the value of the stack pointer) and the value of the stack pointer at the time when the break exception occurs, the stack pointer of the program to be analyzed is set. A value is obtained (step A9). For example, the specified instruction code is
If the instruction indicates a command to push (write) data to the address indicated by the stack pointer before the change, the analysis unit 33 adds 1 to the value of the stack pointer at the time when the break exception occurs, and obtains the obtained value. Is the value of the stack pointer that the program to be analyzed was trying to set.

【0036】次に、解析手段33は、解析データ記憶部
52から、解析対象のプログラムが使用しているスタッ
ク領域を識別する所有者識別子と、該スタック領域のア
ドレス範囲の情報とを読み出す。そして、読み出した情
報と、ステップA9で求められたスタックポインタの値
とを、トレースデータ記憶部53に記憶する(ステップ
A10)。
Next, the analysis means 33 reads from the analysis data storage section 52 an owner identifier for identifying the stack area used by the program to be analyzed and information on the address range of the stack area. Then, the read information and the value of the stack pointer obtained in step A9 are stored in the trace data storage unit 53 (step A10).

【0037】さらに、解析手段33は、ステップA9で
求めたスタックポインタの値が解析データ記憶部52に
記憶されているアドレス範囲内(すなわち、解析対象の
プログラムに割り当てられているスタック領域があるア
ドレス範囲内)のアドレスを指しているか否かを判別す
る(ステップA11)。そして、該アドレス範囲内のア
ドレスを指していない場合は、スタックポインタが不正
に変更されたものと判断し、プログラムを停止して終了
する。該アドレス範囲内にある場合は、命令記憶部51
に格納されている対応表を検索することにより、ブレー
ク例外が発生したアドレスに存在していた命令コード
(元命令)を特定する。そして、特定された元命令を実
行した後、解析対象のプログラムが示す処理のうち、そ
の元命令を実行する処理の次に実行されるべき処理を実
行させる(ステップA12)。
Further, the analyzing means 33 determines whether the value of the stack pointer obtained in step A9 is within the address range stored in the analysis data storage section 52 (that is, the address where the stack area allocated to the program to be analyzed exists). It is determined whether or not the address is within the range (step A11). If it does not point to an address within the address range, it is determined that the stack pointer has been illegally changed, and the program is stopped and terminated. If it is within the address range, the instruction storage unit 51
, The instruction code (original instruction) existing at the address where the break exception has occurred is specified. Then, after executing the specified original instruction, a process to be executed next to the process of executing the original instruction among the processes indicated by the analysis target program is executed (step A12).

【0038】以下、このスタックポインタトレース装置
は、解析対象のプログラムが最後まで走行する(ステッ
プA6)か、又は、ステップA11でスタックポインタ
が不正に変更されたと判断されるまで、解析対象のプロ
グラムを走行させる。
Hereinafter, the stack pointer tracing device continues to execute the program to be analyzed until the program to be analyzed runs to the end (step A6) or until it is determined in step A11 that the stack pointer has been illegally changed. Let it run.

【0039】このようにして、このスタックポインタト
レース装置は、解析対象のプログラムによるスタックの
使用状況を示す情報として、(1)該プログラムがスタ
ックポインタの値を変更した場合の変更後のスタックポ
インタの値と、(2)該プログラムが使用しているスタ
ック領域を識別する所有者識別子と、(3)該スタック
領域のアドレス範囲を示す情報と、をトレースデータ記
憶部53に蓄積しながら、解析対象のプログラムを実行
する。
As described above, this stack pointer tracing device can provide (1) the changed stack pointer value when the program changes the value of the stack pointer as information indicating the use status of the stack by the program to be analyzed. While accumulating the value, (2) an owner identifier for identifying the stack area used by the program, and (3) information indicating the address range of the stack area in the trace data storage unit 53, Run the program.

【0040】(第2の実施の形態)以上説明した第1の
実施の形態では、全てのスタックの使用状況を示すデー
タが収集されていた。しかし、使用状況を示すデータ
は、特定のスタックに限定して収集されてもよく、これ
により、トレースデータ記憶部53が有する記憶領域を
有効に活用でき、また収集されたデータの整理も容易と
なる。以下、特定のスタックの使用状況を示すデータを
収集する、この発明の第2の実施の形態にかかるスタッ
クポインタトレース装置を説明する。
(Second Embodiment) In the first embodiment described above, data indicating the usage status of all stacks has been collected. However, the data indicating the usage status may be collected only for a specific stack, whereby the storage area of the trace data storage unit 53 can be effectively used, and the collected data can be easily organized. Become. Hereinafter, a stack pointer tracing device according to the second embodiment of the present invention, which collects data indicating the usage status of a specific stack, will be described.

【0041】図3は、この発明の第2の実施形態にかか
るスタックポインタトレース装置の構成を示す。図示す
るように、このスタックポインタトレース装置のトレー
ス装置3は、図1に示すトレース装置3の構成に加えて
スタック選択手段34を備える。また、このスタックポ
インタトレース装置の記憶装置5は、図1に示す記憶装
置5の構成に加えて、選択スタック記憶部54を備え
る。
FIG. 3 shows the configuration of a stack pointer trace device according to a second embodiment of the present invention. As shown, the tracing device 3 of the stack pointer tracing device includes a stack selecting means 34 in addition to the configuration of the tracing device 3 shown in FIG. The storage device 5 of the stack pointer tracing device includes a selected stack storage unit 54 in addition to the configuration of the storage device 5 shown in FIG.

【0042】選択スタック記憶部54は、操作者等が入
力装置2を用いて入力した、トレースデータ記憶部53
に使用状況を記録する対象のスタック領域を識別する所
有者識別子を記憶する。
The selection stack storage unit 54 stores the trace data storage unit 53 input by the operator or the like using the input device 2.
An owner identifier for identifying a stack area for which the usage status is to be recorded is stored.

【0043】スタック選択手段34は、解析データ記憶
部52に記憶されている所有者識別子と、選択スタック
記憶部54に記憶されている所有者識別子とが実質的に
一致するか否かを判別する。そして、両者が一致すると
判別されたとき、解析対象のプログラムが使用している
スタック領域が、使用状況を記録する対象のスタック領
域であると判断し、解析手段33に処理を実行させる。
The stack selecting unit 34 determines whether or not the owner identifier stored in the analysis data storage unit 52 substantially matches the owner identifier stored in the selected stack storage unit 54. . When it is determined that the two match, the stack area used by the program to be analyzed is determined to be the stack area for recording the usage status, and the analysis unit 33 executes the processing.

【0044】次に、図4を参照して、このスタックポイ
ンタトレース装置の動作を説明する。なお、図4に示す
ステップA1からA12は、図2に示すステップA1か
らA12と実質的に同一の処理である。また、このスタ
ックポインタトレース装置における命令変更手段31、
解析データ記憶手段32及び解析手段33の動作は、第
1の実施の形態における命令変更手段31、解析データ
記憶手段32及び解析手段33の動作と実質的に同一で
ある。
Next, the operation of the stack pointer tracing device will be described with reference to FIG. Steps A1 to A12 shown in FIG. 4 are substantially the same as steps A1 to A12 shown in FIG. Further, the instruction changing means 31 in the stack pointer tracing device,
The operations of the analysis data storage unit 32 and the analysis unit 33 are substantially the same as the operations of the instruction change unit 31, the analysis data storage unit 32, and the analysis unit 33 in the first embodiment.

【0045】まず、操作者等が、入力装置2を用いて、
使用状況を記録する対象のスタック領域を示す所有者識
別子を入力すると、選択スタック記憶部54が、入力さ
れた所有者識別子を記憶する(ステップB1)。ステッ
プB1の処理が終了すると、このスタックポインタトレ
ース装置は、ステップA1以降の処理を実行する。
First, an operator or the like uses the input device 2 to
When the owner identifier indicating the stack area for which the usage status is to be recorded is input, the selected stack storage unit 54 stores the input owner identifier (step B1). When the processing of step B1 is completed, the stack pointer tracing device executes the processing of step A1 and thereafter.

【0046】解析対象のプログラムの実行中、ブレーク
例外が発生すると、スタック選択手段34が、ステップ
B2の処理を実行する。ステップB2において、スタッ
ク選択手段34は、解析データ記憶部52に記憶されて
いる所有者識別子と、選択スタック記憶部54に記憶さ
れている所有者識別子とが実質的に一致するか否かを判
別する。すなわち、スタック選択手段34は、解析対象
のプログラムが使用しているスタック領域が、使用状況
を記録する対象のスタック領域であるか否かを判別す
る。
When a break exception occurs during the execution of the program to be analyzed, the stack selecting means 34 executes the processing of step B2. In step B2, the stack selecting unit 34 determines whether or not the owner identifier stored in the analysis data storage unit 52 substantially matches the owner identifier stored in the selected stack storage unit 54. I do. That is, the stack selecting unit 34 determines whether or not the stack area used by the program to be analyzed is the stack area for recording the usage status.

【0047】そして、両者が一致すると判別されたと
き、解析手段33にステップA8以降の処理を行うよう
指示し、指示を受けた解析手段33は、ステップA8以
降の処理を行う。一致しないと判別されたとき、スタッ
ク選択手段34は、解析手段33にステップA12以降
の処理を行うよう指示する。指示を受けたスタック選択
手段34は、ステップA12の処理を行う。すなわち、
ブレーク例外が発生したアドレスに存在した元命令を実
行し、再び解析対象のプログラムの実行を開始する。
When it is determined that they match, the analyzing means 33 is instructed to perform the processing of step A8 and thereafter, and the analyzing means 33 receiving the instruction performs the processing of step A8 and thereafter. When it is determined that they do not match, the stack selecting unit 34 instructs the analyzing unit 33 to perform the processing after step A12. The stack selecting means 34 having received the instruction performs the process of step A12. That is,
The original instruction existing at the address where the break exception occurred is executed, and the execution of the analysis target program is started again.

【0048】以上、この発明の実施の形態を説明した
が、この発明のスタックポインタトレース装置は、専用
のシステムによらず、通常のコンピュータシステムを用
いて実現可能である。例えば、パーソナルコンピュータ
に上述の動作を実行するためのプログラムを格納した媒
体(フロッピーディスク、CD−ROM等)から該プロ
グラムをインストールすることにより、上述の処理を実
行するスタックポインタトレース装置を構成することが
できる。
The embodiment of the present invention has been described above. However, the stack pointer tracing device of the present invention can be realized by using a general computer system without using a dedicated system. For example, a stack pointer tracing device that executes the above-described processing may be configured by installing the program for executing the above-described operation in a personal computer from a medium (a floppy disk, a CD-ROM, or the like) storing the program. Can be.

【0049】また、コンピュータにプログラムを供給す
るための媒体は、通信媒体(通信回線、通信ネットワー
ク、通信システムのように、一時的且つ流動的にプログ
ラムを保持する媒体)でも良い。例えば、通信ネットワ
ークの掲示板(BBS)に該プログラムを掲示し、これ
をネットワークを介して配信してもよい。そして、この
プログラムを起動し、OSの制御下に、他のアプリケー
ションプログラムと同様に実行することにより、上述の
処理を実行することができる。
The medium for supplying the program to the computer may be a communication medium (a medium that temporarily and fluidly stores the program, such as a communication line, a communication network, or a communication system). For example, the program may be posted on a bulletin board (BBS) of a communication network and distributed via the network. Then, by starting this program and executing it in the same manner as other application programs under the control of the OS, the above-described processing can be executed.

【0050】なお、OSが処理の一部を分担する場合
や、OSが本願発明のいくつかの構成要素を構成する場
合や、OSが1つの構成要素の一部を構成するような場
合には、記録媒体には、その部分をのぞいたプログラム
を格納してもよい。この場合も、その記録媒体には、コ
ンピュータが実行する各機能又はステップを実行するた
めのプログラムが格納されているものとする。
In the case where the OS shares part of the processing, the case where the OS constitutes some components of the present invention, or the case where the OS constitutes a part of one component, Alternatively, the recording medium may store a program excluding that part. Also in this case, it is assumed that the recording medium stores a program for executing each function or step executed by the computer.

【0051】[0051]

【発明の効果】以上説明したように、この発明によれ
ば、プログラムを実行中に、そのプログラムによるスタ
ックの使用状況が正確に把握できるスタックポインタト
レース装置及びスタックポインタトレース方法が実現さ
れる。
As described above, according to the present invention, a stack pointer tracing device and a stack pointer tracing method capable of accurately grasping the status of use of a stack by a program during execution of the program are realized.

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

【図1】この発明の第1の実施の形態にかかるスタック
ポインタトレース装置の基本構成を示すブロック図であ
る。
FIG. 1 is a block diagram showing a basic configuration of a stack pointer tracing device according to a first embodiment of the present invention.

【図2】図1のスタックポインタトレース装置が実行す
る処理を示すフローチャートである。
FIG. 2 is a flowchart showing a process executed by the stack pointer tracing device of FIG. 1;

【図3】この発明の第2の実施の形態にかかるスタック
ポインタトレース装置の基本構成を示すブロック図であ
る。
FIG. 3 is a block diagram showing a basic configuration of a stack pointer trace device according to a second embodiment of the present invention.

【図4】図3のスタックポインタトレース装置が実行す
る処理を示すフローチャートである。
FIG. 4 is a flowchart illustrating a process executed by the stack pointer tracing device of FIG. 3;

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

1 プログラム記憶装置 2 入力装置 3 トレース装置 31 命令変更手段 32 解析データ記憶手段 33 解析手段 34 スタック選択手段 4 出力装置 5 記憶装置 51 命令記憶部 52 解析データ記憶部 53 トレースデータ記憶部 54 選択スタック記憶部 DESCRIPTION OF SYMBOLS 1 Program storage device 2 Input device 3 Trace device 31 Instruction change means 32 Analysis data storage means 33 Analysis means 34 Stack selection means 4 Output device 5 Storage device 51 Instruction storage unit 52 Analysis data storage unit 53 Trace data storage unit 54 Selected stack storage Department

───────────────────────────────────────────────────── フロントページの続き (58)調査した分野(Int.Cl.7,DB名) G06F 11/28 310 G06F 9/34 340 ──────────────────────────────────────────────────続 き Continued on front page (58) Field surveyed (Int.Cl. 7 , DB name) G06F 11/28 310 G06F 9/34 340

Claims (7)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】スタック領域にアクセスしてデータを読み
書きするプログラムが実行される間に、前記データを読
み書きする位置を指示するスタックポインタの指示先を
示すアドレスを記録するためのスタックポインタトレー
ス装置であって、 前記プログラムのプログラムコードを記憶するプログラ
ム記憶手段と、 前記プログラム記憶手段が記憶する前記プログラムコー
ド上における、前記スタックポインタの指示先を変更す
る命令を表す命令コードが記述されている位置を特定
し、該命令コードを所定のマーカに置換する命令変更手
段と、 前記命令変更手段により前記マーカに置換された前記命
令コードと、置換された該命令コードが記述されていた
前記プログラムコード上の位置を示す情報とを、互いに
対応付けて記憶する被置換命令記憶手段と、 前記命令変更手段により位置を特定された前記命令コー
が前記マーカに置換された前記プログラムコードに含
まれる命令コードを逐次実行しつつマーカを検出する
プログラム実行手段と、 前記プログラム実行手段が検出したマーカの位置を特定
して、前記被置換命令記憶手段に記憶されている前記命
令コードのうち、位置を特定したマーカの位置に記述
されていたものを特定する被置換命令特定手段と、 前記スタックポインタが現に指示している箇所と、前記
被置換命令特定手段により特定された前記命令コードと
に基づいて、特定された該命令コードが実行された場合
において前記スタックポインタが指示すべき箇所を特定
し、特定された前記箇所を示すアドレスを記録する解析
手段とを備え、 前記プログラム実行手段は、前記被置換命令特定手段に
より特定された前記命令コードを前記被置換命令特定手
段より取得して実行し、該命令コードに続いて実行され
るべき命令コードを逐次実行する手段を備える、 ことを特徴とするスタックポインタトレース装置。
1. A stack pointer tracing device for recording an address indicating a point indicated by a stack pointer indicating a position at which data is read or written while a program for accessing and reading data from a stack area is executed. A program storage means for storing a program code of the program; and a position on the program code stored in the program storage means, the position where an instruction code representing an instruction for changing an instruction destination of the stack pointer is described. Command changing means for specifying and replacing the command code with a predetermined marker; the command code replaced by the marker by the command changing means; and the program code on which the replaced command code is described. Instructions to be replaced that store information indicating the position in association with each other Means and said instruction code specified position by said instruction changing means
And program executing means for de detects the marker while executing the instruction code sequentially included in the program code is replaced with the marker, to identify <br/> the position of the marker in which the program executing means detects, among the instruction codes the stored in the replacement instruction storage means, and the replacement instruction specifying means for specifying what was described on the position of the marker identifying the location, the stack pointer is pointing currently A location to be indicated by the stack pointer when the identified instruction code is executed, based on the location and the instruction code identified by the replaced instruction identification means, and the identified location Analysis means for recording an address indicating the instruction code, wherein the program execution means includes the instruction code specified by the replaced instruction specification means. The obtained from the replaced command specifying means by performing comprises means for sequentially executing the instruction code to be executed following the instruction code, the stack pointer trace and wherein the.
【請求項2】前記プログラム実行手段は、前記スタック
領域のうち自らが実行している前記プログラムが使用す
る対象である部分を識別する識別情報を記憶する手段を
備え、 前記解析手段は、 前記スタック領域のうちの特定の部分を識別する識別情
報を記憶する手段と、 前記プログラム実行手段より、前記プログラム実行手段
が記憶している前記識別情報を取得して、取得した該識
別情報が、前記解析手段自身が記憶する前記識別情報と
実質的に同一の部分を示すか否かを判別し、示すと判別
されたとき、前記被置換命令特定手段により特定された
命令コードが実行された場合においてスタックポインタ
が指示すべきアドレスを特定する手段とを備える、 ことを特徴とする請求項1に記載のスタックポインタト
レース装置。
2. The program execution means according to claim 1, wherein:
And means for storing identification information identifying the portion is a target to be used is the program itself is running in the region, the analysis means, the identification information identifying a particular portion of the stack area Means for storing, from the program execution means, acquiring the identification information stored in the program execution means, and the acquired identification information is substantially the same as the identification information stored in the analysis means itself. it is determined whether or not showing a part, when it is judged illustrated, the and means for specifying the address the stack pointer to be indicated when the instruction code specified by the replaced command specifying means is executed The stack pointer trace device according to claim 1, wherein:
【請求項3】前記解析手段は、前記スタック領域のうち
前記プログラムが使用し得る部分の範囲を特定するスタ
ック領域情報を記憶するスタック領域記憶手段と、 該解析手段自身により特定された前記アドレスが、前記
スタック領域情報が示す範囲内にあるか否かを判別し、
ないと判別された場合に判別結果を外部に通知する異常
アクセス通知手段とを備える、 ことを特徴とする請求項1又は2に記載のスタックポイ
ンタトレース装置。
Wherein said analyzing means includes a stack area storage means for storing a stack area information specifying a range of <br/> the part program may be used among the stack area, identified by the analysis means itself Determining whether the address is within a range indicated by the stack area information,
3. The stack pointer trace device according to claim 1, further comprising: an abnormal access notification unit that notifies a determination result to the outside when it is determined that the stack pointer does not exist. 4.
【請求項4】前記異常アクセス通知手段は、前記解析手
段により特定された前記アドレスが前記スタック領域情
報が示す範囲内にないと判別された場合に、前記プログ
ラム実行手段が実行している前記プログラムの処理を停
止する手段を備える、 ことを特徴とする請求項3に記載のスタックポインタト
レース装置。
4. The program executed by the program executing means when the abnormal access notifying means determines that the address specified by the analyzing means is not within a range indicated by the stack area information. The stack pointer tracing device according to claim 3, further comprising means for stopping the processing of (1).
【請求項5】前記プログラム実行手段は、前記スタック領域のうちの 前記プログラムが使用し得る
部分の範囲を変更するための前記命令コードを検知する
スタック変更命令検知手段と、 前記スタック変更命令検知手段が検知した前記命令コー
ドを実行したとき、変更後の前記範囲を特定する前記ス
タック領域情報を新たに作成し、前記スタック領域記憶
手段に記憶されている変更前の前記スタック領域情報
を、新たに作成された前記スタック領域情報に更新する
手段とを備える、 ことを特徴とする請求項3又は4に記載のスタックポイ
ンタトレース装置。
5. The program execution means can be used by the program in the stack area.
Stack change instruction detecting means for detecting the instruction code for changing the range of the portion; and when executing the instruction code detected by the stack change instruction detecting means, the stack area information for specifying the range after the change. Means for newly creating the stack area information and updating the stack area information before change stored in the stack area storage means to the newly created stack area information. Or the stack pointer trace device according to 4.
【請求項6】スタック領域にアクセスしてデータを読み
書きするプログラムが実行される間に、前記データを読
み書きする位置を指示するスタックポインタの指示先を
示すアドレスを記録するためのスタックポインタトレー
方法であって、 前記プログラムのプログラムコードを記憶するプログラ
ム記憶ステップと、 前記プログラム記憶ステップが記憶する前記プログラム
コード上における、前記スタックポインタの指示先を変
更する命令を表す命令コードが記述されている位置を特
定し、該命令コードを所定のマーカに置換する命令変更
ステップと、 前記命令変更ステップにより前記マーカに置換された前
記命令コードと、置換された該命令コードが記述されて
いた前記プログラムコード上の位置を示す情報とを、互
いに対応付けて記憶する被置換命令記憶ステップと、 前記命令変更ステップにより位置を特定された前記命令
コードが前記マーカに置換された前記プログラムコード
に含まれる前記命令コードを逐次実行しつつマーカを
検出するプログラム実行ステップと、 前記プログラム実行ステップが検出したマーカの位置を
特定して、前記被置換命令記憶ステップに記憶されてい
る前記命令コードのうち、位置を特定したマーカの位
置に記述されていたものを特定する被置換命令特定ステ
ップと、 前記スタックポインタが現に指示している箇所と、前記
被置換命令特定ステップにより特定された前記命令コー
ドとに基づいて、特定された該命令コードが実行された
場合において前記スタックポインタが指示すべき箇所を
特定し、特定された前記箇所を示すアドレスを記録する
解析ステップとを備え、 前記プログラム実行ステップは、前記被置換命令特定ス
テップにより特定された前記命令コードを前記被置換命
令特定ステップより取得して実行し、該命令コードに続
いて実行されるべき命令コードを逐次実行するステップ
を備える、 ことを特徴とするスタックポインタトレース方法。
6. A stack pointer tracing method for recording an address indicating a point indicated by a stack pointer indicating a position at which data is read or written while a program for accessing and reading data from or accessing a stack area is executed. A program storage step for storing a program code of the program; and a position on the program code stored in the program storage step, the position where an instruction code representing an instruction for changing an instruction destination of the stack pointer is described. An instruction changing step of specifying and replacing the instruction code with a predetermined marker; the instruction code replaced by the marker in the instruction changing step; and the program code on which the replaced instruction code is described. Information indicating the position is stored in association with each other And the replacement instruction storage step, the identified position by the instruction changing step said instructions that
A program execution step of detecting the marker while sequentially executing the instruction code code is included in the program code is replaced with the marker, the position of the marker in which the program execution step detects
Identify and, among the instruction codes the stored in the replaced instruction storage step, and the replaced command specifying stearyl <br/>-up to identify what was described on the position of the marker identifying the location The stack pointer should indicate when the specified instruction code is executed based on the location currently specified by the stack pointer and the instruction code specified in the replaced instruction specifying step. An analysis step of identifying a location and recording an address indicating the identified location, wherein the program execution step acquires the instruction code identified by the replaced instruction identification step from the replaced instruction identification step And sequentially executing an instruction code to be executed following the instruction code. Click pointer trace method.
【請求項7】コンピュータを、 スタック領域にアクセスしてデータを読み書きするプロ
グラムのプログラムコードを記憶するプログラム記憶手
段と、 前記プログラム記憶手段が記憶する前記プログラムコー
ド上における、前記データを読み書きする位置を指示す
スタックポインタの指示先を変更する命令を表す命令
コードが記述されている位置を特定し、該命令コード
所定のマーカに置換する命令変更手段と、 前記命令変更手段により前記マーカに置換された前記命
令コードと、置換された該命令コードが記述されていた
前記プログラムコード上の位置を示す情報とを、互いに
対応付けて記憶する被置換命令記憶手段と、 前記命令変更手段により位置を特定された前記命令コー
が前記マーカに置換された前記プログラムコードに含
まれる前記命令コードを逐次実行しつつマーカを検出
するプログラム実行手段と、 前記プログラム実行手段が検出したマーカの位置を特定
して、前記被置換命令記憶手段に記憶されている前記命
令コードのうち、位置を特定したマーカの位置に記述
されていたものを特定する被置換命令特定手段と、 前記スタックポインタが現に指示している箇所と、前記
被置換命令特定手段により特定された前記命令コードと
に基づいて、特定された該命令コードが実行された場合
において前記スタックポインタが指示すべき箇所を特定
し、特定された前記箇所を示すアドレスを記録する解析
手段として機能させ、 前記プログラム実行手段を、前記被置換命令特定手段に
より特定された前記命令コードを前記被置換命令特定手
段より取得して実行し、該命令コードに続いて実行され
るべき命令コードを逐次実行する手段として機能させ
る、 ためのプログラムを記録したコンピュータ読み取り可能
な記録媒体。
7. A computer, comprising: a program storage means for storing a program code of a program for reading and writing data by accessing a stack area; and a position for reading and writing the data on the program code stored in the program storage means. Indicate
Instruction that represents the instruction to change the indication destination of the stack pointer that
An instruction changing means for specifying a position where the code is described and replacing the instruction code with a predetermined marker; the instruction code replaced by the marker by the instruction changing means; and the replaced instruction code being described. and information indicating a position on the program code that has been, and the replaced instruction storage means for storing in association with each other, the instruction code specified position by said instruction changing means
And program executing means for de detects the marker while sequentially executing the instruction code included in the program code is replaced with the marker, the position of the marker in which the program executing unit detects identify <br/> the one of the instruction codes stored in the replacement instruction storage means, and the replacement instruction specifying means for specifying what was described on the position of the marker identifying the location, the stack pointer is indicated currently Location, and based on the instruction code specified by the replaced instruction specifying means, when the specified instruction code is executed, specifies the location to be indicated by the stack pointer, and specifies the specified Functioning as analysis means for recording an address indicating a location, wherein the program execution means is the Decree the code and run obtained from the replaced command specifying means, instruction codes followed by to function as means for sequentially executing the instruction code to be executed, computer-readable recording medium storing a program for.
JP00761498A 1998-01-19 1998-01-19 Stack pointer trace device, stack pointer trace method, and recording medium Expired - Fee Related JP3309792B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP00761498A JP3309792B2 (en) 1998-01-19 1998-01-19 Stack pointer trace device, stack pointer trace method, and recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP00761498A JP3309792B2 (en) 1998-01-19 1998-01-19 Stack pointer trace device, stack pointer trace method, and recording medium

Publications (2)

Publication Number Publication Date
JPH11203166A JPH11203166A (en) 1999-07-30
JP3309792B2 true JP3309792B2 (en) 2002-07-29

Family

ID=11670701

Family Applications (1)

Application Number Title Priority Date Filing Date
JP00761498A Expired - Fee Related JP3309792B2 (en) 1998-01-19 1998-01-19 Stack pointer trace device, stack pointer trace method, and recording medium

Country Status (1)

Country Link
JP (1) JP3309792B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106354575A (en) * 2016-08-12 2017-01-25 中国航空工业集团公司西安飞行自动控制研究所 Troubleshooting device and method based on stack tracing

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS5873099A (en) * 1981-10-23 1983-05-02 Canon Inc Data processor
JPS61279951A (en) * 1985-06-06 1986-12-10 Nec Corp Instrumentation system for program including factor
JPS62219143A (en) * 1986-03-20 1987-09-26 Fujitsu Ltd Address fetch controlling and processing system
JPH02226441A (en) * 1989-02-28 1990-09-10 Toshiba Corp Software test device
JPH05113902A (en) * 1991-10-23 1993-05-07 Nec Corp Microprogram controller
JPH06202904A (en) * 1993-01-06 1994-07-22 Nec Ic Microcomput Syst Ltd Development support device
JPH09167117A (en) * 1995-12-15 1997-06-24 Hitachi Ltd Microcomputer and real time system using the microcomputer

Also Published As

Publication number Publication date
JPH11203166A (en) 1999-07-30

Similar Documents

Publication Publication Date Title
US5528753A (en) System and method for enabling stripped object software monitoring in a computer system
US5732272A (en) Subroutine execution time tracer
US7000225B2 (en) Method for inserting global breakpoints
EP0665496B1 (en) Method and apparatus for run-time error checking using dynamic patching
US8762958B2 (en) System and method for troubleshooting software configuration problems using application tracing
US7478282B2 (en) Log acquisition method and its control program and storage medium
US20040268315A1 (en) System and method for processing breakpoint events in a child process generated by a parent process
US20080270840A1 (en) Device and method for testing embedded software using emulator
US7401322B1 (en) Software debugging tool
US5960460A (en) Non-intrusive replication of hard disk
CN111756575A (en) Performance analysis method and device of storage server and electronic equipment
US7765434B2 (en) Resource efficient software tracing for problem diagnosis
TW389855B (en) Method and apparatus for allowing continued operation for overflow and invalid data
JP3206641B2 (en) Microcomputer system debugging method, debugging device, and recording medium recording debug program
JP3309792B2 (en) Stack pointer trace device, stack pointer trace method, and recording medium
JP3459898B2 (en) Fault information tracer for embedded systems
CN113722170B (en) PFR function test method, device, equipment and readable storage medium
JP3001470B2 (en) Boot failure detection system for personal computer
JPH0934754A (en) Instrument and method for measuring performance of program
JP2000076095A (en) Device and method for tracing program and storage medium storing program therefor
JPH096709A (en) Method for controlling electronic device with extension slot, and its device and extension medium
CN116932325A (en) System state monitoring method and device and electronic equipment
JP2677043B2 (en) Program development support device
JP3317336B2 (en) Instruction combination test method and recording medium
JPH08314766A (en) Information processor

Legal Events

Date Code Title Description
FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20090524

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20100524

Year of fee payment: 8

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

Free format text: PAYMENT UNTIL: 20110524

Year of fee payment: 9

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

Free format text: PAYMENT UNTIL: 20110524

Year of fee payment: 9

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

Free format text: PAYMENT UNTIL: 20120524

Year of fee payment: 10

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

Free format text: PAYMENT UNTIL: 20120524

Year of fee payment: 10

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

Free format text: PAYMENT UNTIL: 20130524

Year of fee payment: 11

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

Free format text: PAYMENT UNTIL: 20140524

Year of fee payment: 12

LAPS Cancellation because of no payment of annual fees