JP4327416B2 - Trace data processing apparatus, trace data processing method, and program for executing the method - Google Patents

Trace data processing apparatus, trace data processing method, and program for executing the method Download PDF

Info

Publication number
JP4327416B2
JP4327416B2 JP2002175786A JP2002175786A JP4327416B2 JP 4327416 B2 JP4327416 B2 JP 4327416B2 JP 2002175786 A JP2002175786 A JP 2002175786A JP 2002175786 A JP2002175786 A JP 2002175786A JP 4327416 B2 JP4327416 B2 JP 4327416B2
Authority
JP
Japan
Prior art keywords
subroutine
pointer
call
value
counter
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
JP2002175786A
Other languages
Japanese (ja)
Other versions
JP2004021614A (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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric 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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP2002175786A priority Critical patent/JP4327416B2/en
Publication of JP2004021614A publication Critical patent/JP2004021614A/en
Application granted granted Critical
Publication of JP4327416B2 publication Critical patent/JP4327416B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

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

Description

【0001】
【発明の属する技術分野】
この発明は、コントローラに搭載されるプログラムのサブルーチンの呼び出し経路と、異常発生時のサブルーチンの呼び出しタイミングとをトレースできるトレースデータ処理装置、トレースデータ処理方法およびその方法を実行するためのプログラムに関するものである。
【0002】
【従来の技術】
最近の工場では、FAシステム(ファクトリー・オートメーション・システム)を活用した生産活動が行われることが多い。このFAシステムとは、生産機器、搬送機器等の機器と、生産計画、生産管理等の生産行為とを総合的に制御するような、自動化と情報化とを兼ね備えた制御システムのことを指してこう呼んでいる。
【0003】
図8は、FAシステムにおけるシステム構成の一例を示し図である。同図において、コントローラ81は、システムバスを介して接続されたインテリジェントユニット82や非インテリジェントユニット83を制御する。インテリジェントユニット82には、I/O機器84、サーボモータ85、センサ86、ランプ、アクチュエータ87等の様々な制御機器が接続され、非インテリジェントユニット83には、スイッチ、出力機器、電光管等88が接続されている。また、これらの制御機器等は、夫々外部との物理的な入出力、通信、データ変換などを行っている。コントローラ81は、内部にマイクロプロセッサ(MPU)を搭載しており、このMPUに搭載されたユーザの制御プログラムを実行させ、システム全体の動作を制御している。
【0004】
ところで、コントローラの制御プログラムをデバッグする場合などにおいて、ある実行されたサブルーチンがどのような経路で呼び出されたかを履歴としてトレースしたい場合がある。さらに、サブルーチン内で異常が発生するような場合には、そのトレースデータを元に異常が発生した場合の経路を辿ってデバッグしたいと考えるのは制御プログラムの開発者の心理である。
【0005】
図9は、従来技術のコントローラの内部構成を示すブロック図である。91はMPUであり、ユーザの制御プログラムを実行し、システム全体の動作を制御する。92はワークRAM、93はシステムROMである。システムROM93にはコントローラの動作を制御するシステムプログラムが記述されており、このシステムプログラムがユーザの制御プログラムを実行することで、システム全体の制御が実行される。ワークRAM92は、MPU91がシステムROM93に格納されたシステムプログラムを実行する際に使用する作業(ワーク)に用いるメモリである。すなわち、一時的に保存する必要があるデータを退避したり、コントローラ外部との入出力時に発生したデータを蓄えるために使用する。
【0006】
また、図9において、94はユーザRAM、95はパラメータ、96はユーザプログラム、97はデバイスメモリである。ユーザの制御プログラムはユーザプログラム96に格納される。その際、デバイスメモリ97はユーザの制御プログラム実行時のワ−クエリアとして使われる。パラメータ95は制御プログラムの実行時の条件が与えられる。98はアドレスバス、99はデータバスである。アドレスバス98はMPU91がワークRAM92、システムROM93、ユーザRAM94、デバイスメモリ97にアクセスするために使用し、データバス99は各メモリとのデータの読み出しまたは書き込みに使用する。システムROM93は読み出し専用メモリである。
【0007】
図10は、従来技術のコントローラの制御プログラムの動作の一例を示す図である。ステップS10201〜S10205までがメインプログラムの記述である。まず、ステップS10201で実行条件aを読み出し、実行条件が成立した時、ステップS10202でポインタPaから始まるサブルーチンを呼び出し、ステップS10203で実行条件bを読み出し、実行条件が成立した時、ステップS10204でポインタPbから始まるサブルーチンを呼び出す。なお、ステップS10205はメインプログラムの終了をあらわす命令(FEND命令)を示している。
【0008】
つぎに、PaはステップS10202で呼び出されたサブルーチンの先頭を示すポインタであり、ステップS10206で実行条件Paaを読み出し、実行条件が成立した時、ステップS10207でポインタPcomから始まるサブルーチンを呼び出す。このサブルーチンの実処理終了後、ステップS10208〜S10209の命令を実行し、ステップS10210でサブルーチンから復帰する命令(RET命令)を実行する。同様に、PbはステップS10211で呼び出されたサブルーチンの先頭を示すポインタであり、ステップS10211で実行条件Pbbを読み出し、実行条件が成立した時、ステップS10212でポインタPcomから始まるサブルーチンを呼び出す。このサブルーチンの実処理終了後、ステップS10213〜S10214の命令を実行し、ステップS10215でサブルーチンから復帰する命令(RET命令)を実行する。
【0009】
Pcomは、ステップS10207またはS10212で呼び出されたサブルーチンの先頭を示すポインタであり、ステップS10216で実行条件Pccを読み出し、実行条件が成立した時、ステップS10217でサブルーチンの実処理を開始し、ステップS10218〜S10219の命令を実行し、ステップS10220でサブルーチンから復帰する命令(RET命令)を実行する。なお、ステップS10221は全てのプログラムの終了を意味する命令(END命令)を示している。
【0010】
図11は、従来技術におけるコントローラのサブルーチンプログラムの処理を示す図である。同図に示すように、通常コントローラは、外部からの入力処理、プログラム実行、外部への出力処理を一周期として繰り返すことでプログラムを実行している。この一周期の時間をスキャンタイムと呼ぶ。また、プログラム実行中にサブルーチン呼び出しが発生すると、メインプログラムの実行が一旦中断され、サブルーチン呼び出しのポインタに応じたプログラムが実行され、サブルーチンプログラムの実行が終了すると、サブルーチン呼び出し発生時のつぎの命令へ復帰し、中断していたプログラムの処理が再開される。
【0011】
サブルーチンはプログラミングテクニックのなかでも大変重要な概念であり、プログラムを効率よく開発し、読みやすいプログラムを作成する上で、欠くことのできない考え方である。その中で、特に、サブルーチンを必要とする理由の一つは、「同じことを何度も書かずに済ませる」ことができることである。プログラムを作っているとプログラムの流れの中の異なる場面で、まったく同じ処理をする必要があったり、ほとんど同じ処理だけれど、微妙に違うような処理がしばしば現れる。できればそういった処理は共用できるものを一つ記述しておき、つぎからはその記述を利用したいものである。そこで何度も出てくる処理はプログラム本体(メインルーチン)とは別の場所に一つだけ作ることにして、その処理が必要になったときにそれを呼び出すという方法が考え出された。
【0012】
図12は、サブルーチンの処理概念を示す説明図である。同図の例では、メインルーチンによって処理Aが3回呼び出され(同図に示すタイミング121、123、125)、また、メインルーチンによって処理Bが1回呼び出されている(同図に示すタイミング127)。このようにメインルーチンとは別の場所に記述され、プログラム本体から呼び出されるためのあるまとまった処理を行うプログラムのことをサブルーチンと呼ぶ。なお、同じサブルーチンを別々の場所から呼び出すとしても、復帰する際は、毎回別々の場所へ復帰することとなる(同図に示すタイミング122、124、126、128)。
【0013】
図13は、CALL命令とRET命令とスタックの概念を示す説明図である。スタックとは、「最後に格納したデータを最初に取り出す」動作のことをいう。スタックは本を積み上げる行為に似ている。本を積み上げていくと、最初に取り出せるのは最後に積み上げた本である。すなわち、スタックに幾つかのデータを積んだとすると、最初に取り出せるのは最後に積んだデータである。このスタックを実現するために用意されているのがスタックポインタ(SP)である。ポインタと呼ばれることからもわかるように、スタックポインタはスタックエリアのメモリを指し示す役割を持っており、常にスタックトップ(積み上げられたスタックの一番上)を指している。
【0014】
このスタックの状態がサブルーチンの呼び出しに応じてどのように推移するのかを、図13を用いて説明する。まず、CALL命令実行前のスタックの状態は、「▲1▼CALL命令実行前のスタックの状態」であるとする。ステップS10401でCALL命令が実行されると、つぎに実行すべき命令のアドレスを示す“bbb”がスタックに積まれる。このとき、スタックポインタは、つぎのスタック処理のためにポインタが更新される。すなわち、スタックポインタは、この“bbb”が積まれた場所に移動する。同時に、スタックの状態は、「▲2▼CALL命令実行後のスタックの状態」のようになる。さらに、ステップS10402でCALL命令が実行されると、つぎに実行すべき命令のアドレスを示す“ccc”がスタックに積まれ、スタックポインタはつぎのスタック処理のために更新され、スタックの状態は、「▲3▼CALL命令実行後のスタックの状態」のようになる。この状態で、「▲4▼サブルーチン実処理実行」が行われると、ステップS10404でステップS10402に対応するRET命令が実行され、つぎに実行すべき命令のアドレス“ccc”がスタックから取り出され、つぎのスタック処理のためにポインタが更新され、スタックの状態は、「▲5▼RET命令実行後のスタックの状態」のようになる。
【0015】
同様に、ステップS10405でステップS10401に対応するRET命令が実行され、つぎに実行すべき命令のアドレス“bbb”がスタックから取り出され、つぎのスタック処理のためにポインタが更新され、スタックの状態は、「▲6▼RET命令実行後のスタックの状態」のようになる。このように、一連のサブルーチンの呼び出し処理が終了すると、最終的には呼び出し前の状態、すなわち「▲1▼CALL命令実行前のスタックの状態」に戻る。
【0016】
このように、メインルーチンの途中からサブルーチンにジャンプしても、RET命令実行時に、つぎに実行するべき命令のアドレスをスタックから取り出すことができるので、スタックポインタの管理を行っているだけで、メインルーチンをサブルーチンに分割して、プログラムの可読性を向上することができる。
【0017】
図14は、従来技術におけるCALL命令とRET命令の動作の一例を示す図である。同図では、図10のプログラムが図9のユーザプログラム96にどのように格納されているのか具体的に示している。
【0018】
図14において、ステップS10601には「LD 実行条件a」(実行条件aの読出し命令)、ステップS10602には「CALL Pa」(ポインタPaから始まるサブルーチン呼び出し命令)、ステップS10603には「LD 実行条件b」(実行条件bの読出し命令)、ステップS10604には「CALL Pb」(ポインタPbから始まるサブルーチン呼び出し命令)、ステップS10605には「FEND」(メインプログラムの終了を意味する命令)が夫々格納されている。
【0019】
つぎに、ステップS10606には「LD 実行条件Paa」(実行条件Paaの読出し命令)、ステップS10607には「CALL Pcom」(ポインタPcomから始まるサブルーチン呼び出し命令)、ステップS10608〜S10609には命令AA〜AZ、ステップS10610には「RET」(サブルーチンPaから復帰する命令)が夫々格納されている。
【0020】
また、ステップS10611には「LD 実行条件Pbb」(実行条件Pbbの読出し命令)、ステップS10612には「CALL Pcom」(ポインタPcomから始まるサブルーチン呼び出し命令)、ステップS10613〜S10614には命令BA〜BZ、ステップS10615には「RET」(サブルーチンPから復帰する命令)が夫々格納されている。
【0021】
最後に、ステップS10616には「LD 実行条件Pcc」(実行条件Pccの読出し命令)、ステップS10617〜S10619には命令CA〜CZ、ステップS10620には「RET」(サブルーチンPcomから復帰する命令)、ステップS10621には、「END」(全てのプログラムの終了を意味する命令)が夫々格納されている。
【0022】
つぎに、図14を用いて、CALL命令とRET命令の概念を説明する。処理の開始は、図10に示すように、「LD 実行条件a」が成立しているか否かを判断するところから開始される。ステップS10601で「LD 実行条件a」が成立していると判断した場合は、ステップS10602で「CALL Pa」を実行する。このとき、「CALL Pa」のつぎに実行すべき命令のステップ番号(ステップS10603)をスタックに積み、処理141で示すように、ステップS10606へジャンプする。
【0023】
ステップS10606で「LD 実行条件Paa」が成立していると判断した場合は、ステップS10607で「CALL Pcom」を実行する。このとき、「CALL Pcom」のつぎに実行すべき命令のステップ番号(ステップS10608)をスタックに積み、処理142で示すように、ステップS10616へジャンプする。
【0024】
ステップS10616で「LD 実行条件Pcc」が成立していると判断した場合は、ステップS10617で「命令CA」を実行し、ステップS10618で「命令CB」を実行し、以下順次、命令を実行し、ステップS10619で「命令CZ」を実行し、最後にステップS10621でRET命令を実行する。このとき、スタックに積んだ「つぎに実行すべき命令のステップ番号(ここではステップS10608)」を読み出し、処理143で示すように、ステップS10608へジャンプする。
【0025】
ステップS10608で「命令AA」を実行し、以下順次、命令を実行し、ステップS10609で「命令AZ」を実行し、最後にステップS10610でRET命令を実行する。このとき、さらにスタックに積んだ「つぎに実行すべき命令のステップ番号(ここではステップS10603)」を読み出し、処理144で示すように、ステップS10603へジャンプする。以下処理145〜処理148についても同様な処理の繰り返しになるので、説明は省略する。
【0026】
【発明が解決しようとする課題】
近年、コンピュータプログラムはオブジェクト指向化が進み、OA、FAといった対象分野を問わず、標準化されたプログラムを使おうとする傾向が強い。特に、FA分野において唯一の国際標準規格であるIEC61131−3の影響を受け、ラダー、リストによるプログラミングからファンクションブロック(FB)またはファンクションブロックダイアグラム(FBD)によるプログラミングに移行する動きがある。このIEC61131−3規格によれば、よく使うプログラムを部品化(FB化)し、メインプログラムにてFBを使うことができるので、プログラム全体の見通しがよくなり、開発効率は一見向上したかのように錯覚する。
【0027】
FBは、よく使うプログラム部品だからこそFB化されているのであり、メインプログラムの数箇所で複数回に渡って使われている可能性が大である。いま、FB内で異常発生したときのことを考えてみる。例えば、FB内でサブルーチンをCALLし、サブルーチン内で異常が発生した場合などである。この場合、メインプログラムのどこから呼び出されたのか、どのタイミングで異常発生したのかわからなければ、デバッグすることができない。
【0028】
しかしながら、上述した従来技術の場合、サブルーチン呼び出しの順番をトレースすることはできないという欠点があった。また、特開平7−141222、特開平4−336631、特開平2−294845、特開昭64−48133、特開昭59−221753号公報などに示される従来技術は、異常発生のタイミングをトレースすることができなかったり、あるいは、たとえできたとしても特別な手段を用いる必要があった。
【0029】
この発明は上記に鑑みてなされたものであり、少ないオーバヘッドでサブルーチンに関するトレース情報を記録し、異常発生時のサブルーチンCALLのタイミングをトレースできるトレースデータ処理装置、トレースデータ処理方法およびその方法を実行するためのプログラムを得ることを目的とする。
【0030】
【課題を解決するための手段】
上記目的を達成するため、この発明にかかるトレースデータ処理装置は、プログラムを搭載し、このプログラムから階層的に呼び出されるサブルーチンの実行情報をトレースするトレースデータ処理装置において、プログラムから階層的に呼び出されるサブルーチンの実行情報を格納する記憶領域であるスタックエリアと、呼び出し元サブルーチンの呼び出しステップ番号、呼び出し先サブルーチンのポインタ値および呼び出し先サブルーチンの実行結果を含む実行情報を格納する記憶領域であり、前記スタックエリアとは異なるデータテーブルと、が設けられ、プログラムまたはサブルーチンから呼び出される最初のアドレス位置に、前記データテーブルへの格納を指示するための指標として機能するトレースポイントが存在するときに前記データテーブルにおける実行情報の格納位置を示す第1のポインタの指し示す位置に、前記呼び出し元サブルーチンの呼び出しステップ番号および前記呼び出し先サブルーチンのポインタ値を格納し、前記呼び出し先サブルーチンからの復帰処理の際、前記データテーブルにおける実行情報の格納位置を示し、前記第1のポインタとは異なる第2のポインタの指し示す位置に、前記呼び出し先サブルーチンの処理結果を格納することを特徴とする。
【0031】
この発明によれば、プログラムから階層的に呼び出されるサブルーチンの実行情報を格納する記憶領域であるスタックエリアと、呼び出し元サブルーチンの呼び出しステップ番号、呼び出し先サブルーチンのポインタ値および呼び出し先サブルーチンの実行結果を含む実行情報を格納する記憶領域であり、スタックエリアとは異なるデータテーブルと、が設けられる。トレースデータ処理装置は、プログラムまたはサブルーチンから呼び出される最初のアドレス位置に、データテーブルへの格納を指示するための指標として機能するトレースポイントが存在するときに、データテーブルにおける実行情報の格納位置を示す第1のポインタの指し示す位置に、呼び出し元サブルーチンの呼び出しステップ番号および呼び出し先サブルーチンのポインタ値を格納し、呼び出し先サブルーチンからの復帰処理の際、データテーブルにおける実行情報の格納位置を示し、第1のポインタとは異なる第2のポインタの指し示す位置に、呼び出し先サブルーチンの処理結果を格納する。
【0032】
つぎの発明にかかるトレースデータ処理装置は、上記の発明において、前記データテーブルに格納された前記サブルーチンの呼び出し回数を保持する第1のカウンタと、前記サブルーチンの実行処理後の復帰回数を保持する第2のカウンタと、が設けられ、前記呼び出し先サブルーチンに前記トレースポイントがあるときに前記第1のカウンタの値を増加させ、前記トレースポイントを有する前記呼び出し先サブルーチンからの復帰処理時に、前記第1のカウンタの値を増加させ、かつ、前記第2のカウンタの値を減少させることを特徴とする。
【0033】
この発明によれば、データテーブルに格納されたサブルーチンの呼び出し回数を保持する第1のカウンタと、サブルーチンの実行処理後の復帰回数を保持する第2のカウンタと、が設けられ、呼び出し先サブルーチンにトレースポイントがあるときに第1のカウンタの値を増加させ、トレースポイントを有する呼び出し先サブルーチンからの復帰処理時に、第1のカウンタの値を増加させ、かつ、第2のカウンタの値を減少させる。
【0034】
つぎの発明にかかるトレースデータ処理装置は、上記の発明において、前記第1のポインタの値をnとし、前記第2のカウンタの値をmとするときに、前記第2のポインタの値pを、
p=n−((m−1)×3+1)
の計算式で算出することを特徴とする。
【0035】
この発明によれば、第1のポインタの値をnとし、第2のカウンタの値をmとするときに、前記第2のポインタの値pを、
p=n−((m−1)×3+1)
の計算式で算出することができる。
【0036】
つぎの発明にかかるトレースデータ処理方法は、プログラムから階層的に呼び出されるサブルーチンの実行情報をトレースするトレースデータ処理方法において、プログラムから階層的に呼び出されるサブルーチンの実行情報を格納する記憶領域であるスタックエリアと、呼び出し元サブルーチンの呼び出しステップ番号、呼び出し先サブルーチンのポインタ値および呼び出し先サブルーチンの実行結果を含む実行情報を格納する記憶領域であり、前記スタックエリアとは異なるデータテーブルと、が設けられ、プログラムまたはサブルーチンから呼び出される最初のアドレス位置に、前記データテーブルへの格納を指示するための指標として機能するトレースポイントが存在するか否かを判断し、前記トレースポイントが存在するときに、前記データテーブルにおける実行情報の格納位置を示す第1のポインタの指し示す位置に、前記呼び出し元サブルーチンの呼び出しステップ番号および前記呼び出し先サブルーチンのポインタ値を格納し、前記呼び出し先サブルーチンからの復帰処理の際、前記データテーブルにおける実行情報の格納位置を示し、前記第1のポインタとは異なる第2のポインタの指し示す位置に、前記呼び出し先サブルーチンの処理結果を格納することを特徴とする。
【0037】
この発明によれば、プログラムから階層的に呼び出されるサブルーチンの実行情報を格納する記憶領域であるスタックエリアと、呼び出し元サブルーチンの呼び出しステップ番号、呼び出し先サブルーチンのポインタ値および呼び出し先サブルーチンの実行結果を含む実行情報を格納する記憶領域であり、スタックエリアとは異なるデータテーブルと、が設けられる。プログラムまたはサブルーチンから呼び出される最初のアドレス位置に、データテーブルへの格納を指示するための指標として機能するトレースポイントが存在するか否かが判断され、このトレースポイントが存在するときに、データテーブルにおける実行情報の格納位置を示す第1のポインタの指し示す位置に、呼び出し元サブルーチンの呼び出しステップ番号および呼び出し先サブルーチンのポインタ値が納され、呼び出し先サブルーチンからの復帰処理の際、データテーブルにおける実行情報の格納位置を示し、第1のポインタとは異なる第2のポインタの指し示す位置に、呼び出し先サブルーチンの処理結果が格納される。
【0038】
つぎの発明にかかるトレースデータ処理方法は、上記の発明において、前記データテーブルに格納された前記サブルーチンの呼び出し回数を保持する第1のカウンタと、前記サブルーチンの実行処理後の復帰回数を保持する第2のカウンタと、が設けられ、前記呼び出し先サブルーチンに前記トレースポイントがあるときに、前記データテーブルに格納された前記第1のカウンタの値を増加させ、前記トレースポイントを有する前記呼び出し先サブルーチンからの復帰処理時に、前記第1のカウンタの値を増加させ、かつ、前記第2のカウンタの値を減少させることを特徴とする。
【0039】
この発明によれば、呼び出し先サブルーチンにトレースポイントがあるときに、データテーブルに格納されたサブルーチンの呼び出し回数を保持する第1のカウンタの値を増加させ、トレースポイントを有する呼び出し先サブルーチンからの復帰処理時に、第1のカウンタの値を増加させ、かつ、サブルーチンの実行処理後の復帰回数を保持する第2のカウンタの値を減少させる。
【0040】
つぎの発明にかかるトレースデータ処理方法は、上記の発明において、前記第1のポインタの値をnとし、前記第2のカウンタの値をmとするときに、前記第2のポインタの値pを、
p=n−((m−1)×3+1)
の計算式で算出することを特徴とする。
【0041】
この発明によれば、第1のポインタの値をnとし、第2のカウンタの値をmとするときに、前記第2のポインタの値pを、
p=n−((m−1)×3+1)
の計算式で算出することができる。
【0042】
つぎの発明にかかるプログラムは、上記の発明のいずれか一つに記載された方法をコンピュータに実行させるプログラムであり、そのプログラムがコンピュータ読み取り可能となり、これによって、上記の発明のいずれか一つの動作をコンピュータによって実行することができる。
【0043】
【発明の実施の形態】
以下に添付図面を参照して、この発明にかかるトレースデータ処理装置、トレースデータ処理方法およびその方法を実行するためのプログラムの好適な実施の形態を詳細に説明する。
【0044】
図1は、この発明にかかるコントローラの制御プログラムの動作の一例を示す図である。ステップS101〜S105までがメインプログラムの記述である。まず、ステップS101で実行条件aを読み出し、実行条件が成立した時、ステップS102でポインタPaから始まるサブルーチンを呼び出し、ステップS103で実行条件bを読み出し、実行条件が成立した時、ステップS104でポインタPbから始まるサブルーチンを呼び出す。なお、ステップS105はメインプログラムの終了をあらわす命令(FEND命令)を示している。
【0045】
つぎに、PaはステップS102で呼び出されたサブル−チンの先頭を示すポインタであり、ステップS106で実行条件Paaを読み出し、実行条件が成立した時、ステップS107でポインタPcomから始まるサブルーチンを呼び出す。このサブルーチンの実処理終了後、ステップS108〜S109の命令を実行し、ステップS110でサブルーチンから復帰する命令(RET命令)を実行する。同様に、PbはステップS104で呼び出されたサブルーチンの先頭を示すポインタであり、ステップS111で実行条件Pbbを読み出し、実行条件が成立した時、ステップS112でポインタPcomから始まるサブルーチンを呼び出す。このサブルーチンの実処理終了後、ステップS113〜S114の命令を実行し、ステップS115でサブルーチンから復帰する命令(RET命令)を実行する。
【0046】
ところで、PcomはステップS107またはS112で呼び出されたサブルーチンの先頭を示すポインタであるが、このPcomは“tp(トレースポイント)”で修飾されている点に特徴があり、従来技術との相違点である。なお、このtpについては、後で詳述する。
【0047】
その後の処理は従来技術で説明したのと同様に、ステップS116で実行条件Pccを読み出し、実行条件が成立した時、ステップS117でサブルーチンの実処理を開始し、ステップS118〜S119の命令を実行し、ステップS120でサブルーチンから復帰する命令(RET命令)を実行する。なお、ステップS121は全てのプログラムの終了を意味する命令(END命令)である。
【0048】
図2は、この発明にかかる階層構造プログラムの実施の概念を示す説明図である。同図において、21はCALLカウンタ、22はRETカウンタ、23はデータテーブル、24はCALLポインタ、25はRETポインタを夫々示している。
【0049】
CALLポインタ24とRETポインタ25は、▲1▼呼び出し元サブルーチンの呼び出しステップ番号、▲2▼呼び出し先サブルーチンのポインタ番号、▲3▼呼び出し先サブルーチンの実行結果の3つの情報をひとつのブロックとしてデータテーブル23に格納するためのポインタである。また、CALLカウンタ21とRETカウンタ22はCALLポインタ24とRETポインタ25の算出に用いるためのCALL処理とRET処理の回数を格納するための作業(ワーク)エリアである。
【0050】
図3は、この発明にかかるCALL命令とRET命令の動作の一例を示す図である。同図は、図1のプログラムが図9に示すユーザプログラム96にどのように格納されているのかを具体的に示す図である。図14に示す従来技術と比較して、ステップS315の「RET」とステップS316の「LD 実行条件Pcc」との間に、ステップS322の「tp」が格納されている。その他、命令が格納される位置や呼び出しの動作については、従来技術で説明した内容と同一であるので、説明を省略する。
【0051】
図4は、この発明にかかるCALL処理の処理手順を示すフローチャートである。同図を用いて、通常のCALL処理とtp付ポインタを呼び出した場合のCALL処理とを比較しながら説明する。
【0052】
まず、ステップS401でスタックポインタを読出し、ステップS402でスタックポインタの指す位置のつぎの位置に実行するステップ番号を格納し、ステップS403でスタックポインタを更新し、ステップS404で呼び出し先のサブルーチンポインタ番号を読み出す。ここまでは、通常のCALL処理と何ら変わる処理ではない。
【0053】
つぎに、ステップS405でCALLするポインタが、tp付ポインタであるか否かを判断する。ステップS405でCALLするポインタが、tp付ポインタの場合には、ステップS407へ移行し、図2に示すデータテーブル23のCALLポインタ24を読出し、ステップS408でCALLポインタ24の指す位置に呼び出し元ステップ番号を格納し、ステップS409でCALLポインタ24の更新を行い、ステップS410で呼び出し先サブルーチンのポインタ番号を読出し、ステップS411でCALLポインタ24の指す位置に呼び出し先サブルーチンのポインタ番号を格納し、ステップS412でCALLポインタ24を更新し、ステップS413で、図2に示すCALLカウンタ21を更新し、ステップS414でCALLポインタ24を、図2に示すRETポインタ25にコピーする。ステップS415でtp付ポインタ呼び出しフラグを、図9に示すワークRAM92にセットしておき、ステップS416で呼び出したポインタ番号の指すステップ番号の処理を実行する。なお、上記のステップS401〜S404の処理からステップS416の処理に移行する流れが通常の処理の流れである。
【0054】
一方、ステップS405の処理において、CALLするポインタがtp付ポインタでない場合には、さらに、ステップS406でワークRAM92に格納されたtp付ポインタ呼び出しフラグがセットされているか否かを判断する。このtp付ポインタ呼び出しフラグがセットされている場合には、ステップS407からの処理を実行し、tp付ポインタ呼び出しフラグがセットされていない場合には、ステップS416の処理を実行する。
【0055】
図5は、図4のCALL処理に対応したRET処理の処理手順を示すフローチャートである。同図を用いて、RET処理の流れについて説明する。
【0056】
まず、ステップS502で、図2に示すCALLカウンタ21が“0”か否かを判断する。このCALLカウンタ21が“0”の場合には、tp付きのサブルーチンCALL処理は行われていないので、通常のRET処理を行うために、ステップS510へ移行し、ステップS510でスタックポインタを読出し、ステップS511でスタックからつぎに実行するステップ番号を読み出し、ステップS512で読み出したステップ番号の命令を実行する。
【0057】
一方、ステップS502でCALLカウンタ21が“0”でない場合には、tp付きのサブルーチンCALL処理が行われた場合であり、ステップS503で、図2に示すRETカウンタ22を読み出し、ステップS504でRETカウンタ22を更新し、ステップS505でRETカウンタ22の値(m)を用いてRETポインタ25の演算を行う。このRETポインタ25の演算内容は、RETポインタ25=CALLポインタ24−{(m−1)×3+1}の計算式で行う。さらに、ステップS506でRETポインタ25演算結果の指す位置にRET処理結果を格納し、ステップS507でRET処理が終了を示すために、CALLカウンタ21を更新する。
【0058】
つぎに、ステップS508でCALLカウンタ21の値を再度確認し、この値が0であれば、tp付ポインタ呼び出し処理が全て終了しており、ステップS509でtp付ポインタ呼び出しフラグをクリアし、ステップS510に移行し、通常のRET処理を行う。また、ステップS508でCALLカウンタ21の値が0でなければ、tp付ポインタ呼び出し処理が完了していないので、tp付ポインタ呼び出しフラグはクリアせず、ステップS510に移行して通常のRET処理を行う。
【0059】
図6は、tp付き呼び出しのCALL処理が行われたときのデータテーブル等の動きを示す説明図である。同図は、図2に示すデータテーブル23、CALLポインタ(CP)24、RETポインタ(RP)25、CALLカウンタ21、RETカウンタ22が、初期状態からCALL命令の実行と共に推移する様子を示している。なお、CALLのネスト(深さ)は“5”であり、全てtp付き呼び出しのCALL処理が実行されたものとしている。
【0060】
図6において、初期状態では、CALLカウンタ、RETカウンタは共に“0”であり、CP、RPは図示しない所定の位置に設定されている。1回目のCALL命令が実行されると、CALLカウンタがインクリメント(+1)され、すなわち“1”に設定され(図4のステップS413の処理に対応)、CPがインクリメント(+3)され(図4のステップS409、S412の処理に対応)、RPもCPと同じポインタ値にセットされる(図4のステップS414の処理に対応)。したがって、CP、RPは、図6の位置61のポインタがセットされることになる。
【0061】
同様に、2回目のCALL命令が実行されると、CALLカウンタがインクリメント(+1)され、すなわち“2”に設定され、CPがインクリメント(+3)され、RPもCPと同じポインタ値にセットされる。したがって、CP、RPは、位置62のポインタがセットされる。以下、5回目のCALL命令が実行されると、最終的には、CALLカウンタが“5”に設定され、CP、RPは、位置65のポインタがセットされる。
【0062】
図7は、図6のCALL処理が行われた後に、RET命令が実行されるときのデータテーブル等の動きを示す説明図である。同図は、図2に示すデータテーブル23、CALLポインタ(CP)24、RETポインタ(RP)25、CALLカウンタ21、RETカウンタ22が、図6の状態からRET命令の実行と共に推移する様子を示している。
【0063】
図7において、RET命令が実行されていない状態は、図6において5回目のCALL命令が実行された状態と同一である。すなわち、CALLカウンタ25は“5”に設定され、RETカウンタは“0”に設定され、CP、RPは、位置65のポインタがセットされている。1回目のRET命令が実行されると、RETカウンタがインクリメント(+1)され、すなわち“1”に設定され(図5のステップS504の処理に対応)、CALLカウンタがディクリメント(−1)され、すなわち“4”に設定され(図5のステップS507の処理に対応)、CPの値はそのままであり、RPがディクリメント(−1)され、位置66のポインタがセットされる(図5のステップS505の演算処理に対応)。
【0064】
同様に、2回目のRET命令が実行されると、RETカウンタがインクリメント(+1)され、すなわち“2”に設定され、CALLカウンタがディクリメント(−1)され、すなわち“3”に設定され、CPの値はそのままであり、RPがディクリメント(−3)され、位置67のポインタがセットされる。以下、5回目のRET命令が実行されると、最終的には、CALLカウンタが“0”に設定され、RETカウンタが“5”に設定され、CPは位置65のポインタのままであり、RPは位置70のポインタがセットされる。
【0065】
例えば、図7において、3回目のRET命令が実行され、4回目のRET命令が実行される前にエラーが発生したと仮定すると、RPは位置69のポインタには更新されず、位置68のポインタのままである。このとき、CALLカウンタ値、RETカウンタ値、RPの値の情報から、どの呼び出し処理でエラーが発生したのかを判定することができる。また、エラーが発生した位置(この例では、位置68)のポインタをXとすると、X−1には呼び出し先のポインタ番号が設定され、X−2には呼び出し元のステップ番号が設定されているので、これらの情報からエラーの発生の原因を探求するためのプログラム実行情報を得ることができる。
【0066】
このトレース処理は、▲1▼呼び出し元サブルーチンの呼び出しステップ番号、▲2▼呼び出し先サブルーチンのポインタ番号、▲3▼呼び出し先サブルーチンの実行結果の3つの情報のみで構成されるため、少ないオーバヘッドで階層構造プログラムに関する実行情報を得ることができる。また、トレース情報だけでなく、サブルーチンの実行結果の情報も含んでいるため、正常に終了した処理においても、処理結果そのものの妥当性に関して評価できるので、効率のよいデバックをすることができる。
【0067】
以上詳述してきたように、この発明にかかるトレースデータ処理装置、トレースデータ処理方法およびその方法を実行するプログラムによれば、構造化されたプログラムを処理する情報処理装置のプログラム実行に関し、階層構造をもつ構造化プログラムの実行において、階層構造プログラムの実行タイミングをトレース(追跡)することができ、実行の途中でエラーが発生した場合にそのエラー要因とプログラムの実行タイミングを把握でき、かつ少ないオーバヘッドで階層構造プログラムに関する実行情報を得ることができる。
【0068】
【発明の効果】
以上説明したように、この発明によれば、プログラムから階層的に呼び出されるサブルーチンの実行情報を格納する記憶領域であるスタックエリアと、呼び出し元サブルーチンの呼び出しステップ番号、呼び出し先サブルーチンのポインタ値および呼び出し先サブルーチンの実行結果を含む実行情報を格納する記憶領域であり、スタックエリアとは異なるデータテーブルと、が設けられ、プログラムまたはサブルーチンから呼び出される最初のアドレス位置に、データテーブルへの格納を指示するための指標として機能するトレースポイントが存在するときに、データテーブルにおける実行情報の格納位置を示す第1のポインタの指し示す位置に、呼び出し元サブルーチンの呼び出しステップ番号および呼び出し先サブルーチンのポインタ値が格納され、呼び出し先サブルーチンからの復帰処理の際、データテーブルにおける実行情報の格納位置を示し、第1のポインタとは異なる第2のポインタの指し示す位置に、呼び出し先サブルーチンの処理結果が格納されるので、サブルーチンのネストが深い段階でエラーが発生してもCALL命令の動きを順番にトレースすることができ、かつ、どのCALL処理の段階でエラーが発生したのかをトレースできるので、サブルーチンを多用した標準化プログラムのデバッグ効率の向上が期待できるという効果を奏する。また、1回のCALL処理に要する情報は、▲1▼呼び出し元サブルーチンの呼び出しステップ番号、▲2▼呼び出し先サブルーチンのポインタ番号、▲3▼呼び出し先サブルーチンの実行結果の3情報のみなので、少ないオーバヘッドで上記の効果が得られるというさらなる効果がある。さらに、通常のCALL処理と本CALL処理は使い分けが可能なので、必要に応じて、FBやFBDを使うようなところにtp付ポインタを使うことで、デバッグ効率の向上、処理効率の向上、メモリ資源の効率的な使用が可能になる等ユーザにとって、最適なデバッグ手段を提供できるという効果を奏する。
【0069】
つぎの発明によれば、データテーブルに格納されたサブルーチンの呼び出し回数を保持する第1のカウンタと、サブルーチンの実行処理後の復帰回数を保持する第2のカウンタと、が設けられ、呼び出し先サブルーチンにトレースポイントがあるときに第1のカウンタの値を増加させ、トレースポイントを有する呼び出し先サブルーチンからの復帰処理時に、第1のカウンタの値を増加させ、かつ、第2のカウンタの値を減少させるようにしているので、サブルーチンのネストが深い段階でエラーが発生してもCALL命令の動きを順番にトレースすることができ、かつ、どのCALL処理の段階でエラーが発生したのかをトレースできるので、サブルーチンを多用した標準化プログラムのデバッグ効率の向上が期待できるという効果を奏する。また、通常のCALL処理と本CALL処理は使い分けが可能なので、必要に応じて、FBやFBDを使うようなところにtp付ポインタを使うことで、デバッグ効率の向上、処理効率の向上、メモリ資源の効率的な使用が可能になる等ユーザにとって、最適なデバッグ手段を提供できるという効果を奏する。
【0070】
つぎの発明によれば、第1のポインタの値をnとし、第2のカウンタの値をmとするときに、前記第2のポインタの値pを、
p=n−((m−1)×3+1)
の計算式で算出するようにしているので、サブルーチンのネストが深い段階でエラーが発生してもCALL命令の動きを順番にトレースすることができ、かつ、どのCALL処理の段階でエラーが発生したのかをトレースできるので、サブルーチンを多用した標準化プログラムのデバッグ効率の向上が期待できるという効果を奏する。
【0071】
つぎの発明によれば、プログラムから階層的に呼び出されるサブルーチンの実行情報を格納する記憶領域であるスタックエリアと、呼び出し元サブルーチンの呼び出しステップ番号、呼び出し先サブルーチンのポインタ値および呼び出し先サブルーチンの実行結果を含む実行情報を格納する記憶領域であり、スタックエリアとは異なるデータテーブルと、が設けられ、データテーブルへの格納を指示するための指標として機能するトレースポイントが呼び出し先サブルーチン上に存在するか否かが判断され、トレースポイントが呼び出し先サブルーチン上に存在するときに、データテーブルにおける実行情報の格納位置を示す第1のポインタの指し示す位置に、呼び出し元サブルーチンの呼び出しステップ番号および呼び出し先サブルーチンのポインタ値が納され、呼び出し先サブルーチンからの復帰処理の際、データテーブルにおける実行情報の格納位置を示し、第1のポインタとは異なる第2のポインタの指し示す位置に、呼び出し先サブルーチンの処理結果が格納されるので、サブルーチンのネストが深い段階でエラーが発生してもCALL命令の動きを順番にトレースすることができ、かつ、どのCALL処理の段階でエラーが発生したのかをトレースできるので、サブルーチンを多用した標準化プログラムのデバッグ効率の向上が期待できるという効果を奏する。また、1回のCALL処理に要する情報は、▲1▼呼び出し元サブルーチンの呼び出しステップ番号、▲2▼呼び出し先サブルーチンのポインタ番号、▲3▼呼び出し先サブルーチンの実行結果の3情報のみなので、少ないオーバヘッドで上記の効果が得られるというさらなる効果がある。さらに、通常のCALL処理と本CALL処理は使い分けが可能なので、必要に応じて、FBやFBDを使うようなところにtp付ポインタを使うことで、デバッグ効率の向上、処理効率の向上、メモリ資源の効率的な使用が可能になる等ユーザにとって、最適なデバッグ方法を提供できるという効果を奏する。
【0072】
つぎの発明によれば、プログラムまたはサブルーチンから呼び出される最初のアドレス位置に、データテーブルへの格納を指示するための指標として機能するトレースポイントが存在するときに、データテーブルに格納されたサブルーチンの呼び出し回数を保持する第1のカウンタの値を増加させ、トレースポイントを有する呼び出し先サブルーチンからの復帰処理時に、第1のカウンタの値を増加させ、かつ、サブルーチンの実行処理後の復帰回数を保持する第2のカウンタの値を減少させるようにしているので、サブルーチンのネストが深い段階でエラーが発生してもCALL命令の動きを順番にトレースすることができ、かつ、どのCALL処理の段階でエラーが発生したのかをトレースできるので、サブルーチンを多用した標準化プログラムのデバッグ効率の向上が期待できるという効果を奏する。また、通常のCALL処理と本CALL処理は使い分けが可能なので、必要に応じて、FBやFBDを使うようなところにtp付ポインタを使うことで、デバッグ効率の向上、処理効率の向上、メモリ資源の効率的な使用が可能になる等ユーザにとって、最適なデバッグ方法を提供できるという効果を奏する。
【0073】
つぎの発明によれば、第1のポインタの値をnとし、第2のカウンタの値をmとするときに、前記第2のポインタの値pを、
p=n−((m−1)×3+1)
の計算式で算出するようにしているので、サブルーチンのネストが深い段階でエラーが発生してもCALL命令の動きを順番にトレースすることができ、かつ、どのCALL処理の段階でエラーが発生したのかをトレースできるので、サブルーチンを多用した標準化プログラムのデバッグ効率の向上が期待できるという効果を奏する。
【0074】
つぎの発明にかかるプログラムによれば、上記の発明のいずれか一つに記載された方法をコンピュータに実行させるようにしたので、そのプログラムがコンピュータ読み取り可能となり、これによって、上記の発明のいずれか一つの動作をコンピュータによって実行することができるという効果を奏する。
【図面の簡単な説明】
【図1】 この発明にかかるコントローラの制御プログラムの動作の一例を示す図である。
【図2】 この発明にかかる階層構造プログラムの実施の概念を示す説明図である。
【図3】 この発明にかかるCALL命令とRET命令の動作の一例を示す図である。
【図4】 この発明にかかるCALL処理の処理手順を示すフローチャートである。
【図5】 図4のCALL処理に対応したRET処理の処理手順を示すフローチャートである。
【図6】 tp付き呼び出しのCALL処理が行われたときのデータテーブル等の動きを示す説明図である。
【図7】 図6のCALL処理が行われた後に、RET命令が実行されるときのデータテーブル等の動きを示す説明図である。
【図8】 FAシステムにおけるシステム構成の一例を示す図である。
【図9】 従来技術のコントローラの内部構成を示すブロック図である。
【図10】 従来技術のコントローラの制御プログラムの動作の一例を示す図である。
【図11】 従来技術におけるコントローラのサブルーチンプログラムの処理を示す図である。
【図12】 サブルーチンの処理概念を示す説明図である。
【図13】 CALL命令とRET命令とスタックの概念を示す説明図である。
【図14】 従来技術におけるCALL命令とRET命令の動作の一例を示す図である。
【符号の説明】
21 CALLカウンタ、22 RETカウンタ、23 データテーブル、24 CALLポインタ、25 RETポインタ、61,62,63,64,65,66,67,68,69,70 位置、81 コントローラ、82 インテリジェントユニット、83 非インテリジェントユニット、84 I/O機器、85 サーボモータ、86 センサ、87 アクチュエータ、88 スイッチ、出力機器、電光管等、91 MPU、92 ワークRAM、93 システムROM、94 ユーザRAM、95 パラメータ、96 ユーザプログラム、97 デバイスメモリ、98 アドレスバス、99 データバス、121,122,123,124,125,126,127,128 タイミング、141,142,143,144,145,146,147,148 処理。
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a trace data processing apparatus, a trace data processing method, and a program for executing the method, which can trace a subroutine call path of a program mounted on a controller and a subroutine call timing when an abnormality occurs. is there.
[0002]
[Prior art]
In recent factories, production activities utilizing the FA system (factory automation system) are often performed. This FA system refers to a control system that combines automation and computerization that comprehensively controls equipment such as production equipment and transport equipment, and production activities such as production planning and production management. I call it this way.
[0003]
FIG. 8 is a diagram illustrating an example of a system configuration in the FA system. In the figure, a controller 81 controls an intelligent unit 82 and a non-intelligent unit 83 connected via a system bus. Various control devices such as an I / O device 84, a servo motor 85, a sensor 86, a lamp, and an actuator 87 are connected to the intelligent unit 82, and a switch, an output device, a light pipe, and the like 88 are connected to the non-intelligent unit 83. It is connected. These control devices perform physical input / output, communication, data conversion, and the like with the outside. The controller 81 includes a microprocessor (MPU) therein, and executes a user control program mounted on the MPU to control the operation of the entire system.
[0004]
By the way, when debugging a control program of a controller, there are cases where it is desired to trace as a history what route a certain executed subroutine was called. Furthermore, when an abnormality occurs in a subroutine, it is the psychology of the developer of the control program that wants to debug following the path when the abnormality occurs based on the trace data.
[0005]
FIG. 9 is a block diagram showing an internal configuration of a conventional controller. An MPU 91 executes a user control program and controls the operation of the entire system. 92 is a work RAM and 93 is a system ROM. The system ROM 93 describes a system program for controlling the operation of the controller, and the system program executes the user's control program, whereby the entire system is controlled. The work RAM 92 is a memory used for work (work) used when the MPU 91 executes a system program stored in the system ROM 93. That is, it is used to save data that needs to be temporarily saved, or to store data generated during input / output with the outside of the controller.
[0006]
In FIG. 9, 94 is a user RAM, 95 is a parameter, 96 is a user program, and 97 is a device memory. The user control program is stored in the user program 96. At that time, the device memory 97 is used as a work area when the user's control program is executed. The parameter 95 is given a condition when the control program is executed. Reference numeral 98 is an address bus, and 99 is a data bus. The address bus 98 is used by the MPU 91 to access the work RAM 92, the system ROM 93, the user RAM 94, and the device memory 97, and the data bus 99 is used to read / write data from / to each memory. The system ROM 93 is a read-only memory.
[0007]
FIG. 10 is a diagram illustrating an example of the operation of a control program of a conventional controller. Steps S10201 to S10205 are descriptions of the main program. First, the execution condition a is read in step S10201. When the execution condition is satisfied, a subroutine starting from the pointer Pa is called in step S10202. The execution condition b is read in step S10203. When the execution condition is satisfied, the pointer Pb is read in step S10204. Call a subroutine starting with. Step S10205 shows an instruction (FEND instruction) indicating the end of the main program.
[0008]
Next, Pa is a pointer indicating the head of the subroutine called in step S10202. The execution condition Paa is read in step S10206. When the execution condition is satisfied, the subroutine starting from the pointer Pcom is called in step S10207. After the actual processing of this subroutine is completed, the instructions in steps S10208 to S10209 are executed, and the instruction for returning from the subroutine (RET instruction) is executed in step S10210. Similarly, Pb is a pointer indicating the head of the subroutine called in step S10211. The execution condition Pbb is read in step S10211. When the execution condition is satisfied, the subroutine starting from the pointer Pcom is called in step S10212. After the actual processing of this subroutine is completed, the instructions of steps S10213 to S10214 are executed, and the instruction for returning from the subroutine (RET instruction) is executed in step S10215.
[0009]
Pcom is a pointer indicating the head of the subroutine called in step S10207 or S10212. The execution condition Pcc is read in step S10216. When the execution condition is satisfied, the actual processing of the subroutine is started in step S10217. The instruction of S10219 is executed, and an instruction to return from the subroutine (RET instruction) is executed in step S10220. Step S10221 indicates an instruction (END instruction) that means the end of all programs.
[0010]
FIG. 11 is a diagram showing processing of a subroutine program of the controller in the prior art. As shown in the figure, the normal controller executes the program by repeating external input processing, program execution, and external output processing as one cycle. This period of time is called a scan time. When a subroutine call occurs during program execution, the execution of the main program is temporarily interrupted, the program corresponding to the subroutine call pointer is executed, and when execution of the subroutine program ends, the next instruction when the subroutine call occurs After returning, the processing of the suspended program is resumed.
[0011]
Subroutines are a very important concept in programming techniques, and are an essential concept for developing programs efficiently and creating easy-to-read programs. Among them, in particular, one of the reasons for requiring a subroutine is that it can “do the same thing over and over”. When creating a program, it is necessary to perform exactly the same processing in different scenes in the flow of the program, or the processing is almost the same, but slightly different processing often appears. If possible, describe one process that can be shared, and then use that description. Therefore, a method has been devised in which only one process that appears many times is created in a different location from the main program (main routine), and that process is called when it becomes necessary.
[0012]
FIG. 12 is an explanatory diagram showing a processing concept of a subroutine. In the example shown in the figure, the process A is called three times by the main routine (timing 121, 123, 125 shown in the figure), and the process B is called once by the main routine (timing 127 shown in the figure). ). A program that is described in a place different from the main routine and performs a certain process to be called from the program body is called a subroutine. Even if the same subroutine is called from different locations, when returning, the same subroutine is returned to different locations each time (timing 122, 124, 126, 128 shown in the figure).
[0013]
FIG. 13 is an explanatory diagram showing the concept of a CALL instruction, a RET instruction, and a stack. The stack is an operation of “retrieving the last stored data first”. Stacking is similar to stacking books. As books are stacked, the first one that can be taken out is the last one. That is, if some data is loaded on the stack, the first data that can be taken out is the last loaded data. A stack pointer (SP) is prepared for realizing this stack. As can be seen from what is called a pointer, the stack pointer has a role of pointing to the memory in the stack area, and always points to the top of the stack (the top of the stacked stack).
[0014]
How the stack state changes in response to the subroutine call will be described with reference to FIG. First, it is assumed that the stack state before the CALL instruction is executed is “(1) stack state before the CALL instruction is executed”. When the CALL instruction is executed in step S10401, “bbb” indicating the address of the instruction to be executed next is stacked on the stack. At this time, the stack pointer is updated for the next stack processing. That is, the stack pointer moves to the place where this “bbb” is stacked. At the same time, the stack state becomes “(2) Stack state after execution of CALL instruction”. When the CALL instruction is executed in step S 10402, “ccc” indicating the address of the instruction to be executed next is stacked on the stack, the stack pointer is updated for the next stack processing, and the stack state is “ (3) Stack state after execution of CALL instruction ". In this state, when “(4) Subroutine actual process execution” is performed, the RET instruction corresponding to step S10402 is executed in step S10404, and the address “ccc” of the instruction to be executed next is taken out of the stack. The pointer is updated for the stack processing, and the stack state becomes “(5) Stack state after execution of RET instruction”.
[0015]
Similarly, in step S10405, the RET instruction corresponding to step S10401 is executed, the address “bbb” of the instruction to be executed next is fetched from the stack, the pointer is updated for the next stack processing, and the state of the stack is , “(6) Stack state after execution of RET instruction”. In this way, when a series of subroutine call processing is completed, the state finally returns to the state before the call, that is, “(1) stack state before execution of CALL instruction”.
[0016]
In this way, even when jumping to the subroutine from the middle of the main routine, the address of the instruction to be executed next can be taken out from the stack when executing the RET instruction. Therefore, the main pointer can be managed only by managing the stack pointer. By dividing the routine into subroutines, the readability of the program can be improved.
[0017]
FIG. 14 is a diagram illustrating an example of the operation of the CALL instruction and the RET instruction in the prior art. FIG. 10 specifically shows how the program of FIG. 10 is stored in the user program 96 of FIG.
[0018]
In FIG. 14, “LD execution condition a” (reading instruction for execution condition a) is included in step S10601, “CALL Pa” (subroutine call instruction starting from pointer Pa) is included in step S10602, and “LD execution condition b is included in step S10603. "(Reading instruction of execution condition b)", "CALL Pb" (subroutine call instruction starting from pointer Pb) is stored in step S10604, and "FEND" (instruction indicating the end of the main program) is stored in step S10605. Yes.
[0019]
Next, in step S10606, “LD execution condition Paa” (reading instruction for execution condition Paa), “CALL Pcom” (subroutine call instruction starting from pointer Pcom) in step S10607, and instructions AA to AZ in steps S10608 to S10609. In step S10610, “RET” (an instruction for returning from the subroutine Pa) is stored.
[0020]
Also, “LD execution condition Pbb” (reading instruction for execution condition Pbb) is included in step S10611, “CALL Pcom” (subroutine call instruction starting from pointer Pcom) is included in step S10612, and instructions BA to BZ are included in steps S10613 to S10614. In step S10615, “RET” (an instruction for returning from the subroutine P) is stored.
[0021]
Finally, "LD execution condition Pcc" (reading instruction for execution condition Pcc) is included in step S10616, instructions CA to CZ are included in steps S10617 to S10619, "RET" (an instruction for returning from subroutine Pcom) is included in step S10620, In S10621, “END” (an instruction indicating the end of all programs) is stored.
[0022]
Next, the concept of the CALL instruction and the RET instruction will be described with reference to FIG. As shown in FIG. 10, the process starts when it is determined whether “LD execution condition a” is satisfied. If it is determined in step S10601 that the “LD execution condition a” is satisfied, “CALL Pa” is executed in step S10602. At this time, the step number (step S10603) of the instruction to be executed next to “CALL Pa” is stacked on the stack, and the process jumps to step S10606 as indicated by process 141.
[0023]
If it is determined in step S10606 that the “LD execution condition Paa” is satisfied, “CALL Pcom” is executed in step S10607. At this time, the step number (step S10608) of the instruction to be executed next to “CALL Pcom” is stacked on the stack, and the process jumps to step S10616 as indicated by process 142.
[0024]
If it is determined in step S10616 that the “LD execution condition Pcc” is satisfied, “command CA” is executed in step S10617, “instruction CB” is executed in step S10618, and the instructions are executed sequentially. In step S10619, “instruction CZ” is executed. Finally, in step S10621, the RET instruction is executed. At this time, the “step number of the instruction to be executed next (in this case, step S10608)” loaded on the stack is read, and the process jumps to step S10608 as indicated by processing 143.
[0025]
In step S10608, “instruction AA” is executed, and thereafter the instructions are sequentially executed. In step S10609, “instruction AZ” is executed. Finally, in step S10610, the RET instruction is executed. At this time, the “step number of the next instruction to be executed (here, step S10603)” further loaded on the stack is read, and the process jumps to step S10603 as indicated by process 144. Since the same processing is repeated for processing 145 to processing 148, the description thereof is omitted.
[0026]
[Problems to be solved by the invention]
In recent years, computer programs have become object-oriented, and there is a strong tendency to use standardized programs regardless of target fields such as OA and FA. In particular, under the influence of IEC 61131-3 which is the only international standard in the FA field, there is a movement to shift from programming by ladder and list to programming by function block (FB) or function block diagram (FBD). According to the IEC61131-3 standard, a frequently used program can be made into a component (FB), and the FB can be used in the main program. Therefore, the prospect of the whole program is improved, and development efficiency seems to have improved at first glance. Illusion.
[0027]
The FB is converted to the FB because it is a frequently used program part, and it is highly possible that the FB is used multiple times at several locations in the main program. Let's consider what happens when an abnormality occurs in the FB. For example, when a subroutine is called in the FB and an abnormality occurs in the subroutine. In this case, debugging cannot be performed unless it is known where the main program was called from and at what timing.
[0028]
However, the above-described prior art has a drawback that the order of subroutine calls cannot be traced. Further, the prior art disclosed in JP-A-7-141222, JP-A-4-336663, JP-A-2-294845, JP-A-64-48133, JP-A-59-221753, etc. traces the timing of occurrence of an abnormality. I couldn't do it, or even if I could, I had to use special means.
[0029]
The present invention has been made in view of the above, and performs trace data processing apparatus, trace data processing method and method capable of recording trace information related to a subroutine with little overhead and tracing the timing of the subroutine CALL when an abnormality occurs. The purpose is to obtain a program for.
[0030]
[Means for Solving the Problems]
  In order to achieve the above object, a trace data processing apparatus according to the present invention comprises:Loaded with this programExecution information of subroutines called hierarchically from the programToStores execution information of subroutines called hierarchically from a program in a trace data processing device to be racedIs a storage areaStack area andCallCall source subroutine call step number, callee subroutine pointer value, and callee subroutine execution resultExecution information includingPayStorage area, A data table different from the stack areaAnd the first address location called from the program or subroutineTrace points that serve as indicators for instructing storage in the data tableExistWhen you are,In the data tableExecution informationIndicates the storage location ofFirstPointerIn the position indicated byCalling step number of the calling subroutine and pointer value of the calling subroutineThe caseAnd return processing from the called subroutineWhenIn the data tableIndicates the storage location of execution information, which is different from the first pointerSecond pointerAt the position indicated byProcessing result of called subroutineThe caseIt is characterized by paying.
[0031]
  According to the present invention, execution information of subroutines called hierarchically from a program is stored.Is a storage areaStack areaWhen,Calling step number of calling subroutine, pointer value of calling subroutine, and execution result of calling subroutineIs a storage area for storing execution information includingData table different from stack areaAnd are provided. The trace data processing unit is located at the first address location called from the program or subroutine.Trace points that serve as indicators for instructing storage in the data tableExistWhen you areThe call step number of the call source subroutine and the pointer value of the call destination subroutine are stored at the position indicated by the first pointer indicating the storage position of the execution information in the data table. The execution information storage position is stored, and the processing result of the called subroutine is stored at the position indicated by the second pointer different from the first pointer.
[0032]
  A trace data processing apparatus according to a next invention is the above-described invention, wherein a first counter that holds the number of calls of the subroutine stored in the data table and a number of times of return after execution of the subroutine are stored. 2 counter, and the trace point is added to the callee subroutine.GThe trace counter is increased by increasing the value of the first counter at a certain time.TheIn the return processing from the called subroutine having, the value of the first counter is increased and the value of the second counter is decreased.
[0033]
  According to the present invention, a first counter that holds the number of subroutine calls stored in the data table, a second counter that holds the number of times the subroutine is returned after execution processing,Is providedTrace point in the called subroutineGIncrease the value of the first counter at a certain time, trace pointsTheAt the time of the return processing from the called subroutine, the value of the first counter is increased and the value of the second counter is decreased.
[0034]
In the trace data processing apparatus according to the next invention, in the above invention, when the value of the first pointer is n and the value of the second counter is m, the value p of the second pointer is set. ,
p = n − ((m−1) × 3 + 1)
It is calculated by the following formula.
[0035]
According to the present invention, when the value of the first pointer is n and the value of the second counter is m, the value p of the second pointer is
p = n − ((m−1) × 3 + 1)
It can be calculated by the following formula.
[0036]
  The trace data processing method according to the next invention is a subroutine execution information called hierarchically from a program.ToStores execution information of subroutines that are called hierarchically from a program in the trace data processing method to be raced.Is a storage areaStack area andCallCall source subroutine call step number, callee subroutine pointer value, and callee subroutine execution resultExecution information includingPayStorage area, A data table different from the stack areaAnd the first address location called from the program or subroutineTrace points that serve as indicators for instructing storage in the data tableExistWhether it exists, and the trace pointExistWhen present in the data tableExecution informationIndicates the storage location ofFirstPointerIn the position indicated byCalling step number of the calling subroutine and pointer value of the calling subroutineThe caseAnd return processing from the called subroutineWhenIn the data tableIndicates the storage location of execution information, which is different from the first pointerSecond pointerAt the position indicated byProcessing result of called subroutineThe caseIt is characterized by paying.
[0037]
  According to the present invention, execution information of subroutines called hierarchically from a program is stored.Is a storage areaStack area andCallCall source subroutine call step number, callee subroutine pointer value, and callee subroutine execution resultExecution information includingPayStorage area, Data table different from stack areaAnd are provided. At the first address location called from a program or subroutine,Trace points that serve as indicators for instructing storage in the data tableExistWhether it exists or not,thisTrace pointExistIn the data tableExecution informationIndicates the storage location ofFirstPointerIn the position indicated byThe calling step number of the calling subroutine and the pointer value of the called subroutine areCaseReturn processing from the called subroutineWhenIn the data tableIndicates the storage location of execution information, different from the first pointerSecond pointerIn the position indicated byStores the processing result of the called subroutine.
[0038]
  In the trace data processing method according to the next invention, in the above invention, a first counter that holds the number of calls of the subroutine stored in the data table and a number of times of return after execution of the subroutine are stored. 2 counter, and the trace point is added to the callee subroutine.GOne time, the value of the first counter stored in the data table is increased, and the trace point is increased.TheIn the return processing from the called subroutine having, the value of the first counter is increased and the value of the second counter is decreased.
[0039]
  According to the present invention, the trace point is set in the called subroutine.GAt some point, the value of the first counter holding the number of subroutine calls stored in the data table is increased, and the trace point is increased.TheAt the time of return processing from the called subroutine, the value of the first counter is increased, and the value of the second counter that holds the number of times of return after execution processing of the subroutine is decreased.
[0040]
In the trace data processing method according to the next invention, in the above invention, when the value of the first pointer is n and the value of the second counter is m, the value p of the second pointer is ,
p = n − ((m−1) × 3 + 1)
It is calculated by the following formula.
[0041]
According to the present invention, when the value of the first pointer is n and the value of the second counter is m, the value p of the second pointer is
p = n − ((m−1) × 3 + 1)
It can be calculated by the following formula.
[0042]
A program according to the next invention is a program for causing a computer to execute the method described in any one of the above inventions, and the program can be read by a computer, whereby the operation according to any one of the above inventions is performed. Can be executed by a computer.
[0043]
DETAILED DESCRIPTION OF THE INVENTION
Exemplary embodiments of a trace data processing device, a trace data processing method, and a program for executing the method will be described below in detail with reference to the accompanying drawings.
[0044]
FIG. 1 is a diagram showing an example of the operation of the control program of the controller according to the present invention. Steps S101 to S105 are descriptions of the main program. First, the execution condition a is read in step S101. When the execution condition is satisfied, a subroutine starting from the pointer Pa is called in step S102. The execution condition b is read in step S103. When the execution condition is satisfied, the pointer Pb is read in step S104. Call a subroutine starting with. Step S105 represents an instruction (FEND instruction) indicating the end of the main program.
[0045]
Next, Pa is a pointer indicating the head of the subroutine called in step S102. The execution condition Paa is read in step S106. When the execution condition is satisfied, a subroutine starting from the pointer Pcom is called in step S107. After the actual processing of this subroutine is completed, the instructions in steps S108 to S109 are executed, and the instruction for returning from the subroutine (RET instruction) is executed in step S110. Similarly, Pb is a pointer indicating the head of the subroutine called in step S104. The execution condition Pbb is read in step S111. When the execution condition is satisfied, the subroutine starting from the pointer Pcom is called in step S112. After the actual processing of this subroutine is completed, the instructions in steps S113 to S114 are executed, and the instruction for returning from the subroutine (RET instruction) is executed in step S115.
[0046]
By the way, Pcom is a pointer indicating the head of the subroutine called in step S107 or S112, but this Pcom is characterized by being modified by “tp (trace point)”, and is different from the prior art. is there. This tp will be described in detail later.
[0047]
In the subsequent processing, the execution condition Pcc is read in step S116, and when the execution condition is satisfied, the actual processing of the subroutine is started in step S117 and the instructions in steps S118 to S119 are executed in the same manner as described in the prior art. In step S120, an instruction for returning from the subroutine (RET instruction) is executed. Step S121 is an instruction (END instruction) that means the end of all programs.
[0048]
FIG. 2 is an explanatory diagram showing the concept of implementation of the hierarchical structure program according to the present invention. In the figure, 21 is a CALL counter, 22 is a RET counter, 23 is a data table, 24 is a CALL pointer, and 25 is a RET pointer.
[0049]
The CALL pointer 24 and the RET pointer 25 are a data table in which three pieces of information: (1) the calling step number of the calling subroutine, (2) the pointer number of the calling subroutine, and (3) the execution result of the calling subroutine are stored as one block. 23 is a pointer to be stored in 23. The CALL counter 21 and the RET counter 22 are work areas for storing the number of CALL processing and RET processing used for calculating the CALL pointer 24 and the RET pointer 25.
[0050]
FIG. 3 is a diagram showing an example of operations of the CALL instruction and the RET instruction according to the present invention. This figure is a diagram specifically showing how the program of FIG. 1 is stored in the user program 96 shown in FIG. Compared with the prior art shown in FIG. 14, “tp” in step S322 is stored between “RET” in step S315 and “LD execution condition Pcc” in step S316. In addition, the position where the instruction is stored and the call operation are the same as those described in the related art, and thus the description thereof is omitted.
[0051]
FIG. 4 is a flowchart showing a processing procedure of CALL processing according to the present invention. A normal CALL process and a CALL process in the case of calling a pointer with tp will be described with reference to FIG.
[0052]
First, the stack pointer is read in step S401, the step number to be executed is stored in the position next to the position pointed to by the stack pointer in step S402, the stack pointer is updated in step S403, and the subroutine pointer number of the call destination is determined in step S404. read out. Up to this point, the process is not different from the normal CALL process.
[0053]
Next, it is determined whether or not the pointer to be CALLed in step S405 is a pointer with tp. If the pointer to be CALLed in step S405 is a pointer with tp, the process proceeds to step S407, where the CALL pointer 24 in the data table 23 shown in FIG. 2 is read, and in step S408, the caller step number is displayed at the position indicated by the CALL pointer 24. In step S409, the CALL pointer 24 is updated. In step S410, the pointer number of the call destination subroutine is read. In step S411, the pointer number of the call destination subroutine is stored at the position indicated by the CALL pointer 24. In step S412. The CALL pointer 24 is updated. In step S413, the CALL counter 21 shown in FIG. 2 is updated. In step S414, the CALL pointer 24 is copied to the RET pointer 25 shown in FIG. In step S415, a pointer call flag with tp is set in the work RAM 92 shown in FIG. 9, and the process of the step number indicated by the pointer number called in step S416 is executed. In addition, the flow which transfers to the process of step S416 from the process of said step S401-S404 is a flow of a normal process.
[0054]
On the other hand, if the CALL pointer is not a pointer with tp in the process of step S405, it is further determined whether or not the pointer call flag with tp stored in the work RAM 92 is set in step S406. If the pointer call flag with tp is set, the process from step S407 is executed. If the pointer call flag with tp is not set, the process of step S416 is executed.
[0055]
FIG. 5 is a flowchart showing the processing procedure of the RET process corresponding to the CALL process of FIG. The flow of RET processing will be described with reference to FIG.
[0056]
First, in step S502, it is determined whether or not the CALL counter 21 shown in FIG. 2 is “0”. When the CALL counter 21 is “0”, since the subroutine CALL processing with tp has not been performed, the routine proceeds to step S510 to perform normal RET processing, and the stack pointer is read out at step S510. In step S511, the step number to be executed next is read from the stack, and the instruction of the step number read in step S512 is executed.
[0057]
On the other hand, if the CALL counter 21 is not “0” in step S502, it means that the subroutine CALL processing with tp has been performed. In step S503, the RET counter 22 shown in FIG. 2 is read, and in step S504 the RET counter is read. 22 is updated, and the RET pointer 25 is calculated using the value (m) of the RET counter 22 in step S505. The calculation contents of the RET pointer 25 are calculated by the following formula: RET pointer 25 = CALL pointer 24-{(m−1) × 3 + 1}. Further, in step S506, the RET processing result is stored at the position indicated by the calculation result of the RET pointer 25. In step S507, the CALL counter 21 is updated to indicate the end of the RET processing.
[0058]
Next, in step S508, the value of the CALL counter 21 is checked again. If this value is 0, all the pointer call processing with tp has been completed, the pointer call flag with tp is cleared in step S509, and step S510. The normal RET process is performed. If the value of the CALL counter 21 is not 0 in step S508, the pointer call process with tp has not been completed. Therefore, the pointer call flag with tp is not cleared, and the routine proceeds to step S510 to perform normal RET processing. .
[0059]
FIG. 6 is an explanatory diagram showing the movement of the data table and the like when the CALL process for the call with tp is performed. This figure shows how the data table 23, CALL pointer (CP) 24, RET pointer (RP) 25, CALL counter 21, and RET counter 22 shown in FIG. 2 change from the initial state with the execution of the CALL instruction. . Note that the CALL nest (depth) is “5”, and it is assumed that the CALL processing for all calls with tp has been executed.
[0060]
In FIG. 6, in the initial state, the CALL counter and the RET counter are both “0”, and CP and RP are set at predetermined positions (not shown). When the first CALL instruction is executed, the CALL counter is incremented (+1), that is, set to “1” (corresponding to the process of step S413 in FIG. 4), and CP is incremented (+3) (in FIG. 4). The RP is also set to the same pointer value as the CP (corresponding to the processing in step S414 in FIG. 4). Therefore, the pointer at position 61 in FIG. 6 is set for CP and RP.
[0061]
Similarly, when the second CALL instruction is executed, the CALL counter is incremented (+1), that is, set to “2”, CP is incremented (+3), and RP is also set to the same pointer value as CP. . Therefore, the pointer at position 62 is set in CP and RP. Thereafter, when the fifth CALL instruction is executed, the CALL counter is finally set to “5”, and pointers at position 65 are set in CP and RP.
[0062]
FIG. 7 is an explanatory diagram showing the movement of the data table and the like when the RET instruction is executed after the CALL process of FIG. 6 is performed. This figure shows how the data table 23, CALL pointer (CP) 24, RET pointer (RP) 25, CALL counter 21, and RET counter 22 shown in FIG. 2 change from the state of FIG. 6 with the execution of the RET instruction. ing.
[0063]
In FIG. 7, the state where the RET instruction is not executed is the same as the state where the fifth CALL instruction is executed in FIG. That is, the CALL counter 25 is set to “5”, the RET counter is set to “0”, and pointers at position 65 are set in CP and RP. When the first RET instruction is executed, the RET counter is incremented (+1), that is, set to “1” (corresponding to the process of step S504 in FIG. 5), the CALL counter is decremented (−1), That is, it is set to “4” (corresponding to the process of step S507 in FIG. 5), the value of CP remains unchanged, RP is decremented (−1), and the pointer at position 66 is set (step in FIG. 5). Corresponding to the arithmetic processing in S505).
[0064]
Similarly, when the second RET instruction is executed, the RET counter is incremented (+1), that is, set to “2”, and the CALL counter is decremented (−1), that is, set to “3”. The value of CP remains unchanged, RP is decremented (-3), and the pointer at position 67 is set. Thereafter, when the fifth RET instruction is executed, the CALL counter is finally set to “0”, the RET counter is set to “5”, and the CP remains as a pointer at the position 65. The pointer at position 70 is set.
[0065]
For example, in FIG. 7, assuming that an error has occurred before the third RET instruction is executed and the fourth RET instruction is executed, RP is not updated to the pointer at position 69, but the pointer at position 68. Remains. At this time, it is possible to determine in which calling process an error has occurred from information on the CALL counter value, the RET counter value, and the RP value. If the pointer at the position where the error occurred (position 68 in this example) is X, the pointer number of the callee is set in X-1, and the step number of the caller is set in X-2. Therefore, it is possible to obtain program execution information for searching for the cause of the error occurrence from these pieces of information.
[0066]
This trace processing is composed of only three pieces of information: (1) the calling step number of the calling subroutine, (2) the pointer number of the calling subroutine, and (3) the execution result of the calling subroutine. Execution information related to the structure program can be obtained. Further, since not only the trace information but also the information on the execution result of the subroutine is included, the validity of the processing result itself can be evaluated even in a normally completed process, so that efficient debugging can be performed.
[0067]
As described above in detail, according to the trace data processing device, the trace data processing method, and the program for executing the method according to the present invention, the hierarchical structure relates to the program execution of the information processing device for processing the structured program. The execution timing of a hierarchical program can be traced in the execution of a structured program with, and if an error occurs during execution, the cause of the error and the execution timing of the program can be grasped, and the overhead is low The execution information related to the hierarchical structure program can be obtained.
[0068]
【The invention's effect】
  As described above, according to the present invention, execution information of subroutines called hierarchically from a program is stored.A stack area that is a storage area; andCalling step number of calling subroutine, pointer value of calling subroutine, and execution result of calling subroutineIs a storage area for storing execution information includingData table different from stack areaWhen a trace point that functions as an index for instructing storage in the data table exists at the first address position called from the program or subroutine, the storage position of execution information in the data table is indicated. The calling step number of the caller subroutine and the pointer value of the callee subroutine are stored at the position indicated by the first pointer. The return position from the callee subroutine indicates the storage position of the execution information in the data table. Since the processing result of the called subroutine is stored at the position indicated by the second pointer different from the pointer ofEven if an error occurs in a deep subroutine nesting stage, the movement of the CALL instruction can be traced in order, and the CALL processing stage in which the error has occurred can be traced. There is an effect that improvement in debugging efficiency can be expected. The information required for one CALL process is only (1) the calling step number of the calling subroutine, (2) the pointer number of the calling subroutine, and (3) the execution result of the calling subroutine. There is a further effect that the above effect can be obtained. Further, since the normal CALL process and the present CALL process can be used properly, if necessary, a pointer with tp is used where FB or FBD is used, thereby improving debugging efficiency, improving processing efficiency, and memory resources. For example, it is possible to provide an optimal debugging means for the user, such as enabling efficient use of the device.
[0069]
  According to the next invention, a first counter that holds the number of subroutine calls stored in the data table, a second counter that holds the number of times the subroutine has been returned, andIs providedTrace point in the called subroutineGIncrease the value of the first counter at a certain time, trace pointsTheSince the value of the first counter is increased and the value of the second counter is decreased at the time of return processing from the called subroutine that has an error, even if an error occurs in a deeply nested subroutine The movement of the CALL instruction can be traced in order, and it can be traced at which CALL processing stage an error has occurred, so that it is possible to expect an improvement in debugging efficiency of a standardized program using many subroutines. In addition, since the normal CALL process and the present CALL process can be used properly, if necessary, a pointer with tp is used where FB or FBD is used, thereby improving debugging efficiency, improving processing efficiency, and memory resources. For example, it is possible to provide an optimal debugging means for the user, such as enabling efficient use of the device.
[0070]
According to the next invention, when the value of the first pointer is n and the value of the second counter is m, the value p of the second pointer is
p = n − ((m−1) × 3 + 1)
Therefore, even if an error occurs when the subroutine is deeply nested, the movement of the CALL instruction can be traced in order, and the error occurs at any CALL processing stage. Therefore, the debugging efficiency of a standardized program using many subroutines can be expected to be improved.
[0071]
  According to the next invention, execution information of subroutines called hierarchically from a program is stored.Is a storage areaStack area andCallCall source subroutine call step number, callee subroutine pointer value, and callee subroutine execution resultExecution information includingPayStorage area, Data table different from stack areaAnd provided,Trace points that serve as indicators for instructing storage in the data tableGIt is determined whether it exists on the called subroutine, and the trace pointGIn the data table when it exists on the called subroutineExecution informationIndicates the storage location ofFirstPointerIn the position indicated byThe calling step number of the calling subroutine and the pointer value of the called subroutine areCaseReturn processing from the called subroutineWhenIn the data tableIndicates the storage location of execution information, different from the first pointerSecond pointerIn the position indicated bySince the processing result of the called subroutine is stored, even if an error occurs when the subroutine is deeply nested, the movement of the CALL instruction can be traced in order, and the error occurs at any CALL processing stage. Therefore, the debugging efficiency of a standardized program using many subroutines can be expected to be improved. The information required for one CALL process is only (1) the calling step number of the calling subroutine, (2) the pointer number of the calling subroutine, and (3) the execution result of the calling subroutine. There is a further effect that the above effect can be obtained. Further, since the normal CALL process and the present CALL process can be used properly, if necessary, a pointer with tp is used where FB or FBD is used, thereby improving debugging efficiency, improving processing efficiency, and memory resources. For example, it is possible to provide an optimal debugging method for the user, such as enabling efficient use.
[0072]
  According to the following invention,When there is a tracepoint at the first address called from a program or subroutine that serves as an indicator for directing storage to the data table,Increase the value of the first counter that holds the number of subroutine calls stored in the data table,TheSince the value of the first counter is increased and the value of the second counter that holds the number of times of return after execution of the subroutine is decreased during the return processing from the called subroutine that has the subroutine, Even if an error occurs at a deep nesting stage, the movement of the CALL instruction can be traced in order, and the CALL processing stage at which the error has occurred can be traced, so debugging of a standardized program using many subroutines There is an effect that an improvement in efficiency can be expected. In addition, since the normal CALL process and the present CALL process can be used properly, if necessary, the pointer with tp is used where FB or FBD is used, thereby improving debugging efficiency, improving processing efficiency, and memory resources. For example, it is possible to provide an optimal debugging method for the user, such as enabling efficient use.
[0073]
According to the next invention, when the value of the first pointer is n and the value of the second counter is m, the value p of the second pointer is
p = n − ((m−1) × 3 + 1)
Therefore, even if an error occurs when the subroutine is deeply nested, the movement of the CALL instruction can be traced in order, and the error occurs at any CALL processing stage. Therefore, the debugging efficiency of a standardized program using many subroutines can be expected to be improved.
[0074]
According to the program of the next invention, since the method described in any one of the above inventions is caused to be executed by a computer, the program can be read by a computer. There is an effect that one operation can be executed by a computer.
[Brief description of the drawings]
FIG. 1 is a diagram showing an example of the operation of a control program of a controller according to the present invention.
FIG. 2 is an explanatory diagram showing a concept of implementing a hierarchical structure program according to the present invention.
FIG. 3 is a diagram showing an example of operations of a CALL instruction and a RET instruction according to the present invention.
FIG. 4 is a flowchart showing a processing procedure of CALL processing according to the present invention.
5 is a flowchart showing a processing procedure of RET processing corresponding to the CALL processing of FIG. 4;
FIG. 6 is an explanatory diagram showing movement of a data table or the like when CALL processing for a call with tp is performed.
7 is an explanatory diagram showing movement of a data table or the like when a RET instruction is executed after the CALL process of FIG. 6 is performed.
FIG. 8 is a diagram illustrating an example of a system configuration in an FA system.
FIG. 9 is a block diagram showing an internal configuration of a conventional controller.
FIG. 10 is a diagram illustrating an example of an operation of a control program of a controller of a conventional technique.
FIG. 11 is a diagram showing processing of a subroutine program of a controller in the prior art.
FIG. 12 is an explanatory diagram showing a processing concept of a subroutine.
FIG. 13 is an explanatory diagram showing a concept of a CALL instruction, a RET instruction, and a stack.
FIG. 14 is a diagram illustrating an example of operations of a CALL instruction and a RET instruction in the prior art.
[Explanation of symbols]
21 CALL counter, 22 RET counter, 23 data table, 24 CALL pointer, 25 RET pointer, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70 position, 81 controller, 82 intelligent unit, 83 non Intelligent unit, 84 I / O device, 85 servo motor, 86 sensor, 87 actuator, 88 switch, output device, lightning tube, etc. 91 MPU, 92 work RAM, 93 system ROM, 94 user RAM, 95 parameters, 96 user program 97 device memory, 98 address bus, 99 data bus, 121, 122, 123, 124, 125, 126, 127, 128 timing, 141, 142, 143, 144, 145, 146, 14 , 148 processing.

Claims (7)

プログラムを搭載し、このプログラムから階層的に呼び出されるサブルーチンの実行情報をトレースするトレースデータ処理装置において、
プログラムから階層的に呼び出されるサブルーチンの実行情報を格納する記憶領域であるスタックエリアと
び出し元サブルーチンの呼び出しステップ番号、呼び出し先サブルーチンのポインタ値および呼び出し先サブルーチンの実行結果を含む実行情報を格納する記憶領域であり、前記スタックエリアとは異なるデータテーブルと、
が設けられ、
プログラムまたはサブルーチンから呼び出される最初のアドレス位置に、前記データテーブルへの格納を指示するための指標として機能するトレースポイントが存在するときに
前記データテーブルにおける実行情報の格納位置を示す第1のポインタの指し示す位置に、前記呼び出し元サブルーチンの呼び出しステップ番号および前記呼び出し先サブルーチンのポインタ値を格納し、
前記呼び出し先サブルーチンからの復帰処理の際、前記データテーブルにおける実行情報の格納位置を示し、前記第1のポインタとは異なる第2のポインタの指し示す位置に、前記呼び出し先サブルーチンの処理結果を格納する
ことを特徴とするトレースデータ処理装置。
Equipped with a program, the trace data processing apparatus for trace execution information of subroutine hierarchically called from the program,
A stack area that is a storage area for storing execution information of subroutines called hierarchically from a program ;
Call out the original subroutine call step numbers, and the pointer value and executing information including an execution result of the called subroutine call destination subroutine storage area you store a different data tables and the stack area,
Is provided,
When the first address location to be called from a program or subroutine, before Symbol trace point that acts as an indicator for indicating the storage in the data table exists,
The position indicated by the first pointer indicating the storage location of the execution information in the data table, the pointer value of the call step number and the call destination subroutine of the calling subroutine to store,
During the process of returning from the call destination subroutine said indicate the storage location of the execution information in the data table, the position indicated by the different second pointer from the first pointer, store the processing result of the call destination subroutine A trace data processing apparatus characterized by:
前記データテーブルに格納された前記サブルーチンの呼び出し回数を保持する第1のカウンタと、
前記サブルーチンの実行処理後の復帰回数を保持する第2のカウンタと、
が設けられ、
前記呼び出し先サブルーチンに前記トレースポイントがあるときに前記第1のカウンタの値を増加させ、
前記トレースポイントを有する前記呼び出し先サブルーチンからの復帰処理時に、前記第1のカウンタの値を増加させ、かつ、前記第2のカウンタの値を減少させることを特徴とする請求項1に記載のトレースデータ処理装置。
A first counter that holds the number of calls of the subroutine stored in the data table;
A second counter for holding the number of return times after execution of the subroutine;
Is provided,
Increasing the value of the first counter when there is the trace points in the call destination subroutine,
When returning process from the callee subroutine with said trace points, the increase the value of the first counter, and, according to claim 1, characterized in that reducing the value of the second counter Trace data processing device.
前記第1のポインタの値をnとし、前記第2のカウンタの値をmとするときに、前記第2のポインタの値pを、
p=n−((m−1)×3+1)
の計算式で算出することを特徴とする請求項2に記載のトレースデータ処理装置。
When the value of the first pointer is n and the value of the second counter is m, the value p of the second pointer is
p = n − ((m−1) × 3 + 1)
The trace data processing device according to claim 2, wherein the trace data processing device is calculated by the following formula.
プログラムから階層的に呼び出されるサブルーチンの実行情報をトレースするトレースデータ処理方法において、
プログラムから階層的に呼び出されるサブルーチンの実行情報を格納する記憶領域であるスタックエリアと
び出し元サブルーチンの呼び出しステップ番号、呼び出し先サブルーチンのポインタ値および呼び出し先サブルーチンの実行結果を含む実行情報を格納する記憶領域であり、前記スタックエリアとは異なるデータテーブルと、
が設けられ、
プログラムまたはサブルーチンから呼び出される最初のアドレス位置に、前記データテーブルへの格納を指示するための指標として機能するトレースポイントが存在するか否かを判断し、
前記トレースポイントが存在するときに、前記データテーブルにおける実行情報の格納位置を示す第1のポインタの指し示す位置に、前記呼び出し元サブルーチンの呼び出しステップ番号および前記呼び出し先サブルーチンのポインタ値を格納し、
前記呼び出し先サブルーチンからの復帰処理の際、前記データテーブルにおける実行情報の格納位置を示し、前記第1のポインタとは異なる第2のポインタの指し示す位置に、前記呼び出し先サブルーチンの処理結果を格納する
ことを特徴とするトレースデータ処理方法。
In the trace data processing method for trace execution information of subroutine hierarchically called from a program,
A stack area that is a storage area for storing execution information of subroutines called hierarchically from a program ;
Call out the original subroutine call step numbers, and the pointer value and executing information including an execution result of the called subroutine call destination subroutine storage area you store a different data tables and the stack area,
Is provided,
The first address location to be called from a program or subroutine, it is determined whether the trace points Togason standing functioning as an indicator for indicating the storage of previous SL data table,
When the trace point exists at a position indicated by the first pointer indicating the storage location of the execution information in the data table, the pointer value of the call step number and the call destination subroutine of the calling subroutine to store ,
During the process of returning from the call destination subroutine said indicate the storage location of the execution information in the data table, the position indicated by the different second pointer from the first pointer, store the processing result of the call destination subroutine A trace data processing method characterized by:
前記データテーブルに格納された前記サブルーチンの呼び出し回数を保持する第1のカウンタと、前記サブルーチンの実行処理後の復帰回数を保持する第2のカウンタと、が設けられ、
前記呼び出し先サブルーチンに前記トレースポイントがあるときに、前記データテーブルに格納された前記第1のカウンタの値を増加させ、
前記トレースポイントを有する前記呼び出し先サブルーチンからの復帰処理時に、前記第1のカウンタの値を増加させ、かつ、前記第2のカウンタの値を減少させることを特徴とする請求項4に記載のトレースデータ処理方法。
A first counter for holding the number of calls of the subroutine stored in the data table, and a second counter for holding the number of return after execution of the subroutine are provided,
Wherein when there is a trace point to the called subroutine, increasing the value of the said first counter stored in the data table,
When returning process from the callee subroutine with said trace points, the increase the value of the first counter, and, according to claim 4, characterized in that to reduce the value of the second counter Trace data processing method.
前記第1のポインタの値をnとし、前記第2のカウンタの値をmとするときに、前記第2のポインタの値pを、
p=n−((m−1)×3+1)
の計算式で算出することを特徴とする請求項5に記載のトレースデータ処理方法。
When the value of the first pointer is n and the value of the second counter is m, the value p of the second pointer is
p = n − ((m−1) × 3 + 1)
The trace data processing method according to claim 5, wherein the trace data processing method is calculated by the following formula.
請求項4〜6のいずれか一つに記載された方法をコンピュータに実行させるプログラム。  The program which makes a computer perform the method as described in any one of Claims 4-6.
JP2002175786A 2002-06-17 2002-06-17 Trace data processing apparatus, trace data processing method, and program for executing the method Expired - Fee Related JP4327416B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002175786A JP4327416B2 (en) 2002-06-17 2002-06-17 Trace data processing apparatus, trace data processing method, and program for executing the method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2002175786A JP4327416B2 (en) 2002-06-17 2002-06-17 Trace data processing apparatus, trace data processing method, and program for executing the method

Publications (2)

Publication Number Publication Date
JP2004021614A JP2004021614A (en) 2004-01-22
JP4327416B2 true JP4327416B2 (en) 2009-09-09

Family

ID=31174341

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002175786A Expired - Fee Related JP4327416B2 (en) 2002-06-17 2002-06-17 Trace data processing apparatus, trace data processing method, and program for executing the method

Country Status (1)

Country Link
JP (1) JP4327416B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014136228A1 (en) * 2013-03-06 2014-09-12 三菱電機株式会社 Programmable controller, programmable controller system, and execute error information creation method
GB2586954B (en) * 2019-07-10 2023-06-14 Siemens Ind Software Inc Handling trace data

Also Published As

Publication number Publication date
JP2004021614A (en) 2004-01-22

Similar Documents

Publication Publication Date Title
US11338434B2 (en) Controlling process of robots having a behavior tree architecture
US6154684A (en) Template language for industrial controller programming
CN111400899B (en) Processing method, system and storage medium for cable laying modeling
JP2019084664A (en) Programming assist device, robot system, and program generating method
CN110271009B (en) Method for realizing manipulator teaching function based on PLC robot-simulated instruction
EP2677379B1 (en) Control method, control program and controller of numerical control machine tool
JPH09269808A (en) Cnc data correcting method
CA2318098A1 (en) A method of a sequence control
KR910009462B1 (en) Operating control device of f.a instrument
JPH0424826A (en) Production system
JP4327416B2 (en) Trace data processing apparatus, trace data processing method, and program for executing the method
WO2020066949A1 (en) Robot path determination device, robot path determination method, and program
US5940293A (en) Bar chart editor for industrial controller
CN112327744B (en) Method for interconverting ladder diagram and instruction list for programmable logic controller
KR102096595B1 (en) Monitor supported devices, monitor support methods, and monitor support programs
WO2018120166A1 (en) Stacking method and device, and robot
JP3744969B2 (en) Information processing apparatus and output method
JP3661336B2 (en) Programmable controller loader
JPH03105503A (en) Programmable controller
CN115016384A (en) Winding control method, device, equipment and medium based on PLC modular programming
JP2936089B2 (en) Method of creating shape data for mold processing
JP2000099128A (en) Method and device for teaching and controlling robot, and robot controller
JP3240647B2 (en) Computer language structured processing
JPS6214265A (en) Tree structure drawing preparing system
JPS61282952A (en) Configurating system for input/output device control system

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20050118

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20070921

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20071113

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20080115

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20080701

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20080828

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20090203

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20090406

A911 Transfer of reconsideration by examiner before appeal (zenchi)

Free format text: JAPANESE INTERMEDIATE CODE: A911

Effective date: 20090413

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20090609

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20090611

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

Free format text: PAYMENT UNTIL: 20120619

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20130619

Year of fee payment: 4

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

LAPS Cancellation because of no payment of annual fees