JP3857842B2 - Program analysis apparatus and recording medium - Google Patents
Program analysis apparatus and recording medium Download PDFInfo
- Publication number
- JP3857842B2 JP3857842B2 JP32518999A JP32518999A JP3857842B2 JP 3857842 B2 JP3857842 B2 JP 3857842B2 JP 32518999 A JP32518999 A JP 32518999A JP 32518999 A JP32518999 A JP 32518999A JP 3857842 B2 JP3857842 B2 JP 3857842B2
- Authority
- JP
- Japan
- Prior art keywords
- variable
- program
- value
- setting
- sentence
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Images
Description
【0001】
【発明の属する技術分野】
本発明は、ソースプログラムを修正する際に、該プログラムを分析し理解を助けるために利用されるプログラム分析装置及び記録媒体に関する。近年、既存のプログラムを変更して仕様変更、追加を行うことが広く行われるようになってきている。そのために、既存のプログラムの動作を迅速に理解し、変更による有害な副作用がないことを容易に確認できることが重要である。プログラムには、不十分な参考資料しか付随しない場合が多く、プログラム分析装置は不可欠となっている。
【0002】
【従来の技術】
図14は従来例の説明図であり、A図は従来例1、B図は従来例2を示す。以下、図14に基づいて従来例を説明する。
【0003】
§1:従来例1の説明
図14のA図に示したように、従来例1のプログラム分析装置は、装置本体1と、該装置本体1に接続された表示部3(ディスプレイ装置)を備えると共に、該装置本体1内に、分析対象のソースプログラム4の解析を行う構文解析部2等を備えている。装置本体1は、利用者の指示を入力したり、表示部3に対し、ソースプログラム4や構文解析結果のデータ等の表示を行う際の制御等を行うものである。
【0004】
このプログラム分析装置でソースプログラム4の分析を行う場合、装置本体1の制御に基づき、構文解析部2がソースプログラム4の構文解析を行ない、その結果を表示部3の画面に表示する。このプログラム分析装置は、ソースプログラム4中の指定された変数の定義情報を参照したり、その変数が使用されている箇所全てを一覧する機能を持っている。
【0005】
§2:従来例2の説明
図14のB図に示したように、従来例2のプログラム分析装置は、装置本体1と、該装置本体1に接続された表示部3を備えると共に、前記装置本体1内に、分析対象のソースプログラム4の解析を行う構文解析部2と、関係生成部5と、関係検索部6等を備えている。前記装置本体1は、利用者の指示を入力したり、表示部3に対し、ソースプログラムや構文解析結果のデータ等の表示を行う際の制御等を行うものである。
【0006】
関係生成部5は、ソースプログラム4の各文について、その文が代入や比較など、変数、定数、データファイル間の関係を使っている場合、関係の種別と共に、それら変数、定数、データファイルの情報を、変数はその値の設定箇所の情報と共に抽出し、関係データ7としてワーク用メモリ等に格納する機能を備えている。
【0007】
関係データ7は、複数のプログラムについて、関係生成部5が生成した関係データである。関係検索部6は、利用者が指示した変数を起点として、その変数が持っている関係を使って、影響する他の変数、定数、データファイルの検索を行うものである。波及抑止変数データ8及び設定箇所無視変数データ9は、前記検索に先立って利用者が指定するデータである。
【0008】
この従来例2のプログラム分析装置では、関係生成部5により、変数やデータファイル間の値の代入などの関係を抽出し、関係検索部6により、大量のプログラムの中から、或る変数に影響を受ける部分を効率良く検索する機能を持ったものもある。これらの機能により、注目している変数の情報や、その影響範囲を知ることができるようになっている。
【0009】
【発明が解決しようとする課題】
前記のような従来のものにおいては、次のような課題があった。
【0010】
ソースプログラムを修正する場合、修正しようとする箇所における変数の値がどこで参照されているのかを知ることは重要である。従来のプログラム分析装置では、この場所を簡単に知ることができず、利用者はその都度問い合わせを行うなどして確認する必要があった。
【0011】
また、代入関係などを使って変数の影響を受ける部分を検索する際には、複数の用途のために使い回される作業変数などの影響で、本来は無関係であるはずの変数まで検索され、結果の精度を損なう場合があった。更に、精度を高めるには、実際のプログラムの実行経路に沿って逐一分析を行って行く必要があったが、この方法では、大量のプログラムを一括して分析することができず、作業の効率を著しく損なう欠点があった。
【0012】
本発明は、このような従来の課題を解決するため、変数の各出現位置に対して、その直前に実行される値の設定箇所を求めておき、この設定箇所情報を変数の識別に利用する。つまり、プログラム表示の際に、各変数の値の設定箇所を識別できるようにし、また、変数間の代入関係を使用する際の影響の検索においても、値の設定箇所を考慮して関係を検索することで、値のつながりのない箇所への影響を出さないようにして、作業効率を向上させると共に、多くのプログラムを組み合わせた大規模なシステムでも高い精度で効率良く分析できるようにすることを目的とする。
【0013】
【課題を解決するための手段】
図1は本発明の原理説明図である。本発明は前記の目的を達成するため、次のように構成した。
【0014】
(1) :プログラム分析装置において、ソースプログラム4を構文解析する構文解析手段2Aと、実行経路に沿ってプログラム中の文を探索する実行経路探索手段11Aと、或る変数の値を設定する文を識別する設定文識別手段12Aと、利用者の要求に応じてソースプログラムを出力する出力手段(表示部3、プリンタ等)13を備えると共に、前記設定文識別手段12Aは、ソースプログラム4中の各変数の出現位置に対し、その値を設定することになる箇所を求め、各出現位置に対する値の設定箇所を識別できるような形式でソースプログラム4を出力する(例えば、表示部3で表示する)機能を備えている。
【0015】
(2) :プログラム分析装置において、ソースプログラム4を構文解析する構文解析手段2Aと、実行経路に沿ってプログラム中の文を探索する実行経路探索手段11Aと、或る変数の値を設定する文を識別する設定文識別手段12Aと、文中における変数や定数、データファイル間の代入、比較等の関係を抽出する関係生成手段5Aと、その関係を用いて注目する変数やデータファイルから影響を受ける変数を検索する関係検索手段6Aと、利用者の要求に応じて検索結果を出力する出力手段13を備えると共に、前記関係検索手段6Aは、抽出した各関係における変数に対して、その値の設定箇所を求めておき、同一変数であっても値の設定箇所毎に区別して関係を検索する機能を備えている。
【0016】
(3) :コンピュータを、ソースプログラムを構文解析する構文解析手段と、実行経路に沿ってプログラム中の文を探索する実行経路探索手段と、ソースプログラム中の各変数の出現位置に対し、前記実行経路探索手段で探索した文の中から、その変数の値を設定する文を識別して変数の設定箇所を求め、前記各変数の出現位置に対する値の設定箇所を識別できるような形式でソースプログラムを出力できるように処理を行う設定文識別手段として機能させるためのプログラムを記録したコンピュータ読み取り可能な記録媒体。
【0017】
(作用)
前記構成に基づく本発明の作用を、図1に基づいて説明する。
【0018】
(a) :前記(1) では、構文解析手段2Aはソースプログラム4を構文解析し、実行経路探索手段11Aは実行経路に沿ってプログラム中の文を探索し、設定文識別手段12Aは或る変数の値を設定する文を識別し、出力手段13は利用者の要求に応じてソースプログラム4を出力する。そして、前記設定文識別手段12Aは、ソースプログラム4中の各変数の出現位置に対し、その値を設定することになる箇所を求め、各出現位置に対する値の設定箇所を識別できるような形式でソースプログラム4を出力する(例えば、表示部3で表示する)。
【0019】
このようにすれば、変数の出現箇所についてその値の設定箇所が容易に識別できるため、何度も問い合わせを行う必要がなく、自然な形で注目箇所の影響範囲を知ることができる。従って、プログラム分析処理が効率良く行える。
【0020】
(b) :前記(2) では、構文解析手段2Aはソースプログラム4を構文解析し、実行経路探索手段11Aは実行経路に沿ってプログラム中の文を探索し、設定文識別手段12Aは或る変数の値を設定する文を識別し、関係生成手段5Aは文中における変数や定数、データファイル間の代入、比較等の関係を抽出し、出力手段13は利用者の要求に応じて検索結果を出力する(例えば、表示する)。
【0021】
そして、関係検索手段6Aは、抽出した各関係における変数に対して、その値の設定箇所を求めておき、同一変数であっても値の設定箇所毎に区別して関係を検索する。
【0022】
このようにすれば、変数の出現箇所についてその値の設定箇所が容易に識別できるため、何度も問い合わせを行う必要がなく、自然な形で注目箇所の影響範囲を知ることができる。また、変数やファイルの代入などの関係を使った変数の影響の分析においても、作業変数による分析精度の劣化を避けることができるから、従来、困難だった、多くのプログラムを組み合わせた大規模なシステムでも、高い精度で効率良く分析することができる。
【0023】
(c) :前記(3) では、コンピュータが、前記記録媒体からプログラムを読み出して実行することにより、ソースプログラム4を構文解析する手順と、実行経路に沿ってプログラム中の文を探索する手順と、或る変数の値を設定する文を識別する手順と、利用者の要求に応じてソースプログラム4を出力する手順と、ソースプログラム4中の各変数の出現位置に対し、その値を設定することになる箇所を求め、各出現位置に対する値の設定箇所を識別できるような形式でソースプログラム4を出力する手順とを実行する。
【0024】
このようにすれば、変数の出現箇所についてその値の設定箇所が容易に識別できるため、何度も問い合わせを行う必要がなく、自然な形で注目箇所の影響範囲を知ることができる。従って、プログラム分析処理が効率良く行える。
【0025】
【発明の実施の形態】
以下、本発明の実施の形態を図面に基づいて詳細に説明する。
【0026】
§1:装置例の説明・・・図2参照
図2は具体的な装置例であり、A図は装置構成例、B図は磁気ディスクの説明図である。前記プログラム分析装置は、パーソナルコンピュータ、ワークステーション等の任意のコンピュータにより実現する。
【0027】
この例では、プログラム分析装置を、装置本体(コンピュータ本体)1と、該装置本体1に接続された表示部(ディスプレイ装置)3、キーボード、マウス等の入力装置21、光ディスクドライブやフロッピィディスクドライブ等のリムーバブルディスクドライブ(RDD)22、磁気ディスク装置(MDD)23、プリンタ24等により構成する。
【0028】
そして、装置本体1には、CPU25と、該CPU25にバスを介して接続されたROM26、メモリ27、インターフェイス制御部(I/F制御部)28、通信制御部29等を設ける。
【0029】
そして、前記磁気ディスク装置23の磁気ディスク(記録媒体)には、図2のB図に示したような領域を設定し、プログラム等を格納する。この場合、例えば、前記領域は、ソースプログラムを格納するためのソースプログラム格納領域32と、処理結果データを格納するための処理結果データ格納領域33と、処理プログラムを格納するための処理プログラム格納領域34と、その他のデータを格納するためのその他データ格納領域35等を設ける。
【0030】
なお、以下に説明するプログラム分析処理用のプログラムは、前記処理プログラム格納領域34に格納しておき、CPU25がこのプログラムを読み出して実行することによりプログラム分析処理を実現する。
【0031】
しかし、本願発明は、このような例に限らず、例えば、前記磁気ディスク31に、次のようにしてプログラムを格納し、このプログラムをCPU25が実行することで前記プログラム分析処理を行うことも可能である。
【0032】
▲1▼:他の装置で作成されたリムーバブルディスクに格納されているプログラム(他の装置で作成したプログラムデータ)を、リムーバブルディスクドライブ(RDD)22により読み取り、磁気ディスク装置23の磁気ディスク31に格納する。
【0033】
▲2▼:LAN等の通信回線を介して他の装置から伝送されたプログラム等のデータを、通信制御部29を介して受信し、そのデータを磁気ディスク装置23の磁気ディスク31(記録媒体)に格納する。
【0034】
§2:プログラム分析装置の構成と機能等の説明・・・図3参照
図3はプログラム分析装置の説明図であり、A図は装置例1、B図は装置例2を示す。以下、図3に基づいて、プログラム分析装置の構成と機能等を説明する。
【0035】
(1) :装置例1の説明
図3のA図に示したように、装置例1のプログラム分析装置は、装置本体1と、該装置本体1に接続された表示部3を備えると共に、該装置本体1内に、分析対象のソースプログラム4の構文解析を行う構文解析部2と、実行経路探索部11と、設定文識別部12等を備えている。装置本体1(図2の装置本体1に対応する)は、利用者(以下「ユーザ」と記す)の指示を入力したり、表示部3に対しソースプログラム4や構文解析結果のデータ等の表示を行う際の制御等を行うものである。この場合、前記実行経路探索部11と設定文識別部12は一体となって処理を行う。
【0036】
すなわち、装置例1のプログラム分析装置は、ソースプログラム4を構文解析する構文解析部2と、実行経路に沿ってプログラム中の文を探索する実行経路探索部11と、或る変数の値を設定する文を識別する設定文識別部12と、利用者の要求に応じてソースプログラムを出力する表示部3を備えている。そして、設定文識別部12は、ソースプログラム4中の各変数の出現位置に対し、その値を設定することになる箇所を求め、各出現位置に対する値の設定箇所を識別できるような形式でソースプログラム4を出力する(例えば、表示部3で表示する)機能を備えている。
【0037】
また、設定文識別部12は、利用者が指定した特定の変数の特定の使用箇所について、それと同じ値の設定箇所となる使用箇所のみ識別できるような形式でソースプログラムを出力する機能と、ソースプログラム4中の各変数の各出現位置に対する値の設定箇所を識別できる情報を、ソースプログラム4にコメント文の形式で挿入する機能を備えている。なお、前記構文解析部2、実行経路探索部11、設定文識別部12は、それぞれ図1の構文解析手段2A、実行経路探索手段11A、設定文識別手段12Aに対応している。
【0038】
(2) :装置例2の説明
図3のB図に示したように、装置例2のプログラム分析装置は、装置本体1と、該装置本体1に接続された表示部3を備えると共に、前記装置本体1内に、分析対象のソースプログラム4の解析を行う構文解析部2と、実行経路探索部11と、設定文識別部12と、関係生成部5と、関係検索部6等を備えている。
【0039】
装置本体1は、利用者の指示を入力したり、表示部3に対しソースプログラム4や構文解析結果のデータ等の表示を行う際の制御等を行うものである。この場合、実行経路探索部11と設定文識別部12は一体となって処理を行う。
【0040】
関係生成部5は、ソースプログラム4の各文についてその文が代入や比較など、変数、定数、データファイル間の関係を使っている場合、関係の種別と共に、それら変数、定数、データファイルの情報を、変数はその値の設定箇所の情報と共に抽出し、関係データ7としてワーク用メモリ等に格納するものである。
【0041】
関係データ7は、複数のプログラムについて関係生成部5が生成した関係データである。関係検索部6は、ユーザが指示した変数を起点として、その変数が持っている関係を使って、影響する他の変数、定数、データファイルの検索を行うものである。波及抑止変数データ8、及び設定箇所無視変数データ9は、前記検索に先立ってユーザが指定するデータである。
【0042】
装置例2のプログラム分析装置では、関係生成部5により、変数やデータファイル間の値の代入などの関係を抽出し、関係検索部6により、大量のプログラムの中から、或る変数に影響を受ける部分を効率良く検索する機能を持ったものもある。これらの機能により、注目している変数の情報や、その影響範囲を知ることができる。
【0043】
すなわち、装置例2のプログラム分析装置は、ソースプログラム4を構文解析する構文解析部2と、実行経路に沿ってプログラム中の文を探索する実行経路探索部11と、或る変数の値を設定する文を識別する設定文識別部12と、文中における変数や定数、データファイル間の代入、比較等の関係を抽出する関係生成部5と、その関係を用いて注目する変数やデータファイルから影響を受ける変数を検索する関係検索部6と、利用者の要求に応じて検索結果を表示する表示部3を備えている。
【0044】
そして、関係検索部6は、抽出した各関係における変数に対して、その値の設定箇所を求めておき、同一変数であっても値の設定箇所毎に区別して関係を検索する機能を備えている。また、予め検索が不要と判明している変数(波及抑止変数データ8)を設定箇所単位でユーザが指定した場合、関係検索部6は、検索の際に、その設定箇所が持つ関係は検索しない機能を備えている。
【0045】
更に、設定箇所単位で区別せずに検索してよいと判明している変数(設定箇所無視変数データ9)をユーザが指定した場合、関係検索部6は、検索の際に、その変数は設定箇所で区別せずに検索する機能と、検索結果の一部として、値の設定箇所が異なるために検索しなかった関係を持つ変数を出力する機能と、作業変数として複数の用途で使われる可能性のある変数をリストアップする機能を備えている。
【0046】
なお、前記構文解析部2、実行経路探索部11、設定文識別部12、関係生成部5、関係検索部6は、それぞれ図1の構文解析手段2A、実行経路探索手段11A、設定文識別手段12A、関係生成手段5A、関係検索手段6Aに対応している。
【0047】
§3:処理例の説明
以下、プログラム分析装置の処理例について詳細に説明する。
【0048】
(例1の説明)
(1) :例1の処理の説明・・・図4参照
図4は例1の処理フローチャートである。以下、図4に基づいて例1の処理を説明する。なお、S1〜S7は各処理ステップを示す。
【0049】
例1では、先ず、構文解析部2は、ソースファイルのソースプログラム4から構文要素を読み込み(S1)、読み終えたかどうかを判断する(S2)。その結果、読み終えていなければ、前記読み込んだ構文要素に対し構文解析を行う(S3)。そして、設定文識別部12は、前記構文解析の結果が変数を示す構文要素かどうかを判断する(S4)。
【0050】
もし、変数を示す構文要素であると判断したら、実行経路探索部11は、実行経路を遡って変数の設定箇所を求める(S6)。そして、設定文識別部12は、変数名に設定箇所を示す情報を付加して表示部3へ送り、該表示部3の画面に表示し(S7)、前記S1の処理へ戻る。
【0051】
また、設定文識別部12は、前記S4の処理で変数を示す構文要素でないと判断したら、前記解析結果の情報を表示部3へ送り、該表示部3の画面にそのまま表示し(S5)、前記S1の処理へ戻る。また、前記S2の処理で、全部読み終えたと判断した場合(分析対象のソースプログラム4を全て読み終えた場合)は、この処理を終了する。
【0052】
(2) :例1のデータの説明・・・図5参照
図5は例1のデータ例であり、A図は例1の入力となるプログラム(ソースプログラム)であり、B図は例1の出力例である。前記例1の処理におけるデータ例は次の通りである。
【0053】
▲1▼:ソースプログラム例
入力となるプログラム(ソースプログラム4)としては、例えば、図5のA図のようなプログラムである。このプログラム例において、行番号が10、20、30の「int x=1」、「int y,z」、「int a=2」は、それぞれ変数宣言である。この場合、「int」は変数の型を表しており、「intx=1」は変数xがあり、その値は1であることを示し、「int y,z」は、変数y,zがあることを示し、「int a=2」は変数aがあり、その値は2であることを示す。
【0054】
行番号40の「y=x」はxの値をyに代入することを示し、行番号50の「x=3」は3という値をxに代入することを示す。行番号60の「if(y>1)」は、もし、yの値が1より大きいなら」ということを示し、行番号70の「x=a」は、もし、yの値が1より大きいなら、xにaを代入し、「行番号80の「z=x」は、xをzに代入することを示す。以上のようなプログラムをソースプログラム4として処理を行う。
【0055】
▲2▼:出力例
前記図5のA図に示したソースプログラム4を入力して処理を行ない、例えば、図5のB図のようなデータを出力する。この場合、@印は、設定する位置を識別するための識別情報(図4のS7の処理で付加する情報)である。例えば、行番号10の「int x@10=1」は、「xは行番号=10で値が代入される」ことを示し、行番号20の「int y@20,z@20;」は、「yは行番号=20で値が代入され、zは行番号=20で値が代入される」ことを示している。
【0056】
また、行番号=30の「int a@30=2」は、「aは行番号=30で値=2が代入される」ことを示し、行番号=40の「y@40=x@10」は、「行番号=10で代入されるxの値を、行番号=40で代入されるyの値に代入する」ことを示している。
【0057】
以下同様にして、行番号80の「z@80=x@50or70」は、行番号=50で代入されるxの値、又は、行番号=70で代入されるxの値を、行番号=80で代入されるzの値に代入することを示す。このように、変数名に設定箇所を示す情報として@印を付加して出力(表示、印刷等)することにより、設定箇所が容易に識別できるため、何度も問い合わせを行う必要がなく、自然な形で注目箇所の影響範囲を知ることができる。従って、プログラム分析処理が効率良く行える。
【0058】
(例2の説明)
(1) :例2の処理概要
例2は、前記例1において、ユーザが指定した変数についてだけ行う処理例である。この場合、表示前にユーザに変数の出現箇所を選択させ、それと同じ設定箇所となる出現箇所のみを、他と区別できる方法で表示する。
【0059】
(2) :例2の処理の説明・・・図6参照
図6は例2の処理フローチャートである。以下、図6に基づいて例2の処理を説明する。なお、S11〜S19は各処理ステップを示す。
【0060】
例2では、先ず、ユーザがキーボード、或いはマウス等の操作により特定の変数を指定する。この時、構文解析部2が前記指定した変数を検出すると(S11)、ソースファイルのソースプログラム4から、構文要素を読み込み(S12)、読み終えたかどうかを判断する(S13)。
【0061】
その結果、読み終えていなければ、構文解析部2は、前記読み込んだ構文要素に対し構文解析を行う(S14)。そして、設定文識別部12は前記構文解析の結果が変数を示す構文要素であるかどうかを判断する(S15)。
【0062】
もし、変数を示す構文要素であると判断したら、実行経路探索部11が実行経路を遡って変数の設定箇所を求める(S16)。そして、該当箇所がユーザの指定した変数かどうかを判断し(S17)、ユーザの指定した箇所であれば、変数名に設定箇所を示す情報を付加して表示し(S18)、前記S12の処理へ戻る。
【0063】
しかし、前記S17の処理で、該当箇所がユーザの指定した変数でなければ、そのまま表示し(S19)、前記S12の処理へ戻る。このようにして処理を行ない、前記S13の処理で全部読み終えたと判断した場合は処理を終了する。
【0064】
(3) :出力例
図7のA図は例2の出力例である。例2では、前記処理により、例えば、図7のA図に示すようなデータを出力する。この例では、注目している変数を見やすくするため、該当する部分をアンダーラインにより強調している。
【0065】
例えば、行番号=10では出力が「int x=1」となっており、xがアンダーラインにより強調されている。また、行番号=40では出力が「y=x」となっており、xがアンダーラインにより強調されている。このようにして、アンダーラインにより注目している変数を見やすくする。
【0066】
このように、例2では、設定文識別部12が、ユーザの指定した特定の変数の特定の使用箇所について、それと同じ値の設定箇所となる使用箇所のみ識別できるように、例えば、アンダーラインを付加した形式でソースプログラム4を出力する。このようにすれば、注目している変数のみを見易くすることができる。従って、プログラム分析処理が効率良く行える。
【0067】
(例3の説明)
例3は、前記例1において、ソースプログラムを、装置本体側の表示部3に表示する代わりに、コメントの形式で設定箇所の情報を付加してファイルに出力するものである。
【0068】
この場合の出力例を図7のB図に示す。例3の出力例において、例えば、行番号=40では、出力「y=x」に対し、「/* x@10 */」のように、コメントの形式で設定箇所の情報を付加してファイルに出力する。この場合、前記設定箇所の情報である「/* x@10 */」は、「この行で使われている変数xの値は、行番号=10で代入されている。」という内容のコメント文の形式で挿入されたものである。このようにコメントの形式で設定箇所の情報を付加してファイルに出力すれば、出力をそのままプログラムとして使用できる、という利点がある。
【0069】
(例4の説明)
例4で使用する装置は、図3のB図に示した構成の装置である。例4では、変数、定数、データファイル間の関係を用いて、変数の影響を検索する際に、影響する変数を、値の設定箇所単位で求める。
【0070】
(1) :関係データ作成時の処理の説明・・・図8参照
図8は例4の関係データ作成時の処理フローチャートである。以下、図8に基づいて、例4の関係データ作成時の処理を説明する。なお、S21〜S30は各処理ステップを示す。
【0071】
構文解析部2は、ソースファイルのソースプログラム4から構文要素を読み込み(S21)、データを読み終えたかどうかを判断し(S22)、読み終えてなければ、前記読み出した構文要素について構文解析を行う(S23)。そして、構文解析を行った結果が、変数初期値の宣言なら、初期値の関係を作成し(S24)、代入文なら、代入先と代入元の値の設定箇所との関係を作成し(S25)、比較文なら、比較値同士の値の設定箇所の関係を作成し(S26)、ファイル入力なら、ファイルと受け取り変数の関係を作成する(S27)。
【0072】
更に、ファイル出力なら、ファイルと書き込み値の設定箇所との関係を作成し(S28)、サブルーチンコールなら、引数の値の設定箇所と呼出先の仮引数の関係を作成する(S29)。そして、前記作成した関係データを出力し(S30)、前記S21の処理へ戻る。このようにして処理を行ない、前記S22の処理で、全て読みおえたと判断したら、この処理を終了する。
【0073】
(2) :関係データ検索時の処理の説明・・・図9参照
図9は例4の関係データ検索時の処理フローチャートである。以下、図9に基づいて、例4の関係データ検索時の処理を説明する。なお、S31〜S36は各処理ステップを示す。
【0074】
関係データ検索時には、先ず、ユーザに起点変数を指定させる(S31)。その後、関係検索部6は、前記起点変数の設定箇所を全て検索リストに入れて(S32)、関係データ7に、検索リストにある未検索設定箇所があるかどうかを判断し(S33)、未検索設定箇所が有れば、その関係先が未だ未検索かどうかを判断する(S34)。
【0075】
その結果、その関係先が未だ未検索ならば、検索リストに入れて(S35)、前記S33の処理へ戻る。また、前記S34の処理で、その関係先が未検索でなければ、前記S33の処理へ戻る。更に、前記S33の処理で、検索リストに未検索設定箇所がなければ、検索リストの設定箇所を出力して(S36)、この処理を終了する。
【0076】
(3) :ソースプログラム例
図10はソースプログラム例1、図11はソースプログラム例2、図12は作成された関係データ例、図13は出力例を示す。
【0077】
前記例4の処理において、検索の入力となるソースプログラム4の例は、例えば、図10、11に示したようなものであり、このソースプログラム4から作成された関係データの例は図12に示した通りである。また、検索結果の出力は、例えば、図13に示した通りである。
【0078】
すなわち、図12の関係データは、図8のS24〜S29の処理により作成された関係データ例であり、代入先と代入元のデータが関係しているデータとして並んでいる。また、図13の出力例は、図9の処理による出力例である。
【0079】
図13では、波及数(波及レベル)とユーザが指定した変数を含むデータがある。例えば、変数「YEAR」はユーザが指定した変数であり、その波及数は0(波及しない)であり、関係の種類は「起点」であり、プログラム名はPG2(図11に示したプログラム)であり、プログラムの行数は130行である。その内容は、前記変数「YEAR」は、PG2の130行にある起点文によって影響を受け、波及数は0であることを示す。
【0080】
また、変数「’00’」はユーザが指定した変数であり、その波及数は1であり、関係の種類は「比較」であり、プログラム名はPG2であり、プログラムの行数は130行である。その内容は、前記変数「’00’」は、PG2の130行にある比較文によって影響を受け、波及数は1であることを示す。
【0081】
また、変数「10000」はユーザが指定した変数であり、その波及数は1であり、関係の種類は「代入」であり、プログラム名はPG2であり、プログラムの行数は120行である。その内容は、前記変数「10000」は、PG2の120行にある「代入」によって影響を受け、波及数は1であることを示す。
【0082】
以下、同様にして、変数が「NYUKIN−HI@10」はユーザが指定した変数であり、その波及数は4(波及レベル=4)であり、関係の種類は「代入」であり、プログラム名はPG1(図10に示したソースプログラム)であり、プログラムの行数は50行である。その内容は、前記変数「NYUKIN−HI@10」は、PG1の50行にある「代入」文によって影響を受け、波及数は4であることを示す。
【0083】
このように、例4では、変数の出現箇所についてその値の設定箇所が容易に識別できるため、何度も問い合わせを行う必要がなく、自然な形で注目箇所の影響範囲を知ることができる。また、変数やファイルの代入などの関係を使った変数の影響の分析においても、作業変数による分析精度の劣化を避けることができるから、従来、困難だった、多くのプログラムを組み合わせた大規模なシステムでも、高い精度で効率良く分析することができる。
【0084】
(例5の説明)
例5は、前記例4の処理を行う際に、予めユーザに指定されている設定箇所の変数については、その関係を無効にすることで、不要な検索を行わないようにする例である。
【0085】
すなわち、例5では、ユーザは、波及抑止変数指定手段(キーボード、マウス等)により予め検索が不要と判明している変数(波及抑止変数データ8)を設定箇所単位で指定する。このようにすると、関係検索手段6Aは、検索の際に、その設定箇所が持つ関係は検索しない。このようにすれば、余計なデータが出力されないから、検索結果が簡素化され、分析処理が効率良くできる。
【0086】
(例6の説明)
例6は、前記例4の処理を行う際に、予めユーザに指定されている変数については、設定箇所を区別せずに、関係を検索することで、より多くの検索を行うようにするものである。
【0087】
すなわち、例6では、ユーザが設定箇所無視変数指定手段(キーボード、マウス等)により、設定箇所単位で区別せずに検索してよいと判明している変数(設定箇所無視変数データ9)を指定する。このようにすれば、関係検索部6は、検索の際に、その変数は設定箇所で区別せずに検索する。このようにすれば、例えば、細切れで値が設定されている変数の影響を出したい場合に有利である。
【0088】
(例7の説明)
例7は、前記例4の処理を行う際に、値の設定箇所が異なるために検索しなかった関係がある変数を保存しておき、その一覧を出力(例えば、表示)することで、複数の用途で使われている可能性がある変数を見つけ出すものである。図13の出力例では、PG1の変数xがそれに該当する。
【0089】
このように、例7では、関係検索部6は、検索結果の一部として、値の設定箇所が異なるために検索しなかった関係を持つ変数を出力すると共に、作業変数として複数の用途で使われる可能性のある変数をリストアップする。このようにすれば、変数の見分けを付けやすいため、分析の精度が向上する。
【0090】
【発明の効果】
以上説明したように、本発明によれば次のような効果がある。
【0091】
(1) :本発明は、変数の各出現位置に対して、その直前に実行される値の設定箇所を求めておき、この設定箇所情報を変数の識別に利用する。つまり、プログラム表示の際に、各変数の値の設定箇所を識別できるようにし、また、変数間の代入関係を使用する際の影響の検索においても、値の設定箇所を考慮して関係を検索することで、値のつながりのない箇所への影響を出さないようにして、作業効率を向上させることができる。また、多くのプログラムを組み合わせた大規模なシステムでも高い精度で分析できる。
【0092】
(2) :構文解析手段はソースプログラムを構文解析し、実行経路探索手段は実行経路に沿ってプログラム中の文を探索し、設定文識別手段は或る変数の値を設定する文を識別し、出力手段は利用者の要求に応じてソースプログラムを出力する。そして、設定文識別手段は、ソースプログラム中の各変数の出現位置に対し、その値を設定することになる箇所を求め、各出現位置に対する値の設定箇所を識別できるような形式でソースプログラムを出力する。
【0093】
このようにすれば、変数の出現箇所についてその値の設定箇所が容易に識別できるため、何度も問い合わせを行う必要がなく、自然な形で注目箇所の影響範囲を知ることができる。従って、プログラム分析処理が効率良く行える。
【0094】
(3) :構文解析手段はソースプログラムを構文解析し、実行経路探索手段は実行経路に沿ってプログラム中の文を探索し、設定文識別手段は或る変数の値を設定する文を識別し、関係生成手段は文中における変数や定数、データファイル間の代入、比較等の関係を抽出し、出力手段は利用者の要求に応じて検索結果を出力する(例えば、表示する)。
【0095】
そして、関係検索手段は、抽出した各関係における変数に対して、その値の設定箇所を求めておき、同一変数であっても値の設定箇所毎に区別して関係を検索する。
【0096】
このようにすれば、変数の出現箇所についてその値の設定箇所が容易に識別できるため、何度も問い合わせを行う必要がなく、自然な形で注目箇所の影響範囲を知ることができる。また、変数やファイルの代入などの関係を使った変数の影響の分析においても、作業変数による分析精度の劣化を避けることができるから、従来、困難だった、多くのプログラムを組み合わせた大規模なシステムでも、高い精度で効率良く分析することができる。
【0097】
(4) :コンピュータが記録媒体からプログラムを読み出して実行することにより、ソースプログラムを構文解析する構文解析手段と、実行経路に沿ってプログラム中の文を探索する実行経路探索手段と、ソースプログラム中の各変数の出現位置に対し、前記実行経路探索手段で探索した文の中から、その変数の値を設定する文を識別して変数の設定箇所を求め、前記各変数の出現位置に対する値の設定箇所を識別できるような形式でソースプログラムを出力できるように処理を行う設定文識別手段として機能させる。
【0098】
このようにすれば、変数の出現箇所についてその値の設定箇所が容易に識別できるため、何度も問い合わせを行う必要がなく、自然な形で注目箇所の影響範囲を知ることができる。従って、プログラム分析処理が効率良く行える。
【0099】
以上の説明に関して、更に以下の項を開示する。
【0100】
▲1▼:請求項1のプログラム分析装置において、設定文識別手段12Aは、利用者が指定した特定の変数の特定の使用箇所について、それと同じ値の設定箇所となる使用箇所のみ識別できるような形式でソースプログラム4を出力する機能を備えていることを特徴とする。このようにすれば、注目している変数のみを見易くすることができる。従って、プログラム分析処理が効率良く行える。
【0101】
▲2▼:請求項1のプログラム分析装置において、ソースプログラム4中の各変数の各出現位置に対する値の設定箇所を識別できる情報を、ソースプログラム4にコメント文の形式で挿入する情報挿入処理手段(設定文識別手段12Aの一部)を備えている。この場合、出力されたプログラムはそのままプログラムとして使用することができる。従って、プログラム分析処理が効率良く行える。
【0102】
▲3▼:請求項4のプログラム分析装置において、予め検索が不要と判明している変数(波及抑止変数データ8)を設定箇所単位で利用者が指定する波及抑止変数指定手段(キーボード、マウス等)を備え、前記関係検索手段6Aは、検索の際に、その設定箇所が持つ関係は検索しない機能を備えている。このようにすれば、余計なデータが出力されないから、検索結果が簡素化され、分析処理が効率良くできる。
【0103】
▲4▼:前記請求項4のプログラム分析装置において、設定箇所単位で区別せずに検索してよいと判明している変数(設定箇所無視変数データ9)を利用者が指定する設定箇所無視変数指定手段(キーボード、マウス等)を備え、前記関係検索手段6Aは、検索の際に、その変数は設定箇所で区別せずに検索する機能を備えている。このようにすれば、例えば、細切れで値が設定されている変数の影響を出したい場合に有利である。
【0104】
▲5▼:請求項4のプログラム分析装置において、前記関係検索手段6Aは、検索結果の一部として、値の設定箇所が異なるために検索しなかった関係を持つ変数を出力する機能と、作業変数として複数の用途で使われる可能性のある変数をリストアップする機能を備えている。このようにすれば、変数の見分けを付けやすいため、分析の精度が向上する。
【図面の簡単な説明】
【図1】本発明の原理説明図である。
【図2】本発明の実施の形態における具体的な装置例である。
【図3】本発明の実施の形態におけるプログラム分析装置の説明図である。
【図4】本発明の実施の形態における例1の処理フローチャートである。
【図5】本発明の実施の形態における例1のデータ例である。
【図6】本発明の実施の形態における例2の処理フローチャートである。
【図7】本発明の実施の形態における例2、例3の出力例である。
【図8】本発明の実施の形態における例4の関係データ作成時の処理フローチャートである。
【図9】本発明の実施の形態における例4の関係データ検索時の処理フローチャートである。
【図10】本発明の実施の形態におけるソースプログラム例1である。
【図11】本発明の実施の形態におけるソースプログラム例2である。
【図12】本発明の実施の形態における作成された関係データ例である。
【図13】本発明の実施の形態における出力例である。
【図14】従来例の説明図である。
【符号の説明】
1 装置本体
2 構文解析部
3 表示部
4 ソースプログラム
5 関係生成部
6 関係検索部
7 関係データ
8 波及抑止変数データ
9 設定箇所無視変数データ
11 実行経路探索部
12 設定文識別部
13 出力手段
21 入力装置
22 リムーバブルディスクドライブ(RDD)
23 磁気ディスク装置(MDD)
24 プリンタ
25 CPU
26 ROM
27 メモリ
28 I/F制御部(インターフェイス制御部)
29 通信制御部
31 磁気ディスク
32 ソースプログラム格納領域
33 処理結果データ格納領域
34 処理プログラム格納領域
35 その他データ格納領域[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a program analysis apparatus and a recording medium that are used to analyze and assist understanding of a program when a source program is modified. In recent years, changing an existing program to change or add specifications has been widely performed. For this reason, it is important to be able to quickly understand the operation of existing programs and easily confirm that there are no harmful side effects due to changes. Programs are often accompanied by insufficient reference material, and program analyzers are indispensable.
[0002]
[Prior art]
FIG. 14 is an explanatory diagram of a conventional example. FIG. 14A shows a conventional example 1 and FIG. Hereinafter, a conventional example will be described with reference to FIG.
[0003]
§1: Description of Conventional Example 1
As shown in FIG. 14A, the program analysis apparatus of the conventional example 1 includes an apparatus
[0004]
When analyzing the
[0005]
§2: Description of Conventional Example 2
As shown in FIG. 14B, the program analysis apparatus of the conventional example 2 includes an apparatus
[0006]
For each sentence of the
[0007]
The
[0008]
In the program analysis apparatus of Conventional Example 2, the
[0009]
[Problems to be solved by the invention]
The conventional apparatus as described above has the following problems.
[0010]
When modifying a source program, it is important to know where the value of the variable at the location to be modified is referenced. In the conventional program analysis apparatus, this place cannot be easily known, and the user has to confirm by making an inquiry each time.
[0011]
Also, when searching for parts affected by variables using substitution relationships, etc., variables that should be irrelevant due to the effects of work variables that are reused for multiple purposes are searched, In some cases, the accuracy of the results was impaired. Furthermore, in order to improve accuracy, it was necessary to perform analysis one by one along the execution path of the actual program. However, this method cannot analyze a large number of programs at the same time. There was a drawback that significantly deteriorated.
[0012]
In order to solve such a conventional problem, the present invention obtains a setting location of a value to be executed immediately before each occurrence position of a variable, and uses this setting location information for variable identification. . In other words, it is possible to identify the location where the value of each variable is set when displaying the program. Also, in the search for the effect when using the substitution relationship between variables, the relationship is searched in consideration of the location where the value is set. By doing so, it is possible to improve the work efficiency by not affecting the places where the values are not connected, and to enable efficient analysis with high accuracy even in a large-scale system combining many programs. Objective.
[0013]
[Means for Solving the Problems]
FIG. 1 is a diagram illustrating the principle of the present invention. In order to achieve the above object, the present invention is configured as follows.
[0014]
(1): In the program analysis apparatus, a
[0015]
(2): In the program analysis apparatus, a syntax analysis means 2A for parsing the
[0016]
(3): ComputerTheParse the source programParsing meansAnd search for statements in the program along the execution pathExecution path search meansAnd for the position of each variable in the source program,From the sentences searched by the execution path search means, the statement that sets the value of the variable is identified to obtain the variable setting location, and the value setting location for the appearance position of each variable can be identified. Functions as a setting statement identification means that performs processing so that the source program can be outputA computer-readable recording medium on which a program for causing the program to be recorded is recorded.
[0017]
(Function)
The operation of the present invention based on the above configuration will be described with reference to FIG.
[0018]
(a): In the above (1), the syntax analysis means 2A parses the
[0019]
In this way, the location where the value is set can be easily identified for the location where the variable appears, so that it is not necessary to make multiple inquiries, and the influence range of the location of interest can be known in a natural manner. Therefore, the program analysis process can be performed efficiently.
[0020]
(b): In the above (2), the syntax analysis means 2A parses the
[0021]
Then, the relationship search means 6A obtains a location where the value is set for the extracted variable in each relationship, and searches for the relationship separately for each location where the value is set even for the same variable.
[0022]
In this way, the location where the value is set can be easily identified for the location where the variable appears, so that it is not necessary to make multiple inquiries, and the influence range of the location of interest can be known in a natural manner. Also, in the analysis of the effects of variables using relationships such as variable and file substitution, it is possible to avoid degradation of analysis accuracy due to work variables. Even with the system, it is possible to analyze efficiently with high accuracy.
[0023]
(c): In (3), the computer reads the program from the recording medium and executes it to parse the
[0024]
In this way, the location where the value is set can be easily identified for the location where the variable appears, so that it is not necessary to make multiple inquiries, and the influence range of the location of interest can be known in a natural manner. Therefore, the program analysis process can be performed efficiently.
[0025]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
[0026]
§1: Explanation of device example ... See FIG.
FIG. 2 is a specific apparatus example, FIG. 2A is an apparatus configuration example, and FIG. 2B is an explanatory diagram of a magnetic disk. The program analysis device is realized by an arbitrary computer such as a personal computer or a workstation.
[0027]
In this example, the program analysis apparatus includes an apparatus main body (computer main body) 1, a display unit (display apparatus) 3 connected to the apparatus
[0028]
The apparatus
[0029]
Then, in the magnetic disk (recording medium) of the magnetic disk device 23, an area as shown in FIG. 2B is set, and a program and the like are stored. In this case, for example, the area includes a source program storage area 32 for storing the source program, a processing result data storage area 33 for storing the processing result data, and a processing program storage area for storing the processing program. 34, and other
[0030]
A program analysis processing program described below is stored in the processing
[0031]
However, the present invention is not limited to such an example. For example, the program can be stored in the
[0032]
(1): A program stored in a removable disk created by another device (program data created by another device) is read by a removable disk drive (RDD) 22 and is read into the
[0033]
(2): Data such as a program transmitted from another device via a communication line such as a LAN is received via the
[0034]
§2: Explanation of the configuration and functions of the program analyzer ... See Fig. 3
FIG. 3 is an explanatory diagram of the program analysis apparatus. FIG. 3A shows an apparatus example 1 and FIG. Hereinafter, the configuration and functions of the program analysis apparatus will be described with reference to FIG.
[0035]
(1): Explanation of device example 1
As shown in FIG. 3A, the program analysis apparatus of the apparatus example 1 includes an apparatus
[0036]
That is, the program analysis apparatus of the apparatus example 1 sets a value of a certain variable, a
[0037]
The setting sentence identifying unit 12 has a function of outputting a source program in a format that can identify only a used location that is a set location of the same value for a specific used location of a specific variable designated by the user, It has a function of inserting information that can identify a setting location of a value for each occurrence position of each variable in the
[0038]
(2): Explanation of device example 2
As shown in FIG. 3B, the program analysis apparatus of the apparatus example 2 includes an apparatus
[0039]
The apparatus
[0040]
When the
[0041]
The
[0042]
In the program analysis apparatus of the apparatus example 2, the
[0043]
That is, the program analysis apparatus of the apparatus example 2 sets a value of a certain variable, a
[0044]
And the
[0045]
Furthermore, when the user designates a variable that has been found to be searchable without being distinguished in units of set locations (set location ignored variable data 9), the
[0046]
Note that the
[0047]
§3: Explanation of processing examples
Hereinafter, a processing example of the program analysis apparatus will be described in detail.
[0048]
(Description of Example 1)
(1): Explanation of processing in Example 1 ... see FIG.
FIG. 4 is a processing flowchart of Example 1. Hereinafter, the processing of Example 1 will be described with reference to FIG. S1 to S7 indicate each processing step.
[0049]
In Example 1, first, the
[0050]
If it is determined that the syntax element indicates a variable, the execution
[0051]
If the setting sentence identification unit 12 determines that it is not a syntax element indicating a variable in the process of S4, the information of the analysis result is sent to the
[0052]
(2): Explanation of data in Example 1 ... See FIG.
FIG. 5 is a data example of Example 1, FIG. 5A is a program (source program) that is an input of Example 1, and FIG. 5B is an output example of Example 1. An example of data in the processing of Example 1 is as follows.
[0053]
(1) Source program example
As an input program (source program 4), for example, a program as shown in FIG. In this example program, “int x = 1”, “int y, z”, and “int a = 2” with
[0054]
“Y = x” in
[0055]
(2) Output example
The
[0056]
In addition, “int a @ 30 = 2” of line number = 30 indicates that “a is line number = 30 and value = 2 is substituted”, and “y @ 40 = x @ 10” of line number = 40. "Indicates that“ the value of x substituted with row number = 10 is substituted for the value of y substituted with row number = 40 ”.
[0057]
Similarly, “z @ 80 = x @ 50 or 70” of the
[0058]
(Description of Example 2)
(1): Outline of processing in Example 2
Example 2 is an example of processing performed only for variables designated by the user in Example 1. In this case, the user is made to select the appearance location of the variable before display, and only the appearance location that is the same setting location is displayed in a manner that can be distinguished from the others.
[0059]
(2): Explanation of processing in Example 2 ... See FIG.
FIG. 6 is a processing flowchart of Example 2. Hereinafter, the processing of Example 2 will be described with reference to FIG. S11 to S19 indicate each processing step.
[0060]
In Example 2, first, the user designates a specific variable by operating the keyboard or the mouse. At this time, when the
[0061]
As a result, if the reading has not been completed, the
[0062]
If it is determined that the syntax element indicates a variable, the execution
[0063]
However, if the corresponding part is not a variable designated by the user in the process of S17, it is displayed as it is (S19), and the process returns to S12. The process is performed in this way, and when it is determined that the reading has been completed in the process of S13, the process ends.
[0064]
(3): Output example
FIG. 7A is an output example of Example 2. In Example 2, for example, data as shown in FIG. In this example, in order to make it easy to see the variable of interest, the corresponding part is highlighted with an underline.
[0065]
For example, when line number = 10, the output is “intx= 1 "and x is emphasized by an underline. When the line number is 40, the output is “y =xX is highlighted by an underline. In this way, it is easier to see the variable being noticed by underlining.
[0066]
Thus, in Example 2, for example, an underline is set so that the setting sentence identification unit 12 can identify only the usage location that is the setting location of the same value for the specific usage location of the specific variable designated by the user. The
[0067]
(Description of Example 3)
In Example 3, instead of displaying the source program on the
[0068]
An output example in this case is shown in FIG. 7B. In the output example of Example 3, for example, when the line number is 40, the output “y = x” is added to the output “y = x” by adding the information of the set location in the form of a comment like “/ * x @ 10 * /”. Output to. In this case, “/ * x @ 10 * /”, which is the information of the set location, is a comment with the content “The value of the variable x used in this line is substituted with line number = 10”. It is inserted in the form of a sentence. As described above, if the information on the set location is added in the comment format and output to the file, the output can be used as it is as a program.
[0069]
(Description of Example 4)
The apparatus used in Example 4 is an apparatus having the configuration shown in FIG. 3B. In Example 4, when the influence of a variable is searched using the relationship between variables, constants, and data files, the variable to be affected is obtained in units of set values.
[0070]
(1): Explanation of processing when creating relational data ... See FIG.
FIG. 8 is a processing flowchart for creating relational data in Example 4. Hereinafter, based on FIG. 8, the process at the time of creation of the relationship data of Example 4 is demonstrated. S21 to S30 indicate each processing step.
[0071]
The
[0072]
Further, if it is a file output, a relationship between the file and the setting position of the write value is created (S28), and if it is a subroutine call, a relation between the argument value setting location and the callee temporary argument is created (S29). Then, the created relational data is output (S30), and the process returns to S21. The process is performed in this way, and if it is determined that all of the data has been read in the process of S22, this process is terminated.
[0073]
(2): Explanation of processing at the time of relational data search ... See FIG.
FIG. 9 is a flowchart of processing for retrieving relational data in Example 4. Hereinafter, based on FIG. 9, the process at the time of the related data search of Example 4 is demonstrated. S31 to S36 indicate each processing step.
[0074]
When searching for related data, first, the user is made to specify a starting point variable (S31). Thereafter, the
[0075]
As a result, if the related party has not been searched yet, it is put in the search list (S35), and the process returns to S33. If the related party is not searched in the process of S34, the process returns to the process of S33. Further, if there is no unsearched set location in the search list in the processing of S33, the set location of the search list is output (S36), and this processing is terminated.
[0076]
(3): Source program example
10 shows a source program example 1, FIG. 11 shows a source program example 2, FIG. 12 shows an example of created relational data, and FIG. 13 shows an output example.
[0077]
In the processing of Example 4, an example of the
[0078]
That is, the relational data in FIG. 12 is an example of relational data created by the processes of S24 to S29 in FIG. 8, and is arranged as data in which the substitution destination and substitution source data are related. Moreover, the output example of FIG. 13 is an output example by the process of FIG.
[0079]
In FIG. 13, there is data including the number of ripples (Ripple level) and variables specified by the user. For example, the variable “YEAR” is a variable specified by the user, the number of ripples is 0 (no ripple), the type of relationship is “starting point”, and the program name is PG2 (the program shown in FIG. 11). Yes, the program has 130 lines. The contents indicate that the variable “YEAR” is affected by the starting sentence in
[0080]
Also, the variable “'00” ”is a variable designated by the user, the number of ripples is 1, the type of relationship is“ comparison ”, the program name is PG2, and the number of program lines is 130 lines. is there. The contents indicate that the variable “00” is affected by the comparison sentence in
[0081]
The variable “10000” is a variable specified by the user, the number of ripples is 1, the type of relationship is “assignment”, the program name is PG2, and the number of program lines is 120 lines. The contents indicate that the variable “10000” is influenced by “substitution” in the 120th line of PG2, and the ripple number is 1.
[0082]
Similarly, the variable “NYUKIN-HI @ 10” is a variable designated by the user, the number of ripples is 4 (spreading level = 4), the type of relationship is “assignment”, and the program name Is PG1 (source program shown in FIG. 10), and the number of lines of the program is 50 lines. The contents indicate that the variable “NYUKIN-HI @ 10” is affected by the “assignment” statement in the 50th line of PG1, and the ripple number is four.
[0083]
As described above, in Example 4, since the location where the value is set can be easily identified with respect to the appearance location of the variable, it is not necessary to make multiple inquiries, and the influence range of the attention location can be known in a natural manner. Also, in the analysis of the effects of variables using relationships such as variable and file substitution, it is possible to avoid degradation of analysis accuracy due to work variables. Even with the system, it is possible to analyze efficiently with high accuracy.
[0084]
(Description of Example 5)
Example 5 is an example in which, when the processing of Example 4 is performed, an unnecessary search is not performed by invalidating the relationship of the variables at the setting points designated in advance by the user.
[0085]
That is, in Example 5, the user designates a variable (Ripple Suppression Variable Data 8), which has been previously determined to be unnecessary by a ripple suppression variable designation means (keyboard, mouse, etc.) in units of set points. If it does in this way, 6 A of relationship search means will not search the relationship which the setting location has at the time of a search. In this way, since unnecessary data is not output, the search result is simplified and the analysis process can be performed efficiently.
[0086]
(Description of Example 6)
In Example 6, when the process of Example 4 is performed, the search is made more for the variables specified by the user in advance without searching for the set locations. It is.
[0087]
That is, in Example 6, the user designates a variable (setting location ignoring variable data 9) that has been found to be searchable without distinction in units of setting locations by the setting location ignoring variable designation means (keyboard, mouse, etc.). To do. If it does in this way, the
[0088]
(Description of Example 7)
In Example 7, when the processing of Example 4 is performed, a variable that is not searched because the setting location of the value is different is stored, and a list is output (for example, displayed), so that To find variables that may be used in the. In the output example of FIG. 13, the variable x of PG1 corresponds to this.
[0089]
Thus, in Example 7, the
[0090]
【The invention's effect】
As described above, the present invention has the following effects.
[0091]
(1): In the present invention, for each occurrence position of a variable, a set location of a value to be executed immediately before is obtained, and this set location information is used for variable identification. In other words, it is possible to identify the location where the value of each variable is set when displaying the program. Also, in the search for the effect when using the substitution relationship between variables, the relationship is searched in consideration of the location where the value is set. By doing so, it is possible to improve the work efficiency without affecting the places where the values are not connected. In addition, even a large-scale system combining many programs can be analyzed with high accuracy.
[0092]
(2): The syntax analysis means parses the source program, the execution path search means searches for a sentence in the program along the execution path, and the set sentence identification means identifies a sentence for setting a value of a certain variable. The output means outputs a source program in response to a user request. Then, the setting sentence identifying means obtains a location where the value is to be set with respect to the appearance position of each variable in the source program, and the source program is formatted in such a way that the set position of the value for each appearance position can be identified. Output.
[0093]
In this way, the location where the value is set can be easily identified for the location where the variable appears, so that it is not necessary to make multiple inquiries, and the influence range of the location of interest can be known in a natural manner. Therefore, the program analysis process can be performed efficiently.
[0094]
(3): The syntax analysis means parses the source program, the execution path search means searches for a sentence in the program along the execution path, and the set sentence identification means identifies a sentence for setting a value of a certain variable. The relationship generating means extracts variables and constants in the sentence, assignments such as substitution between data files, and comparisons, and the output means outputs (for example, displays) a search result in response to a user request.
[0095]
Then, the relationship search means obtains a location where the value is set for the extracted variable in each relationship, and searches for the relationship by distinguishing it for each location where the value is set even if the variable is the same variable.
[0096]
In this way, the location where the value is set can be easily identified for the location where the variable appears, so that it is not necessary to make multiple inquiries, and the influence range of the location of interest can be known in a natural manner. Also, in the analysis of the effects of variables using relationships such as variable and file substitution, it is possible to avoid degradation of analysis accuracy due to work variables. Even with the system, it is possible to analyze efficiently with high accuracy.
[0097]
(4): The computer reads the program from the recording medium and executes it to parse the source programParsing meansAnd search for statements in the program along the execution pathExecution path search meansAnd for the position of each variable in the source program,From the sentences searched by the execution path search means, the statement that sets the value of the variable is identified to obtain the variable setting location, and the value setting location for the appearance position of each variable can be identified. It is made to function as a setting sentence identifying means for performing processing so that a source program can be output.
[0098]
In this way, the location where the value is set can be easily identified for the location where the variable appears, so that it is not necessary to make multiple inquiries, and the influence range of the location of interest can be known in a natural manner. Therefore, the program analysis process can be performed efficiently.
[0099]
Regarding the above description, the following items are further disclosed.
[0100]
(1): In the program analyzing apparatus according to
[0101]
(2): In the program analysis apparatus according to
[0102]
{Circle over (3)} In the program analysis apparatus according to
[0103]
(4): In the program analysis apparatus according to
[0104]
(5) In the program analyzing apparatus according to
[Brief description of the drawings]
FIG. 1 is a diagram illustrating the principle of the present invention.
FIG. 2 is a specific apparatus example according to the embodiment of the present invention.
FIG. 3 is an explanatory diagram of a program analysis apparatus according to the embodiment of the present invention.
FIG. 4 is a processing flowchart of Example 1 in the embodiment of the present invention;
FIG. 5 is a data example of Example 1 in the embodiment of the present invention.
FIG. 6 is a processing flowchart of Example 2 in the embodiment of the present invention;
FIG. 7 is an output example of Example 2 and Example 3 in the embodiment of the present invention.
FIG. 8 is a processing flowchart at the time of creating relational data in Example 4 according to the embodiment of the present invention.
FIG. 9 is a processing flowchart at the time of searching related data in Example 4 according to the embodiment of the present invention;
FIG. 10 is a source program example 1 according to the embodiment of the present invention.
FIG. 11 is a source program example 2 in the embodiment of the present invention.
FIG. 12 is an example of relation data created in the embodiment of the present invention.
FIG. 13 is an output example in the embodiment of the present invention.
FIG. 14 is an explanatory diagram of a conventional example.
[Explanation of symbols]
1 Main unit
2 Parsing section
3 Display section
4 Source program
5 Relationship generator
6 Relation Search Department
7 relationship data
8 Ripple suppression variable data
9 Set location ignored variable data
11 Execution route search unit
12 Setting sentence identification part
13 Output means
21 Input device
22 Removable disk drive (RDD)
23 Magnetic disk unit (MDD)
24 Printer
25 CPU
26 ROM
27 memory
28 I / F control unit (interface control unit)
29 Communication controller
31 Magnetic disk
32 Source program storage area
33 Processing result data storage area
34 Processing program storage area
35 Other data storage area
Claims (3)
前記設定文識別手段は、ソースプログラム中の各変数の出現位置に対し、その値を設定することになる箇所を求め、各出現位置に対する値の設定箇所を識別できるような形式でソースプログラムを出力する機能を備えていることを特徴とするプログラム分析装置。A syntax analysis means for parsing the source program, an execution path search means for searching for a sentence in the program along the execution path, a setting sentence identification means for identifying a sentence for setting a value of a variable, a user's In addition to providing output means for outputting the source program upon request,
The setting sentence identifying means obtains a location where the value is to be set with respect to the appearance position of each variable in the source program, and outputs the source program in a format that can identify the set position of the value for each appearance position. A program analyzer having a function of
前記関係検索手段は、抽出した各関係における変数に対して、その値の設定箇所を求めておき、同一変数であっても値の設定箇所毎に区別して関係を検索する機能を備えていることを特徴とするプログラム分析装置。Syntax analysis means for parsing the source program, execution path search means for searching for a sentence in the program along the execution path, setting identification means for identifying a sentence for setting a value of a certain variable, and variable in the sentence A relation generation means that extracts relations such as assignments, constants, and comparisons between data files, comparisons, etc., a relation search means that searches for variables that are of interest using the relations and variables that are affected by data files, and user requests In response to the output means for outputting the search results in response,
The relationship search means has a function of obtaining a set point of a value for each extracted variable in each relationship, and searching for the relationship separately for each set point of the value even for the same variable. A program analyzer characterized by the above.
ソースプログラムを構文解析する構文解析手段と、
実行経路に沿ってプログラム中の文を探索する実行経路探索手段と、
ソースプログラム中の各変数の出現位置に対し、前記実行経路探索手段で探索した文の中から、その変数の値を設定する文を識別して変数の設定箇所を求め、前記各変数の出現位置に対する値の設定箇所を識別できるような形式でソースプログラムを出力できるように処理を行う設定文識別手段
として機能させるためのプログラムを記録したコンピュータ読み取り可能な記録媒体。 The computer,
A parsing means for parsing the source program;
Execution path search means for searching for statements in the program along the execution path ;
With respect to the appearance position of each variable in the source program, the sentence for setting the value of the variable is identified from the sentences searched by the execution path search means, the variable setting position is obtained, and the appearance position of each variable Setting statement identification means for processing so that the source program can be output in a format that can identify the setting location of the value for
A computer-readable recording medium in which a program for functioning as a computer is recorded.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP32518999A JP3857842B2 (en) | 1999-11-16 | 1999-11-16 | Program analysis apparatus and recording medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP32518999A JP3857842B2 (en) | 1999-11-16 | 1999-11-16 | Program analysis apparatus and recording medium |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2001142688A JP2001142688A (en) | 2001-05-25 |
JP3857842B2 true JP3857842B2 (en) | 2006-12-13 |
Family
ID=18174015
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP32518999A Expired - Fee Related JP3857842B2 (en) | 1999-11-16 | 1999-11-16 | Program analysis apparatus and recording medium |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP3857842B2 (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP4782315B2 (en) * | 2000-06-27 | 2011-09-28 | 新日鉄ソリューションズ株式会社 | Impact analysis apparatus and method, recording medium, and program |
KR20040029616A (en) * | 2002-10-01 | 2004-04-08 | 주식회사 서진정보기술 | A system and management method have enterprise type program source analysis function |
JP2007264863A (en) * | 2006-03-28 | 2007-10-11 | Hitachi Ltd | Analyzer used for business |
JP5901668B2 (en) * | 2013-02-28 | 2016-04-13 | タタ コンサルタンシー サービシズ リミテッドTATA Consultancy Services Limited | System and method for grouping warnings generated during static analysis |
-
1999
- 1999-11-16 JP JP32518999A patent/JP3857842B2/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
JP2001142688A (en) | 2001-05-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7716575B2 (en) | System for capturing document style by example | |
US5946488A (en) | Method for selectively and incrementally displaying the results of preprocessing | |
US7966170B2 (en) | Computer program product and computer system for language-enhanced programming tools | |
US20040049768A1 (en) | Method and program for compiling processing, and computer-readable medium recoding the program thereof | |
JPH0778182A (en) | Keyword allocating system | |
US5940615A (en) | Programming aid for enabling a computer program in source code form to be viewed using a general purpose document browser | |
JPH07325827A (en) | Automatic hyper text generator | |
JP2012063868A (en) | Method to generate combined parser by combining language processing parsers, and its computer and computer program | |
US7562343B2 (en) | User configurable language independent code assist engine method, system, article of manufacture, and computer program product | |
JP3857842B2 (en) | Program analysis apparatus and recording medium | |
EP3432161A1 (en) | Information processing system and information processing method | |
JP4996262B2 (en) | Program parts support equipment | |
JP3943582B2 (en) | Bilingual text matching device | |
JP2000207246A (en) | Debugging support device, method therefor and recording medium recorded with softwater for supporting debugging | |
JPH1115830A (en) | Sentence abbreviation device and medium recording sentence abbreviation program | |
JPH08194611A (en) | Device for analyzing rang of influence caused by program correction | |
JP2004152041A (en) | Program, recording medium and apparatus for extracting key phrase | |
JP3712320B2 (en) | Variable document creation system, variable document output device and variable document creation device | |
JP2018049492A (en) | Analysis device, analysis program and analysis method | |
JP2022135700A (en) | Rewriting program and method for rewriting | |
CN113688131A (en) | Method, system, device and computer program product for field level impact analysis | |
JP2002082811A (en) | Compiling method and recording medium | |
JP2022045948A (en) | Retrieval device, retrieval method and retrieval program | |
JP2000172495A (en) | Device and method for outputting data setting reference place | |
JPH1083288A (en) | Text editor and recording medium where program of the same text editor is recorded |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20060529 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20060620 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20060810 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20060912 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20060915 |
|
R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20090922 Year of fee payment: 3 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20100922 Year of fee payment: 4 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20100922 Year of fee payment: 4 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110922 Year of fee payment: 5 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120922 Year of fee payment: 6 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120922 Year of fee payment: 6 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130922 Year of fee payment: 7 |
|
LAPS | Cancellation because of no payment of annual fees |