JP2005128773A - Microprocessor and compiling method - Google Patents
Microprocessor and compiling method Download PDFInfo
- Publication number
- JP2005128773A JP2005128773A JP2003363419A JP2003363419A JP2005128773A JP 2005128773 A JP2005128773 A JP 2005128773A JP 2003363419 A JP2003363419 A JP 2003363419A JP 2003363419 A JP2003363419 A JP 2003363419A JP 2005128773 A JP2005128773 A JP 2005128773A
- Authority
- JP
- Japan
- Prior art keywords
- debug
- program
- cpu core
- interrupt
- user program
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
- Microcomputers (AREA)
Abstract
【課題】 ユーザプログラムにおける所定区間の実行中は、デバッグ割込み信号の入力に拘わらず、デバッグプログラム実行モードへの遷移を防ぐ。
【解決手段】 本発明のプロセッサは、ユーザプログラム及びデバッグプログラムを実行するCPUコアと、実行の中断を禁止する割込禁止区間を前記CPUコアが前記ユーザプログラムにおいて実行しているか否かを検出する検出ブロックと、前記CPUコアが前記割込禁止区間以外の区間の実行中に、前記デバッグプログラムの実行を要求するデバッグ割込み信号が入力された場合は、前記CPUコアに前記ユーザプログラムを中断させて前記デバッグプログラムを実行させ、一方、前記CPUコアが前記割込禁止区間の実行中に、前記デバッグ割込み信号が入力された場合は、前記CPUコアに前記ユーザプログラムをそのまま継続して実行させる判定ブロックと、を備える。
【選択図】 図1PROBLEM TO BE SOLVED: To prevent a transition to a debug program execution mode during execution of a predetermined section in a user program regardless of input of a debug interrupt signal.
A processor according to the present invention detects a CPU core that executes a user program and a debug program, and whether or not the CPU core is executing an interrupt-prohibited section that prohibits interruption of execution in the user program. When a detection interrupt and a debug interrupt signal requesting execution of the debug program are input during execution of a section other than the interrupt-prohibited section, the CPU core causes the CPU core to interrupt the user program. A determination block for causing the CPU core to continuously execute the user program as it is when the debug interrupt signal is input while the CPU core is executing the interrupt prohibited section while the debug program is executed. And comprising.
[Selection] Figure 1
Description
本発明は、デバッグプログラムを用いてユーザプログラムの検証を行うマイクロプロセッサ及びコンパイル方法に関する。 The present invention relates to a microprocessor and a compiling method for verifying a user program using a debug program.
従来におけるマイクロプロセッサ等が有するデバッグ機能(例えばCPUコアに接続されたDSU(Debug Support Unit)により実現)は、マイクロプロセッサの動作モードをユーザプログラム実行モードからデバッグプログラム実行モードへ遷移させることを実現する。 A debugging function of a conventional microprocessor or the like (implemented by a DSU (Debug Support Unit) connected to the CPU core, for example) realizes transition of the microprocessor operation mode from the user program execution mode to the debug program execution mode. .
具体的には、ユーザ端末等の外部機器からDSUに特定の信号(デバッグ割込み信号)が入力されると、DSUは、CPUコアにユーザプログラムを中断させて、デバッグプログラムを実行させる。あるいは、CPUコアがユーザプログラムの実行中に特定の命令を実行することによってもデバッグプログラム実行モードへの遷移が実現される。 Specifically, when a specific signal (debug interrupt signal) is input to the DSU from an external device such as a user terminal, the DSU causes the CPU core to interrupt the user program and execute the debug program. Alternatively, the transition to the debug program execution mode is also realized by the CPU core executing a specific instruction during execution of the user program.
モード遷移によりデバッグプログラムを実行したマイクロプロセッサは、復帰命令(例えばDRET命令)を実行するなどして、ユーザプログラム実行モードへ復帰する。つまり、マイクロプロセッサは、デバッグプログラム実行モードへ遷移した際のプログラムカウンタ(PC)+1に格納された命令を実行する。従って、ユーザから見た場合、デバッグプログラムの実行中は、ユーザプログラムは中断している。 The microprocessor that has executed the debug program by mode transition returns to the user program execution mode by executing a return instruction (for example, a DRET instruction). That is, the microprocessor executes the instruction stored in the program counter (PC) +1 when transitioning to the debug program execution mode. Therefore, when viewed from the user, the user program is interrupted while the debug program is being executed.
以上のように、マイクロプロセッサのモード遷移機能を用いてユーザプログラムの実行・中断を制御することで、ユーザプログラム実行中のシステム状況に影響を与えることなく、デバッグ処理を行うことができる。
しかしながら、従来においては、ユーザ端末等の外部機器からDSUへデバッグ割込み信号が入力されると、ユーザプログラムのいかなる区間が実行されていても、強制的にデバッグプログラム実行モードへ遷移させられる問題があった。 However, conventionally, when a debug interrupt signal is input to the DSU from an external device such as a user terminal, there is a problem that a transition to the debug program execution mode is forced even if any section of the user program is executed. It was.
一般的に、ユーザプログラムにはOS(Operating System)カーネルやライブラリなど、ユーザ以外によって作成されたルーチンプログラム等がリンクされている。ユーザプログラムにリンクされたルーチンプログラム等は情報(例えばソース・コード)が公開されていないことが多く、このような場合、ユーザプログラムのデバッグ作業が困難になることがある。 In general, a user program is linked with a routine program created by a user other than the user, such as an OS (Operating System) kernel or a library. In many cases, the routine program linked to the user program does not disclose information (for example, source code), and in such a case, it may be difficult to debug the user program.
例えば、このようなルーチンプログラムを実行しているときに、マイクロプロセッサがデバッグプログラム実行モードへ遷移させられてしまうと、中断した箇所がルーチンプログラム内のどこであるか特定できないなどの状況が起こる。 For example, when such a routine program is being executed, if the microprocessor is shifted to the debug program execution mode, a situation may occur in which it is impossible to specify where the interrupted location is in the routine program.
また、I/O処理を実現するユーザプログラム、例えばイーサネット(登録商標)・コントローラ用のプログラムでは、データの入出力の途中でプログラムが中断すると、データ取得が不完全となる場合がある。つまり、プログラムの続きを実行したとしても、続きのデータを完全に取得できる保障がなく、従って、続きのプログラム実行に支障をきたすこともある。 Also, in a user program that implements I / O processing, for example, a program for an Ethernet (registered trademark) controller, if the program is interrupted during data input / output, data acquisition may be incomplete. That is, even if the continuation of the program is executed, there is no guarantee that the continuation data can be completely acquired, and therefore, the subsequent program execution may be hindered.
本発明は、上記問題点に鑑みてなされたものであり、その目的は、ユーザプログラムにおける特定区間の実行中は、デバッグ割込み信号の入力に拘わらず、デバッグプログラム実行モードへの遷移を防ぐことを可能にしたマイクロプロセッサ及びコンパイル方法を提供することにある。 The present invention has been made in view of the above problems, and its purpose is to prevent transition to the debug program execution mode during execution of a specific section in the user program regardless of the input of the debug interrupt signal. It is an object of the present invention to provide a microprocessor and a compiling method that are made possible.
本発明のマイクロプロセッサは、ユーザプログラム及びデバッグプログラムを実行するCPUコアと、実行の中断を禁止する割込禁止区間を前記CPUコアが前記ユーザプログラムにおいて実行しているか否かを検出する検出ブロックと、前記CPUコアが前記割込禁止区間以外の区間の実行中に、前記デバッグプログラムの実行を要求するデバッグ割込み信号が入力された場合は、前記CPUコアに前記ユーザプログラムを中断させて前記デバッグプログラムを実行させ、一方、前記CPUコアが前記割込禁止区間の実行中に、前記デバッグ割込み信号が入力された場合は、前記CPUコアに前記ユーザプログラムをそのまま継続して実行させる判定ブロックと、を備えたものとして構成される。 A microprocessor according to the present invention includes a CPU core that executes a user program and a debug program, and a detection block that detects whether or not the CPU core is executing an interrupt-prohibited section that prohibits interruption of execution in the user program. When a debug interrupt signal for requesting execution of the debug program is input while the CPU core is executing an interval other than the interrupt-prohibited interval, the CPU core interrupts the user program and the debug program On the other hand, if the debug interrupt signal is input while the CPU core is executing the interrupt-prohibited section, a determination block that causes the CPU core to continuously execute the user program It is configured as a provision.
また、本発明のマイクロプロセッサは、ユーザプログラムを実行して、接続された制御対象機器を制御するCPUコアと、デバッグプログラムの実行を要求するデバッグ割込み信号が入力された場合は、前記CPUコアに前記ユーザプログラムを中断させて、前記デバッグプログラムを実行させるデバッグ要求ブロックとを備え、前記デバッグ要求ブロックは、前記制御対象機器により特定処理が行われている場合は、前記デバッグ割込み信号の入力に拘わらず、前記ユーザプログラムを中断させないことを特徴とする。 The microprocessor according to the present invention executes a user program to control a connected control target device, and when a debug interrupt signal for requesting execution of a debug program is input to the CPU core. A debug request block for interrupting the user program and executing the debug program. The debug request block is related to the input of the debug interrupt signal when the specific process is performed by the control target device. The user program is not interrupted.
また、本発明のコンパイル方法は、コンパイラがソースプログラムをアセンブリコードにコンパイルする方法であって、実行の中断が禁止される割込禁止区間を前記ソースプログラム中で検出するステップと、前記ソースプログラムをアセンブリコードにコンパイルすると共に前記検出された割込禁止区間の前後に割込禁止区間を表す命令コードを挿入するステップと、を備えたことを特徴とする。 The compiling method of the present invention is a method in which a compiler compiles a source program into assembly code, the step of detecting an interrupt-prohibited section in which interruption of execution is prohibited in the source program, and the source program And compiling into assembly code and inserting an instruction code representing an interrupt-prohibited section before and after the detected interrupt-prohibited section.
本発明によれば、ユーザプログラムの中断を禁止する区間をCPUコアが実行しているか否かを判定する判定ブロックを設けたので、前記区間の実行中は、デバッグ割込み信号の入力に拘わらず、デバッグプログラム実行モードへの遷移を阻止することを実現できる。 According to the present invention, since the determination block for determining whether or not the CPU core is executing the section for prohibiting the interruption of the user program is provided during execution of the section, regardless of the input of the debug interrupt signal, It is possible to prevent the transition to the debug program execution mode.
(第1の実施の形態)
先ず、本実施の形態の特徴について簡単に説明する。
(First embodiment)
First, features of this embodiment will be briefly described.
本実施の形態は、ユーザプログラムにおいて実行の中断を禁止する区間 (クリティカル区間)をCPUコアが実行しているか否かを判定し、クリティカル区間を実行中である場合は、デバッグ割込み信号の入力に拘わらず、CPUコアをデバッグプログラム実行モードへ遷移させないことを特徴とする。 In the present embodiment, it is determined whether or not the CPU core is executing a section (critical section) in which execution interruption is prohibited in the user program. When the critical section is being executed, a debug interrupt signal is input. Regardless, the CPU core is not changed to the debug program execution mode.
以下、図面を参照しながら、本実施の形態について説明する。 Hereinafter, the present embodiment will be described with reference to the drawings.
図1は、本発明の第1の実施の形態としてマイクロプロセッサ1の構成を示すブロック図である。
FIG. 1 is a block diagram showing a configuration of a
このマイクロプロセッサ1は、ユーザプログラムを格納したメモリ2に接続されている。マイクロプロセッサ1とメモリ2とは例えばワンチップにより構成される。
The
メモリ2内のユーザプログラムには、実行中の中断を禁止する区間を特定するクリティカル区間進入命令及びクリティカル区間終了命令が挿入されている。
The user program in the
図3は、ユーザプログラム(アセンブリコード)例を示す図である。 FIG. 3 is a diagram illustrating an example of a user program (assembly code).
このユーザプログラムは、LANケーブル等から送られてきたデータを取り込んでメモリ2内に格納することを実現する。ユーザプログラムは、初期処理などを行う第1の命令群と、I/O処理を行うI/O処理命令群と、終了処理などを行う第2の命令群等を含む。I/O処理命令群の前後には、クリティカル区間進入命令(dentcli)とクリティカル区間終了命令(dextcli)が挿入されている。
This user program realizes that data sent from a LAN cable or the like is captured and stored in the
また、マイクロプロセッサ1は、ユーザ端末3に接続され、ユーザ端末3から、デバッグプログラムの実行を要求するデバッグ割込み信号を受信する。
The
以上のようにメモリ2及びユーザ端末3に接続されたマイクロプロセッサ1は、CPUコア4と、フラグ設定部5と、条件判定ブロック6と、DSU(Debug Support Unit)8とを備える。
As described above, the
CPUコア4は、上述のユーザプログラムを実行する。CPUコア4は、クリティカル区間進入命令(dentcli命令)の実行の結果、フラグ設定命令を生成し、フラグ設定部5に出力する。また、CPUコア4は、クリティカル区間終了命令(dextcli命令)の実行の結果、フラグ解除命令を生成し、フラグ設定部5に出力する。
The
フラグ設定部5は、CPUコア4からフラグ設定命令を受け取ると、クリティカル区間フラグに真(“1”)を設定する。一方、フラグ設定部5は、CPUコア4からフラグ解除命令を受け取ると、クリティカル区間フラグに偽(“0”)を設定する。このクリティカル区間フラグには、初期値として、偽(“0”)が設定されている。
When the
条件判定ブロック6は、ユーザ端末3からのデバッグ割込み信号(デバッグプログラム実行モードへの遷移を要求する信号)を、上述のクリティカル区間フラグの内容に応じて、DSU8に通過させたり、させなかったりする。
The
より詳しくは、クリティカル区間フラグが真(“1”)のときは、条件判定ブロック6は、ユーザ端末3からのデバッグ割込み信号をDSU8に通過させない。一方、クリティカル区間フラグが偽(“0”)のときは、条件判定ブロック6は、ユーザ端末3からのデバッグ割込み信号をそのままDSU8に通過させる。
More specifically, when the critical section flag is true (“1”), the
DSU8は、CPUコア4やメモリ2内の内部リソースを参照すること等(デバッグ処理)を実現するデバッグプログラムを備える。
The DSU 8 includes a debug program that realizes referring to internal resources in the
DSU8は、ユーザ端末3からデバッグ割込み信号を受け取った場合は、ユーザプログラム実行モードからデバッグプログラム実行モードにCPUコア4を遷移させる。より詳しくは、DSU8は、デバッグ割込み信号を受け取った場合は、CPUコア4にデバッグ開始信号を送出する。デバッグ開始信号を受け取ったCPUコア4は、実行中のユーザプログラムを中断して(次に実行する命令を格納したプログラムカウンタ値を記憶して)、DSU8内のデバッグプログラム8を実行する。
When the DSU 8 receives a debug interrupt signal from the
CPUコア4によるデバッグプログラムの実行中にDSU8がユーザ端末3からデバッグを中止する指示(図示せず)を受け取った場合は、DSU8はデバッグ終了信号をCPUコア4に送出する。デバッグ終了信号を受け取ったCPUコア4は、デバッグプログラムの実行を終了する命令(例えばDRET等)(予めCPUコア4内に格納されている)を実行してデバッグプログラムを終了し、その旨をDSU8に通知する。この後、CPUコア4は、引き続き、中断した箇所から、ユーザプログラムを実行する。
When the DSU 8 receives an instruction (not shown) to stop debugging from the
次に、図3のユーザプログラムを参照して、マイクロプロセッサ1による処理ステップについて説明する。
Next, processing steps performed by the
図2は、マイクロプロセッサ1による処理ステップを説明するフローチャートである。
FIG. 2 is a flowchart for explaining processing steps performed by the
CPUコア4は、メモリ2内のユーザプログラム(図3参照)を読み出し、まず、第1の命令群を実行する(ステップS1)。この結果、CPUコア4は、後続のI/O処理に必要な初期データを内部レジスタに設定する(ステップS1)。
The
次に、CPUコア4は、第1の命令群の次に配置された、クリティカル区間進入命令(dentcli)を実行する(ステップS2)。即ち、CPUコア4は、フラグ設定部5にフラグ設定命令を送出し、フラグ設定命令を受け取ったフラグ設定部5は、クリティカル区間フラグを“1”に設定する。
Next, the
次に、CPUコア4は、クリティカル区間進入命令(dentcli)の次に配置されたI/O処理命令群を実行する(ステップS3)。即ち、CPUコア4は、LANケーブル等から送られてくるデータを順次、取り込み、メモリ2内に格納する(ステップS3−1、S3−2)。図2に示すように、データの取り込み中、ユーザ端末3からデバッグ割込み信号が条件判定ブロック6に入力された場合、クリティカル区間フラグが真(“1”)であるため、条件判定ブロック6は、デバッグ割込み信号をDSU8に通過させない。従って、CPUコア4は、実行中のI/O処理命令群を中断しない。
Next, the
CPUコア4は、全てのデータを受け取ったら(ステップS3−2のYES)、I/O処理命令群の実行を終了し、このI/O処理命令群の次に配置されたクリティカル区間終了命令(dextcli)を実行する(ステップS4)。即ち、CPUコア4は、フラグ設定部5にフラグ解除命令を送出し、フラグ解除命令を受け取ったフラグ設定部5は、クリティカル区間フラグを“0”に設定する。
When the
クリティカル区間フラグが“0”に設定されたら、条件判定ブロック6は、ユーザ端末3からのデバッグ割込み信号をDSU8に通過させる(ステップS5)。デバッグ割込み信号を受け取ったDSU8は、デバッグ開始信号をCPUコア4に送出する。デバッグ開始信号を受け取ったCPUコア4は、実行中のユーザプログラムを中断して、デバッグプログラムの実行を開始する(ステップS5)。
If the critical section flag is set to “0”, the
CPUコア4によるデバッグプログラムの実行中に、DSU8が、ユーザ端末3からデバッグ中止の指示(図示せず)を受け取ったら、CPUコア4にデバッグ終了命令を送出する(ステップS6)。デバッグ終了命令を受け取ったCPUコア4は、例えば上述のDRET命令を実行して、デバッグプログラムを終了する。デバッグプログラムを終了したCPUコア4は、上で中断した箇所から、引き続き、ユーザプログラムを実行する(ステップS6)。
When the
ここで、本実施の形態をより良く理解するために、従来のマイクロプロセッサによる処理ステップについて見てみる。 Here, in order to better understand this embodiment, the processing steps by a conventional microprocessor will be examined.
図4は、従来のマイクロプロセッサによる処理ステップを説明するフローチャートである。 FIG. 4 is a flowchart for explaining processing steps by a conventional microprocessor.
図4に示すように、従来においては、I/O処理(ステップS22)中に、デバッグ割込み信号が入力されると、強制的にデバッグプログラム実行モードに遷移させられる(ステップS23)。このため、デバッグプログラム実行モードの終了後、ユーザプログラム実行モードに戻ったとしても(ステップS24)、データの完全性は保証されない(ステップS22−2)。 As shown in FIG. 4, conventionally, when a debug interrupt signal is input during the I / O process (step S22), the mode is forcibly shifted to the debug program execution mode (step S23). For this reason, even if it returns to user program execution mode after completion | finish of debug program execution mode (step S24), the integrity of data is not guaranteed (step S22-2).
これに対して、本実施の形態では、クリティカル区間進入命令(dentcli)とクリティカル区間終了命令(dextcli)によってI/O処理命令群は中断を阻止されるので、送られてきたデータを確実に取得できる。 On the other hand, in this embodiment, the I / O processing instruction group is prevented from being interrupted by the critical section entry instruction (dentcli) and the critical section end instruction (dextcli), so the transmitted data is reliably acquired. it can.
上述した例では、クリティカル区間進入命令及びクリティカル区間終了命令により特定された区間における中断を阻止したが、CPUコア4により制御される機器(制御対象機器)側から中断を阻止することも可能である。
In the above-described example, the interruption in the section specified by the critical section entry instruction and the critical section end instruction is prevented. However, it is also possible to prevent the interruption from the device (control target device) controlled by the
例えば、ユーザプログラムの内容が、制御対象機器が保有する容器内に満たされた液体を加熱し、液体が所定の温度になったことを検知したら、加熱を停止するものであったとする。制御対象機器は、CPUコア4による制御の下、容器内の液体を加熱したり、加熱を停止したりする。この場合、加熱中は、実行中のユーザプログラムを中断することは安全性の観点から好ましくない。容器内の液体が許容の温度を超えて加熱される恐れがあるからである。
For example, it is assumed that the content of the user program is to heat the liquid filled in the container held by the device to be controlled and to stop heating when it is detected that the liquid has reached a predetermined temperature. The control target device heats the liquid in the container or stops the heating under the control of the
そこで、図5に示すように、制御対象機器10にクリティカル区間フラグを保有させる。制御対象機器10は、加熱等の特定処理を行っている場合は、クリティカル区間フラグを“1”に設定し、特定処理以外の処理を行っている場合は、クリティカル区間フラグを“0”に設定する。条件判定ブロック6は、このクリティカル区間フラグに基づきデバッグ割込み信号を通過させるか否かを判断する。
Therefore, as shown in FIG. 5, the
上述のようにユーザプログラム中にクリティカル区間進入命令及びクリティカル区間終了命令を挿入する場合では例えば人間による挿入のし忘れ等によるリスクがあるが、このように制御対象機器10側に、中断を許可するか否かを判断させることで、不測の事態を確実に防止できる。
As described above, when a critical section entry instruction and a critical section end instruction are inserted into the user program, for example, there is a risk of forgetting to insert by a human being, but in this way, the
ここで、上述では、クリティカル区間をアセンブリコードで特定する例を示したが、クリティカル区間進入及び終了命令に対応する文法をC言語などの高級言語にも用意し、これに対応したコンパイラを用意することで、C言語などの高級言語でも、クリティカル区間を特定するプログラムを作成できる。 Here, in the above example, the critical section is specified by the assembly code. However, a grammar corresponding to the critical section entry and termination instructions is also prepared in a high-level language such as C language, and a compiler corresponding to this is prepared. As a result, a program for specifying a critical section can be created even in a high-level language such as C language.
この場合、コンパイルの処理ステップとしては、まず、C言語等で記述されたソースプログラム内からクリティカル区間を検出する。クリティカル区間を検出したら、ソースプログラムをコンパイルして、検出したクリティカル区間の前後にクリティカル区間進入及び終了命令を挿入した状態のアセンブリコードを生成する。 In this case, as a compilation processing step, first, a critical section is detected from within a source program described in C language or the like. When the critical section is detected, the source program is compiled to generate assembly code in which a critical section entry and end instruction is inserted before and after the detected critical section.
以上のように、本実施の形態によれば、クリティカル区間進入命令及びクリティカル区間終了命令によりクリティカル区間を特定し、クリティカル区間の実行中はデバッグ割込み信号を通過させないようにしたので、クリティカル区間の実行中に、ユーザプログラムが中断して、デバッグプログラム実行モードに遷移することを阻止できる。つまり、本実施の形態によれば、クリティカル区間内ではデバッグプログラム実行モードへの遷移を確実に防ぐと共に、クリティカル区間以外の区間ではモード遷移要求を確実に実行するデバッグ手法を提供できる。以上ように、本実施の形態によれば、デバッグプログラムの実行許可/不許可をユーザプログラムによって制御できる。 As described above, according to the present embodiment, the critical section is specified by the critical section entry instruction and the critical section end instruction, and the debug interrupt signal is not passed during the execution of the critical section. It is possible to prevent the user program from being interrupted and transiting to the debug program execution mode. In other words, according to the present embodiment, it is possible to provide a debugging method that reliably prevents a transition to the debug program execution mode within a critical section and reliably executes a mode transition request in a section other than the critical section. As described above, according to the present embodiment, execution permission / non-permission of the debug program can be controlled by the user program.
また、本実施の形態によれば、高級言語等により記述された従来のユーザプログラム(ソースプログラム)を多少変更すると共に、従来のコンパイラの設定を多少変更して、ソースプログラムを再コンパイルするだけで、クリティカル区間を特定したアセンブリコードを容易に生成できる。従って、ソースプログラムの再利用化も容易になる。 In addition, according to the present embodiment, the conventional user program (source program) written in a high-level language or the like is slightly changed, the setting of the conventional compiler is slightly changed, and the source program is simply recompiled. The assembly code specifying the critical section can be easily generated. Accordingly, it becomes easy to reuse the source program.
(第2の実施の形態)
本実施の形態は、CPUコアが特定のアドレスビットパターンを有する命令を実行中であるか否かを判定し、特定のアドレスビットパターンを有する命令を実行中である場合は、ユーザ端末3からのデバッグ割込み信号をDSU8に通過させないことを特徴とする。
(Second Embodiment)
In the present embodiment, it is determined whether or not the CPU core is executing an instruction having a specific address bit pattern. When an instruction having a specific address bit pattern is being executed, The debug interrupt signal is not passed through the
以下、本実施の形態について詳しく説明する。 Hereinafter, this embodiment will be described in detail.
図6は、本発明の第2の実施の形態としてのマイクロプロセッサ11の構成を示すブロック図である。 FIG. 6 is a block diagram showing a configuration of the microprocessor 11 as the second embodiment of the present invention.
図6に示すように、アドレスマスクレジスタ12は、所定長のアドレスビットパターン(アドレスマスク)を格納する。アドレス長が32ビットの場合、アドレスマスクは、例えば「1111XXX・・X」(Xは、“1”あるいは“0”のどちらでも可)(Xは28ビット分)となる。この場合のアドレスマスクは、上位4ビット[31:29]が全て1となるパターンを表す。アドレスマスクレジスタ12内のアドレスマスクは、CPUコア4から、随時、変更可能である。
As shown in FIG. 6, the address mask register 12 stores an address bit pattern (address mask) having a predetermined length. When the address length is 32 bits, the address mask is, for example, “1111XXX.X” (X can be “1” or “0”) (X is 28 bits). The address mask in this case represents a pattern in which the upper 4 bits [31:29] are all 1. The address mask in the
アドレスマスク比較ブロック13は、CPUコア4からプログラムカウンタ(PC)値を受け取り、このプログラムカウンタ値をアドレスマスクと比較する。プログラムカウンタ値がアドレスマスクに示されるビットパターンを有していれば、アドレスマスク比較ブロック13は、内部に保持しているクリティカル区間フラグを“1”に設定する。一方、プログラムカウンタ値がアドレスマスクに示されるビットパターンを有していない場合は、アドレスマスク比較ブロック13は、クリティカル区間フラグを“0”に設定する。
The address
条件判定ブロック6は、アドレスマスク比較ブロック13内のクリティカル区間フラグが“1”であればユーザ端末3からのデバッグ割込み信号をDSU8に通過させないが、 “0”であればこのデバッグ割込み信号をDSU8に通過させる。
The
以上のように、本実施の形態によれば、プログラムカウンタ値とアドレスマスクとを比較し、プログラムカウンタ値がアドレスマスクに示されるビットパターンを有する場合は、デバッグ割込み信号を通過させないようにしたので、同一のビットパターンを有するアドレス群(例えばメモリ2における特定セグメント)を実行している間は、ユーザプログラムの中断を阻止できる。つまり、ユーザプログラム実行モードからデバッグプログラム実行モードへ遷移することを阻止できる。以上の効果を具体例を用いて説明すると以下の通りである。 As described above, according to the present embodiment, the program counter value is compared with the address mask, and when the program counter value has the bit pattern indicated by the address mask, the debug interrupt signal is not allowed to pass. While the address group having the same bit pattern (for example, a specific segment in the memory 2) is being executed, interruption of the user program can be prevented. That is, the transition from the user program execution mode to the debug program execution mode can be prevented. The above effects will be described below using specific examples.
例えば、TX49コア(登録商標)向けのLinux(登録商標)などのOS(Operating System)では、上位4ビット[31:29]によって32ビットアドレス空間内を複数のセグメントに分けて管理している。LinuxなどのOSは、例えば、カーネルプログラムとアプリケーションプログラムとをそれぞれ別のセグメントに格納する。 For example, in an OS (Operating System) such as Linux (registered trademark) for TX49 core (registered trademark), a 32-bit address space is divided into a plurality of segments and managed by upper 4 bits [31:29]. For example, an OS such as Linux stores a kernel program and an application program in separate segments.
このような場合、カーネルプログラムが格納されたセグメントのビットパターンをアドレスマスクとすることで、カーネルプログラムの実行中はデバッグプログラム実行モードへの遷移を阻止することが可能となる。 In such a case, the transition to the debug program execution mode can be prevented during execution of the kernel program by using the bit pattern of the segment storing the kernel program as an address mask.
また、本実施の形態によれば、以上のように構成したので、ユーザプログラムに変更を加える必要はない。従って、既に存在するユーザプログラムをそのままの状態で、デバッグ対象として用いることができる。 Moreover, according to this Embodiment, since it comprised as mentioned above, it is not necessary to add a change to a user program. Therefore, the existing user program can be used as a debugging target in the state as it is.
(第3の実施の形態)
本実施の形態は、CPUコアが、指定されたアドレス範囲の命令を実行中であるか否かを判定し、指定のアドレス範囲を実行中である場合は、ユーザ端末3からのデバッグ割込み信号をDSU8に通過させないことを特徴とする。
(Third embodiment)
In the present embodiment, the CPU core determines whether or not an instruction in a designated address range is being executed. If the designated address range is being executed, a debug interrupt signal from the
以下、本発明の実施の形態について詳しく説明する。 Hereinafter, embodiments of the present invention will be described in detail.
図7は、本発明の第3の実施の形態としてのマイクロプロセッサ14の構成を示すブロックである。
FIG. 7 is a block diagram showing a configuration of the
図7に示すように、開始アドレスレジスタ15及び終了アドレスレジスタ16は、それぞれ、開始アドレス及び終了アドレスを保持する。これらの開始アドレス及び終了アドレスは、ユーザプログラムにおいて、中断を禁止するクリティカル区間を定める。開始アドレス及び終了アドレスは、CPUコア4によって、随時、変更可能である。
As shown in FIG. 7, the
開始終了アドレス比較ブロック18は、CPUコア4からプログラムカウンタ値を受信し、このプログラムカウンタ値が、開始アドレス及び終了アドレスによるアドレス範囲に含まれる場合は、内部に保持したクリティカル区間フラグを“1”に設定する。例えば、受け取ったプログラムカウンタ値が開始アドレスと一致した時点でクリティカル区間フラグを“1”に設定し、受け取ったプログラムカウンタ値が終了アドレスを越えた時点で、クリティカル区間フラグを“0”に設定する。
The start / end
条件判定ブロック6は、開始終了アドレス比較ブロック18内のクリティカル区間フラグが“1”であれば、ユーザ端末3からのデバッグ割込み信号をDSU8に通過させず、 “0”であればこのデバッグ割込み信号をDSU8に通過させる。
The
以上のように、本実施の形態によれば、開始アドレスと終了アドレスとにより特定されるアドレス範囲の命令の実行中は、ユーザ端末3からのデバッグ割込み信号をDSU8に通過させないようにしたので、特定のアドレス範囲の実行中に、ユーザプログラムが中断されて、デバッグプログラム実行モードに遷移することを阻止できる。これにより、マイクロプロセッサ固有のハードウェアアーキテクチャに即したプログラムデバッグシステムの構築も可能となる。
As described above, according to the present embodiment, the debug interrupt signal from the
また、本実施の形態によれば、以上のように構成したので、ユーザプログラムに変更を加える必要はない。従って、既に存在するユーザプログラムをそのままの状態でデバッグ対象として用いることができる。 Moreover, according to this Embodiment, since it comprised as mentioned above, it is not necessary to add a change to a user program. Therefore, an existing user program can be used as a debugging target as it is.
ここで、上述において、開始アドレス及び終了アドレスは随時、変更可能であると述べたが、開始アドレス及び終了アドレスの変更は、ユーザプログラムの中身を一切変更することなくできることが好ましい。このためには、例えば、開始アドレス及び終了アドレスを設定可能なROMモニタプログラムを別途用意し、このROMモニタプログラムをデバッグプログラム実行モード中に動作させればよい。これにより、デバッグ作業者は、ユーザプログラムの中身等を一切変更することなく、デバッグ作業中に、随時、システムの状況などを確認しながら、クリティカル区間を特定できる。 Here, in the above description, the start address and the end address can be changed at any time. However, it is preferable that the start address and the end address can be changed without changing the contents of the user program. For this purpose, for example, a ROM monitor program in which a start address and an end address can be set is prepared separately, and this ROM monitor program is operated in the debug program execution mode. As a result, the debug operator can specify the critical section while confirming the system status and the like at any time during the debug operation without changing the contents of the user program.
以上では、第1〜第3の実施の形態をそれぞれ別個のものとして説明したが、これらを組み合わせることもできる。 In the above description, the first to third embodiments have been described as being separate from each other, but these may be combined.
例えば、第1〜第3の実施の形態におけるクリティカル区間フラグにそれぞれ適宜変更可能な優先順位を設定し、最も高い優先順位を有するクリティカル区間フラグを適用するようにする。これにより、より柔軟性に富んだ、デバッグ作業が可能となる。 For example, priorities that can be appropriately changed are set for the critical section flags in the first to third embodiments, and the critical section flag having the highest priority is applied. This enables more flexible debugging work.
1,11,14 マイクロプロセッサ
2 メモリ
3 ユーザ端末
4 CPUコア
5 フラグ設定部
6 条件判定ブロック
8 DSU
10 制御対象機器
12 アドレスマスクレジスタ
13 アドレスマスク比較ブロック
15 開始アドレスレジスタ
16 終了アドレスレジスタ
18 開始終了アドレス比較ブロック
1, 11, 14
10
Claims (6)
実行の中断を禁止する割込禁止区間を前記CPUコアが前記ユーザプログラムにおいて実行しているか否かを検出する検出ブロックと、
前記CPUコアが前記割込禁止区間以外の区間の実行中に、前記デバッグプログラムの実行を要求するデバッグ割込み信号が入力された場合は、前記CPUコアに前記ユーザプログラムを中断させて前記デバッグプログラムを実行させ、一方、前記CPUコアが前記割込禁止区間の実行中に、前記デバッグ割込み信号が入力された場合は、前記CPUコアに前記ユーザプログラムをそのまま継続して実行させる判定ブロックと、
を備えたことを特徴とするマイクロプロセッサ。 A CPU core for executing a user program and a debug program;
A detection block for detecting whether or not the CPU core is executing in the user program an interrupt prohibition section that prohibits interruption of execution;
When a debug interrupt signal for requesting execution of the debug program is input while the CPU core is executing an interval other than the interrupt-prohibited interval, the user program is interrupted by the CPU core and the debug program is executed. On the other hand, when the debug interrupt signal is input while the CPU core is executing the interrupt prohibited section, a determination block that causes the CPU core to continuously execute the user program;
A microprocessor comprising:
前記検出ブロックは、前記CPUコアが前記割込禁止命令による前記指定区間を実行しているか否かに基づき、前記CPUコアが前記割込禁止区間を実行中であるか否かを検出する検出手段を含むことを特徴とする請求項1に記載のマイクロプロセッサ。 The user program has an interrupt prohibition instruction that prohibits interruption of execution in a specified section,
The detection block detects whether or not the CPU core is executing the interrupt prohibited section based on whether or not the CPU core is executing the specified section by the interrupt prohibition instruction. The microprocessor of claim 1, comprising:
デバッグプログラムの実行を要求するデバッグ割込み信号が入力された場合は、前記CPUコアに前記ユーザプログラムを中断させて、前記デバッグプログラムを実行させるデバッグ要求ブロックとを備え、
前記デバッグ要求ブロックは、前記制御対象機器により特定処理が行われている場合は、前記デバッグ割込み信号の入力に拘わらず、前記ユーザプログラムを中断させないことを特徴とするマイクロプロセッサ。 A CPU core that executes a user program to control a connected control target device; and
A debug request block for interrupting the user program to cause the CPU core to execute the debug program when a debug interrupt signal requesting execution of the debug program is input;
The microprocessor characterized in that the debug request block does not interrupt the user program regardless of the input of the debug interrupt signal when a specific process is performed by the control target device.
実行の中断が禁止される割込禁止区間を前記ソースプログラム中で検出するステップと、
前記ソースプログラムをアセンブリコードにコンパイルすると共に前記検出された割込禁止区間の前後に割込禁止区間を表す命令コードを挿入するステップと、
を備えたコンパイル方法。 A method by which a compiler compiles a source program into assembly code,
Detecting in the source program an interrupt prohibited section in which execution interruption is prohibited;
Compiling the source program into assembly code and inserting an instruction code representing an interrupt-prohibited section before and after the detected interrupt-prohibited section;
Compile method with
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2003363419A JP2005128773A (en) | 2003-10-23 | 2003-10-23 | Microprocessor and compiling method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2003363419A JP2005128773A (en) | 2003-10-23 | 2003-10-23 | Microprocessor and compiling method |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JP2005128773A true JP2005128773A (en) | 2005-05-19 |
Family
ID=34642751
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2003363419A Pending JP2005128773A (en) | 2003-10-23 | 2003-10-23 | Microprocessor and compiling method |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP2005128773A (en) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| KR100781554B1 (en) | 2004-11-29 | 2007-12-03 | 주식회사 안철수연구소 | Method for preventing from debugging computer program in real time and recording material thereof |
| JP2014507720A (en) * | 2011-01-28 | 2014-03-27 | エイアールエム リミテッド | Controlling debug exception generation |
| JP2014059748A (en) * | 2012-09-18 | 2014-04-03 | Yokogawa Electric Corp | Fault-tolerant system |
-
2003
- 2003-10-23 JP JP2003363419A patent/JP2005128773A/en active Pending
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| KR100781554B1 (en) | 2004-11-29 | 2007-12-03 | 주식회사 안철수연구소 | Method for preventing from debugging computer program in real time and recording material thereof |
| JP2014507720A (en) * | 2011-01-28 | 2014-03-27 | エイアールエム リミテッド | Controlling debug exception generation |
| GB2487575B (en) * | 2011-01-28 | 2017-04-12 | Advanced Risc Mach Ltd | Controlling generation of debug exceptions |
| JP2014059748A (en) * | 2012-09-18 | 2014-04-03 | Yokogawa Electric Corp | Fault-tolerant system |
| US9378094B2 (en) | 2012-09-18 | 2016-06-28 | Yokogawa Electric Corporation | Fault tolerant system and method for performing fault tolerant |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11113384B2 (en) | Stack overflow protection by monitoring addresses of a stack of multi-bit protection codes | |
| US6029222A (en) | Method and processor for selectively marking instructions as interruptible or uninterruptible and judging interrupt requests based on the marked instruction | |
| US7016807B2 (en) | Device and method for monitoring a program execution | |
| CN100334561C (en) | Program debug apparatus, program debug method and program | |
| JPS63250702A (en) | sequence controller | |
| JP2005128773A (en) | Microprocessor and compiling method | |
| KR100652538B1 (en) | Microcomputer | |
| JP7095513B2 (en) | Multi-core microcomputers and in-vehicle devices | |
| JP2653412B2 (en) | How to set breakpoints | |
| JP2008140124A (en) | Data processing device | |
| KR19990030244A (en) | Language processing system and method for generating an object program from a source program using two-stage jump | |
| JPS61180344A (en) | Step execution system for high level language | |
| JPH04235604A (en) | Programmable controller | |
| JP3019330B2 (en) | Compiling device | |
| JP2007004516A (en) | Program debugging method of built-in system | |
| JP2000242319A (en) | Numerical controller | |
| JPS60126731A (en) | Program control method | |
| JPH01251142A (en) | Program trace method | |
| JP2008217506A (en) | Program debugging method | |
| JPH01240941A (en) | Information processor | |
| JPS595931B2 (en) | Address stop method for arithmetic processing system | |
| JPH07281924A (en) | Trace device and emulator equipped with the same | |
| JPH07319729A (en) | Software debugging method | |
| JP2005063429A (en) | Program debugging apparatus, program debugging method and program | |
| JPS62162107A (en) | Program changing method for programmable controller |