JPH08272623A - Device and method for program analysis - Google Patents

Device and method for program analysis

Info

Publication number
JPH08272623A
JPH08272623A JP7077933A JP7793395A JPH08272623A JP H08272623 A JPH08272623 A JP H08272623A JP 7077933 A JP7077933 A JP 7077933A JP 7793395 A JP7793395 A JP 7793395A JP H08272623 A JPH08272623 A JP H08272623A
Authority
JP
Japan
Prior art keywords
abstract
program
value
error
syntax tree
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP7077933A
Other languages
Japanese (ja)
Inventor
Yasushi Fujiwara
靖 藤原
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.)
Toshiba Corp
Original Assignee
Toshiba 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 Toshiba Corp filed Critical Toshiba Corp
Priority to JP7077933A priority Critical patent/JPH08272623A/en
Publication of JPH08272623A publication Critical patent/JPH08272623A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)
  • Debugging And Monitoring (AREA)

Abstract

PURPOSE: To provide a program analysis device and method which can offer even the information on the detectable errors. CONSTITUTION: A program is inputted from an input device 1 in the form of an abstract syntax tree that can be evaluated by a prescribed evaluation rule. A setting means 2 sets an abstract area where the relation is shown between plural abstract value including the error value showing the possibility of at least the detectable errors and the abstract value that is produced as the result of every processing type included in the program for those abstract value. An allocation means 3 allocates the abstract value to every variable of the abstract syntax tree. Then an evaluation means 4 evaluates the abstract syntax tree based on every allocated abstract value, the abstract area and the evaluation rule, and therefore evaluates the possibility of errors at every stage of the program.

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、コンピュータのプログ
ラムを解析するプログラム解析装置及びプログラム解析
方法の改良に関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to improvements in a program analysis device and a program analysis method for analyzing a computer program.

【0002】[0002]

【従来の技術】プログラムの信頼性・実行効率を向上さ
せるために各種検査や最適化を施す手法が盛んに研究さ
れているが、各手法では、実行前にプログラムを解析す
ることが一般的である。プログラムを解析し、プログラ
ムに関する情報を実行前に集めてプログラムの開発や実
行の際にそれを利用することは、実行時にすべての処理
を行なう場合と比べ、次のような長所がある。すなわ
ち、型の不一致などプログラムのエラーを早めに検出で
き、実行時の負荷が軽減でき、さらに、各種最適化技術
の適用が容易になる。
2. Description of the Related Art Methods for performing various tests and optimizations have been actively studied in order to improve the reliability and execution efficiency of programs, but in each method, it is common to analyze the program before execution. is there. Analyzing a program, collecting information about the program before execution, and using the information when developing or executing the program has the following advantages over the case where all the processing is performed at the time of execution. That is, a program error such as a type mismatch can be detected early, the load at the time of execution can be reduced, and various optimization techniques can be easily applied.

【0003】例えば、遅延評価に基づく関数型言語で
は、変数を評価(結果の演算)しないで渡す引数渡し方
法でそのプログラムの実行規則が定義されている。しか
し渡された変数は、プログラム中のそれぞれの出現場所
でもその都度評価されるので、変数を評価してから渡す
場合に比べ、実行効率が劣る傾向にある。このようなプ
ログラムを解析し、ある変数が必ず引き渡し先のモジュ
ール中で使われることが事前に判明すれば、その変数を
評価してから引数として渡すことで、プログラムの実行
結果に影響を与えることなく実行効率の向上を図ること
ができる。
For example, in a functional language based on lazy evaluation, the execution rules of the program are defined by an argument passing method for passing variables without evaluation (calculation of the result). However, since the passed variables are evaluated at each occurrence location in the program, the execution efficiency tends to be inferior to the case where the variables are evaluated and then passed. If such a program is analyzed and it is known in advance that a certain variable will always be used in the module to which it is passed, it may affect the execution result of the program by evaluating the variable and then passing it as an argument. Therefore, the execution efficiency can be improved.

【0004】プログラムの解析は、一般にコンピュータ
を用い、プログラム解析装置(プログラム解析方法)と
して実現されるが、プログラム解析の手法としてよく用
いられるものとして抽象解釈が存在する。抽象解釈と
は、プログラムの具体的な記述やデータを、型・実行や
評価の有無・正常異常などの一般的要素に抽象化し、そ
の抽象化された領域の上でプログラムを記号的(抽象的
・一般的)に実行・評価することによって、具体的なプ
ログラムの性質を解析する手法である。ここでプログラ
ムの「評価」とは、プログラムの最終的結果を得ること
を意味する。
Computer analysis is generally realized by using a computer as a program analysis apparatus (program analysis method), and abstract interpretation is often used as a program analysis method. Abstract interpretation is an abstraction of a concrete description or data of a program into general elements such as types, execution and presence / absence of evaluation, and normal / abnormality, and the program is symbolically (abstract) on the abstracted area.・ It is a method of analyzing the specific properties of a program by executing and evaluating (generally). As used herein, "evaluating" a program means obtaining the final result of the program.

【0005】従来の抽象解釈は、典型的には、ある変数
の値がアボートエラーを起こすとき、それがプログラム
全体のアボートを必ず引き起こすかどうかを抽象的に解
析することを主眼としている。なお、アボートエラーと
は、プログラム(の評価)が停止しないエラーと把握す
ることができる。
The conventional abstract interpretation typically focuses on abstractly analyzing whether or not the value of a certain variable causes an abort error of the entire program when the abort error occurs. The abort error can be understood as an error in which the program (evaluation) does not stop.

【0006】すなわち、特定の変数の評価が停止はしな
いが本来意図する結果とは異なる異常な結果をもって終
了し、その他の変数の評価はすべて(正常に)停止する
状況を考える。このとき、プログラムの評価をする(最
終的な結果を得る)際に、前記の特定の変数が必ず評価
されるときは、異常な評価結果がプログラム全体の結果
の基礎となるので、プログラム全体の結果に異常の影響
が及ぶ。しかも、その変数の評価は停止しないので、プ
ログラム全体の評価も停止せず、異常の存在を機械的に
検出することはできない。このような状態がすなわちア
ボートエラーである。
That is, consider a situation in which the evaluation of a specific variable does not stop, but ends with an abnormal result different from the originally intended result, and the evaluations of other variables all stop (normally). At this time, when the above-mentioned specific variable is always evaluated when evaluating the program (obtaining the final result), the abnormal evaluation result becomes the basis of the result of the entire program. Abnormal influence on the result. Moreover, since the evaluation of that variable is not stopped, the evaluation of the entire program is not stopped, and the existence of an abnormality cannot be detected mechanically. Such a state is an abort error.

【0007】それに対して、その変数の評価がプログラ
ム全体の評価に必ずしも必要でなければ、プログラム全
体の評価はその変数の評価抜きで可能である。このた
め、プログラム全体の評価は正常に停止することが期待
できる。このことから抽象解釈は、非停止性の陰に隠れ
ているエラーが、一つの変数からプログラム全体に必ず
波及するかどうかの問題とみなせる。
On the other hand, if the evaluation of the variable is not always necessary for the evaluation of the entire program, the evaluation of the entire program can be performed without evaluating the variable. Therefore, it can be expected that the evaluation of the entire program will stop normally. Therefore, the abstract interpretation can be regarded as a problem whether or not an error hidden in non-stopping is always transmitted from one variable to the whole program.

【0008】ここで、プログラムの一例として、Here, as an example of the program,

【数1】if(x=0)then x else y を考える。## EQU1 ## Consider if (x = 0) then x else y.

【0009】この中で、x,yともに整数型の変数とす
る。このような記述は、字句読み取り・構文解析などの
従来技術を用いて前処理を行えば、抽象構文木の形式に
変換することが容易である。ここで、抽象構文木とは、
プログラムの最終的結果を頂点のノードとし、その結果
に至る各処理や変数を順次下位のノードとした木構造デ
ータである。変数x,yは整数型であるので、無限個の
値を取る可能性があるが、抽象解析では上のプログラム
を二個の元0,1からなる抽象領域上で考える。
Of these, both x and y are integer type variables. Such a description can be easily converted into an abstract syntax tree format by performing preprocessing using a conventional technique such as lexical reading / syntactic analysis. Here, the abstract syntax tree is
This is tree-structured data in which the final result of the program is a vertex node and each process and variable leading to the result are sequentially lower nodes. Since the variables x and y are integer types, there is a possibility that they will take infinite numbers of values, but in the abstract analysis, the above program is considered on the abstract area consisting of two elements 0 and 1.

【0010】そして、抽象解釈では各変数にはこれら0
又は1を割り当てるが、この場合、0はその変数が必ず
評価されることを意味し、また、1はその変数は評価さ
れるか否かは不明であることを意味する。そして、変数
xを必ず評価する必要があるかどうかを調べる時は、プ
ログラム中に現れる他の変数については1を割り当て
る、すなわち他の変数が評価されるかどうかは知られて
いないとする。
In the abstract interpretation, each variable has these 0
Or 1 is assigned, where 0 means that the variable is always evaluated and 1 means that it is unknown whether or not the variable is evaluated. Then, when checking whether or not the variable x must be evaluated, it is assumed that 1 is assigned to other variables appearing in the program, that is, whether or not the other variables are evaluated is unknown.

【0011】プログラムの一部x=0に対応する抽象構
文木の部分木を考える場合、xが必ず評価されるなら、
この部分も評価されるので、この部分木に0を割り当て
る。
If we consider the subtree of the abstract syntax tree corresponding to the part x = 0 of the program, if x is always evaluated, then
Since this part is also evaluated, 0 is assigned to this subtree.

【0012】一方、構文木全体は、上記のif部に0が
割り当てられている時は、全体にも0が割り当てられる
とすると、構文木全体に0が割り当てられることから、
xはプログラム内部で必ず用いられることが判明する。
すなわち、プログラム(の抽象構文木)の各変数に抽象
領域の元(0または1)を与え、インタプリタによる抽
象構文木の評価と同様な手法で、抽象領域上でプログラ
ムの抽象構文木を評価することで、プログラムに関する
各種情報を得るのが、抽象解釈と呼ばれる手法である。
On the other hand, in the entire syntax tree, when 0 is assigned to the if part, if 0 is also assigned to the entire if part, 0 is assigned to the entire syntax tree.
It turns out that x is always used inside the program.
That is, the element (0 or 1) of the abstract area is given to each variable of (the abstract syntax tree of) the program, and the abstract syntax tree of the program is evaluated on the abstract area by the same method as the evaluation of the abstract syntax tree by the interpreter. Therefore, a method called abstract interpretation is used to obtain various kinds of information about programs.

【0013】この場合、ある変数がかならず評価される
場合は、その変数に0を割り当てたら必ずプログラム全
体の抽象領域での値が0となる。また、ある変数が評価
されるとは限らない場合は、その変数に0を割り当てて
もプログラム全体は1を返す可能性がある。
In this case, when a certain variable is always evaluated, if 0 is assigned to the variable, the value in the abstract area of the entire program becomes 0. Further, when a variable is not always evaluated, the entire program may return 1 even if 0 is assigned to the variable.

【0014】例えばこのような場合、次の表に従って値
を割り当てると良いことが知られている(参考文献:S.
Abramsky and C.Hankin(eds).Abstract Interpretation
ofDeclarative Languages. Ellis Horwood Limited,19
87.)。
For example, in such a case, it is known that values should be assigned according to the following table (reference: S.
Abramsky and C. Hankin (eds) .Abstract Interpretation
of Declarative Languages. Ellis Horwood Limited, 19
87.).

【0015】[0015]

【表1】 [Table 1]

【0016】[0016]

【発明が解決しようとする課題】上記のような抽象解釈
は有用であるが、近年、プログラムの大規模化が進むに
つれて、エラーの発見は困難になり、また、一つのエラ
ーがプログラムのより広い範囲に影響を及ぼすようにな
っている。エラーを事前に検出するためには、テストを
繰り返し行なうことや、静的型検査によりデータの整合
性を実行前に検査することなども行なわれているが、す
べてのエラーを事前に取り除くことは非常に困難であ
る。
Although the above-described abstract interpretation is useful, as the scale of programs has increased in recent years, it has become difficult to find errors, and one error is wider than that of programs. It affects the range. In order to detect errors in advance, it is possible to repeat tests or check the data integrity by static type checking before execution, but it is not possible to remove all errors in advance. Very difficult.

【0017】エラーについて考察してみると、エラーに
もいくつかの種類が存在することが理解できる。そのう
ち、上記のようなアボートエラーはしばしば見受けられ
るものであるが、同じループを回り続けるなど、主にプ
ログラムのアルゴリズム構成上のエラーである。このよ
うなエラーは、通常、複数命令が理論的に関わり合って
構成される。このため実行時に機械的に検出することは
困難である。
Considering errors, it can be seen that there are several types of errors. Among them, the above-mentioned abort error is often seen, but it is mainly an error in the algorithm configuration of the program such as continuing to go through the same loop. Such an error is usually constructed by theoretically involving a plurality of instructions. Therefore, it is difficult to detect it mechanically at the time of execution.

【0018】一方、エラーのうちでも、ある数を0で割
ろうとするような状況は実行時に検出が可能である。多
くのハードウェアやソフトウェアのシステムは、これら
のエラーを検出するためのエラーフラグや割り込みなど
の機能を備えている。したがって、このような検出可能
なエラーが発生しても、処理を続行できるようにするに
は、プログラム記述を適宜拡張すればよい。例えば、検
出可能なエラーを表す値としてerrorを考えると、
プログラムの構文を少し変更して
On the other hand, among the errors, a situation in which a certain number is divided by 0 can be detected at the time of execution. Many hardware and software systems have features such as error flags and interrupts to detect these errors. Therefore, even if such a detectable error occurs, the program description may be appropriately expanded so that the processing can be continued. For example, considering error as a value that represents a detectable error,
I changed the syntax of the program a little

【数2】if(x/y>0)=error then 1 else -1 のようなプログラムを作成することが考えられる。但
し、このようなプログラムを考える場合は、error
は本来の真偽値ではないので、言語体系、特にコンパイ
ラやインタプリタにこのような値に対応する機能を追加
しておく。
[Equation 2] It is possible to create a program such as if (x / y> 0) = error then 1 else -1. However, when considering such a program, error
Is not a true / false value, so add a function corresponding to such a value to the language system, especially the compiler and interpreter.

【0019】なお、本明細書において、検出可能なエラ
ーは、型検査などの静的な手段では検出できないが、実
行時には検出できるエラーである。例えば、除算におい
て引数の型、結果の型ともに整数の場合、第2の引数が
0でも型検査はパスするが、実行時にはエラーが発生す
る。このようなエラー検出にあたっては、プログラマや
言語の設計者がエラー発生や検出について可能性・必要
性を認識していることが前提となる。
In the present specification, a detectable error is an error that cannot be detected by static means such as type checking, but can be detected at the time of execution. For example, when the argument type and the result type are both integers in the division, the type check passes even if the second argument is 0, but an error occurs at the time of execution. In such error detection, it is premised that the programmer or language designer recognizes the possibility / necessity of error occurrence and detection.

【0020】従来の抽象解釈では、検出可能なエラーは
アボートエラーと特段区別されていなかったが、プログ
ラムが停止するか否かという挙動の相違から両者は区別
可能である。さらに、検出可能なエラーを構成する要素
は性質上単純であるから、アボートエラーとは異なる手
法で回避策を講ずることができる場合が多い。このた
め、アボートエラーとは区別してプログラミングを行な
うことがプログラム開発の効率化に役立つ。
In the conventional abstract interpretation, the detectable error is not particularly distinguished from the abort error, but the two can be distinguished from each other because of the difference in behavior such as whether or not the program stops. Furthermore, since the elements that make up a detectable error are simple in nature, it is often possible to take workarounds in a manner different from the abort error. For this reason, it is useful to make programming different from the abort error to improve the efficiency of program development.

【0021】すなわち、従来の抽象解釈はアボートエラ
ーに関する情報は与えるが、検出可能なエラーを反映し
たものではなかった。大規模プログラムの開発において
は、エラー処理を含めた例外処理が重要になることはよ
く知られており、検出可能エラーを取り込んだプログラ
ムの解析は今後重要性が増大すると期待される。特にプ
ログラム解析技術として広く用いられている抽象解釈
を、このような場合に拡張するすれば上記のようにプロ
グラム開発の効率が向上する。
That is, the conventional abstract interpretation gives information about an abort error, but does not reflect a detectable error. It is well known that exception handling including error handling is important in the development of large-scale programs, and it is expected that the analysis of programs incorporating detectable errors will become more important in the future. In particular, if the abstract interpretation, which is widely used as a program analysis technique, is extended to such a case, the efficiency of program development is improved as described above.

【0022】本発明は、上記のような従来技術の問題点
を解決するために提案されたもので、その目的は、抽象
解釈を用いて検出可能エラーに関する情報をも提供する
プログラム解析装置及びプログラム解析方法を提供する
ことである。また、本発明の他の目的は、エラーへの対
応が容易なプログラム解析装置及びプログラム解析方法
を提供することである。
The present invention has been proposed in order to solve the above-mentioned problems of the prior art, and its object is to provide a program analysis device and a program which also provide information regarding a detectable error using abstract interpretation. It is to provide an analysis method. Another object of the present invention is to provide a program analysis device and a program analysis method that can easily deal with errors.

【0023】[0023]

【課題を解決するための手段】上記の目的を達成するた
め、請求項1のプログラム解析装置は、所定の評価規則
で評価されうる抽象構文木の形式でプログラムを入力す
るための入力手段と、少なくとも検出可能なエラーの可
能性を表すエラー値を含む複数の抽象値と、抽象値に対
する前記プログラム中の処理の種類ごとの結果として生
じる抽象値との関係、を表す抽象領域を設定する設定手
段と、前記抽象構文木の各変数に前記抽象値を割り当て
る割り当て手段と、割り当てられた前記各抽象値、前記
抽象領域及び前記評価規則に基づいて、前記抽象構文木
を評価することによって、前記プログラムの各段階にお
けるエラーの可能性を評価する評価手段と、を有するこ
とを特徴とする。
In order to achieve the above object, the program analysis device according to claim 1 comprises an input means for inputting a program in the form of an abstract syntax tree which can be evaluated by a predetermined evaluation rule, Setting means for setting an abstract area indicating a relation between a plurality of abstract values including at least an error value indicating the possibility of a detectable error and the resulting abstract value for each type of processing in the program for the abstract value An assigning unit that assigns the abstract value to each variable of the abstract syntax tree; and the program by evaluating the abstract syntax tree based on the assigned abstract value, the abstract area, and the evaluation rule. And an evaluation means for evaluating the possibility of an error in each stage of.

【0024】また、請求項2の発明は、請求項1記載の
プログラム解析装置において、前記評価の結果を解析す
ることによって、前記抽象構文木においてエラー値の発
生する箇所又は前記抽象構文木においてエラー値の伝達
する経路のうち少なくとも一方、を特定する解析手段を
有することを特徴とする。
According to the invention of claim 2, in the program analysis device according to claim 1, by analyzing the result of the evaluation, an error value occurs in the abstract syntax tree or an error occurs in the abstract syntax tree. It is characterized by having an analysis means for specifying at least one of the paths through which the value is transmitted.

【0025】また、請求項3のプログラム解析方法は、
所定の評価規則で評価されうる抽象構文木の形式でプロ
グラムを入力するための入力のステップと、少なくとも
検出可能なエラーの可能性を表すエラー値を含む複数の
抽象値と、抽象値に対する前記プログラム中の処理の種
類ごとの結果として生じる抽象値との関係、を表す抽象
領域を設定する設定のステップと、前記抽象構文木の各
変数に前記抽象値を割り当てる割り当てのステップと、
割り当てられた前記各抽象値、前記抽象領域及び前記評
価規則に基づいて、前記抽象構文木を評価することによ
って、前記プログラムの各段階におけるエラーの可能性
を評価する評価のステップと、を含むことを特徴とす
る。
The program analysis method according to claim 3 is
An input step for entering a program in the form of an abstract syntax tree that can be evaluated by a predetermined evaluation rule, a plurality of abstract values including at least an error value indicating a possibility of a detectable error, and the program for the abstract value A relationship with the resulting abstract value for each type of processing in, a step of setting an abstract region that represents, a step of assigning the abstract value to each variable of the abstract syntax tree,
An evaluation step of evaluating the possibility of an error at each stage of the program by evaluating the abstract syntax tree based on each of the assigned abstract values, the abstract area, and the evaluation rule. Is characterized by.

【0026】また、請求項4の発明は、請求項3記載の
プログラム解析方法において、前記評価の結果を解析す
ることによって、前記抽象構文木においてエラー値の発
生する箇所又は前記抽象構文木においてエラー値の伝達
する経路のうち少なくとも一方、を特定する解析のステ
ップを含むことを特徴とする。
According to a fourth aspect of the present invention, in the program analysis method according to the third aspect, by analyzing the result of the evaluation, an error value occurs in the abstract syntax tree or an error occurs in the abstract syntax tree. It is characterized by including an analysis step of specifying at least one of the paths through which the value is transmitted.

【0027】[0027]

【作用】上記のような構成を有する本発明は、次のよう
な作用を有する。まず、請求項1,3において、抽象構
文木は処理を表すノードと変数の利用関係を表すアーク
からなる木構造データである。抽象構文木では、演算式
における下位関数など先の処理が下位ノードで表され、
上位ノード(部分木の頂点)が下位ノードで生成された
値を用いた後の処理を表す。また、末端ノードは個々の
変数を表し、ルートが最終的結果を生じる処理を表す。
各ノードの種類ごとの処理内容はインタプリタのような
評価規則として保持しておく。
The present invention having the above structure has the following functions. First, in claims 1 and 3, the abstract syntax tree is tree-structured data composed of arcs representing a usage relationship between a node representing a process and a variable. In the abstract syntax tree, the previous processing such as the lower function in the arithmetic expression is represented by the lower node,
This represents the processing after the upper node (vertex of the subtree) uses the value generated by the lower node. Also, terminal nodes represent individual variables, and the root represents the process that produces the final result.
The processing content for each type of each node is held as an evaluation rule such as an interpreter.

【0028】抽象値はエラーの可能性の有無を表し、例
えば0による割り算のような検出可能なエラーの可能性
は特定のエラー値で表される。これら抽象値を各変数に
割り当て、抽象構文木の下位側から評価規則に基づいて
順次ノードを評価する。各ノードでは、下位ノードの処
理で生じた抽象値を引数として処理の結果たる抽象値が
決定される。このとき、処理の種類によっては、処理の
基礎となる各抽象値がエラー値の可能性を持たない場合
も、当該処理の結果たる新たな抽象値はエラー値の可能
性を含むことも考えられる。このような引数と処理結果
の抽象値の種類の組合せは、プログラム中の処理の種類
ごとに設定され抽象領域に含まれる。例えば、除算x/
yではx,yともに正常値でもy=0の可能性が存在す
るため結果的にエラー値が生じる。
The abstract value indicates the presence or absence of an error possibility, and the possibility of a detectable error such as division by 0 is represented by a specific error value. These abstract values are assigned to each variable, and the nodes are sequentially evaluated from the lower side of the abstract syntax tree based on the evaluation rule. At each node, the abstract value that is the result of the processing is determined by using the abstract value generated by the processing of the lower node as an argument. At this time, depending on the type of processing, even if each abstract value that is the basis of processing does not have the possibility of an error value, the new abstract value resulting from the processing may include the possibility of an error value. . Such a combination of the argument and the type of the abstract value of the processing result is set for each type of processing in the program and is included in the abstract area. For example, division x /
In y, there is a possibility that y = 0 even if both x and y are normal values, and as a result, an error value occurs.

【0029】この評価は、構文木中の処理でエラー値の
可能性が発生し、変数を介して伝達する様子をシミュレ
ートすることを意味する。このため、検出可能なエラー
の可能性に対処すべきプログラムの箇所を特定でき、場
合分け等の対応策をとることが容易になるので、大規模
プログラム等のプログラムの信頼性が向上する。
This evaluation means simulating the possibility that an error value will occur during processing in the syntax tree and will be propagated via variables. Therefore, it is possible to specify the location of the program that should deal with the possibility of a detectable error, and it becomes easy to take countermeasures such as case classification, so that the reliability of the program such as a large-scale program is improved.

【0030】また、請求項2,4の発明では、評価が行
われるだけではなく、エラー値の発生箇所や伝達経路が
解析によって特定され出力されるので、プログラマはエ
ラーへの対応が容易になる。
According to the second and fourth aspects of the invention, not only the evaluation is performed, but also the generation place of the error value and the transmission path are specified by the analysis and output, so that the programmer can easily deal with the error. .

【0031】[0031]

【実施例】次に、本発明の実施例について図面にしたが
って具体的に説明する。なお、実施例の各機能は、所定
のソフトウェアがコンピュータ及び周辺機器を制御する
ことで実現される。すなわち、本明細書では、発明及び
実施例を、各機能や各処理に対応する仮想的回路ブロッ
ク(「〜手段」や「〜部」など)を想定して説明してい
る。このため、各ブロックに対して、各ハードウェア要
素やソフトウェア要素は1対1には対応しない。
Embodiments of the present invention will now be specifically described with reference to the drawings. It should be noted that each function of the embodiment is realized by a predetermined software controlling a computer and peripheral devices. That is, in the present specification, the invention and the embodiments are described on the assumption of virtual circuit blocks (“-means”, “-units”, etc.) corresponding to each function and each process. Therefore, each hardware element or software element does not correspond to each block on a one-to-one basis.

【0032】実施例を実現するためのコンピュータは、
CPU、RAMからなる主記憶装置の他に、典型的に
は、キーボードやマウスなどの入力装置と、ハードディ
スク装置などの外部記憶装置と、CRT表示装置やプリ
ンタ印字装置などの出力装置と、必要な入出力制御回路
を含む。但し、コンピュータの規模・構成やCPUの数
・形式は自由で、例えば、コンピュータネットワーク、
分散処理、マルチタスクなどを自由に用い得る。また、
トラックボールやイメージスキャナなど他の入力装置
や、フロッピーディスク装置・光磁気ディスク装置・フ
ラッシュメモリなど他の記憶装置や、液晶表示装置など
他の出力装置を用いてもよい。
A computer for realizing the embodiment is
In addition to a main storage device including a CPU and a RAM, typically, an input device such as a keyboard and a mouse, an external storage device such as a hard disk device, and an output device such as a CRT display device and a printer printing device are required. It includes an input / output control circuit. However, the scale and configuration of the computer and the number and form of the CPU are arbitrary, such as a computer network,
Distributed processing, multitasking, etc. can be used freely. Also,
Other input devices such as a trackball and an image scanner, other storage devices such as a floppy disk device, a magneto-optical disk device, a flash memory, and other output devices such as a liquid crystal display device may be used.

【0033】また、実施例を実現するソフトウェアの形
式は、典型的には、OS上の応用ソフトウェアが考えら
れ、また、高級言語やアセンブラからコンパイルされた
機械語が考えられるが、本発明が実施できる限り、OS
を用いない、ソフトウェアをインタプリタで実行するな
ど自由に変更し得る。また、ソフトウェアの格納態様も
自由で、例えば、ROMに格納しておいても、外部記憶
装置から一度に又は一部づつ読み込んでも、部分ごとの
格納態様が異なってもよい。また、処理の各ステップに
ついては、その性質に反しない限り、順序の変更や並行
処理は自由である。
Further, the software format for realizing the embodiment is typically application software on an OS, or a high-level language or a machine language compiled from an assembler, but the present invention is embodied. OS as much as possible
You can change it freely, such as not using, or running the software in an interpreter. Further, the software may be stored in any desired manner, for example, it may be stored in the ROM, read from the external storage device at one time or in part, or may be stored in different parts. Further, with respect to each step of the processing, the order can be changed and the parallel processing can be freely performed unless the property is violated.

【0034】また、本明細書において「入力」とは、外
部からのみならずファイルなどからの入力を含み、本来
の入力のみならずエコーバックや修正・編集などを含
む。同様に、「出力」とは、外部へのみならずファイル
などへの出力を含み、本来の出力のみならず出力範囲の
指定などを含む。また、ユーザインタフェースの形式
も、対話形式、メニュー形式、グラフィカルユーザイン
タフェースやマルチウインドウなど自由である。なお、
対話的入出力手順によって入力と出力を一体的操作によ
って実現してもよく、このような一体的操作によって、
選択・指定・特定などの処理を行ってもよい。
Further, in the present specification, "input" includes not only external input but also file input, and includes not only original input but also echo back and correction / edit. Similarly, "output" includes not only external output but also file output, and includes not only original output but also output range designation. The user interface may be of any type such as an interactive type, a menu type, a graphical user interface, or a multi-window. In addition,
Input and output may be realized by an integrated operation by an interactive input / output procedure, and by such an integrated operation,
Processing such as selection / designation / specification may be performed.

【0035】また、本明細書におけるデータの表現形式
やデータの格納手段の形式は自由で、例えば、データの
格納場所は内部記憶や外部記憶でもよく、ファイル形式
を用いるかも自由である。また、データは必要な間だけ
保持されれば十分でその後消滅してもよい。また、辞書
データのように当面変更されない情報はROMに格納し
てもよい。
Further, in the present specification, the expression format of data and the format of the data storage means are arbitrary. For example, the data storage location may be internal storage or external storage, and the file format may be used. Further, the data need only be retained for as long as necessary, and may be lost thereafter. Information that is not changed for the time being, such as dictionary data, may be stored in the ROM.

【0036】また、本明細書で明示せずとも、動作に必
要な一般的な情報やその格納領域、例えば、各種ポイン
タ、スタック、カウンタ、フラグ、パラメータ、ワーク
エリア、バッファなどが適宜用いられる。
Further, general information necessary for operation and a storage area thereof, such as various pointers, stacks, counters, flags, parameters, work areas, buffers, etc., are appropriately used, even if not explicitly stated in this specification.

【0037】実施例の各部分が処理に要する情報は、特
に記載がない場合、当該情報を保持している他の部分か
ら獲得され、例えば、当該情報を格納している変数やメ
モリへのアクセスによって獲得される。また、実施例
は、他のソフトウェアとともに又はその一部として実現
したり、機能の一部を電子回路に置き換えてもよい。
Unless otherwise specified, information required by each part of the embodiment for processing is obtained from another part holding the information, for example, access to a variable or memory storing the information. Earned by. Further, the embodiment may be realized together with or as a part of other software, or part of the function may be replaced with an electronic circuit.

【0038】(1)実施例の構成 本実施例のプログラム解析装置(以下「本装置」とい
う)は、請求項1〜4に対応するもので、その目的は、
抽象解釈を用いて検出可能エラーに関する情報をも提供
するプログラム解析装置及びプログラム解析方法を提供
することである。また、本実施例の他の目的は、エラー
への対応が容易なプログラム解析装置及びプログラム解
析方法を提供することである。
(1) Configuration of the Embodiment A program analysis device of this embodiment (hereinafter referred to as "this device") corresponds to claims 1 to 4, and its purpose is to:
It is an object of the present invention to provide a program analysis device and a program analysis method which also provide information regarding a detectable error using abstract interpretation. Another object of the present embodiment is to provide a program analysis device and a program analysis method that can easily deal with errors.

【0039】まず、図1は、本実施例のプログラム解析
装置の構成を示す機能ブロック図である。すなわち、本
装置は、この図に示すように、所定の評価規則で評価さ
れうる抽象構文木の形式でプログラムを入力するための
入力手段1と、少なくとも検出可能なエラーの可能性を
表すエラー値を含む複数の抽象値と、抽象値に対するプ
ログラム中の処理の種類ごとの結果として生じる抽象値
との関係、を表す抽象領域を設定する設定手段2と、を
有する。
First, FIG. 1 is a functional block diagram showing the configuration of the program analysis apparatus of this embodiment. That is, the present apparatus, as shown in this figure, has an input means 1 for inputting a program in the form of an abstract syntax tree that can be evaluated by a predetermined evaluation rule, and at least an error value indicating the possibility of a detectable error. And setting means 2 for setting an abstract area that represents the relationship between a plurality of abstract values including the following and the resulting abstract value for each type of processing in the program for the abstract value.

【0040】また、本装置は、抽象構文木の各変数に抽
象値を割り当てる割り当て手段3と、割り当てられた各
抽象値、抽象領域及び評価規則に基づいて、抽象構文木
を評価することによって、プログラムの各段階における
エラーの可能性を評価する評価手段4と、を有する。
Also, the present apparatus evaluates the abstract syntax tree based on the assigning means 3 for assigning an abstract value to each variable of the abstract syntax tree and the assigned abstract value, abstract area and evaluation rule. The evaluation means 4 evaluates the possibility of an error at each stage of the program.

【0041】また、本装置は、前記評価の結果を解析す
ることによって、抽象構文木においてエラー値の発生す
る箇所又は抽象構文木においてエラー値の伝達する経路
のうち少なくとも一方、を特定する解析手段5と、解析
結果を出力する出力手段6と、を有する。
Further, the present apparatus analyzes the result of the evaluation to specify at least one of a location where an error value occurs in the abstract syntax tree or a path through which the error value is transmitted in the abstract syntax tree. 5 and output means 6 for outputting the analysis result.

【0042】(2)実施例の作用及び効果 上記のような構成を有する本実施例は、次のような作用
を有する。ここで、図2は、本実施例における処理手順
を示すフローチャートである。
(2) Operation and effect of the embodiment This embodiment having the above-mentioned structure has the following operation. Here, FIG. 2 is a flowchart showing a processing procedure in the present embodiment.

【0043】[抽象領域設定のステップ]まず、プログ
ラムの入力に前後して(ここでは入力前)、設定手段2
を用い、抽象領域を設定しておく(ステップ1)。ここ
で、抽象領域は、エラーの可能性を表すエラー値を含む
複数の抽象値と、抽象値に対する前記プログラム中の処
理の種類ごとの結果として生じる抽象値との関係、を表
す。
[Abstract Area Setting Step] First, before and after the input of the program (here, before the input), the setting means 2 is set.
Using, the abstract area is set (step 1). Here, the abstract area represents a relationship between a plurality of abstract values including an error value indicating a possibility of an error and an abstract value generated as a result of each type of processing in the program for the abstract value.

【0044】各変数に割り当てるべき抽象値としては、
検出可能エラー値2、正常値1、アボート値0の、三つ
の元からなる集合を用いる。このとき、検出可能エラー
値は、当該変数に検出可能エラー、正常実行、アボート
のどの可能性もあることを意味し、正常値は、当該変数
に正常実行もしくはアボートの可能性があることを意味
し、アボート値は当該変数にアボートの可能性のみが存
在することを意味する。
As an abstract value to be assigned to each variable,
A set consisting of three elements of a detectable error value 2, a normal value 1, and an abort value 0 is used. At this time, the detectable error value means that the variable may have any of a detectable error, normal execution, and abort. The normal value means that the variable may be normally executed or aborted. However, the abort value means that there is only the possibility of abort in the variable.

【0045】また、抽象領域は、抽象値に対する前記プ
ログラム中の処理の種類ごとの結果として生じる抽象値
との関係を含む。例えば、除算x/yについては次の関
係が与えられる。
The abstract area also includes the relationship between the abstract value and the resulting abstract value for each type of processing in the program. For example, for division x / y, the following relationship is given.

【表2】 [Table 2]

【0046】また、乗算x*yに関する関係は、次の表
で与えられる。
Further, the relation regarding the multiplication x * y is given in the following table.

【表3】 [Table 3]

【0047】両者の違いは、組(x,y)=(0,0)
に対する値で、これは除算ではyが0の時に、検出可能
エラーが起こる可能性があることに対応する。抽象領域
は一旦設定が済めば、同一の抽象領域で挙動する他のプ
ログラムをその後評価する場合については設定を省略す
ることができる。
The difference between the two is that the pair (x, y) = (0, 0)
, Which corresponds to a detectable error that can occur when y is 0 in the division. Once the abstract area has been set, the setting can be omitted when another program that behaves in the same abstract area is subsequently evaluated.

【0048】[プログラム入力のステップ]そして、入
力手段1から、抽象構文木の形式で評価すべきプログラ
ムを入力する(ステップ2)。この抽象構文木は、処理
を表すノードと変数の利用関係を表すアークからなる木
構造データである。抽象構文木では、演算式における下
位関数など先の処理が下位ノードで表され、上位ノード
(部分木の頂点)が下位ノードで生成された値を用いた
後の処理を表す。また、末端ノードは個々の変数を表
し、ルートが最終的結果を生じる処理を表す。図3は、
本実施例における抽象構文木の例を示す図である。
[Program Input Step] Then, the program to be evaluated is input from the input means 1 in the form of the abstract syntax tree (step 2). This abstract syntax tree is tree structure data composed of arcs that represent the usage relationships between nodes and variables that represent processing. In the abstract syntax tree, the previous processing such as a lower function in the arithmetic expression is represented by the lower node, and the upper node (the vertex of the subtree) represents the processing after using the value generated by the lower node. Also, terminal nodes represent individual variables, and the root represents the process that produces the final result. FIG.
It is a figure which shows the example of the abstract syntax tree in a present Example.

【0049】ここでは、プログラムが検出可能エラーを
生じる可能性がある記述を含むものとする。また、この
プログラムを評価すなわちシミュレーション実行するた
めの評価規則は、各ノードの種類ごとに処理内容をイン
タプリタのように実行する個々の評価規則の集合として
あらかじめ与えておく。
Here, it is assumed that the program includes a description that may cause a detectable error. Further, the evaluation rule for evaluating or executing the simulation of this program is given in advance as a set of individual evaluation rules for executing the processing contents for each type of node like an interpreter.

【0050】[割り当てのステップ]続いて、割り当て
手段3によって、抽象構文木の各変数に抽象値を割り当
てる(ステップ3)。この割り当ては、自動的に行って
もよいし、手作業で行ってもよい。例えば、通常の変数
には自動的に正常値1を割り当ててもよいし、他のサブ
ルーチンの処理結果としてアボート値を持ち込むことが
あらかじめ分かっている変数にはアボート値0を与えて
もよい。図4は、本実施例において、変数A,B,C,
D,Eに正常値1が割り当てられた状態の抽象構文木を
示す。
[Assignment Step] Subsequently, the assigning means 3 assigns an abstract value to each variable of the abstract syntax tree (step 3). This allocation may be done automatically or manually. For example, a normal value 1 may be automatically assigned to a normal variable, or an abort value 0 may be given to a variable which is known in advance to bring an abort value as the processing result of another subroutine. FIG. 4 shows the variables A, B, C, and
An abstract syntax tree in a state where a normal value 1 is assigned to D and E is shown.

【0051】[評価のステップ]次に、評価手段4が、
割り当てられた各抽象値、抽象領域及び評価規則に基づ
いて、抽象構文木のノードを下位側から順次評価するこ
とによって、プログラムの各段階におけるエラーの可能
性を評価する。この評価は、具体的には、次のような手
順で実現することができる。
[Evaluation Step] Next, the evaluation means 4
The possibility of an error at each stage of the program is evaluated by sequentially evaluating the nodes of the abstract syntax tree based on each assigned abstract value, abstract region, and evaluation rule. Specifically, this evaluation can be realized by the following procedure.

【0052】すなわち、部分木の末端側から未処理すな
わち抽象値が決定されていない頂点(ノード)を(ステ
ップ4)1つずつ順次選択する(ステップ5)。言い換
えれば、末端の要素単位又は抽象値の決定が終了し値を
得ている頂点の直近上位の頂点を選択する。そして、既
に得られている末端側の各抽象値と選択されている頂点
が表す構文単位に対応する評価規則を用い、当該頂点の
抽象値を評価・決定する(ステップ6)。
That is, vertices (nodes) which have not been processed, that is, whose abstract value has not been determined (step 4) are sequentially selected one by one from the terminal side of the subtree (step 5). In other words, the vertices immediately above the vertices for which the end element unit or the abstract value determination is completed and the value is obtained are selected. Then, the abstract value of the vertex is evaluated / determined by using the evaluation rules corresponding to the already-obtained end-side abstract values and the syntactic unit represented by the selected vertex (step 6).

【0053】ここで再帰的な関数定義がある場合は、不
動点作用素“fix”により再帰的な定義を除去できる
ことに注意する。例えば、階乗関数factの標準的な
定義は、
Note that if there is a recursive function definition, the fixed point operator "fix" can remove the recursive definition. For example, the standard definition of the factorial function fact is

【数3】fact(x)=if(x=0) then 1 else x*fact(x-1) で与えられる。この再帰的定義から再帰性を除去するた
め、次のような高階関数FACTを導入する:
[Formula 3] fact (x) = if (x = 0) then 1 else x * fact (x-1). To remove recursion from this recursive definition, we introduce the higher-order function FACT as follows:

【数4】FACT(f)=x->if(x=0) then 1 else x*f(x-1) x−>Eは、xにEを対応させる関数を表す。例えば、
x−>xは恒等関数である。このとき、関数factは
関係式
## EQU00004 ## FACT (f) = x-> if (x = 0) then 1 else x * f (x-1) x-> E represents a function that associates E with x. For example,
x-> x is an identity function. At this time, the function fact is the relational expression

【数5】FACT(fact)=fact を満たす、すなわちfactは高階関数FACTの不動
点である。高階関数に対しその不動点を対応させる高階
関数をfixで表すと、階乗関数factは、fix
(FACT)として定義できる。このように、再帰的定
義は不動点作用素を用いて書き直されているとして差支
えない。
(5) FACT (fact) = fact is satisfied, that is, fact is a fixed point of the higher-order function FACT. If a higher-order function that associates the fixed point with a higher-order function is represented by fix, the factorial function fact is
Can be defined as (FACT). In this way, the recursive definition can be rewritten using the fixed point operator.

【0054】このような抽象構文木を与える場合、高階
関数Fに対しその不動点をどう計算するかが問題にな
る。すべての入力に対してアボート値0を返すような関
数を
When such an abstract syntax tree is given, the problem is how to calculate the fixed point of the higher-order function F. A function that returns an abort value of 0 for all inputs

【数6】 で表す。この時関数列(Equation 6) It is represented by. Function sequence at this time

【数7】 が構成される。この関数列を用いて、fix(F)を(Equation 7) Is configured. Using this function sequence, fix (F)

【数8】 で定義すると、fix(F)は高階関数Fの不動点、す
なわち
(Equation 8) , Fix (F) is a fixed point of the higher-order function F, that is,

【数9】fix(F)=F(fix(F)) であることが知られている。ここで## EQU9 ## It is known that fix (F) = F (fix (F)). here

【数10】 は、列{ai }に現れる0,1,2のうち、最大のもの
(順序0<1<2に関して)とする。
[Equation 10] Is the largest of 0, 1, 2 appearing in the column {a i } (for the order 0 <1 <2).

【0055】すべての部分木の頂点に対し、抽象値0,
1,2どれかの値が与えられるまで、このループを繰り
返す。この結果、各ノードでは、下位ノードの処理で生
じた抽象値を引数として処理の結果たる抽象値が決定さ
れる。図5は、本実施例における評価途中の抽象構文木
の状態を示す図であり、この状態では、強調表示されて
いるノードが評価されようとしている。
The abstract value 0, for the vertices of all subtrees
This loop is repeated until a value of 1 or 2 is given. As a result, in each node, the abstract value that is the result of the processing is determined by using the abstract value that has occurred in the processing of the lower node as an argument. FIG. 5 is a diagram showing a state of the abstract syntax tree in the middle of evaluation in the present embodiment, and in this state, the highlighted node is about to be evaluated.

【0056】なお、処理の種類によっては、処理の基礎
となる各抽象値がエラー値の可能性を持たない場合も、
当該処理の結果たる新たな抽象値はエラー値の可能性を
含むことも考えられる。このような引数と処理結果の抽
象値の種類の組合せは、プログラム中の処理の種類ごと
に設定され抽象領域に含まれる。例えば、除算x/yで
はx,yともに正常値でもy=0の可能性が存在するた
め結果的にエラー値が生じる。図5では、除算C/Dに
おいて検出可能エラー値2が生じている。
Depending on the type of processing, even if each abstract value that is the basis of processing does not have the possibility of an error value,
It is possible that the new abstract value that is the result of this processing includes the possibility of an error value. Such a combination of the argument and the type of the abstract value of the processing result is set for each type of processing in the program and is included in the abstract area. For example, in division x / y, even if both x and y are normal values, there is a possibility that y = 0, resulting in an error value. In FIG. 5, the detectable error value 2 occurs in the division C / D.

【0057】上記のような評価は、構文木中の処理でエ
ラー値の可能性が発生し、変数を介して伝達する様子を
シミュレートすることを意味する。このため、検出可能
なエラーの可能性に対処すべきプログラムの箇所を特定
でき、場合分け等の対応策をとることが容易になるの
で、大規模プログラム等のプログラムの信頼性が向上す
る。図6は、本実施例において、評価が終了した抽象構
文木の状態を示す図であり、すべてのノードについて抽
象値が決定されている。
The evaluation as described above means simulating a situation in which a possibility of an error value occurs in the processing in the syntax tree and the error value is transmitted via a variable. Therefore, it is possible to specify the location of the program that should deal with the possibility of a detectable error, and it becomes easy to take countermeasures such as case classification, so that the reliability of the program such as a large-scale program is improved. FIG. 6 is a diagram showing the state of the abstract syntax tree that has been evaluated in this embodiment, and the abstract value has been determined for all nodes.

【0058】[解析のステップ]最後に、解析手段5
が、前記評価の結果を解析することによって、前記抽象
構文木においてエラー値の発生する箇所又は前記抽象構
文木においてエラー値の伝達する経路のうち少なくとも
一方、を特定する(ステップ7)。このような特定は決
定された抽象値のうち所定のエラー値例えば検出可能エ
ラー値2を検出し、検出されたエラー値に対応するノー
ドや経路を指摘することによって実現することができ
る。
[Analysis Step] Finally, the analysis means 5
By analyzing the result of the evaluation, at least one of a location where an error value occurs in the abstract syntax tree and a path through which the error value propagates in the abstract syntax tree is specified (step 7). Such identification can be realized by detecting a predetermined error value, for example, a detectable error value 2 in the determined abstract value, and pointing out a node or a route corresponding to the detected error value.

【0059】特定された箇所や経路は出力手段6から出
力される(ステップ8)。例えば、部分木末端側におけ
る検出可能エラーが、上位側のどの範囲にどの様な経路
で及ぶかが指摘される。図7は、本実施例における解析
結果の出力例を示す図であり、検出可能エラー値2の伝
達経路が強調表示されている。
The specified location and route are output from the output means 6 (step 8). For example, it is pointed out what kind of route the detectable error at the end of the subtree extends to which range on the upper side. FIG. 7 is a diagram showing an output example of the analysis result in the present embodiment, in which the transmission path of the detectable error value 2 is highlighted.

【0060】プログラマは、このような出力結果を利用
し、下位側のプログラミングでエラー対応をしたり、ま
た、上位側で値を受け入れる際にエラー対応をしたりす
ることで、信頼性の向上を図ることができる。
The programmer can improve reliability by utilizing such output results and handling errors in the programming on the lower side, and handling errors when accepting the values on the upper side. Can be planned.

【0061】エラー対応の一例は、演算ルーチン又は演
算チップにおいてエラーを生じさせる値を、プログラム
上同じ意味を持つがエラーを生じない他の値に置き換え
ることが考えられる。また、他の例は、評価関数を定義
するルーチンにおいて、エラーを生じさせる引数をチェ
ックし、その場合、実際には演算を実行せずに停止を回
避し、自分を呼んだモジュールに対しては所定の返り値
を返すことである。
As an example of error handling, it is conceivable to replace a value that causes an error in an arithmetic routine or an arithmetic chip with another value that has the same meaning in a program but does not cause an error. Another example is checking the arguments that cause an error in the routine that defines the evaluation function, in which case avoiding the stop without actually performing the operation, and for the module that called itself, It is to return a predetermined return value.

【0062】このように、本実施例では、評価が行われ
るだけではなく、エラー値の発生箇所や伝達経路が解析
によって特定され出力されるので、プログラマはエラー
への対応が容易になる。
As described above, in the present embodiment, not only the evaluation is performed, but also the place where the error value occurs and the transmission path are specified by the analysis and output, so that the programmer can easily deal with the error.

【0063】(3)他の実施例 なお、本発明は上記実施例に限定されるものではなく、
実施態様の変更は自由であるから、次に例示するような
他の実施例をも包含するものである。例えば、プログラ
ミング言語や評価規則の内容は自由に定義してよい。ま
た、入力手段では抽象構文木の形式でプログラムが獲得
できればよく、例えば、ユーザはソーステキストを入力
し、その後自動的に抽象構文木の形式に変換されるよう
にしてもよい。
(3) Other Embodiments The present invention is not limited to the above embodiments,
Since the embodiment can be freely changed, the present invention also includes other embodiments as illustrated below. For example, the contents of the programming language and evaluation rules may be freely defined. Further, the input means only needs to be able to acquire the program in the format of the abstract syntax tree. For example, the user may input the source text and then automatically convert it into the format of the abstract syntax tree.

【0064】また、エラー値を含む抽象値の具体的な定
義は自由であり、アボート値や検出可能エラー値のみな
らず他の種類のエラー値を定義してもよい。また、抽象
領域の内容も自由に定義でき、例えば、必要な場合に
は、マルチタスクやサーバー利用のようなシステム構成
に基づくウエイトタイムのような制約事項によって、処
理結果として得られる抽象値を条件分けするなどしても
よい。また、抽象値の変数への割り当ての態様も自由で
あり、例えば、エラー対応処理の済んだ部分の抽象値に
仮に正常値を代入して全体のシミュレーションをやり直
してみるなどの態様も考えられる。
Further, the concrete definition of the abstract value including the error value is free, and not only the abort value and the detectable error value but also other kinds of error values may be defined. Also, the contents of the abstract area can be freely defined. For example, if necessary, the abstract value obtained as a processing result can be set as a condition by restrictions such as wait time based on system configuration such as multitasking and server use. It may be divided. Further, the mode of allocating the abstract value to the variable is also free, and for example, a mode may be considered in which a normal value is temporarily substituted for the abstract value of the portion for which the error handling processing has been completed and the entire simulation is performed again.

【0065】また、解析の内容や解析結果の出力態様も
自由であり、例えば、解析結果をプログラムのステート
メントを単位とした一覧表形式で出力したりしてもよ
い。
The content of the analysis and the output form of the analysis result are also free. For example, the analysis result may be output in the form of a list with the statement of the program as a unit.

【0066】[0066]

【発明の効果】以上のように、本発明によれば、検出可
能エラーに関する情報も提供されるので、エラーへの対
応が容易になり、プログラム開発が効率化される。
As described above, according to the present invention, since information about a detectable error is also provided, it is easy to deal with the error and the program development is made efficient.

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

【図1】本発明の実施例のプログラム解析装置の構成を
示す機能ブロック図
FIG. 1 is a functional block diagram showing a configuration of a program analysis device according to an embodiment of the present invention.

【図2】本発明の実施例における処理手順を示すフロー
チャート
FIG. 2 is a flowchart showing a processing procedure in the embodiment of the present invention.

【図3】本発明の実施例における抽象構文木の例を示す
FIG. 3 is a diagram showing an example of an abstract syntax tree in the embodiment of the present invention.

【図4】本発明の実施例において、変数A,B,C,
D,Eに正常値1が割り当てられた状態の抽象構文木を
示す
FIG. 4 shows the variables A, B, C, and
Indicates an abstract syntax tree in which D and E are assigned normal value 1.

【図5】本発明の実施例における評価途中の抽象構文木
の状態を示す図
FIG. 5 is a diagram showing a state of an abstract syntax tree in the middle of evaluation in the embodiment of the present invention.

【図6】本発明の実施例において、評価が終了した抽象
構文木の状態を示す図
FIG. 6 is a diagram showing a state of an abstract syntax tree that has been evaluated in the embodiment of the present invention.

【図7】本発明の実施例における解析結果の出力例を示
す図
FIG. 7 is a diagram showing an output example of an analysis result in the embodiment of the present invention.

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

1…入力手段 2…設定手段 3…割り当て手段 4…評価手段 5…解析手段 6…出力手段 STEP…手順の各ステップ DESCRIPTION OF SYMBOLS 1 ... Input means 2 ... Setting means 3 ... Allocation means 4 ... Evaluation means 5 ... Analysis means 6 ... Output means STEP ... Each step of a procedure

Claims (4)

【特許請求の範囲】[Claims] 【請求項1】 所定の評価規則で評価されうる抽象構文
木の形式でプログラムを入力するための入力手段と、 少なくとも検出可能なエラーの可能性を表すエラー値を
含む複数の抽象値と、抽象値に対する前記プログラム中
の処理の種類ごとの結果として生じる抽象値との関係、
を表す抽象領域を設定する設定手段と、 前記抽象構文木の各変数に前記抽象値を割り当てる割り
当て手段と、 割り当てられた前記各抽象値、前記抽象領域及び前記評
価規則に基づいて、前記抽象構文木を評価することによ
って、前記プログラムの各段階におけるエラーの可能性
を評価する評価手段と、 を有することを特徴とするプログラム解析装置。
1. Input means for inputting a program in the form of an abstract syntax tree that can be evaluated by a predetermined evaluation rule, a plurality of abstract values including at least an error value indicating a possibility of a detectable error, and an abstract The relationship between the value and the resulting abstract value for each type of processing in the program,
Setting means for setting an abstract area that represents the abstract syntax, allocation means for allocating the abstract value to each variable of the abstract syntax tree, and the abstract syntax based on the allocated abstract value, the abstract area, and the evaluation rule. A program analysis device comprising: an evaluation unit that evaluates a possibility of an error at each stage of the program by evaluating a tree.
【請求項2】 前記評価の結果を解析することによっ
て、前記抽象構文木においてエラー値の発生する箇所又
は前記抽象構文木においてエラー値の伝達する経路のう
ち少なくとも一方、を特定する解析手段を有することを
特徴とする請求項1記載のプログラム解析装置。
2. An analysis unit is provided which analyzes at least one of a location where an error value occurs in the abstract syntax tree and a path through which an error value is transmitted in the abstract syntax tree by analyzing the result of the evaluation. The program analysis device according to claim 1, wherein
【請求項3】 所定の評価規則で評価されうる抽象構文
木の形式でプログラムを入力するための入力のステップ
と、 少なくとも検出可能なエラーの可能性を表すエラー値を
含む複数の抽象値と、抽象値に対する前記プログラム中
の処理の種類ごとの結果として生じる抽象値との関係、
を表す抽象領域を設定する設定のステップと、 前記抽象構文木の各変数に前記抽象値を割り当てる割り
当てのステップと、 割り当てられた前記各抽象値、前記抽象領域及び前記評
価規則に基づいて、前記抽象構文木を評価することによ
って、前記プログラムの各段階におけるエラーの可能性
を評価する評価のステップと、 を含むことを特徴とするプログラム解析方法。
3. A step of input for inputting a program in the form of an abstract syntax tree that can be evaluated by a predetermined evaluation rule, and a plurality of abstract values including at least an error value representing a possibility of a detectable error, The relationship between the abstract value and the resulting abstract value for each type of processing in the program,
And a step of assigning the abstract value to each variable of the abstract syntax tree, based on the assigned abstract value, the abstract area and the evaluation rule, And a step of evaluating the possibility of an error at each stage of the program by evaluating an abstract syntax tree.
【請求項4】 前記評価の結果を解析することによっ
て、前記抽象構文木においてエラー値の発生する箇所又
は前記抽象構文木においてエラー値の伝達する経路のう
ち少なくとも一方、を特定する解析のステップを含むこ
とを特徴とする請求項3記載のプログラム解析方法。
4. A step of analysis for analyzing at least one of a location where an error value occurs in the abstract syntax tree and a path through which an error value is transmitted in the abstract syntax tree by analyzing the result of the evaluation. The program analysis method according to claim 3, further comprising:
JP7077933A 1995-04-03 1995-04-03 Device and method for program analysis Pending JPH08272623A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP7077933A JPH08272623A (en) 1995-04-03 1995-04-03 Device and method for program analysis

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP7077933A JPH08272623A (en) 1995-04-03 1995-04-03 Device and method for program analysis

Publications (1)

Publication Number Publication Date
JPH08272623A true JPH08272623A (en) 1996-10-18

Family

ID=13647892

Family Applications (1)

Application Number Title Priority Date Filing Date
JP7077933A Pending JPH08272623A (en) 1995-04-03 1995-04-03 Device and method for program analysis

Country Status (1)

Country Link
JP (1) JPH08272623A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008102576A (en) * 2006-10-17 2008-05-01 Kddi Corp Program analysis method and program
JP2013054650A (en) * 2011-09-06 2013-03-21 Toshiba Corp Program inspection device
JP2015088191A (en) * 2013-10-31 2015-05-07 タタ コンサルタンシー サービシズ リミテッドTATA Consultancy Services Limited System and method to facilitate user interface enabled review of static analysis warnings
JP2019086953A (en) * 2017-11-06 2019-06-06 株式会社日立社会情報サービス Failure detection device and failure detection method

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008102576A (en) * 2006-10-17 2008-05-01 Kddi Corp Program analysis method and program
JP2013054650A (en) * 2011-09-06 2013-03-21 Toshiba Corp Program inspection device
JP2015088191A (en) * 2013-10-31 2015-05-07 タタ コンサルタンシー サービシズ リミテッドTATA Consultancy Services Limited System and method to facilitate user interface enabled review of static analysis warnings
JP2019086953A (en) * 2017-11-06 2019-06-06 株式会社日立社会情報サービス Failure detection device and failure detection method

Similar Documents

Publication Publication Date Title
US5581696A (en) Method using a computer for automatically instrumenting a computer program for dynamic debugging
US7120898B2 (en) Intermediate representation for multiple exception handling models
US7024661B2 (en) System and method for verifying computer program correctness and providing recoverable execution trace information
US6901579B1 (en) Generation of source code from classes and maintaining the comment that indicates the role of the class in the generated source code
US20050204344A1 (en) Program analysis device, analysis method and program of same
JP5403362B2 (en) PATTERN INSPECTION SYSTEM, PATTERN INSPECTION DEVICE, METHOD, AND PATTERN INSPECTION PROGRAM
US8683441B2 (en) Software equivalence checking
US20100223599A1 (en) Efficient symbolic execution of software using static analysis
US20080072214A1 (en) Method and system for detecting interprocedural vulnerability by analysis of source code
US6553362B2 (en) Case-reduced verification condition generation system and method using weakest precondition operator expressed using strongest postcondition operators
AU2004232058A1 (en) Method and system for detecting vulnerabilities in source code
JPH06110734A (en) Method and device for generating automatic inspection test function
US7603647B2 (en) Recognition of a state machine in high-level integrated circuit description language code
US10915302B2 (en) Identification and visualization of associations among code generated from a model and sources that affect code generation
Lu et al. Eagle: CFL-reachability-based precision-preserving acceleration of object-sensitive pointer analysis with partial context sensitivity
JPH08272623A (en) Device and method for program analysis
Asai Binding-time analysis for both static and dynamic expressions
US11442845B2 (en) Systems and methods for automatic test generation
Fisher et al. Scaling a Dataflow Testing Methodology to the MultiparadigmWorld of Commercial Spreadsheets
Correnson et al. Engineering a formally verified automated bug finder
JPH09282173A (en) Static analysis method for program
Sarraga Static data flow analysis of PL/I programs with the PROBE system
JP3167386B2 (en) Automatic program parallelization method
Husein A Type-inferencing Mechanism for Automatically Detecting Variable Types in System Requirements Specifications
Loitzl Supporting Register Pairs in CompCert