JP2008059515A - Method, system, and program for displaying program execution process - Google Patents
Method, system, and program for displaying program execution process Download PDFInfo
- Publication number
- JP2008059515A JP2008059515A JP2006238734A JP2006238734A JP2008059515A JP 2008059515 A JP2008059515 A JP 2008059515A JP 2006238734 A JP2006238734 A JP 2006238734A JP 2006238734 A JP2006238734 A JP 2006238734A JP 2008059515 A JP2008059515 A JP 2008059515A
- Authority
- JP
- Japan
- Prior art keywords
- execution
- information
- line
- program
- source code
- 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
- 238000000034 method Methods 0.000 title claims abstract description 268
- 230000014509 gene expression Effects 0.000 claims description 15
- 238000004590 computer program Methods 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 18
- 230000003252 repetitive effect Effects 0.000 description 11
- 238000012804 iterative process Methods 0.000 description 10
- 238000009877 rendering Methods 0.000 description 2
- 238000007373 indentation Methods 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
Landscapes
- Debugging And Monitoring (AREA)
Abstract
Description
本発明は、プログラム実行過程の表示方法及びシステム並びにプログラムに係り、詳しくは、プログラムの実行単位毎に処理の分岐過程、繰り返し過程などの実行過程を追跡し、その実行過程を表示画面に表示したソースコード上に矢印によって視覚的に表示する方法及びシステム並びにプログラムに関するものである。 The present invention relates to a program execution process display method and system, and a program. More specifically, the execution process such as a process branching process and a repetition process is traced for each execution unit of the program, and the execution process is displayed on a display screen. The present invention relates to a method, a system, and a program for visually displaying the source code by arrows.
コンピュータの利用の拡大によってプログラムの規模と複雑さが増大しており、その品質や生産性の改善が重要な課題となってきている。
近年のプログラム開発の現場では、障害の発生箇所を特定するためにプログラムを実行し、実行ステップに対応するソースコードの行を順次ハイライトさせて実際に動作した過程を確認することが非常に良く行われている。
Increasing use of computers has increased the scale and complexity of programs, and improving their quality and productivity has become an important issue.
In the recent program development field, it is very good to execute the program to identify the location of the failure and to check the actual operation process by sequentially highlighting the source code line corresponding to the execution step. Has been done.
図25はこのようなプログラム開発環境の実行画面を示す図である。
本環境は、実行情報の出力命令をステップ毎に挿入してからプログラムを実行し、出力された実行情報を解析することで実行ステップに対応するソースコードの行を順次ハイライトしていくものである。図の例では45行目の2501から50行目の2502にハイライトが切り替わっているので、開発者は45行目の次に50行目が実行された事が解る。
ここで実行情報とは、実行したステップに対応するソースコード上の位置を特定する情報であり、例えばMyClass.javaファイルの45行目といった情報を指す。
本発明に関連する公知技術文献としては下記特許文献1があげられる。
FIG. 25 is a diagram showing an execution screen of such a program development environment.
In this environment, an execution information output instruction is inserted for each step, the program is executed, and the output execution information is analyzed to sequentially highlight source code lines corresponding to the execution steps. is there. In the example shown in the figure, since the highlight is switched from 2501 in the 45th line to 2502 in the 50th line, the developer understands that the 50th line is executed next to the 45th line.
Here, the execution information is information for specifying a position on the source code corresponding to the executed step, and indicates information such as the 45th line of the MyClass.java file, for example.
The following
ところで、ソースコードには反復や条件分岐、例外処理といった制御構文が存在するため、ハイライト位置は単純に上から下へ切り替わっていくだけではなく、行をまたいで切り替わる事がある。
このため、動作した過程が処理的に正常か判定するには、それまでのハイライトされた順番を開発者が記憶し、次にハイライトされる行を予測しながら観察する必要があった。よって、対象プログラムに対する深い知識が必要となり、経験の浅い初心者や、担当者以外の者がこのような手法で障害の発生箇所を特定するのは困難であった。
これは、ハイライトされた経過を色の濃淡で表現することで解決できる。
By the way, since the source code has a control syntax such as iteration, conditional branching, and exception handling, the highlight position may not only be switched from top to bottom, but may be switched across lines.
For this reason, in order to determine whether the operating process is normal in terms of processing, it is necessary for the developer to memorize the order of highlighting up to that point and to observe while predicting the next highlighted line. Therefore, deep knowledge about the target program is required, and it is difficult for an inexperienced beginner or a person other than the person in charge to specify the location of the failure by such a method.
This can be solved by expressing the highlighted process with shades of color.
しかし、該当行に至った原因はハイライトされた経過だけからは判定できない。例えば、着目行が実行されなかった場合、それが条件分岐によって実行されなかったのか、あるいは例外処理によって中断されなかったのかハイライトされた経過からは読み解く事ができない。よって、結局は開発者がソースコードの構文を判読する必要がある。
また、通常、1つの行は複数回実行されるものであり、個々の実行をどのように区別して表現するかという課題も残る。
However, the reason for reaching the line cannot be determined only from the highlighted progress. For example, when the line of interest is not executed, it cannot be read from the highlighted progress whether it was not executed by a conditional branch or was not interrupted by exception processing. Therefore, in the end, developers need to interpret the syntax of the source code.
In addition, normally, one line is executed a plurality of times, and there remains a problem of how to express each execution separately.
本発明の目的は、プログラムが実際に動いた軌跡を、ソースコードの制御構文に沿った矢印で表現し、プログラムの実行過程をより解りやすく提示することができるプログラム実行過程の表示方法及びシステム並びにプログラムを提供することにある。 SUMMARY OF THE INVENTION An object of the present invention is to display a program execution process display method and system capable of expressing a trajectory in which a program has actually moved with an arrow along a control syntax of a source code and presenting the execution process of the program in an easy-to-understand manner, and To provide a program.
上記目的を達成するために、本発明に係るプログラムの実行過程の表示方法は、対象となるプログラムの実行過程を表示画面に表示した当該プログラムのソースコード上に表示する方法であって、
前記プログラムのソースコードをコンパイルした実行クラスと構文解析結果である抽象構文木の情報を入力として受け付け、前記抽象構文木の情報に基づき前記実行クラスを構成するメソッドの開始、終了位置及び変数宣言、判定式、宣言文、リターン文の先頭に、これらに対応するソースコードの行番号位置を実行情報として出力する命令を第1の手段によって埋め込む第1のステップと、前記実行情報を埋め込んだ前記実行クラスを第2の手段によって実行する第2のステップと、前記第2の手段によって実行された実行クラスが出力した前記実行情報を回収し、実行時刻順にソートした後、メソッド単位に分類し、その分類結果と前記抽象構文木の情報との基づき前記実行クラスにおけるメソッド、変数宣言、判定式、宣言文、リターン文の実行過程を第3の手段によって追跡する第3のステップと、追跡した実行過程を、表示画面に表示した当該プログラムのソースコード上に第4の手段によって矢印により表示する第4のステップとを備えることを特徴とする。
In order to achieve the above object, a display method of a program execution process according to the present invention is a method of displaying the execution process of a target program on the source code of the program displayed on a display screen,
The execution class obtained by compiling the source code of the program and the abstract syntax tree information that is the result of the syntax analysis are accepted as inputs, and the start, end position, and variable declaration of the method constituting the execution class based on the information of the abstract syntax tree; A first step of embedding by a first means an instruction for outputting the line number position of the corresponding source code as execution information at the head of a judgment expression, declaration statement, and return statement, and the execution in which the execution information is embedded The second step of executing the class by the second means, and the execution information output by the execution class executed by the second means are collected, sorted in order of execution time, and then classified into method units. Based on the classification result and the abstract syntax tree information, methods, variable declarations, judgment expressions, declaration statements, and litters in the execution class A third step of tracking the execution process of the sentence by the third means; a fourth step of displaying the tracked execution process by an arrow by the fourth means on the source code of the program displayed on the display screen; It is characterized by providing.
また、本発明に係るプログラムの実行過程の表示システムは、対象となるプログラムの実行過程を表示画面に表示した当該プログラムのソースコード上に表示するシステムであって、
前記プログラムのソースコードをコンパイルした実行クラスと構文解析結果である抽象構文木の情報を入力として受け付け、前記抽象構文木の情報に基づき前記実行クラスを構成するメソッドの開始、終了位置及び変数宣言、判定式、宣言文、リターン文の先頭に、これらに対応するソースコードの行番号位置を実行情報として出力する命令を埋め込む第1の手段と、前記実行情報を埋め込んだ前記実行クラスを実行する第2の手段と、前記第2の手段によって実行された実行クラスが出力した前記実行情報を回収し、実行時刻順にソートした後、メソッド単位に分類し、その分類結果と前記抽象構文木の情報との基づき前記実行クラスにおけるメソッド、変数宣言、判定式、宣言文、リターン文の実行過程を追跡する第3の手段と、追跡した実行過程を、表示画面に表示した当該プログラムのソースコード上に矢印により表示する第4の手段とを備えることを特徴とする。
The program execution process display system according to the present invention is a system for displaying the execution process of the target program on the source code of the program displayed on the display screen,
The execution class obtained by compiling the source code of the program and the abstract syntax tree information that is the result of the syntax analysis are accepted as inputs, and the start, end position, and variable declaration of the method constituting the execution class based on the information of the abstract syntax tree; First means for embedding an instruction to output the line number position of the corresponding source code as execution information at the head of the judgment expression, declaration statement, and return statement, and executing the execution class in which the execution information is embedded The execution information output by the execution class executed by the second means and the second means is collected, sorted in order of execution time, and classified into method units, the classification result and the abstract syntax tree information And a third means for tracking the execution process of the method, variable declaration, judgment expression, declaration statement, and return statement in the execution class based on The execution process, characterized in that it comprises a fourth means for displaying by the arrow on the source code of the program displayed on the display screen.
また、本発明に係るプログラムの実行過程の表示プログラムは、対象プログラムの実行過程を表示画面に表示した当該プログラムのソースコード上に表示するコンピュータプログラムであって、
コンピュータを、
前記対象プログラムのソースコードをコンパイルした実行クラスと構文解析結果である抽象構文木の情報を入力として受け付け、前記抽象構文木の情報に基づき前記実行クラスを構成するメソッドの開始、終了位置及び変数宣言、判定式、宣言文、リターン文の先頭に、これらに対応するソースコードの行番号位置を実行情報として出力する命令を埋め込む第1の手段と、前記実行情報を埋め込んだ前記実行クラスを実行する第2の手段と、前記第2の手段によって実行された実行クラスが出力した前記実行情報を回収し、実行時刻順にソートした後、メソッド単位に分類し、その分類結果と前記抽象構文木の情報との基づき前記実行クラスにおけるメソッド、変数宣言、判定式、宣言文、リターン文の実行過程を追跡する第3の手段と、追跡した実行過程を、表示画面に表示した当該プログラムのソースコード上に矢印により表示する第4の手段として機能させるステップを備えることを特徴とする。
Further, the display program of the execution process of the program according to the present invention is a computer program for displaying the execution process of the target program on the source code of the program displayed on the display screen,
Computer
The execution class obtained by compiling the source code of the target program and the abstract syntax tree information that is the result of the syntax analysis are accepted as input, and the start, end position, and variable declaration of the method constituting the execution class based on the abstract syntax tree information First means for embedding an instruction for outputting the line number position of the corresponding source code as execution information at the head of the judgment expression, declaration statement, and return statement, and executing the execution class in which the execution information is embedded The execution information output by the second means and the execution class executed by the second means is collected, sorted in order of execution time, and then classified into method units. The classification result and the abstract syntax tree information And a third means for tracking the execution process of the method, variable declaration, judgment expression, declaration statement, and return statement in the execution class based on It was execution process, characterized in that it comprises a step to act as a fourth means for displaying by the arrow on the source code of the program displayed on the display screen.
本発明によれば、対象プログラムを構文解析し、その抽象構文木により対象プログラムの実行クラスを構成するメソッドの開始、終了位置及び変数宣言、判定式、宣言文、リターン文の先頭に、これらに対応するソースコードの行番号位置を実行情報として出力する命令を埋め込み、この実行情報を埋め込んだプログラムを実行することによって得られた実行情報を回収し、各メソッド等の実行過程を追跡し、実行過程を示す矢印を生成して対象プログラムのソースコード上に表示するため、例えば、着目行が実行されなかった場合、それが条件分岐によって実行されなかったのか、あるいは着目行が何回実行されたかを視覚的に認識することができる。
この結果、プログラムの実行過程が直感的に理解できるようになり、障害の発生箇所の特定が容易となる。また、経験の浅い初心者でもプログラム処理の流れを理解できるようになるので、プログラム教育の場における教材としても利用できる。
According to the present invention, the target program is parsed, and the start, end position and variable declaration, judgment expression, declaration statement, and return statement of the method that constitutes the execution class of the target program by the abstract syntax tree Embed an instruction that outputs the line number position of the corresponding source code as execution information, collect the execution information obtained by executing the program with this execution information embedded, trace the execution process of each method, etc. An arrow indicating the process is generated and displayed on the source code of the target program. For example, if the target line was not executed, it was not executed by a conditional branch, or how many times the target line was executed Can be visually recognized.
As a result, the execution process of the program can be intuitively understood, and the location where the failure occurs can be easily identified. In addition, even an inexperienced beginner can understand the flow of program processing, so it can be used as a teaching material in the place of program education.
図1は、本発明を適用したプログラム開発システムの一実施形態を示すシステム構成図である。
この実施形態のプログラム開発システムは、Java(サンマイクロシステムズ社の登録商標)のアプリケーション開発を対象としており、プログラム開発環境101を備えた計算機102と、プログラム実行環境103を備えた計算機104とから構成される。
個々の計算機102,104は開発者の入力を受け付けるためのキーボード105と、マウス106を備える。また、プログラム開発環境101の実行画面を表示するための画面表示装置107を備える。
なお、この実施形態ではプログラム開発環境101と、プログラム実行環境103を異なる計算機102,104上に搭載しているが、1つの計算機が両方の環境を搭載しても構わない。
FIG. 1 is a system configuration diagram showing an embodiment of a program development system to which the present invention is applied.
The program development system of this embodiment is intended for Java (registered trademark of Sun Microsystems) application development, and includes a
Each of the
In this embodiment, the
プログラム開発環境101は、プログラムの開発を行うための環境であり、ソースコードを格納するソースコード保持部108と、格納したソースコードの表示と操作を行うソースコード編集部109と、ソースコードをコンパイルするコンパイラ110と、コンパイラ110によって生成された実行クラスを格納する実行クラス保持部111と、ソースコードの構文を解析する構文解析部112と、構文解析部112から生成された抽象構文木を格納する抽象構文木保持部113と、抽象構文木を基に、実行クラスに対して実行情報の出力処理を埋め込む実行情報出力命令埋め込み部114と、出力された実行情報115を実行単位に分類する実行情報分類部116と、分類された実行情報と抽象構文木を基に動作過程情報を生成する動作過程追跡部117と、動作過程情報(実行過程情報)を格納する動作過程情報保持部118と、動作過程情報に基づいてソースコード編集部109が表示したソースコードに矢印を描画する動作過程情報描画部119から構成される。
The
一方、プログラム実行環境103は、プログラム開発環境101によって作成されたプログラムを実行するための環境であり、対象となる実行クラスを格納する実行クラス保持部120と、プログラムを実行するプログラム実行部121から構成される。
なお、プログラム実行部121において、実行情報出力命令埋め込み部114によって実行情報の出力命令が埋め込まれたものを実行した場合は実行情報115を出力する。
なお、実行情報115とは、実行したステップに対応するソースコード上の位置を特定する情報である。
On the other hand, the
If the
The
図2は、図1で述べたプログラム開発環境101の実行画面を示し、上の画面は実行過程を表示する前の状態であり、下の画面は実行過程を表示した後の状態である。
プログラム開発環境101は、プログラムを編集するための領域201と、行番号を示すための領域202と、コンパイルボタン203と、動作過程の表示ボタン204と、プログラムの動作過程を示す矢印205から構成される。
一連の矢印205はそれぞれ個別の実行過程を示す。図の内容を例とすると、行番号=35のメソッドshowDetailは縦方向に3本の矢印線が行番号=37のメソッドとの間で往来していることから、1回のプログラム実行によって計3回実行された事を示す。
また、各矢印は、その水平位置で実行されたかどうかを示す。例えば図の内容を例とすると、38行目のSystem.out.println命令は全体で3回実行されたうち、縦方向に2本の矢印線が往来していることから2回が実際に実行された事を示す。
また、反復に関しては41行目から43行目に示すような繰り返した矢印で表現している。矢印の本数は反復実行された回数を示し、例えば42行目のnext命令は、全体で計3回実行されたうちの1回によって、8回反復実行されたことを意味する。
また、障害によって処理が中断された行は、「×」マークで表現している。例えば40行目のgetItemメソッドは、計3回実行されたうちの1回において障害が発生し、中断された事を意味する。
FIG. 2 shows an execution screen of the
The
A series of
Also, each arrow indicates whether or not it has been executed at that horizontal position. For example, taking the contents of the figure as an example, the System.out.println command on the 38th line was executed three times in total, but two times are actually executed because two arrow lines come and go in the vertical direction. It shows that it was done.
In addition, the repetition is expressed by a repeated arrow as shown in the 41st to 43rd lines. The number of arrows indicates the number of times of repeated execution. For example, the next instruction on the 42nd line means that it has been repeatedly executed eight times by one out of a total of three times.
A line whose processing is interrupted due to a failure is represented by an “x” mark. For example, the getItem method on the 40th line means that a failure has occurred and interrupted once in a total of three times.
図3は、図1の実施形態のプログラム開発システムにおける開発工程の全体の流れを示すフローチャートである。
まず、開発者はプログラム開発環境101を起動する(ステップ301)。プログラム開発環境101はソースコード保持部108から指定されたソースコードを読み込み、プログラム編集領域201に表示する。
開発者はキーボード105とマウス106を使用してソースコードの編集を行い、実装が完了したらインデントの深さなどを整形してコンパイルボタン203を押下する。
するとプログラム開発環境101はコンパイラ110を使用して実行クラスを生成する(ステップ302,303)。
なお、ソースコードから実行クラスを生成するのは公知の技術であるので説明を省略する。
FIG. 3 is a flowchart showing the overall flow of the development process in the program development system of the embodiment of FIG.
First, the developer activates the program development environment 101 (step 301). The
The developer uses the
Then, the
Note that generation of an execution class from source code is a known technique, and thus description thereof is omitted.
コンパイルが完了すると、続いてプログラム開発環境101は構文解析部112で抽象構文木を作成し、実行情報出力命令埋め込み部114で実行クラスに対して実行情報の出力処理を埋め込む(ステップ304)。
次に開発者は実行情報の出力処理が埋め込まれた実行クラスをプログラム実行環境103において実行し、出力された実行情報115を回収する(ステップ305)。
次に開発者はプログラム開発環境101において動作過程の表示ボタン204を押す。するとプログラム開発環境101は回収した実行情報115を読み込み、実行情報分類部116において読み込んだ実行情報115を実行単位に分類する。そして、動作過程追跡部117において分類した結果と構文解析木を基に動作過程情報を生成する(ステップ306)。次に、動作過程情報描画部119は動作過程情報を基にプログラム編集領域201へ矢印205を描画して終了する(ステップ307)。
When the compilation is completed, the
Next, the developer executes the execution class in which the execution information output process is embedded in the
Next, the developer presses an operation
図4は構文解析部112によって生成される抽象構文木の一例を示す図である。
抽象構文木とは、木構造でソースコードの内容を表現したものであり、401のような節で制御構文の範囲を表現し、402のような葉でメソッド実行や変数宣言といった行単位の内容を表現する。また、葉は対応するソースコード上の行番号403や先頭位置の桁番号404を属性で保持する。
なお、ソースコードから抽象構文木を生成する技術は公知であるので構文解析部112の詳細な内部処理は説明を省略する。
FIG. 4 is a diagram illustrating an example of an abstract syntax tree generated by the
An abstract syntax tree is a tree structure that represents the contents of the source code. The section of the control syntax is represented by a section such as 401, and the contents of each line such as method execution and variable declaration are represented by a leaf such as 402. Express. The leaf holds the
Since a technique for generating an abstract syntax tree from source code is known, detailed description of the internal processing of the
図5は、図3におけるステップ304の実行情報の出力処理命令を埋め込む処理の詳細を示すフローチャートである。
実行情報出力命令埋め込み部114は、ソースコード編集部109で開いているソースコードに対する抽象構文木を取得し(ステップ501)、ソースコードに存在する全てのメソッド定義を走査し(ステップ502)、各メソッドの開始行と終了行に対し実行情報の出力命令をバイトコード操作によって挿入する(ステップ503)。
また、抽象構文木の該当メソッドの内容を走査し(ステップ504,505)、取得した行が変数宣言文(ステップ506)、または判定式(ステップ507)、またはメソッド実行文(ステップ508)、またはリターン命令(ステップ509)を含む場合に、行の先頭に実行情報の出力命令をバイトコード操作によって埋め込む(ステップ510)。
ここで、メソッドの開始行や終了行、または指定位置に特定の命令をバイトコード操作によって埋め込む技術については公知であるので説明を省略する。また、終了行に埋め込む出力命令は処理が中断された場合であっても必ず出力されるように埋め込む。これは対象コード全体をtry節で囲み、そのfinally節でログ出力命令を呼び出すようにバイトコード操作することで実現できる。
FIG. 5 is a flowchart showing details of the process of embedding the output processing instruction of the execution information in
The execution information output
Also, the contents of the corresponding method of the abstract syntax tree are scanned (
Here, since a technique for embedding a specific instruction at the start line, end line, or specified position of a method by bytecode operation is well known, description thereof is omitted. Also, an output command to be embedded in the end line is embedded so that it is always output even when processing is interrupted. This can be achieved by enclosing the entire target code in a try clause and manipulating the bytecode so that a log output command is called in the finally clause.
図6は出力される実行情報115の例を示す図である。
実行情報は、出力時刻601、スレッドID602、対象クラス名603、対象メソッド名604、行番号605から構成される。このうち出力時刻601とスレッドID602は、プログラム実行中に内部で動的に決定して出力する。
ここでスレッドID602とは実行されたスレッドを一意に識別するものである。
対象クラス名603、対象メソッド名604、行番号605は、実行情報の埋め込み時に引数に指定された静的な文字列を出力する。また、行番号605では、それがメソッド開始・終了行に出力されるものである場合は、行番号の代わりに開始(S)と終了(E)を表す識別子をそれぞれ出力するものとする。
FIG. 6 is a diagram illustrating an example of the
The execution information includes an
Here, the
A
図7は実行情報分類部116によって分類した結果の例を示す図である。
実行情報分類部116は、回収した実行情報115を出力時刻601でソートし、対象クラス名701と、対象メソッド702と、スレッドID703ごとに分類し、開始識別子(S)から終了識別子(E)までの一連の実行情報を1つにまとめる。
704に示すような開始識別子(S)と終了識別子(E)に挟まれた一連の実行情報の組をここではコンテキストと呼び、コンテキスト中の個々のデータの行番号をコンテキストデータと呼ぶ。コンテキストは一回のメソッド実行において、実行された行の順番を示すものであり、図に示すように一つのメソッドは複数のコンテキストを保持する場合があり、1つのスレッドで複数個のコンテキストを保持する場合がある。
以降ではコンテキストと抽象構文木からソースコード編集部109へ矢印205を描画する手順を説明する。
図4に示したように、抽象構文木はメソッド宣言といった属性や、ブロック範囲といった様々な情報を保持するが、ここでは説明を簡略化するために制御構文の構造と行番号のみを保持する簡略化された抽象構文木を例示して
説明する。
FIG. 7 is a diagram illustrating an example of the result of classification by the execution
The execution
A set of execution information sandwiched between a start identifier (S) and an end identifier (E) as shown in 704 is called a context here, and the line number of each piece of data in the context is called context data. Context indicates the order of executed lines in one method execution. As shown in the figure, one method may hold multiple contexts, and one thread holds multiple contexts. There is a case.
Hereinafter, a procedure for drawing the
As shown in FIG. 4, the abstract syntax tree holds various information such as attributes such as method declarations and block ranges, but here, in order to simplify the explanation, a simple syntax that holds only the structure of control syntax and line numbers. An example of a generalized abstract syntax tree will be described.
図8はこのような簡略化した抽象構文木の一例を示す図である。
この抽象構文木では、ルートの属性で対象メソッド名を表現し、ノードの属性で行番号を表現する。また、この抽象構文木では実行情報出力処理埋め込み部において埋め込み対象となった行、すなわち、変数宣言、判定式、メソッド実行文、リターン文のいずれかが存在する行のみを対象とする。以降、これらの行を有効行と呼ぶ。
例えば、図8の内容は図2に示したソースコードの内容を表したものであるが、図2の44行目、46行目、49行目は上記の命令を含まないので有効行ではない。各ノードに連結した矢印は実行する有効行の順番を意味する。図の内容を例とすると、showDetailメソッド801は36行目86の次に37行目を実行する。また、1つのノードから複数の矢印がのびている場合はif節やswitch節の判定式を表しており、複数のノードのうちどれか1つを実行することを意味する。図の内容を例とすると、37行目が判定式であり、38行目か47行目のいずれかを次に実行する事を意味する。
FIG. 8 shows an example of such a simplified abstract syntax tree.
In this abstract syntax tree, the target method name is represented by the root attribute, and the line number is represented by the node attribute. Further, in this abstract syntax tree, only the lines that are to be embedded in the execution information output processing embedding unit, that is, the lines in which any of variable declarations, judgment expressions, method execution statements, and return statements exist are targeted. Hereinafter, these lines are called effective lines.
For example, the contents of FIG. 8 represent the contents of the source code shown in FIG. 2, but the 44th, 46th, and 49th lines in FIG. 2 are not valid lines because they do not include the above instructions. . The arrow connected to each node means the order of effective rows to be executed. Taking the contents of the figure as an example, the
ノード間を矢印ではなく“直線”で連結した場合はfor節やwhile節の判定式を表しており、連結された一連のノードを反復実行することを意味する。図の内容を例とすると、41行目が判定式であり、42行目から43行目を反復実行する事を意味する。
また、曲線で連結した場合は、連結先のノードが例外処理のジャンプ先であることを表現する。曲線の例は後述する。
矢印が連結されていない終端のノードは、反復かメソッド実行の終点である事を表現する。図の内容を例とすると、50行目か48行目でshowDetailメソッドの実行が終了する。また、43行目で反復処理が終了する。
When nodes are connected by a “straight line” instead of an arrow, it indicates a judgment expression of a for clause or a while clause, and means that a series of connected nodes are repeatedly executed. Taking the content of the figure as an example, the 41st line is a judgment formula, which means that the 42nd to 43rd lines are repeatedly executed.
Further, when connected by a curve, it represents that the node of the connection destination is a jump destination of exception processing. Examples of curves will be described later.
The terminal node that is not connected with an arrow represents the end point of iteration or method execution. Taking the contents of the figure as an example, the execution of the showDetail method ends at the 50th or 48th line. In addition, the iterative process ends at the 43rd line.
図9は、図8で示した簡略化した抽象構文木のデータ構造を示す図である。
この抽象構文木は、ルートとノードの2種類のテーブルを備え、ルートのテーブル901はクラス名903とメソッド名904と、次行ID905を備える。このうちクラス名903は対象クラスの完全修飾名が格納される。また、メソッド名904には対象メソッドの名前と引数の型が格納される。なお、クラス名903とメソッド名904の組み合わせは対象プログラムの中で一意となる。次行ID905には対象となるメソッド中で最初に実行する行のIDを格納する。
FIG. 9 is a diagram showing a data structure of the simplified abstract syntax tree shown in FIG.
This abstract syntax tree includes two types of tables, a root and a node. The root table 901 includes a
ノードのテーブル902は、ID906と行番号907と次行ID908と反復開始行ID909と、ジャンプ行ID910から構成される。このうち、ID906には対象プログラムで一意となる値が格納される。行番号907には対応するソースコード上の行番号が格納される。次行ID908には、次に実行する行のID906が格納される。対象行が条件分岐の判定式の場合は複数の次行ID908が格納される。また、該当行が反復かメソッド実行の終点である場合、次行ID908は空となる。反復開始行ID909、ジャンプ行ID910にはそれぞれ、反復を開始する行のID906と、例外が発生した場合にジャンプする行のID906が格納される。反復開始行ID909は常に1つであるが、ジャンプ行ID910は1つのノードに複数存在する場合がある。
The node table 902 includes an
図10は、動作過程追跡部117によって生成される動作過程情報のデータ構造を示す図である。
動作過程情報はソースコード編集部109に矢印を描画する基となる情報であり、有効行ごとに実行したかどうかといった情報を記憶する。また、1つのコンテキストに対して1つの動作過程情報が生成される。
各動作過程情報は対象となるクラス名1001とメソッド名1002を格納する領域を備える。
また、1つの動作過程情報はメインフローと呼ばれる反復処理を除いた有効行の動作過程を保持し、メインフローは部分フローと呼ばれる反復区間の動作過程を保持する。部分フローがさらに部分フローを保持する事もある。メインフローと部分フローはフローID1003、行番号1004、状態1005、部分フロー1006、ジャンプ行1007から構成される。フローID1003は1つの動作過程情報の中でメインフローと各部分フローを特定する数値であり、メインフローの値は1となる。
FIG. 10 is a diagram illustrating a data structure of the operation process information generated by the operation
The operation process information is information on which an arrow is drawn in the source
Each operation process information includes an area for storing a
Also, one piece of operation process information holds the operation process of the effective row excluding the repetitive process called main flow, and the main flow holds the operation process of the repetitive section called partial flow. A partial flow may also hold a partial flow. The main flow and the partial flow are composed of a
行番号1004はソースコードの行番号と対応するものである。
状態1005はnone、exec、error、returnのいずれかの値をとり、それぞれ該当行が、実行されなかった事、実行された事、実行されるはずであったが障害が発生して中断された事、リターン処理によって中断された事を意味する。
部分フロー1006が存在するノードは、該当行が反復の判定式であり、反復実行された回数だけ部分フローの領域が生成され、そのフローID1003が格納される。例えば例の86行目は2つの部分フロー1006を保持するので、2回反復処理を実行したことを示し、フローIDが2と3で表現される2つの部分フローを実行した事を意味する。
ジャンプ行1007には、例外処理が行われた場合にジャンプ先の行が格納される。
The
In the node where the
The
図11は、図3のステップ306における構文解析木と実行情報から動作過程情報を生成する処理の詳細を示すフローチャートである。
まず、プログラム開発環境101は実行情報分類部116によって分類されたコンテキストを取得する(ステップ1101,1102)。
次に、クラス名701とメソッド名702をコンテキストから取得し、それらが一致するメソッド定義を抽象構文木から取得する(ステップ1103)。次に、1つの動作過程情報の領域を生成し、取得したクラス名とメソッド名を格納する(ステップ1104)。
次に、取得した抽象構文木のルートテーブル901のデータに次行ID905が存在するか調べる(ステップ1105)。もし存在しない場合は、次のコンテキストを処理する(ステップ1101)。
FIG. 11 is a flowchart showing details of processing for generating operation process information from the parse tree and execution information in
First, the
Next, the
Next, it is checked whether the
存在する場合は次行IDが示すノードを走査し、反復区間を除く有効行の行数をカウントする。そしてその数だけ動作過程情報にIDが1であるメインフローの領域を確保して対応する行番号1004を格納し、それぞれの状態1005をnoneで初期化する(ステップ1106,1107,1108)。そしてコンテキストと抽象構文木の内容を比較し、その結果を動作過程情報に格納していく(ステップ1109)。
1つのコンテキストに対する処理を終了すると、次のコンテキストを処理し、全てのコンテキストを処理した時点で終了となる(ステップ1101)。
If it exists, the node indicated by the next row ID is scanned, and the number of valid rows excluding the repeated section is counted. Then, the corresponding number of the main flow with
When the process for one context is completed, the next context is processed, and the process ends when all the contexts are processed (step 1101).
図12は、ステップ1109のコンテキストと抽象構文木の内容を比較してその結果を動作過程情報に格納する処理の詳細を示すフローチャートである。
動作過程追跡部117はまずノードポインタと呼ぶ抽象構文木の参照位置を、ルートテーブルの該当データの位置で初期化する(ステップ1201)。
次にノードポインタが指すデータを取得する(ステップ1202)。
次に動作過程追跡部117は対象コンテキストからコンテキストデータを取得する(ステップ1203)。
次に動作過程追跡部117はノードポインタが指すデータの次行ID905,908に値が存在するか確認する(ステップ1204)。存在する場合はID906が一致するノードから行番号907を取得してコンテキストデータと比較する(ステップ1205)。
一致する場合は、一致した行番号に対応するノードの位置をノードポインタに格納し(ステップ1206)、一致した行番号に対応する動作過程情報のデータの状態1005をexecで上書きして(ステップ1207)、残りのコンテキストデータを処理する(ステップ1202)。
FIG. 12 is a flowchart showing details of the processing of comparing the context of
The operation
Next, data indicated by the node pointer is acquired (step 1202).
Next, the operation
Next, the operation
If they match, the node position corresponding to the matched line number is stored in the node pointer (step 1206), and the
次行ID905,908に値が存在しない場合や、一致しない場合はノードポインタが指すデータに反復開始行ID909に値が存在するかどうか調べる(ステップ1208)。なお、ノードポインタが初期状態であるルートテーブル901のデータを指している場合、反復開始行ID909は必ず存在しない。
ノードポインタがノードテーブル902のデータを参照しており、反復開始行ID909が存在する場合は(ステップ1207)、コンテキストデータの内容を調べる(ステップ1209)。コンテキストデータがnullで残りが存在しない場合は、反復の判定の結果、実行されずに正常終了したと考えられるので、ノードポインタが指すデータの行番号907に対応する動作過程情報のデータの状態1005をreturnで上書きして(ステップ1210)、このコンテキストに対する処理を終了する。
If there is no value in the
When the node pointer refers to the data in the node table 902 and the repetition
コンテキストデータが存在する場合は、反復開始行ID909とID906が一致するノードの行番号907を取得して比較する(ステップ1211)。一致した場合は反復区間の処理が開始されたと考えられるので、ノードポインタが指すデータをスタックに格納し(ステップ1212)、動作過程情報に部分フローの領域を生成する(ステップ1213)。
次にノードポインタへ反復開始行ID909とID906が一致するノードデータの位置を格納して(ステップ1214)、さらに一致した行番号907に対応する動作過程情報のデータの状態1005をexecで上書きして(ステップ1207)、残りのコンテキストデータを処理する。
If context data exists, the
Next, the node pointer stores the position of node data where the iteration
反復開始行ID909が存在しなかったり、コンテキストデータと一致しなかったりした場合は、ノードポインタが指すデータにジャンプ行ID910が存在するかどうか調べる(ステップ1215)。なお、ノードポインタが初期状態であるルートテーブル901のデータを指している場合、ジャンプ行ID910は必ず存在しない。
ノードポインタがノードテーブル902のデータを参照しており、ジャンプ行ID910が存在する場合はジャンプ行ID910に格納されたものとID906が一致するデータの行番号908を取得してコンテキストデータと比較する(ステップ1216)。コンテキストデータと一致する場合は、例外処理が行われたと考えられるので、ノードポインタが指すデータの行番号907に対応する動作過程情報のデータのジャンプ行1007へ一致した行番号907を格納する(ステップ1217)。
If the iteration
If the node pointer refers to the data in the node table 902 and the
次にノードポインタにジャンプ行ID910がID906と一致するデータの位置を格納する(ステップ1218)。次に一致した行番号907に対応する動作過程情報のデータの状態1005をexecで上書きして(ステップ1207)、残りのコンテキストデータを処理する。ジャンプ行ID910にIDが存在しなかったり、コンテキストデータと一致しなかったりした場合は、スタックに退避したデータが存在するかどうか調べる(ステップ1219)。
スタックにデータが存在する場合は、反復ブロックの処理が完了した可能性があるので、スタックからデータを取得し(ステップ1220)、その行番号907と、コンテキストデータを比較する(ステップ1221)。一致した場合は、反復処理が終了し、判定式が再度実行されたと考えられるので、ノードポインタに取得したデータの位置を格納して(ステップ1222)、一致した行番号907に対応する動作過程情報のデータの状態1005をexecで上書きし(ステップ1207)、残りのコンテキストデータを処理する。
Next, the data position where the
If there is data on the stack, processing of the repetitive block may have been completed, so data is acquired from the stack (step 1220), and the
スタックにデータが存在しない場合や、スタックのデータの行番号907がコンテキストデータの内容と一致しない場合はエラーか正常終了の可能性があるので、ノードポインタが指すデータが次行ID908を保持するか再度確認する。存在する場合は抽象構文木の内容と反するので、ノードポインタが指すデータの行番号907に対応する動作過程情報の状態1005をerrorで上書きして対象コンテキストの処理を終了する(ステップ1224)。
存在しない場合は、プログラムが正常終了したと考えられるので、ノードポインタが指すデータの行番号907に対応する動作過程情報の状態1005をreturnで上書きして対象コンテキストの処理を終了する(ステップ1210)。
If there is no data in the stack, or if the stack
If it does not exist, it is considered that the program has ended normally, so the
図13はステップ1213の動作過程情報に部分フローの領域を生成する処理の詳細を示すフローチャートである。
動作過程追跡部117はまず、反復開始行ID909から反復実行する区間を抽象構文木から取得し、反復区間にさらに反復開始行ID909が存在するデータがある場合は、それらを除いた行番号907に対応する領域を動作過程情報に確保して各データに行番号1004を格納する(ステップ1301)。
例えば、反復区間が21,22,23,24,25行目であり、22,23,24行目がさらに反復区間である場合、それを除いた21,25行目に対応する領域が動作過程情報に生成される。
FIG. 13 is a flowchart showing details of the process of generating a partial flow area in the operation process information in step 1213.
First, the operation
For example, when the repetitive section is the 21st, 22nd, 23rd, 24th and 25th lines, and the 22nd, 23rd and 24th lines are further repetitive sections, the area corresponding to the 21st and 25th lines excluding the repetitive sections is the operation process. Generated into information.
次に、生成した領域のフローID1003に、動作過程情報の中で最も大きい値を1増加したものを格納する(ステップ1302)。そして格納したIDを、ノードポインタが指すデータの行番号1004に対応する動作過程情報のデータの部分フロー1006に追加し(ステップ1303)、生成した領域の状態1005を全てnoneで初期化して終了する(ステップ1304)。
Next, the
図14から図18は、図12の処理を具体的に説明するための図である。
なお、これらの例では図の右側で処理対象のコンテキストの内容を、図の中央で処理対象の抽象構文木の内容を、図の左側で処理結果の動作過程情報の内容を表現する。また、抽象構文木において白地の矢印で示す箇所はノードポインタの位置を表現する。
図14はステップ1205において次行ID908が示すデータの行番号とコンテキストデータが一致してexecが格納される場合と、ステップ1224においてノードポインタが指すデータに次行IDの値が存在しなくてerrorが格納される場合の具体例を示す。
この例の抽象構文木1401は11行目から14行目まで逐次実行する事を表現する。また動作過程情報1402には、抽象構文木に対応する11行目から14行目までのメインフローの領域がステップ1106によって作成される。
まず、動作過程追跡部117はステップ1201に従って、ノードポインタにルートテーブル901のデータの位置1403を格納する。
14 to 18 are diagrams for specifically explaining the processing of FIG.
In these examples, the content of the context to be processed is represented on the right side of the diagram, the content of the abstract syntax tree to be processed is represented in the center of the diagram, and the content of the operation process information of the processing result is represented on the left side of the diagram. In the abstract syntax tree, the position indicated by the white arrow represents the position of the node pointer.
FIG. 14 shows the case where the row number of the data indicated by the
The
First, in accordance with
次に、コンテキストデータを取得する。この段階では最初の取得であるので先頭の11となる。
次にステップ1204に従って、ノードポインタが指すデータの次行の行番号を取得する。この例では11行目となる。
次にステップ1205に従ってコンテキストデータの値と一致するかどうか調べる。この例では1404に示すように共に11であるので、11行目に相当するノードのデータ1405の位置をノードポインタに格納し(ステップ1206)、ステップ1207に従って動作過程情報の11行目の状態をexecで上書きする。
次に12,13行目を同様に処理して該当する動作過程情報の状態をexecで上書きする。13行目に対応する動作過程情報の状態をexecで上書きした段階で、ノードポインタは13行目に対応するノードのデータ1406を指している。このデータは次行ID908に、14行目に対応するノードのIDを格納しているが、コンテキストデータが存在しなくnullであり、1407に示すように一致しないため、最終的にステップ1224に至り、ノードポインタが指す13行目に対応する動作過程情報の状態1005をerrorで再度上書きして終了する。
Next, context data is acquired. At this stage, since it is the first acquisition, it becomes the top 11.
Next, according to
Next, in
Next, the 12th and 13th lines are processed in the same manner, and the state of the corresponding operation process information is overwritten with exec. At the stage where the state of the operation process information corresponding to the 13th line is overwritten by exec, the node pointer points to the
図15は、ステップ1205において、次行ID908が複数存在する場合と、ステップ1210によって正常終了する場合の具体例を示す図である。
この例の抽象構文木1501は3行目が判定式となっており、判定式の結果によって4、5、8行目か6、7行目のどちらか片方が実行される。また、動作過程情報1502には、抽象構文木に対応する2行目から8行目に対応するメインフローの領域がステップ1106によって作成される。
動作過程追跡部117は3行目に対応する動作過程情報の状態をexecで上書きした後、次行IDが示す4行目と6行目を取得してコンテキストデータと比較する。この時参照しているコンテキストデータは“4”であるので、ステップ1206に従って、ノードポインタに行番号が“4”であるノードの位置1503を格納し、4行目に対応する動作過程情報の状態1005をステップ1207に従ってexecで上書きする。そして5,8行目を同様に処理し、8行目の状態をexecで上書きした後、ノードポインタ1504が指すデータの内容を確認し、次行ID、反復開始行ID、ジャンプ行ID、およびスタックに積まれているノードが全て存在しないので、ステップ1210に至り、ノードポインタ1504が指す8行目に対応する動作過程情報の状態をreturnで再度上書きして終了する。
FIG. 15 is a diagram illustrating a specific example in the case where there are a plurality of
In the
The operation
図16は、ステップ1213によって部分フローが生成される場合の具体例を示す図である。
この例の抽象構文木1601は、6行目の次に反復処理の判定式となる7行目を実行し、その結果に従って8,9行目を反復実行し、反復実行を抜けた後に10行目を実行して終了する。また、動作過程情報1602には、反復区間である8,9行目を除く6,7,10行目に対応するメインフロー領域がステップ1106によって生成される。
動作過程追跡部117は7行目に対応する動作過程情報の状態1005をexecで上書きした後、次行ID908が示す10行目のノードを取得するが、コンテキストデータは8行目となっているのでステップ1211に至り、反復開始行と一致するので、ノードポインタ1603が指しているノードをスタック1604に格納し、ステップ1301、1302に従って8行目と9行目に対応する部分フローの領域をフローID2で生成する。
FIG. 16 is a diagram illustrating a specific example when a partial flow is generated in step 1213.
The
The operation
次にステップ1303に従って、ノードポインタ1603が指す7行目に対応する動作過程情報の部分フロー1006に2を追加した後、確保したフローID2のデータの状態1005をステップ1304に従ってnoneで初期化する。そしてステップ1214に従って、ノードポインタに8行目に対応するノードの位置を格納し、さらにステップ1207に従って8行目に対応する動作過程情報の状態1005をexecで上書きする。
動作過程追跡部117はその後、9行目に対応する動作過程情報の状態をexecで上書きした後、ノードポインタ1605が指すデータには次行もジャンプ行も反復開始行も存在しないので、ステップ1220に従ってスタックに積まれている7行目に対応するノードのデータを取得した上でコンテキストデータと比較し、共に7行目で一致するのでノードポインタに7行目に対応するノードの位置を格納する。そして7行目に対応する動作過程情報の状態1005をexecで上書きして次のコンテキストデータを処理する。
Next, after adding 2 to the
Thereafter, after the operation
図17はステップ1213によってノードがスタックに積まれる例のうち、スタックに複数のデータが積まれる場合の具体例を示す図である。
この例の抽象構文木1701は、14行目を実行したのち、15行目で反復処理の判定処理を行い、その結果に従って16行目と18行目を反復実行する。また、16行目は反復処理の判定式であり、その結果に従って17行目を反復実行する。
動作過程情報1702には反復区間を除く14、15行目に対応するメインフローの領域がステップ1106によって生成される。
FIG. 17 is a diagram showing a specific example of a case where a plurality of data is stacked on the stack among the examples where nodes are stacked on the stack in step 1213.
In this example, after executing the 14th line, the
In the
動作過程追跡部117は、15行目に該当する動作過程情報の状態をexecで上書きしたのち、反復開始行である16行目がコンテキストデータと一致するので、15行目に対応するノードをスタックに格納する。そしてステップ1301,1302に従って、反復区間である16,17,18行目から、さらなる反復区間である17行目を除いた16、18行目に対応する部分フロー領域をフローID2で生成する。
また、ステップ1303に従って、ノードポインタ1703が指す15行目に対応する動作過程情報のデータの部分フロー1006に、フローID2を格納する。また、ステップ1214に従って、ノードポインタに16行目に対応するノードの位置を格納し、さらに16行目に対応する動作過程情報の状態をexecで上書きする。次にノードポインタ1704が指す反復開始行と、コンテキストデータの内容が共に17行目で一致するので、ステップ1212に従ってノードポインタ1704が指す16行目に対応するノードのデータをスタックに格納する。
The operation
Also, according to step 1303, the
次にステップ1301,1302に従って反復区間である17行目に対応する部分フロー領域をID3で確保して処理する。
次にスタックに積まれた内容とコンテキストデータの内容が共に16行目で一致するので、ステップ1222に従って、ノードポインタに16行目に対応するノードの位置を格納する。また、ステップ1207に従って16行目に対応する動作過程情報のデータの状態をexecで上書きして次のコンテキストデータを処理する。
Next, according to steps 1301 and 1302, a partial flow area corresponding to the 17th line which is a repetitive section is secured by ID3 and processed.
Next, since the contents stacked on the stack coincide with the contents of the context data on the 16th line, the node position corresponding to the 16th line is stored in the node pointer according to
図18はステップ1215によってジャンプ行1007が格納される場合の具体例を示す図である。
この例の抽象構文木1801は34,35,45行目を逐次実行する。34行目と35行目を表現するノードから伸びている実線の曲線1803はジャンプ先を表現しており、34,35行目を実行した際に例外が発生した場合は40,41行目が代わりに実行される事を示す。
動作過程情報1802には34,35,40,41,45行目に対応するメインフローの領域がステップ1106によって生成される。
FIG. 18 is a diagram showing a specific example in the case where the
The
In the
動作追跡部117は34行目に対応する動作過程情報のデータの状態をexecで上書きしたあと、コンテキストデータと、ノードポインタ1804が指すデータのジャンプ行が一致するので、ステップ1217に従ってノードポインタが指す34行目に対応するノードの、ジャンプ行ID910とIDが一致するデータの行番号40を、34行目に対応する動作過程情報のデータのジャンプ行に格納する。
次にステップ1218に従って40行目に対応するノードの位置をノードポインタに格納し、ステップ1207に従って40行目に対応する動作過程情報のデータの状態をexecで上書きして残りのコンテキストデータを処理する。
After the
Next, the position of the node corresponding to the 40th line is stored in the node pointer according to
図19は、図3におけるステップ307の動作過程情報をソースコード編集部上へ描画する処理の詳細を示すフローチャートである。
まず、動作過程情報描画部119は動作過程情報保持部118から1つの動作過程情報を取得し、そのクラス名1001とメソッド名1002が一致する動作過程情報を全て取得する(ステップ1901,1902)。
次に、補正値と呼ぶ矢印を描画する水平方向の位置を補正する値を“0”で初期化する(ステップ1903)。
次に、ステップ1902で取得した動作過程情報群から一つの動作過程情報を取得する(ステップ1904)。
次に、ソースコード編集部109から該当メソッドの宣言行の行番号を取得し、その位置へ左から右方向の矢印を描画する(ステップ1905)。
次に、メソッド宣言の先頭文字の水平位置を桁数から算出し、それに補正値を加えたものを取得する。この位置を以降では左側の位置と呼ぶ(ステップ1906)。
次に、動作過程情報のメインフローから一つのデータを順に取得する(ステップ1907)。
FIG. 19 is a flowchart showing details of the process of drawing the operation process information in
First, the operation process
Next, a value for correcting the horizontal position for drawing an arrow called a correction value is initialized to “0” (step 1903).
Next, one piece of operation process information is acquired from the operation process information group acquired in step 1902 (step 1904).
Next, the line number of the declaration line of the corresponding method is acquired from the source
Next, the horizontal position of the first character of the method declaration is calculated from the number of digits, and the correction value is added to it. This position is hereinafter referred to as the left position (step 1906).
Next, one piece of data is sequentially acquired from the main flow of the operation process information (step 1907).
次に、取得したデータに対応する行の先頭の水平位置を桁数から計算し、それに補正値を加えたものを取得する。以降ではこの水平位置を右側と呼ぶ(ステップ1908)。
なお、右側に線が描画された行は、その行が実行された事を意味し、左側に線が描画された行は、その行が実行されなかった事を意味する。描画する線の水平位置が直前に描いたものと異なる場合は、2つの線を連結する水平方向の矢印が描画されるものとする。
次に、取得したデータの状態1005を調べ、errorやreturnである場合は(ステップ1909,1910)、右側に上下の直線を描き、直線の終端から左方向へ矢印を描画する(ステップ1911)。そして、補正値に定数を加算して(ステップ1912)、残りの動作過程情報を処理する(ステップ1904)。
Next, the horizontal position at the head of the line corresponding to the acquired data is calculated from the number of digits, and a correction value is added to the calculated horizontal position. Hereinafter, this horizontal position is referred to as the right side (step 1908).
A line with a line drawn on the right side means that the line has been executed, and a line with a line drawn on the left side means that the line has not been executed. If the horizontal position of the line to be drawn is different from that drawn immediately before, a horizontal arrow connecting the two lines is drawn.
Next, the
状態がerrorである場合はさらに右側に「×」マークを描画する(ステップ1913)。なお、ステップ1912によって補正値に固定値が加算されるので、動作過程情報が複数ある場合でも描かれた矢印は重なる事がない。
取得したデータにジャンプ行1007が存在する場合は(ステップ1913)、右側に上下方向へ直線を描き、その終端からジャンプ先の行の右側までを曲線で結ぶ(ステップ1914)。そして、ジャンプ先行の以降の動作過程情報のデータを処理していく(ステップ1915,1907)。
If the status is error, a “x” mark is further drawn on the right side (step 1913). Since a fixed value is added to the correction value in
If there is a
取得したデータに部分フロー1006が含まれる場合は(ステップ1916)、反復処理の描画を行い(ステップ1917)、動作過程情報の次のデータを処理する(ステップ1907)。反復処理の描画は後述する。
データの状態1005がnoneである場合は(ステップ1918)、左側に上下の直線を描き(ステップ1919)、残りのデータを処理する(ステップ1907)。
データの状態がexecuteである場合は(ステップ1920)、右側に上下の直線を描き(ステップ1921)、残りのデータを処理する(ステップ1907)。
If the acquired data includes the partial flow 1006 (step 1916), iterative processing is drawn (step 1917), and the next data of the operation process information is processed (step 1907). Drawing of the iterative process will be described later.
If the
If the data state is execute (step 1920), upper and lower straight lines are drawn on the right side (step 1921), and the remaining data is processed (step 1907).
図20は、図19におけるステップ1917の反復処理の描画を行う処理の詳細を示すフローチャートである。
まず、動作過程情報描画部119は対象データが保持する部分フロー1006の数を確認する(ステップ2001)。
フローの数が2つ以上である場合は、反復区間の右側へ下から伸びる矢印を描画して反復実行された事を表現する(ステップ2002)。
次に、反復補正値とよばれる水平位置の補正値を0で初期化する(ステップ2003)。これは内部フローを描画するたびに増加されるものであり、反復区間においては補正値に反復補正値をさらに加算した位置へ線を描画する。
これにより、反復によって描かれた線が重ならないようになる。
FIG. 20 is a flowchart showing details of processing for rendering the iterative processing in
First, the operation process
If the number of flows is two or more, an arrow extending from the bottom to the right side of the iteration section is drawn to express that the iteration has been executed (step 2002).
Next, a horizontal position correction value called an iterative correction value is initialized to 0 (step 2003). This is increased each time the internal flow is drawn, and a line is drawn at a position obtained by further adding the repeated correction value to the correction value in the repeated section.
This prevents lines drawn by repetition from overlapping.
次に、動作過程情報描画部は部分フロー1006で指定された一連のデータを取得し(ステップ2004)、部分フロー内の個々のデータを順に処理していく(ステップ2005,2006)。
この処理は補正値に反復補正値が加わる以外はメインフローの処理と同じであるので説明を省略する。
1つの部分フローを処理すると、その終端に矢印の矢尻を描画し(ステップ2007)、反復補正値を定数で増加させ(ステップ2008)、残りの部分フロー1006を処理する(ステップ2004)。
全ての部分フローの処理が完了すると、描いた各矢印の各始点同士と、各終点同士を水平方向の直線で連結して終了する(ステップ2009)。
Next, the operation process information drawing unit obtains a series of data designated by the partial flow 1006 (step 2004), and sequentially processes individual data in the partial flow (
Since this process is the same as the main flow process except that the iterative correction value is added to the correction value, a description thereof will be omitted.
When one partial flow is processed, an arrowhead at the end is drawn (step 2007), the iterative correction value is increased by a constant (step 2008), and the remaining
When the processing of all the partial flows is completed, the start points of the drawn arrows and the end points are connected by a horizontal straight line, and the process ends (step 2009).
図21〜図24は、図3におけるステップ307の動作過程情報をソースコード編集部109が表示する画面に描画する処理の具体例を示す。
これらの例では図の左の領域で対象となる動作過程情報の内容と、図の右の領域でソースコード編集部の表示内容を示す。
図21は、図19におけるステップ1905のメソッド宣言位置に左から右へ矢印を描画する処理と、ステップ1919の左側に直線を描く処理と、ステップ1930の直線を右側に描く処理の具体例を示す。
まず、動作過程情報描画部119は取得した動作過程情報からクラス名1001とメソッド名1002を取得し、ソースコード編集部109からメソッド宣言の行を取得し、その位置へ左から右方向に矢印を描画する(ステップ1905)。
この例では動作過程情報のクラス名がMyClass、メソッド名がshowDetail(String)であり、該当するメソッド宣言は35行目にあるので位置2101に矢印を描画する。
21 to 24 show specific examples of processing for drawing the operation process information in
In these examples, the contents of the target operation process information are shown in the left area of the figure, and the display contents of the source code editing unit are shown in the right area of the figure.
FIG. 21 shows specific examples of processing for drawing an arrow from left to right at the method declaration position in
First, the operation process
In this example, the class name of the operation process information is MyClass, the method name is showDetail (String), and the corresponding method declaration is on the 35th line, so an arrow is drawn at a
次に、動作過程情報描画部119は取得したメインフローのデータから順にデータを取得して描画していく。
この例では、まず36行目のデータが対象となり、状態がexecであるのでステップ1921に従って右側の位置2102に垂直方向の直線を描画する。同様に、次の37行目のデータも状態がexecであるので右側の位置2102に垂直方向の直線を描画する。
次に、38行目のデータを処理するが、状態がnoneであるので左側の位置2103に垂直方向の直線を描画する。また、直前に描いたのが右側であり水平方向の位置が異なるので水平方向の矢印で37行目の直線の終点と、38行目の直線の始点が連結される。同様に39行目から45行目までは状態がnoneであるので左側の位置2103に直線を描画し、47行目は右側に描画する。48行目は状態がreturnであるので、右側に上下の直線を描画し、その終端から2104に示すように右から左方向へ矢印を描画して、この動作過程情報の処理を終了する。
開発者は描画された一連の矢印によって、36、37、47行目が実行され48行目で処理が中断したということを直感的に認識することができる。
Next, the operation process
In this example, the data on the 36th line is first targeted, and since the state is exec, a straight line in the vertical direction is drawn at the
Next, the data on the 38th line is processed. Since the state is none, a straight line in the vertical direction is drawn at the
The developer can intuitively recognize that the 36th, 37th, and 47th lines are executed and the process is interrupted at the 48th line by the series of drawn arrows.
図22は、図19におけるステップ1917の反復処理を描画する処理の具体例を示す図である。
動作過程情報描画部119は、クラス名1001とメソッド名1002が一致する新たな動作過程情報を取得して矢印を描画する。なお、複数の本数の矢印を描画する際は、ステップ1912で補正値が加算されるので、2201に示すように各矢印が重ならないように表示される。また、41行目の処理で部分フローが含まれるので図20で示した反復処理を描画するフローを実行する。
まず、41行目は2つの部分フローを保持するので、ステップ2001、2002に従って、反復区間の右側に下から上への矢印2202を描画する。
次に、ステップ2003により反復補正値を定数で初期化する。図中の2203で示す距離がこの定数の大きさとなる。
FIG. 22 is a diagram showing a specific example of the process of drawing the iterative process of
The operation process
First, since the 41st line holds two partial flows, an
Next, in
次に、部分フローを1つずつ取得して処理していく。具体的には、まず部分フローにID2が格納されているので、フローIDが“2”である42、43行目のデータを処理し、それぞれ状態がexecであるので反復補正値2203を加算した位置へ水平方向の直線を描画する。43行目の次はデータが存在しないので、ステップ2007に従って描いた直線の終端に矢尻を描画する。
次に、ステップ2008に従って反復補正値を増加し、部分フローの描画結果が重ならないようにする。増加する値は図中の2204の距離となる。
フローIDが3である部分フローも同様に処理し、最終的に2205のように描画され、開発者は描画された線によって42,43行目が反復処理によって2回実行されたことを直感的に認識することができる。
Next, partial flows are acquired and processed one by one. Specifically, first, since ID2 is stored in the partial flow, the data in the 42nd and 43rd lines where the flow ID is “2” is processed, and the state is “exec”, so the repeated
Next, the iterative correction value is increased in accordance with
The partial flow with the
図23は、図19におけるステップ1909の、状態1005がerrorの場合の具体例を示す図である。
この例の動作過程情報は40行目の状態がerrorとなっているので、ステップ1913に従って、右側の位置に「×」マークを描き、さらにステップ1911に従って垂直方向の直線と、その終端から左方向へ伸びる矢印を描画する。描かれた結果が2301となる。
開発者は描かれた矢印から、40行目で障害が発生し、メソッド処理が中断されたことを直感的に認識することができる。
FIG. 23 is a diagram illustrating a specific example in the case where the
In the operation process information of this example, since the state of the 40th line is error, according to
From the drawn arrow, the developer can intuitively recognize that a failure has occurred in the 40th line and the method processing has been interrupted.
また、showDetailメソッドに対する動作過程情報が図21から図23で述べた3つのみとすると、開発者は描かれた3本の矢印から、該当メソッドは計3回実行され、そのうち1回で障害が発生してメソッド処理が中断し、1回は反復処理を2回実行した事を認識することができる。 Also, assuming that there are only three operation process information for the showDetail method as described in FIGS. 21 to 23, the developer executes the method three times in total from the three arrows drawn, and one of them causes a failure. It is possible to recognize that the method processing has been interrupted and the iterative processing has been executed twice.
図24は、図19におけるステップ1913の、ジャンプ行1007が存在する場合の具体例を示す図である。
処理対象となっている動作過程情報の82行目はジャンプ行に値が存在するので、動作過程情報描画部はステップ1914に従って右側に直線を描き、その終端からジャンプ行である84行目の右側までを曲線で結ぶ。描かれた結果が2401となる。
開発者は描画された結果を見ることで、82行目で例外が発生し、84行目が実行された事を直感的に認識することができる。
FIG. 24 is a diagram showing a specific example of
Since the 82nd line of the operation process information to be processed has a value in the jump line, the operation process information drawing unit draws a straight line on the right side according to
By looking at the rendered result, the developer can intuitively recognize that an exception has occurred in the 82nd line and that the 84th line has been executed.
なお、上記実施形態においては、プログラム開発者が、対象のソースコードの実行過程を確認する場合について説明したが、開発担当者以外の者が、既存のソースコードの実行過程を確認する場合についても同様に利用可能であることは言うまでもない。
また、対象となるソースコードをコンパイラによってコンパイルした実行クラスと、構文解析した抽象構文木とが既に存在する場合には、コンパイルと構文解析処理は省略することができる。
In the above embodiment, the case where the program developer confirms the execution process of the target source code has been described. However, the case where a person other than the developer in charge confirms the execution process of the existing source code is also described. It goes without saying that it can be used as well.
If an execution class obtained by compiling the target source code with a compiler and an abstract syntax tree that has been parsed already exist, compilation and parsing processing can be omitted.
101 プログラム開発環境
102 計算機
103 プログラム実行環境
104 計算機
107 画面表示装置
108 ソースコード保持部
109 ソースコード編集部
110 コンパイラ
111 実行クラス保持部
112 構文解析部
113 抽象構文木保持部
114 実行情報出力命令埋め込み部
116 実行情報分類部
117 動作過程追跡部
118 動作過程情報保持部
119 動作過程情報描画部
120 実行クラス保持部
121 プログラム実行部
DESCRIPTION OF
Claims (3)
前記プログラムのソースコードをコンパイルした実行クラスと構文解析結果である抽象構文木の情報を入力として受け付け、前記抽象構文木の情報に基づき前記実行クラスを構成するメソッドの開始、終了位置及び変数宣言、判定式、宣言文、リターン文の先頭に、これらに対応するソースコードの行番号位置を実行情報として出力する命令を第1の手段によって埋め込む第1のステップと、
前記実行情報を埋め込んだ前記実行クラスを第2の手段によって実行する第2のステップと、
前記第2の手段によって実行された実行クラスが出力した前記実行情報を回収し、実行時刻順にソートした後、メソッド単位に分類し、その分類結果と前記抽象構文木の情報との基づき前記実行クラスにおけるメソッド、変数宣言、判定式、宣言文、リターン文の実行過程を第3の手段によって追跡する第3のステップと、
追跡した実行過程を、表示画面に表示した当該プログラムのソースコード上に第4の手段によって矢印により表示する第4のステップと
を備えることを特徴とするプログラム実行過程の表示方法。 A method of displaying the execution process of the target program on the source code of the program displayed on the display screen,
The execution class obtained by compiling the source code of the program and the abstract syntax tree information that is the result of the syntax analysis are accepted as inputs, and the start, end position, and variable declaration of the method constituting the execution class based on the information of the abstract syntax tree; A first step of embedding an instruction to output the line number position of the corresponding source code as execution information at the beginning of a determination formula, a declaration statement, and a return statement by first means;
A second step of executing the execution class embedded with the execution information by a second means;
The execution information output by the execution class executed by the second means is collected, sorted in order of execution time, and then classified into method units. The execution class is based on the classification result and the abstract syntax tree information. A third step of tracking the execution process of the method, variable declaration, judgment expression, declaration statement, and return statement in step 3 by a third means;
A program execution process display method comprising: a fourth step of displaying the tracked execution process by an arrow by means of a fourth means on the source code of the program displayed on the display screen.
前記プログラムのソースコードをコンパイルした実行クラスと構文解析結果である抽象構文木の情報を入力として受け付け、前記抽象構文木の情報に基づき前記実行クラスを構成するメソッドの開始、終了位置及び変数宣言、判定式、宣言文、リターン文の先頭に、これらに対応するソースコードの行番号位置を実行情報として出力する命令を埋め込む第1の手段と、
前記実行情報を埋め込んだ前記実行クラスを実行する第2の手段と、
前記第2の手段によって実行された実行クラスが出力した前記実行情報を回収し、実行時刻順にソートした後、メソッド単位に分類し、その分類結果と前記抽象構文木の情報との基づき前記実行クラスにおけるメソッド、変数宣言、判定式、宣言文、リターン文の実行過程を追跡する第3の手段と、
追跡した実行過程を、表示画面に表示した当該プログラムのソースコード上に矢印により表示する第4の手段と
を備えることを特徴とするプログラム実行過程の表示システム。 A system for displaying the execution process of a target program on the source code of the program displayed on a display screen,
The execution class obtained by compiling the source code of the program and the abstract syntax tree information that is the result of the syntax analysis are accepted as inputs, and the start, end position, and variable declaration of the method constituting the execution class based on the information of the abstract syntax tree; A first means for embedding an instruction to output the line number position of the corresponding source code as execution information at the beginning of a determination expression, a declaration statement, and a return statement;
A second means for executing the execution class in which the execution information is embedded;
The execution information output by the execution class executed by the second means is collected, sorted in order of execution time, and then classified into method units. The execution class is based on the classification result and the abstract syntax tree information. A third means for tracking the execution process of the method, variable declaration, judgment expression, declaration statement, and return statement in
A program execution process display system, comprising: a fourth means for displaying the tracked execution process by an arrow on the source code of the program displayed on the display screen.
コンピュータを、
前記対象プログラムのソースコードをコンパイルした実行クラスと構文解析結果である抽象構文木の情報を入力として受け付け、前記抽象構文木の情報に基づき前記実行クラスを構成するメソッドの開始、終了位置及び変数宣言、判定式、宣言文、リターン文の先頭に、これらに対応するソースコードの行番号位置を実行情報として出力する命令を埋め込む第1の手段と、
前記実行情報を埋め込んだ前記実行クラスを実行する第2の手段と、
前記第2の手段によって実行された実行クラスが出力した前記実行情報を回収し、実行時刻順にソートした後、メソッド単位に分類し、その分類結果と前記抽象構文木の情報との基づき前記実行クラスにおけるメソッド、変数宣言、判定式、宣言文、リターン文の実行過程を追跡する第3の手段と、
追跡した実行過程を、表示画面に表示した当該プログラムのソースコード上に矢印により表示する第4の手段と
して機能させるステップを備えることを特徴とするコンピュータプログラム。 A computer program for displaying the execution process of the target program on the source code of the program displayed on the display screen,
Computer
The execution class obtained by compiling the source code of the target program and the abstract syntax tree information that is the result of the syntax analysis are accepted as input, and the start, end position, and variable declaration of the method constituting the execution class based on the abstract syntax tree information First means for embedding an instruction to output the line number position of the corresponding source code as execution information at the beginning of the determination expression, declaration statement, and return statement;
A second means for executing the execution class in which the execution information is embedded;
The execution information output by the execution class executed by the second means is collected, sorted in order of execution time, and then classified into method units. The execution class is based on the classification result and the abstract syntax tree information. A third means for tracking the execution process of the method, variable declaration, judgment expression, declaration statement, and return statement in
A computer program, comprising: a step of causing a tracked execution process to function as a fourth means for displaying by an arrow on a source code of the program displayed on a display screen.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2006238734A JP2008059515A (en) | 2006-09-04 | 2006-09-04 | Method, system, and program for displaying program execution process |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2006238734A JP2008059515A (en) | 2006-09-04 | 2006-09-04 | Method, system, and program for displaying program execution process |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JP2008059515A true JP2008059515A (en) | 2008-03-13 |
Family
ID=39242132
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2006238734A Pending JP2008059515A (en) | 2006-09-04 | 2006-09-04 | Method, system, and program for displaying program execution process |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP2008059515A (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2010033543A (en) * | 2008-06-24 | 2010-02-12 | Smg Kk | Software operation monitoring system, client computer, server computer thereof, and program thereof |
| JP2010218139A (en) * | 2009-03-16 | 2010-09-30 | Fujitsu Semiconductor Ltd | Execution history tracing method |
| WO2014012464A1 (en) * | 2012-07-20 | 2014-01-23 | Tencent Technology (Shenzhen) Company Limited | Method and device for displaying process information |
| CN113760291A (en) * | 2020-09-16 | 2021-12-07 | 北京沃东天骏信息技术有限公司 | Log output method and device |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPH09160806A (en) * | 1995-12-14 | 1997-06-20 | Hitachi Ltd | Method for supporting debugging and its device |
| JPH11224211A (en) * | 1998-02-06 | 1999-08-17 | Fuji Xerox Co Ltd | Software inspection support device |
| JP2002342113A (en) * | 2001-05-15 | 2002-11-29 | Hitachi Ltd | Program execution status display method, its execution device, and its processing program |
-
2006
- 2006-09-04 JP JP2006238734A patent/JP2008059515A/en active Pending
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPH09160806A (en) * | 1995-12-14 | 1997-06-20 | Hitachi Ltd | Method for supporting debugging and its device |
| JPH11224211A (en) * | 1998-02-06 | 1999-08-17 | Fuji Xerox Co Ltd | Software inspection support device |
| JP2002342113A (en) * | 2001-05-15 | 2002-11-29 | Hitachi Ltd | Program execution status display method, its execution device, and its processing program |
Cited By (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2010033543A (en) * | 2008-06-24 | 2010-02-12 | Smg Kk | Software operation monitoring system, client computer, server computer thereof, and program thereof |
| JP2010218139A (en) * | 2009-03-16 | 2010-09-30 | Fujitsu Semiconductor Ltd | Execution history tracing method |
| US8578216B2 (en) | 2009-03-16 | 2013-11-05 | Spansion Llc | Execution history tracing method |
| US9507688B2 (en) | 2009-03-16 | 2016-11-29 | Cypress Semiconductor Corporation | Execution history tracing method |
| WO2014012464A1 (en) * | 2012-07-20 | 2014-01-23 | Tencent Technology (Shenzhen) Company Limited | Method and device for displaying process information |
| US10169422B2 (en) | 2012-07-20 | 2019-01-01 | Tencent Technology (Shenzhen) Company Limited | Method and device for displaying process information |
| CN113760291A (en) * | 2020-09-16 | 2021-12-07 | 北京沃东天骏信息技术有限公司 | Log output method and device |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| Kats et al. | Pure and declarative syntax definition: paradise lost and regained | |
| EP0643851B1 (en) | Debugger program which includes correlation of computer program source code with optimized objet code | |
| US4860203A (en) | Apparatus and method for extracting documentation text from a source code program | |
| Ferdowsifard et al. | LooPy: interactive program synthesis with control structures | |
| US20110271258A1 (en) | Software Development Tool | |
| US20110271250A1 (en) | Software Development Tool | |
| JPH02272645A (en) | Method for supporting program debugging | |
| Hoschele et al. | Mining input grammars with AUTOGRAM | |
| JPH08202545A (en) | Object-oriented system and method for generation of target language code | |
| JP2012063868A (en) | Method to generate combined parser by combining language processing parsers, and its computer and computer program | |
| CN114911711A (en) | Code defect analysis method and device, electronic equipment and storage medium | |
| CN101206467A (en) | General NC code analysis method | |
| US5949993A (en) | Method for the generation of ISA simulators and assemblers from a machine description | |
| US11126527B2 (en) | Software engineering method including tracing and visualizing | |
| JP4835859B2 (en) | State transition diagram creation device and state transition diagram creation method | |
| Krebs et al. | Jaccie: A Java-based compiler–compiler for generating, visualizing and debugging compiler components | |
| JP2008059515A (en) | Method, system, and program for displaying program execution process | |
| Koskimies et al. | The design of a language processor generator | |
| Alpuente et al. | Symbolic analysis of Maude theories with Narval | |
| Costagliola et al. | Visual parsing and parser visualization | |
| Mazanek et al. | Generating correctness-preserving editing operations for diagram editors | |
| Mercer et al. | Computing and visualizing the impact of change with Java PathFinder extensions | |
| de Almeida | Code-stepping regular expressions in the browser | |
| JP3648710B2 (en) | Program analysis system | |
| JP4458491B2 (en) | Test command file creation system, method and program |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20090120 |
|
| A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20101019 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20110817 |
|
| A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20111214 |