JP4782315B2 - Impact analysis apparatus and method, recording medium, and program - Google Patents

Impact analysis apparatus and method, recording medium, and program Download PDF

Info

Publication number
JP4782315B2
JP4782315B2 JP2001194829A JP2001194829A JP4782315B2 JP 4782315 B2 JP4782315 B2 JP 4782315B2 JP 2001194829 A JP2001194829 A JP 2001194829A JP 2001194829 A JP2001194829 A JP 2001194829A JP 4782315 B2 JP4782315 B2 JP 4782315B2
Authority
JP
Japan
Prior art keywords
variable
table information
source code
variables
information
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 - Lifetime
Application number
JP2001194829A
Other languages
Japanese (ja)
Other versions
JP2002082802A (en
Inventor
博昭 木村
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NS Solutions Corp
Original Assignee
NS Solutions 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 NS Solutions Corp filed Critical NS Solutions Corp
Priority to JP2001194829A priority Critical patent/JP4782315B2/en
Publication of JP2002082802A publication Critical patent/JP2002082802A/en
Application granted granted Critical
Publication of JP4782315B2 publication Critical patent/JP4782315B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Description

【0001】
【発明の属する技術分野】
本発明は影響解析装置および方法、更にはこれらをソフトウェアの機能で実現するためのプログラム、および上記プログラムを格納した記録媒体に関し、特に、一般的なプログラム言語で記述されたソースコードを解析する際に利用される影響解析装置および方法に用いて好適なものである。
【0002】
【従来の技術】
従来、例えば既存のソフトウェア資産を利用してより良いコンピュータシステムを構築することが一般的に行われている。この場合、既に構築されている既存のソースコード(ソースプログラム)をデバッグして保守したり、あるいはソースコードが無いときにはリバース・エンジニリアリングを行ったりしている。このプログラムの保守やリバース・エンジニリアリングでは、プログラム中のある変数およびその変数に関係する部分については修正せず、これら以外の部分だけを修正したいという場合もある。
【0003】
ところが、プログラムの内容によっては、その変数がプログラムの他の部分に影響を与えている場合がある。したがって、ある変数に対して修正を加えるときに、その影響がそのプログラムのどの部分まで及ぶのかを調べることなく無闇に行うと、予測し得ないエラー等が発生して、そのプログラムが正常に動作しなくなってしまうことがある。
【0004】
したがって、ソースコードの解析・修正作業においては、変数の影響がどの範囲まで及び、どの部分には及ばないかを解析することが、プログラムを開発する上において極めて重要となる。そこで本出願人は、このような解析を行うための装置として、例えば特願平10−24355号に記載の変数影響解析装置を提案した。この装置は、プログラム中での影響範囲を解析するものである。
【0005】
【発明が解決しようとする課題】
ところで、1つのプログラムは、例えば機能単位毎に分割した個々のモジュールに対応する複数のソースコードを夫々コンパイルし、それらをリンクすることによって作成されることが多い。以下では、このように1つの実行プログラムを作るに当たってリンクするために必要なソースコード群の単位を「リンク単位」と呼ぶ。さらに、複数のリンク単位の実行プログラムが連携して1つのコンピュータシステムを構築している場合も多い。
【0006】
通常、プログラムを保守する際にはソースコードやそのリンク単位等をユーザが理解しており、これをもとに保守作業を行うことが多い。しかしながら、これらの情報をユーザが必ず理解しているとは限らない。従来の変数影響解析装置では、ユーザがこれらリンク単位等の情報を理解していることを前提に作られているため、ユーザはリンク単位を意識しておく必要があり、リンク単位が不明である場合には解析できなかった。
【0007】
また、別の課題として、リンク単位となっている複数のソースファイルに渡って影響解析を行う場合、例えば対象となるソースファイル自体が数千、数万ファイルになることがある。その場合、従来の変数影響解析装置では全ての影響解析を行っていたために解析結果を得るためには非常に時間がかかり、実質的には使い物にならなかった。
さらに、従来の変数影響解析装置では、影響解析できる範囲は1つのリンク単位内に限られており、複数のリンク単位が連携して構築されるようなシステムに関しては解析できないという課題があった。
【0008】
本発明は、このような問題を解決するために成されたものであり、与えられたソースコード群の中でユーザがリンク単位を意識しなくても影響範囲の解析を行うことができるようにすることを目的とする。
また、本発明は、解析対象となるソースファイルが多くなった場合にも高速に影響解析を行うことができるようにすることを目的とする。
さらに、本発明は、1つのリンク単位を越えて影響範囲の解析を行うことができるようにすることも目的としている。
【0009】
【課題を解決するための手段】
本発明の影響解析装置は、解析の対象となる少なくとも1つ以上のソースコード毎に生成された、変数のデータ依存関係に関する少なくとも1つ以上の変数情報を対象として、代入または参照が行われた変数とその存在場所との対応関係を表す複数のテーブル情報を生成するテーブル生成手段と、上記テーブル生成手段により生成された複数のテーブル情報を用いて、変数の代入および参照関係を辿ることによって変数の影響範囲を求める解析手段とを備え、上記テーブル生成手段は、それぞれのソースコード毎に生成された各変数情報を対象として、変数とその代入が行われた文との対応関係を表す第1のテーブル情報、変数とその参照が行われた文との対応関係を表す第2のテーブル情報、文とそこで代入が行われた変数との対応関係を表す第3のテーブル情報を生成する。
【0013】
また、本発明の影響解析方法は、解析の対象となる少なくとも1つ以上のソースコード毎に生成された、変数のデータ依存関係に関する少なくとも1つ以上の変数情報を対象として、代入または参照が行われた変数とその存在場所との対応関係を表す複数のテーブル情報を生成するテーブル生成ステップと、上記生成された複数のテーブル情報を用いて、変数の代入および参照関係を辿ることによって変数の影響範囲を求める解析ステップとを有し、上記テーブル生成ステップでは、それぞれのソースコード毎に生成された各変数情報を対象として、変数とその代入が行われた文との対応関係を表す第1のテーブル情報、変数とその参照が行われた文との対応関係を表す第2のテーブル情報、文とそこで代入が行われた変数との対応関係を表す第3のテーブル情報を生成する。
【0014】
また、本発明のコンピュータ読み取り可能な記録媒体は、解析の対象となる少なくとも1つ以上のソースコード毎に生成された、変数のデータ依存関係に関する少なくとも1つ以上の変数情報を対象として、代入または参照が行われた変数とその存在場所との対応関係を表す複数のテーブル情報を生成するテーブル生成手段と、上記テーブル生成手段により生成された複数のテーブル情報を用いて、変数の代入および参照関係を辿ることによって変数の影響範囲を求める解析手段としてコンピュータを機能させ、かつ上記テーブル生成手段にて、それぞれのソースコード毎に生成された各変数情報を対象として、変数とその代入が行われた文との対応関係を表す第1のテーブル情報、変数とその参照が行われた文との対応関係を表す第2のテーブル情報、文とそこで代入が行われた変数との対応関係を表す第3のテーブル情報を生成するためのプログラムを記録する。
【0015】
また、本発明のプログラムは、解析の対象となる少なくとも1つ以上のソースコード毎に生成された、変数のデータ依存関係に関する少なくとも1つ以上の変数情報を対象として、代入または参照が行われた変数とその存在場所との対応関係を表す複数のテーブル情報を生成するテーブル生成手段と、上記テーブル生成手段により生成された複数のテーブル情報を用いて、変数の代入および参照関係を辿ることによって変数の影響範囲を求める解析手段としてコンピュータを機能させ、かつ上記テーブル生成手段にて、それぞれのソースコード毎に生成された各変数情報を対象として、変数とその代入が行われた文との対応関係を表す第1のテーブル情報、変数とその参照が行われた文との対応関係を表す第2のテーブル情報、文とそこで代入が行われた変数との対応関係を表す第3のテーブル情報を生成する。
【0016】
【発明の実施の形態】
以下、本発明の一実施形態を図面に基づいて説明する。
図1は、本実施形態による影響解析装置の主要な機能構成を示すブロック図である。
【0017】
図1において、1-1〜1-nは影響範囲解析の対象となるn個のソースコードであり、これらの中の何れかの組み合わせによってリンク単位が構成される。また、これらn個のソースコード1-1〜1-nの中に複数のリンク単位が含まれていても良い。解析の対象として与えられるこれらn個のソースコード1-1〜1-nは、その中の何れの組み合わせによってリンク単位が構成されているのかが不明であっても良い。
【0018】
2は変数情報生成部であり、解析の対象となる上記n個のソースコード1-1〜1-nを読み込み、それぞれのソースコード毎に構文解析して、変数の代入・参照関係を表す変数情報3-1〜3-nをそれぞれ生成する。すなわち、例えば第1のソースコード1-1から第1の変数情報3-1を生成し、第nのソースコード1-nから第nの変数情報3-nを生成する。生成した変数情報3-1〜3-nは、各ソースコード毎に1つのファイルに入れてそれぞれ記憶部4に保存する。
【0019】
5はテーブル情報生成部であり、上記変数情報生成部2によりそれぞれのソースコード毎に生成されて記憶部4に保存された各変数情報3-1〜3-nを対象として、代入または参照が行われた変数とその存在場所との対応関係を表す複数のテーブル情報を生成する。ここでは、例えば変数とその代入が行われた文との対応関係を表す第1のテーブル情報6-1と、変数とその参照が行われた文との対応関係を表す第2のテーブル情報6-2と、文とそこで代入が行われた変数との対応関係を表す第3のテーブル情報6-3とを生成する。
【0020】
7は解析部であり、上記テーブル情報生成部5により生成された3つのテーブル情報6-1〜6-3を用いて、変数の代入および参照関係を辿ることによって所望の変数の影響範囲を解析する。例えば、第1のテーブル情報6-1を起点として、以降第2のテーブル情報6-2と第3のテーブル情報6-3とを交互にアクセスして変数の代入および参照の関係を辿ることにより、当該変数の影響範囲を求める。
そして、その解析結果をリスト8として出力する。
【0021】
以下に、上記のように構成した影響解析装置の動作を、具体例を挙げながら説明する。なお、ここでは説明の簡単のため、変数の影響解析の対象とするソースコードが2つの場合について説明する。図2は、その2つのソースコード1-1,1-2およびこれから生成される変数情報3-1,3-2の一部構成例を示す図である。
【0022】
図2において、第1のソースコード1-1では、1行目において変数Aに"1"が代入され、2行目において変数Bが参照されてその値が変数Xに代入され、3行目において変数Aが参照されてその値が変数Bに代入されている。また、4行目においては2つの変数B,Yが参照され、6行目においては変数Bが参照されてその値が変数Cに代入されている。一方、第2のソースコード1-2では、1行目において変数Aに"0"が代入され、2行目において変数Dが参照されてその値が変数Xに代入され、3行目において2つの変数B,Xが参照されている。
【0023】
変数情報生成部2は、このような2個のソースコード1-1,1-2を読み込み、それぞれのソースコード中に含まれる各変数の代入・参照関係を解析して、変数の代入・参照関係に関する変数情報3-1,3-2をそれぞれのソースコード毎に生成する。例えば、第1のソースコード1-1に関しては、変数Aは1行目で代入されるとともに3行目で参照され、変数Bは2,4,6行目で参照されるとともに3行目で代入され、変数Cは6行目で代入され、変数Xは2行目で代入され、変数Yは4行目で参照されているという変数情報を生成する。第2のソースコード1-2に関しても同様である。
【0024】
このようにして生成された変数情報3-1,3-2は、それぞれ別個のファイルとして記憶部4に保存される。テーブル情報生成部5は、記憶部4に保存された各変数情報3-1,3-2を用いて、上述の3つのテーブル情報6-1〜6-3を生成する。図3は、上記図2に示した2つのソースコード1-1,1-2を解析対象とした場合に生成される3つのテーブル情報6-1〜6-3を示す図である。
【0025】
図3において、第1のテーブル情報6-1は、変数とその代入が行われた文との対応関係を表すものである。この第1のテーブル情報6-1に含まれる各変数A,B,C,Xは、解析対象とする全ソースコード1-1,1-2の中で代入が行われている全ての変数である。また、それらに対応する文は、その変数の代入が行われているソースコード中の場所を示すものである。例えば変数Aは、第1のソースコード1-1の1行目(1−1で表記)と、第2のソースコード1-2の1行目(2−1で表記)とで代入が行われている。
【0026】
また、第2のテーブル情報6-2は、変数とその参照が行われた文との対応関係を表すものである。この第2のテーブル情報6-2に含まれる各変数A,B,D,X,Yは、解析対象とする全ソースコード1-1,1-2の中で参照が行われている全ての変数である。また、それらに対応する文は、その変数の参照が行われているソースコード中の場所を示すものである。例えば変数Aは、第1のソースコード1-1の3行目(1−3で表記)で参照が行われている。
【0027】
また、第3のテーブル情報6-3は、文とそこで代入が行われた変数との対応関係を表すものである。この第3のテーブル情報6-3に含まれる各文1−1,1−2,1−3,1−6,2−1,2−2は、解析対象とする全ソースコード1-1,1-2の中で代入が行われている全ての場所を表すものであり、それらの場所で代入されている変数が夫々対応して示されている。例えば第1のソースコード1-1の1行目では、変数Aの代入が行われている。
【0028】
なお、この図3の例では、変数の代入や参照が行われた文を1−1,1−2…などで表記しているが、1つの文が複数行に渡って記述されることもあるので、これらの表記は単純な行番号を示すものではない。実際には、各テーブル情報6-1〜6-3中の文を表す部分に対して、各ソースコード1-1,1-2の各文ごとにユニークな文IDを与え、この文IDとそれが存在するソースコード中の場所との関係を表すもう1つのテーブル情報を備えている。
【0029】
解析部7は、テーブル情報生成部5により生成された図3に示した3つのテーブル情報6-1〜6-3を用いて、例えば対象変数リスト9にリストアップされているユーザにより指定された所望の変数の代入および参照関係を辿ることによって影響範囲を解析し、その解析結果をリスト8として出力する。
【0030】
例えば、変数Aの影響範囲を解析したい場合は、まず第1のテーブル情報6-1を見て、その変数Aが各ソースコード1-1,1-2の中のどの場所で代入されているかを調べる。ここでは、第1のソースコード1-1の1行目と、第2のソースコード1-2の1行目において変数Aの代入が行われていることが分かる。この時点で、その検出した代入場所を解析結果リスト8に登録する。
【0031】
次に、第2のテーブル情報6-2を見て、指定された変数Aが各ソースコード1-1,1-2の中のどの場所で参照されているかを調べる。ここでは、第1のソースコード1-1の3行目において変数Aの参照が行われていることが分かる。この時点で、その検出した参照場所を解析結果リスト8に追加する。次に、第3のテーブル情報6-3を見て、上記第2のテーブル情報6-2に記述されている場所で参照された変数Aがどの変数に代入されているかを調べる。ここでは、第1のソースコード1-1の3行目において参照された変数Aが変数Bに代入されていることが分かる。
【0032】
この場合、変数Aの値は変数Bに代入されてさらに他の部分に影響を及ぼすことになるので、次に変数Bの影響範囲も調べる必要がある。そこで、第2のテーブル情報6-2を再び見て、その変数Bが各ソースコード1-1,1-2の中のどの場所で参照されているかを調べる。ここでは、第1のソースコード1-1の2,4,6行目と、第2のソースコード1-2の3行目において変数Bの参照が行われていることが分かる。この時点で、それらの検出した参照場所を解析結果リスト8に追加する。
【0033】
さらに、第3のテーブル情報6-3を見て、上記第2のテーブル情報6-2に記述されている場所で参照された変数Bがそれぞれどの変数に代入されているかを調べる。ここでは、第1のソースコード1-1の2行目において参照された変数Bが変数Xに代入されるとともに、第1のソースコード1-1の6行目において参照された変数Bが変数Cに代入されていることが分かる。なお、第1のソースコード1-1の4行目において参照された変数Bと、第2のソースコード1-2の3行目において参照された変数Bは何れの変数にも代入されていないので、これらについてはここで処理が終了する。
【0034】
ここで変数Bの値が代入されている新たな変数X,Cについては、更にその影響範囲を調べるために、再び第2のテーブル情報6-2を見て、その変数X,Cが各ソースコード1-1,1-2の中のどの場所で参照されているかを調べる。ここでは、第2のソースコード1-2の3行目において変数Xの参照が行われていることが分かる。ただし、この参照場所は解析結果リスト8に既に登録されているので、解析結果リスト8への追加は行わない。
【0035】
さらに、第3のテーブル情報6-3を見て、上記第2のテーブル情報6-2に記述されている場所で参照された変数Xがどの変数に代入されているかを調べる。ここでは、変数Xは何れの変数にも代入されていないので、ここで全ての解析処理が終了する。以上のように、第1のテーブル情報6-1を起点として、以降第2のテーブル情報6-2と第3のテーブル情報6-3とを交互にアクセスして変数の代入および参照関係を辿ることにより、変数Aの影響範囲を求めることができる。このとき得られた変数Aの影響範囲の解析結果リスト8を示すと、図4のようになる。
【0036】
なお、今の例では生じていないが、第3のテーブル情報6-3から第2のテーブル情報6-2に戻る際に既に解析済の変数が指定された場合には、その変数について続けて解析しても以前と同じ結果が得られるだけなので、そこで解析処理を終了する。そのために、どの変数について解析を行ったかの履歴情報を保持するようにして、常にこの履歴情報を更新および参考にしながら上述のような処理を実行する。
【0037】
以上の説明から分かるように、本実施形態の影響解析装置では、それぞれのソースコード1-1,1-2中に含まれる同じ名前の変数は、全て同じ変数であるものとしている。これは、複数のソースコード間に渡って影響範囲の解析を行う変数は、殆どの場合が大域変数(グローバル変数)であり、全てのソースコードで名前を統一して使われているため、同じ名前の変数を同一視しても問題がないからである。
【0038】
また、本実施形態の影響解析装置では、それぞれのソースコード1-1,1-2中に含まれる変数がどこかの場所で代入されたら、その変数の全ての参照はその代入に依存しているものと考えている。つまり、プログラムの制御フローは全く無視している。例えば、第1のソースコード1-1において制御フローも考慮して変数Aの影響範囲を解析すると2行目は影響範囲に入らないが、本実施形態のように制御フローを無視した場合にはこの2行目も影響範囲に入る(図4において1−2も影響範囲のリストとして登録されている)。
【0039】
図5および図6は、本実施形態による影響解析方法の処理手順を示すフローチャートである。このうち図5は、図1の記憶部4に保存されている変数情報3-1〜3-nから3つのテーブル情報6-1〜6-3を生成するテーブル情報生成部5の処理、すなわち、解析部7による影響解析の前処理の手順を示す。
【0040】
図5において、まずステップS1で、ユーザがテーブル情報生成部5に対して影響解析を行う対象のソースコード群を指定する。ここでは、特にリンク単位を意識することなく、任意のソースコードを指定することが可能である。また、与えられた全てのソースコード1-1〜1-nを指定することも可能である。次に、ステップS2でテーブル情報生成部5は、上記指定されたソースコード群の各々に対応する変数情報をそれぞれ記憶部4から読み込む。
【0041】
すなわち、複数のソースコード1-1〜1-nの各々に対応する変数情報3-1〜3-nがあらかじめ変数情報生成部2により生成されて記憶部4に保存されているので、その中から指定されたソースコード群に対応する変数情報を読み込む。そして、ステップS3で、その読み込んだ変数情報の全体を対象として、上述した第1〜第3のテーブル情報6-1〜6-3を生成する。
【0042】
図6は、上記テーブル情報生成部5により生成された3つのテーブル情報6-1〜6-3を用いて変数の影響解析を行う解析部7の処理手順を示す。なお、この図6のフローチャートに入る前に、別途ユーザがどの変数に対して影響解析を行いたいかという指定をしておき、対象変数リスト9にその変数がリスト化されているものとする。図6において、まずステップS11で、ユーザから影響解析を行いたい変数の指定があったか否かを判断する(図3の例では、変数Aを指定している)。変数の指定があった場合は、ステップS12で第1のテーブル情報6-1を見て、ステップS13で上記指定された変数が第1のテーブル情報6-1内に存在するか否かを判断する。
【0043】
ここで、指定された変数が第1のテーブル情報6-1内に有る場合は、ステップS14に進み、その変数に対応して第1のテーブル情報6-1内に記述されている代入が行われた文(図3の例では、1−1、2−1の2つの代入文)を解析結果リスト8に登録する。次に、ステップS15で第2のテーブル情報6-2を見て、ステップS16で上記指定された変数が第2のテーブル情報6-2内に存在するか否かを判断する。
【0044】
ここで、指定された変数が第2のテーブル情報6-2内に有る場合は、ステップS17に進み、その変数に対応して第2のテーブル情報6-2内に記述されている参照が行われた文(図3の例では、1−3の参照文)を解析結果リスト8に追加する。さらに、ステップS18で第3のテーブル情報6-3を見て、ステップS19で上記第2のテーブル情報6-2内に記述されている参照文が第3のテーブル情報6-3内に存在するか否かを判断する。
【0045】
ここで、上記第2のテーブル情報6-2内に記述されている参照文が第3のテーブル情報6-3内に有る場合は、ステップS20に進み、最初に指定された変数(図3の例では変数A)を上記参照文に対応して記述されている代入が行われた変数(図3の例では変数B)に置き換える。このように、以降の影響解析処理で対象とする変数名を変更した後、ステップS15に戻り、再び第2のテーブル情報6-2を見て以下同様の処理を繰り返し行う。
【0046】
なお、上記ステップS19で、上記第2のテーブル情報6-2内に記述されている参照文が第3のテーブル情報6-3内に複数有る場合、ステップS20では、以降の処理で対象とする変数を複数設定する。そして、以降のステップS15〜S19の処理では、設定された複数の変数のそれぞれに対して同様の処理を実行する。このとき、ステップS16およびステップS19では、該当するものが1つでも有れば、その該当するものに関してYesの分岐に従って処理を進める。
【0047】
また、上記ステップS13,S16,S19の何れかにおいて、第1のテーブル情報6-1および第2のテーブル情報6-2内に指定された変数が存在しない場合や、上記第2のテーブル情報6-2内に記述されている参照文が第3のテーブル情報6-3内に存在しない場合には、影響解析の処理を終了する。このようにして影響解析の処理を終了したときに解析結果リスト8に記述されている内容が、求めたい変数の影響範囲を表していることになる。
【0048】
以上詳しく説明したように、本実施形態では、まず解析対象となるそれぞれのソースコード毎に変数の代入・参照関係に関する変数情報を夫々生成する。次に、それぞれのソースコード中に含まれる同じ名前の変数は全て同じものであるとし、かつ、ソースコード中の制御フローを無視するという条件の下で、複数の変数情報をもとに3つのテーブル情報を生成する。そして、これらのテーブル情報を用いて変数の代入および参照関係を辿ることによって影響範囲を求めるようにしている。
【0049】
これにより、与えられた複数のソースコード1-1〜1-nの中でどの組み合わせでリンク単位を構成するかを特定できなくても、例えばそれらをまとめて解析処理を行えば、その中である変数の影響する範囲を解析することができる。また、異なるソースコードに含まれる変数でも同じ名前の変数は同じものであるとして解析しているので、従来の変数影響解析装置の解析で制限されていたリンク単位を越えて影響範囲の解析を行うこともできる。
【0050】
また、上述のように制御フローを無視するという条件を課すことにより、影響解析を厳密に行うことはできないが、各ソースコード1-1〜1-n中の各文に現れる変数の代入、参照情報を求めれば良くなるので、構文解析する単位はソースコード毎に行えば良くなり、ある程度良好な解析結果を現実に実行可能な時間内に得ることができる。
【0051】
さらに、本実施形態では、上記変数情報生成部2により生成された変数情報3-1〜3-nを保存する記憶部4を備え、各変数情報3-1〜3-nを変数情報生成部2によりあらかじめ生成して記憶部4に保存しておくようにしている。したがって、上述した変数の影響解析処理を一連に行うのではなく、所望の変数の影響解析を行いたいときにテーブル情報6-1〜6-3の生成から始めれば良く、影響解析の処理を更に高速化することができる。
【0052】
この場合、最初の段階では、全てのソースコード1-1〜1-nについて各変数情報3-1〜3-nを求めて記憶部4に保存することになるが、その後は、変更が加えられたソースコードについてのみ対応する変数情報を生成し、その部分だけ記憶部4の内容を更新すれば良い。なお、この変数情報3-1〜3-nを求める処理自体は、通常の構文解析手法を用いて行うことが可能である。
【0053】
なお、上記実施形態では、解析部7で影響解析を行う際に、第1のテーブル情報6-1からスタートしてその後第2のテーブル情報6-2と第3のテーブル情報6-3とを繰り返し見ていき、該当する変数や文が存在しなくなった時点で解析処理を終了していたが、第2のテーブル情報6-2と第3のテーブル情報6-3の繰り返し処理の回数があらかじめ定めた回数に達したときに解析処理を終了するようにしても良い。
【0054】
また、上記実施形態では、影響解析を行う所望の変数を1つだけ指定する例について説明したが、複数の変数を指定しても良い。この場合、指定された複数の変数の影響範囲を1つ1つ順に解析していき、各変数の解析結果を個別のリストとして出力するようにしても良いし、各変数の解析結果を1つのリストに合わせて出力するようにしても良い。1つのリストに合わせて出力する場合、各変数の解析結果のうち重複するものについては排除するようにしても良い。
【0055】
また、上記実施形態では、ある変数単体の影響解析を行う場合について説明したが、色々な型の変数をいくつか集めて構成した構造体に対しても本発明を適用することが可能である。この場合は、例えば、図6のステップS11で影響解析を行う所望の変数が指定されたときに、その変数が構造体の一部であるかどうかをまず判断し、構造体の一部であれば、その構造体を構成する他の変数も影響解析を行う対象の中に含める。以降は、その構造体を構成する複数の変数に対してステップS12〜S20の処理をそれぞれ実行すれば良い。
【0056】
(本発明の他の実施形態)
以上に説明した本実施形態の影響解析装置は、コンピュータのCPUあるいはMPU、RAM、ROMなどで構成されるものであり、RAMやROMに記憶されたプログラムが動作することによって実現でき、上記プログラムは本発明の実施形態に含まれる。また、コンピュータが上記機能を果たすように動作させるプログラムを、例えばCD−ROMのような記録媒体に記録し、コンピュータに読み込ませることによって実現できるものであり、上記プログラムを記録した記録媒体は本発明の実施形態に含まれる。上記プログラムを記録する記録媒体としては、CD−ROM以外に、フレキシブルディスク、ハードディスク、磁気テープ、光磁気ディスク、不揮発性メモリカード等を用いることができる。
【0057】
また、コンピュータが供給されたプログラムを実行することにより上述の実施形態の機能が実現されるだけでなく、そのプログラムがコンピュータにおいて稼働しているOS(オペレーティングシステム)あるいは他のアプリケーションソフト等と共同して上述の実施形態の機能が実現される場合や、供給されたプログラムの処理の全てあるいは一部がコンピュータの機能拡張ボードや機能拡張ユニットにより行われて上述の実施形態の機能が実現される場合も、かかるプログラムは本発明の実施形態に含まれる。
【0058】
【発明の効果】
本発明は上述したように、解析の対象となる少なくとも1つ以上のソースコードのそれぞれに対応する各変数情報を用いて、代入または参照が行われた変数とその存在場所との対応関係を表す複数のテーブル情報を生成し、その複数のテーブル情報を用いて、変数の代入および参照関係を辿ることによって変数の影響範囲を求めるようにしたので、与えられた複数のソースコードの中でどの組み合わせでリンク単位を構成するかを意識することなく、その中で関係のあるソースコード間で所望の変数の影響範囲を解析することができる。
【0059】
また、それぞれのソースコード中に含まれる同じ名前の変数は全て同じ変数であるとして解析を行っているので、リンク単位を越えて影響範囲の解析を行うこともできる。さらに、それぞれのソースコード中に含まれる変数の全ての参照がその変数の代入に依存しているものとして解析を行っているので、各ソースコード中の各文に現れる変数の代入、参照情報を求めれば良くなり、短い時間で解析処理を実行することができる。
【0060】
さらに、本発明の他の特徴によれば、それぞれのソースコードに対応する変数情報を保存する記憶手段を備え、上記変数情報をあらかじめ生成して保存しておくようにしたので、所望の変数の影響解析を行いたいときには、保存されている変数情報を用いてテーブル情報の生成から始めれば良くなり、影響解析の処理にかかる時間を更に短縮化することができる。
【図面の簡単な説明】
【図1】本実施形態による影響解析装置の主要な機能構成を示すブロック図である。
【図2】ソースコードの一部構成例を示す図である。
【図3】図2に示した2つのソースコードを解析対象とした場合に生成される3つのテーブル情報と影響解析の流れを示す図である。
【図4】変数Aの影響範囲の解析結果リストを示す図である。
【図5】本実施形態による影響解析方法の処理手順を示すフローチャートである。
【図6】本実施形態による影響解析方法の処理手順を示すフローチャートである。
【符号の説明】
-1〜1-n ソースコード
2 変数情報生成部
-1〜3-n 変数情報
4 記憶部
5 テーブル情報生成部
-1〜6-3 テーブル情報
7 解析部
8 解析結果リスト
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to an influence analysis apparatus and method, a program for realizing these functions with software functions, and a recording medium storing the above program, and in particular, when analyzing a source code described in a general program language. It is suitable for use in the influence analysis apparatus and method used in the above.
[0002]
[Prior art]
Conventionally, for example, a better computer system has been generally constructed using, for example, existing software assets. In this case, existing source code (source program) that has already been built is debugged and maintained, or when there is no source code, reverse engineering is performed. In the maintenance and reverse engineering of this program, there are cases where it is desired not to modify a certain variable and a part related to the variable in the program, but to modify only the other parts.
[0003]
However, depending on the contents of the program, the variable may affect other parts of the program. Therefore, when a modification is made to a variable without checking the part of the program that affects it, an unpredictable error occurs and the program operates normally. It may not be done.
[0004]
Therefore, in the analysis / correction work of the source code, it is extremely important in developing a program to analyze to what extent the variable influences and to what part. Therefore, the present applicant has proposed, for example, a variable effect analysis apparatus described in Japanese Patent Application No. 10-24355 as an apparatus for performing such an analysis. This device analyzes the range of influence in a program.
[0005]
[Problems to be solved by the invention]
Incidentally, one program is often created by compiling a plurality of source codes corresponding to individual modules divided for each functional unit and linking them. Hereinafter, a unit of a source code group necessary for linking in creating one execution program is referred to as a “link unit”. Furthermore, there are many cases where a plurality of execution programs for each link unit cooperate to construct one computer system.
[0006]
Usually, when a program is maintained, the user understands the source code and the link unit thereof, and the maintenance work is often performed based on this. However, this information is not always understood by the user. In the conventional variable influence analysis device, it is made on the assumption that the user understands information such as the link unit, so the user needs to be aware of the link unit, and the link unit is unknown. In some cases it could not be analyzed.
[0007]
As another problem, when an influence analysis is performed over a plurality of source files in link units, for example, the target source file itself may be thousands or tens of thousands of files. In that case, since all the influence analysis was performed in the conventional variable influence analysis apparatus, it took a very long time to obtain the analysis result, and it was not practically usable.
Furthermore, in the conventional variable influence analysis apparatus, the range in which the influence analysis can be performed is limited to one link unit, and there is a problem that a system in which a plurality of link units are constructed in cooperation cannot be analyzed.
[0008]
The present invention has been made to solve such a problem, so that the user can analyze the influence range without being aware of the link unit in the given source code group. The purpose is to do.
It is another object of the present invention to perform an impact analysis at high speed even when the number of source files to be analyzed increases.
Another object of the present invention is to enable the analysis of the influence range beyond one link unit.
[0009]
[Means for Solving the Problems]
In the influence analysis apparatus of the present invention, assignment or reference is performed on at least one or more variable information related to the data dependency relationship of variables generated for each of at least one or more source codes to be analyzed. The table generation means for generating a plurality of table information representing the correspondence between the variable and its location, and the variable assignment and the reference relationship are traced using the plurality of table information generated by the table generation means. Analyzing means for determining the influence range of the first, and the table generating means is a first representing a correspondence relationship between the variable and the sentence to which the substitution is performed for each variable information generated for each source code. Table information, the second table information indicating the correspondence between the variable and the statement that referenced it, the correspondence between the statement and the variable that was assigned there Generating a to third table information.
[0013]
Further, the influence analysis method of the present invention performs assignment or reference on at least one or more variable information related to the data dependency relationship of variables generated for each of at least one or more source codes to be analyzed. The table generation step for generating a plurality of table information representing the correspondence relationship between the variable and its location, and the influence of the variable by tracing the variable assignment and the reference relationship using the generated table information. An analysis step for obtaining a range, and in the table generation step, for each variable information generated for each source code, a first relationship representing a correspondence relationship between the variable and the sentence in which the substitution is performed Table information, second table information indicating the correspondence between variables and the statement to which the reference was made, and the correspondence between the statement and the variable assigned there. Generating a third table information.
[0014]
Further, the computer-readable recording medium of the present invention assigns or substitutes at least one or more variable information related to the data dependency relationship of variables generated for each of at least one or more source codes to be analyzed. Table generation means for generating a plurality of table information representing the correspondence between the referenced variables and their locations, and variable assignment and reference relations using the plurality of table information generated by the table generation means. The computer was made to function as an analysis means for determining the variable influence range by tracing the variables, and the variables and substitutions were made for each variable information generated for each source code by the table generation means. First table information representing the correspondence with the sentence, and second table information representing the correspondence between the variable and the sentence in which the reference was made. Bull information, records a program for generating a third table information indicating a correspondence relationship between the text and where the assignment has been made variable.
[0015]
In the program of the present invention, assignment or reference is performed for at least one or more variable information related to the data dependency relationship of variables generated for at least one or more source codes to be analyzed. The table generation means for generating a plurality of table information representing the correspondence between the variable and its location, and the variable assignment and the reference relationship are traced using the plurality of table information generated by the table generation means. Correspondence relationship between variables and sentences assigned to each variable information generated for each source code by the table generation means, with the computer functioning as an analysis means for determining the influence range of The first table information representing the second table information representing the correspondence between the variable and the sentence in which the reference is made, and the sentence Generating a third table information indicating a correspondence relationship between were made variable.
[0016]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, an embodiment of the present invention will be described with reference to the drawings.
FIG. 1 is a block diagram showing the main functional configuration of the influence analysis apparatus according to the present embodiment.
[0017]
In FIG. -1 ~ 1 -n Is n source codes to be subjected to influence range analysis, and a link unit is constituted by any combination of these. These n pieces of source code 1 -1 ~ 1 -n A plurality of link units may be included in. These n source codes given as objects of analysis 1 -1 ~ 1 -n It may be unclear which link unit constitutes the link unit.
[0018]
Reference numeral 2 denotes a variable information generator, which is the n source codes 1 to be analyzed. -1 ~ 1 -n Variable information 3 that represents the substitution / reference relationship of variables by parsing each source code -1 ~ 3 -n Are generated respectively. That is, for example, the first source code 1 -1 To the first variable information 3 -1 And the nth source code 1 -n To nth variable information 3 -n Is generated. Generated variable information 3 -1 ~ 3 -n Are stored in the storage unit 4 in one file for each source code.
[0019]
Reference numeral 5 denotes a table information generation unit. Each variable information 3 generated for each source code by the variable information generation unit 2 and stored in the storage unit 4. -1 ~ 3 -n A plurality of table information representing a correspondence relationship between a variable that has been assigned or referred to and its location is generated. Here, for example, the first table information 6 representing the correspondence between the variable and the sentence in which the substitution is performed. -1 And second table information 6 representing the correspondence between the variable and the sentence in which the variable is referenced -2 And the third table information 6 representing the correspondence between the sentence and the variable assigned there -3 And generate
[0020]
Reference numeral 7 denotes an analysis unit, and the three pieces of table information 6 generated by the table information generation unit 5 described above. -1 ~ 6 -3 Is used to analyze the range of influence of a desired variable by following the substitution and reference relationship of the variable. For example, the first table information 6 -1 From this point, the second table information 6 -2 And third table information 6 -3 Are alternately accessed to trace the relationship of substitution and reference of the variable, thereby obtaining the influence range of the variable.
The analysis result is output as a list 8.
[0021]
Hereinafter, the operation of the influence analysis apparatus configured as described above will be described with a specific example. Here, for simplicity of explanation, a case where there are two source codes to be subjected to variable influence analysis will be described. Figure 2 shows the two source codes 1 -1 , 1 -2 And variable information 3 generated from now -1 , 3 -2 It is a figure which shows the example of a partial structure.
[0022]
In FIG. 2, the first source code 1 -1 In the first line, “1” is assigned to the variable A, the variable B is referred to in the second line, the value is assigned to the variable X, the variable A is referred to in the third line, and the value is the variable B. Is assigned to In the fourth line, two variables B and Y are referred to, and in the sixth line, the variable B is referenced and the value is assigned to the variable C. On the other hand, the second source code 1 -2 In the first line, “0” is assigned to the variable A, the variable D is referred to in the second line, the value is assigned to the variable X, and the two variables B and X are referred to in the third line. .
[0023]
The variable information generation unit 2 has two such source codes 1 -1 , 1 -2 , Analyze the assignment / reference relationship of each variable included in each source code, and variable information 3 regarding variable assignment / reference relationship -1 , 3 -2 Is generated for each source code. For example, the first source code 1 -1 , Variable A is assigned in the first line and referenced in the third line, variable B is referenced in the second, fourth, and sixth lines and assigned in the third line, and variable C is in the sixth line. As a result, the variable X is substituted in the second line, and the variable Y is referred to in the fourth line. Second source code 1 -2 The same applies to.
[0024]
Variable information 3 generated in this way -1 , 3 -2 Are stored in the storage unit 4 as separate files. The table information generation unit 5 includes each variable information 3 stored in the storage unit 4. -1 , 3 -2 Using the above three table information 6 -1 ~ 6 -3 Is generated. FIG. 3 shows the two source codes 1 shown in FIG. -1 , 1 -2 Table information 6 generated when the target is the analysis target 6 -1 ~ 6 -3 FIG.
[0025]
In FIG. 3, the first table information 6 -1 Represents the correspondence between the variable and the sentence in which the assignment was made. This first table information 6 -1 Each variable A, B, C, X included in the -1 , 1 -2 All variables that are assigned in. The corresponding sentence indicates the place in the source code where the variable is assigned. For example, the variable A is the first source code 1 -1 The first line (indicated by 1-1) and the second source code 1 -2 Substitution is performed in the first line (indicated by 2-1).
[0026]
The second table information 6 -2 Indicates the correspondence between the variable and the sentence in which it was referenced. This second table information 6 -2 The variables A, B, D, X, and Y included in are all source code 1 to be analyzed -1 , 1 -2 All variables that are referenced in. The corresponding sentence indicates the location in the source code where the variable is referenced. For example, the variable A is the first source code 1 -1 The third line (denoted by 1-3) is referred to.
[0027]
The third table information 6 -3 Represents the correspondence between the sentence and the variable assigned there. This third table information 6 -3 Sentences 1-1, 1-2, 1-3, 1-6, 2-1, 2-2 included in are all source code 1 to be analyzed -1 , 1 -2 Represents all locations where substitution is performed, and the variables substituted at those locations are shown correspondingly. For example, the first source code 1 -1 In the first line, the variable A is substituted.
[0028]
In the example of FIG. 3, a sentence in which a variable is assigned or referred to is represented by 1-1, 1-2..., But one sentence may be described over a plurality of lines. As such, these notations do not indicate simple line numbers. Actually, each table information 6 -1 ~ 6 -3 Each source code 1 for the part representing the sentence -1 , 1 -2 A unique sentence ID is assigned to each sentence, and another table information representing the relationship between the sentence ID and the location in the source code where the sentence ID exists is provided.
[0029]
The analysis unit 7 includes three pieces of table information 6 shown in FIG. 3 generated by the table information generation unit 5. -1 ~ 6 -3 For example, the influence range is analyzed by following the substitution and reference relationship of a desired variable designated by the user listed in the target variable list 9, and the analysis result is output as a list 8.
[0030]
For example, to analyze the influence range of the variable A, first, the first table information 6 -1 The variable A is the source code 1 -1 , 1 -2 Find out where in the file it is assigned. Here, the first source code 1 -1 1st line and second source code 1 -2 It can be seen that substitution of variable A is performed in the first line. At this time, the detected substitution place is registered in the analysis result list 8.
[0031]
Next, the second table information 6 -2 The specified variable A is the source code 1 -1 , 1 -2 Find out where it is referenced in. Here, the first source code 1 -1 It can be seen that the variable A is referenced in the third line. At this point, the detected reference location is added to the analysis result list 8. Next, the third table information 6 -3 To see the second table information 6 -2 The variable A referred to in the place described in (2) is checked to which variable is assigned. Here, the first source code 1 -1 It can be seen that the variable A referenced in the third line is assigned to the variable B.
[0032]
In this case, since the value of the variable A is assigned to the variable B and affects other parts, it is necessary to check the influence range of the variable B next. Therefore, the second table information 6 -2 Again, variable B is the source code 1 -1 , 1 -2 Find out where it is referenced in. Here, the first source code 1 -1 2nd, 4th and 6th lines and the second source code 1 -2 It can be seen that the variable B is referred to in the third line. At this point, the detected reference locations are added to the analysis result list 8.
[0033]
Further, the third table information 6 -3 To see the second table information 6 -2 It is checked which variable is assigned to each variable B referenced at the location described in (1). Here, the first source code 1 -1 The variable B referenced in the second line is assigned to the variable X, and the first source code 1 -1 It can be seen that the variable B referred to in the sixth line is assigned to the variable C. The first source code 1 -1 The variable B referenced in the fourth line of the second source code 1 -2 Since the variable B referred to in the third line is not assigned to any variable, the processing ends here.
[0034]
Here, for the new variables X and C to which the value of the variable B is assigned, the second table information 6 is again checked in order to investigate the influence range. -2 , The variables X and C are the source code 1 -1 , 1 -2 Find out where it is referenced in. Here, the second source code 1 -2 It can be seen that the variable X is referred to in the third line. However, since this reference location is already registered in the analysis result list 8, it is not added to the analysis result list 8.
[0035]
Further, the third table information 6 -3 To see the second table information 6 -2 The variable X referred to in the place described in (2) is checked to which variable is assigned. Here, since the variable X is not assigned to any variable, all the analysis processes are completed here. As described above, the first table information 6 -1 From this point, the second table information 6 -2 And third table information 6 -3 By alternately accessing and tracing the variable assignment and reference relationship, the influence range of the variable A can be obtained. An analysis result list 8 of the influence range of the variable A obtained at this time is as shown in FIG.
[0036]
Although not occurring in the present example, the third table information 6 -3 To second table information 6 -2 When a variable that has already been analyzed is specified when returning to, the analysis results are terminated because only the same result as before can be obtained even if the variable is subsequently analyzed. For this purpose, history information as to which variable has been analyzed is held, and the above-described processing is executed while constantly updating and referring to this history information.
[0037]
As can be seen from the above description, in the influence analysis apparatus of this embodiment, each source code 1 -1 , 1 -2 All the variables with the same name contained in it are assumed to be the same variable. This is because, in most cases, variables that analyze the range of influence between multiple source codes are global variables (global variables), and the names are the same in all source codes. This is because there is no problem in identifying the name variable.
[0038]
Moreover, in the influence analysis apparatus of this embodiment, each source code 1 -1 , 1 -2 If a variable contained in it is assigned somewhere, we assume that all references to that variable depend on that assignment. In other words, the program control flow is completely ignored. For example, the first source code 1 -1 When the influence range of the variable A is analyzed in consideration of the control flow, the second line does not enter the influence range, but when the control flow is ignored as in this embodiment, the second line also enters the influence range ( In FIG. 4, 1-2 is also registered as a list of influence ranges).
[0039]
5 and 6 are flowcharts showing the processing procedure of the influence analysis method according to this embodiment. Of these, FIG. 5 shows variable information 3 stored in the storage unit 4 of FIG. -1 ~ 3 -n 3 table information from 6 -1 ~ 6 -3 The procedure of the table information generation unit 5 that generates the data, that is, the procedure of the preprocessing of the influence analysis by the analysis unit 7 is shown.
[0040]
In FIG. 5, first, in step S <b> 1, the user designates a source code group to be subjected to influence analysis for the table information generation unit 5. Here, it is possible to specify an arbitrary source code without being particularly conscious of the link unit. All source code given 1 -1 ~ 1 -n Can also be specified. Next, in step S2, the table information generation unit 5 reads variable information corresponding to each of the designated source code groups from the storage unit 4, respectively.
[0041]
That is, a plurality of source codes 1 -1 ~ 1 -n Variable information 3 corresponding to each of -1 ~ 3 -n Is generated in advance by the variable information generation unit 2 and stored in the storage unit 4, so that variable information corresponding to the specified source code group is read from the variable information generation unit 2. Then, in step S3, the first to third table information 6 described above for the entire read variable information. -1 ~ 6 -3 Is generated.
[0042]
FIG. 6 shows three pieces of table information 6 generated by the table information generator 5. -1 ~ 6 -3 The processing procedure of the analysis part 7 which performs the influence analysis of a variable using is shown. Before entering the flowchart of FIG. 6, it is assumed that the user separately specifies which variable the influence analysis is to be performed on and that variable is listed in the target variable list 9. In FIG. 6, first, in step S11, it is determined whether or not the user has specified a variable to be subjected to the influence analysis (in the example of FIG. 3, the variable A is specified). If a variable is specified, the first table information 6 is selected in step S12. -1 In step S13, the designated variable is the first table information 6 -1 It is judged whether it exists in.
[0043]
Here, the designated variable is the first table information 6 -1 If it exists, the process proceeds to step S14, and the first table information 6 corresponds to the variable. -1 The statements (in the example of FIG. 3, two assignment statements 1-1 and 2-1 in the example of FIG. 3) described in are registered in the analysis result list 8. Next, in step S15, the second table information 6 -2 In step S16, the designated variable is the second table information 6. -2 It is judged whether it exists in.
[0044]
Here, the specified variable is the second table information 6 -2 If it exists, the process proceeds to step S17, and the second table information 6 corresponds to the variable. -2 The statement (referred to as 1-3 reference statement in the example of FIG. 3) referred to in is added to the analysis result list 8. In step S18, the third table information 6 -3 In step S19, the second table information 6 -2 The reference sentence described in the table is the third table information 6 -3 It is judged whether it exists in.
[0045]
Here, the second table information 6 -2 The reference sentence described in the table is the third table information 6 -3 If so, the process proceeds to step S20, and the variable (the variable A in the example shown in FIG. 3) that has been assigned corresponding to the above-described reference sentence (the variable A in the example shown in FIG. 3) has been assigned. Replace with variable B). In this way, after changing the target variable name in the subsequent impact analysis processing, the process returns to step S15, and again the second table information 6 -2 Then, the same process is repeated.
[0046]
In step S19, the second table information 6 -2 The reference sentence described in the table is the third table information 6 -3 If there are a plurality of variables, in step S20, a plurality of variables to be processed in the subsequent processes are set. And in the process of subsequent step S15-S19, the same process is performed with respect to each of the set several variable. At this time, in step S16 and step S19, if there is at least one applicable item, the process is advanced according to the Yes branch for that applicable item.
[0047]
In any of the above steps S13, S16, S19, the first table information 6 -1 And second table information 6 -2 If the specified variable does not exist, or if the second table information 6 -2 The reference sentence described in the table is the third table information 6 -3 If not, the impact analysis process is terminated. Thus, when the influence analysis process is completed, the contents described in the analysis result list 8 represent the influence range of the variable to be obtained.
[0048]
As described above in detail, in the present embodiment, first, variable information related to the substitution / reference relationship of variables is generated for each source code to be analyzed. Next, under the condition that all the variables with the same name included in each source code are the same, and the control flow in the source code is ignored, three variables based on the variable information are used. Generate table information. Then, the influence range is obtained by following the substitution of variables and the reference relationship using these table information.
[0049]
Thus, a plurality of given source codes 1 -1 ~ 1 -n Even if it is not possible to specify which combination constitutes the link unit in the list, for example, if they are collectively analyzed, the range affected by the variable in the group can be analyzed. In addition, since the variables with the same name are analyzed even if they are included in different source codes, the range of influence is analyzed beyond the link unit that was limited by the analysis of the conventional variable effect analyzer. You can also.
[0050]
In addition, by imposing the condition of ignoring the control flow as described above, the influence analysis cannot be performed strictly, but each source code 1 -1 ~ 1 -n Since it is only necessary to obtain the assignment and reference information of variables that appear in each sentence in the statement, the unit for parsing is only required to be performed for each source code, and a somewhat good analysis result can be obtained within a practically executable time. it can.
[0051]
Furthermore, in this embodiment, the variable information 3 generated by the variable information generation unit 2 is described above. -1 ~ 3 -n Storage unit 4 for storing each variable information 3 -1 ~ 3 -n Is previously generated by the variable information generation unit 2 and stored in the storage unit 4. Therefore, the table information 6 is not used when it is desired to perform the influence analysis of a desired variable, instead of performing the above-described variable influence analysis processing in series. -1 ~ 6 -3 The impact analysis process can be further accelerated.
[0052]
In this case, in the first stage, all source code 1 -1 ~ 1 -n About each variable information 3 -1 ~ 3 -n However, after that, it is only necessary to generate variable information corresponding to only the changed source code and update the contents of the storage unit 4 only for that portion. This variable information 3 -1 ~ 3 -n The process itself for obtaining can be performed using a normal parsing method.
[0053]
In the above embodiment, when the analysis unit 7 performs the impact analysis, the first table information 6 -1 And then the second table information 6 -2 And third table information 6 -3 The analysis process was terminated when the corresponding variable or sentence no longer exists, but the second table information 6 -2 And third table information 6 -3 The analysis process may be terminated when the number of repetition processes reaches a predetermined number.
[0054]
Moreover, although the said embodiment demonstrated the example which designates only one desired variable which performs influence analysis, you may designate a some variable. In this case, the range of influence of a plurality of designated variables may be analyzed one by one in order, and the analysis results of each variable may be output as a separate list, or the analysis results of each variable may be output as one You may make it output according to a list. When outputting in accordance with one list, duplicate analysis results of each variable may be excluded.
[0055]
In the above-described embodiment, the case where the influence analysis of a single variable is performed has been described. However, the present invention can also be applied to a structure configured by collecting several variables of various types. In this case, for example, when a desired variable for effect analysis is specified in step S11 in FIG. 6, it is first determined whether or not the variable is a part of the structure. For example, other variables constituting the structure are also included in the target of the influence analysis. Thereafter, the processes in steps S12 to S20 may be executed for a plurality of variables constituting the structure.
[0056]
(Other embodiments of the present invention)
The influence analysis apparatus of the present embodiment described above is configured by a CPU or MPU of a computer, RAM, ROM, etc., and can be realized by operating a program stored in the RAM or ROM. It is included in the embodiment of the present invention. In addition, a program that causes a computer to perform the above functions can be realized by recording the program on a recording medium such as a CD-ROM and causing the computer to read the program. It is included in the embodiment. As a recording medium for recording the program, a flexible disk, a hard disk, a magnetic tape, a magneto-optical disk, a nonvolatile memory card, and the like can be used in addition to the CD-ROM.
[0057]
In addition, the functions of the above-described embodiments are realized by executing a program supplied by a computer, and the program is used in cooperation with an OS (operating system) or other application software running on the computer. When the functions of the above-described embodiment are realized, or when the functions of the above-described embodiment are realized by performing all or part of the processing of the supplied program by a function expansion board or function expansion unit of a computer Such a program is included in the embodiment of the present invention.
[0058]
【The invention's effect】
As described above, the present invention uses each variable information corresponding to each of at least one or more source codes to be analyzed, and represents a correspondence relationship between a variable that has been assigned or referred to and its location. Since multiple table information is generated and the variable influence range is obtained by tracing the variable assignment and reference relationship using the multiple table information, any combination of the given multiple source codes Therefore, it is possible to analyze the range of influence of a desired variable between related source codes without being aware of whether or not the link unit is configured.
[0059]
In addition, since the analysis is performed assuming that all the variables with the same name included in each source code are the same variable, it is possible to analyze the influence range beyond the link unit. Furthermore, analysis is performed assuming that all references to variables included in each source code are dependent on the assignment of the variables, so variable substitution and reference information that appears in each statement in each source code The analysis process can be executed in a short time.
[0060]
Furthermore, according to another feature of the present invention, the storage unit stores variable information corresponding to each source code, and the variable information is generated and stored in advance. When it is desired to perform an impact analysis, it is only necessary to start by generating table information using stored variable information, and the time required for the impact analysis process can be further shortened.
[Brief description of the drawings]
FIG. 1 is a block diagram showing a main functional configuration of an influence analysis apparatus according to the present embodiment.
FIG. 2 is a diagram illustrating a partial configuration example of source code;
FIG. 3 is a diagram showing the flow of influence analysis and three table information generated when the two source codes shown in FIG. 2 are analyzed.
FIG. 4 is a diagram illustrating an analysis result list of an influence range of a variable A.
FIG. 5 is a flowchart showing a processing procedure of an influence analysis method according to the present embodiment.
FIG. 6 is a flowchart showing a processing procedure of an influence analysis method according to the present embodiment.
[Explanation of symbols]
1 -1 ~ 1 -n Source code
2 Variable information generator
3 -1 ~ 3 -n Variable information
4 storage
5 Table information generator
6 -1 ~ 6 -3 Table information
7 Analysis Department
8 Analysis result list

Claims (8)

ソースコード中に含まれる変数が他の部分に与える影響を解析する影響解析装置であって、
解析の対象となる少なくとも1つ以上のソースコード毎に生成された、変数のデータ依存関係に関する少なくとも1つ以上の変数情報を対象として、代入または参照が行われた変数とその存在場所との対応関係を表す複数のテーブル情報を生成するテーブル生成手段と、
上記テーブル生成手段により生成された複数のテーブル情報を用いて、変数の代入および参照関係を辿ることによって変数の影響範囲を求める解析手段とを備え、
上記テーブル生成手段は、それぞれのソースコード毎に生成された各変数情報を対象として、変数とその代入が行われた文との対応関係を表す第1のテーブル情報、変数とその参照が行われた文との対応関係を表す第2のテーブル情報、文とそこで代入が行われた変数との対応関係を表す第3のテーブル情報を生成することを特徴とする影響解析装置。
An impact analysis device that analyzes the effects of variables included in source code on other parts,
Correspondence between variables that are assigned or referred to at least one or more variable information related to data dependency of variables generated for at least one or more source codes to be analyzed and their locations Table generating means for generating a plurality of table information representing the relationship;
Using a plurality of table information generated by the table generation means, and comprising an analysis means for determining the variable influence range by following the variable assignment and the reference relationship,
The table generation means performs, for each variable information generated for each source code, first table information representing a correspondence relationship between the variable and the sentence to which the substitution is performed, the variable and the reference thereof. An impact analysis apparatus characterized by generating second table information representing a correspondence relationship with a sentence and third table information representing a correspondence relationship between the sentence and a variable assigned thereto.
上記テーブル生成手段は、それぞれのソースコード中に含まれる同じ名前の変数を全て同じ変数であるとして上記複数のテーブル情報を生成することを特徴とする請求項1に記載の影響解析装置。  2. The influence analysis apparatus according to claim 1, wherein the table generation means generates the plurality of table information by assuming that all variables having the same name included in each source code are the same variable. 上記テーブル生成手段は、それぞれのソースコード中に含まれる変数がどこかで代入された場合に、その変数の全ての参照がその代入に依存しているものとして上記複数のテーブル情報を生成することを特徴とする請求項1または2に記載の影響解析装置。  When the variable included in each source code is assigned somewhere, the table generation means generates the plurality of table information on the assumption that all references to the variable depend on the assignment. The influence analysis device according to claim 1 or 2. 上記解析の対象となる少なくとも1つ以上のソースコードを読み込み、それぞれのソースコード毎に上記変数情報を生成する変数情報生成手段と、
上記変数情報生成手段により生成された各変数情報を保存する記憶手段とを備え、
上記テーブル生成手段および解析手段は、上記変数情報生成手段によりあらかじめ生成されて上記記憶手段に保存されている各変数情報を用いて、上記複数のテーブル情報の生成およびそれらを用いた影響解析を実行することを特徴とする請求項1〜3の何れか1項に記載の影響解析装置。
Variable information generating means for reading at least one source code to be analyzed and generating the variable information for each source code;
Storage means for storing each variable information generated by the variable information generating means,
The table generation means and the analysis means execute the generation of the plurality of table information and the influence analysis using them using the variable information generated in advance by the variable information generation means and stored in the storage means. The influence analysis apparatus according to any one of claims 1 to 3, wherein
ソースコード中に含まれる変数が他の部分に与える影響を解析する影響解析方法であって、
解析の対象となる少なくとも1つ以上のソースコード毎に生成された、変数のデータ依存関係に関する少なくとも1つ以上の変数情報を対象として、代入または参照が行われた変数とその存在場所との対応関係を表す複数のテーブル情報を生成するテーブル生成ステップと、
上記生成された複数のテーブル情報を用いて、変数の代入および参照関係を辿ることによって変数の影響範囲を求める解析ステップとを有し、
上記テーブル生成ステップでは、それぞれのソースコード毎に生成された各変数情報を対象として、変数とその代入が行われた文との対応関係を表す第1のテーブル情報、変数とその参照が行われた文との対応関係を表す第2のテーブル情報、文とそこで代入が行われた変数との対応関係を表す第3のテーブル情報を生成することを特徴とする影響解析方法。
An impact analysis method for analyzing the effects of variables included in source code on other parts,
Correspondence between variables that are assigned or referred to at least one or more variable information related to data dependency of variables generated for at least one or more source codes to be analyzed and their locations A table generation step for generating a plurality of table information representing the relationship;
Using the plurality of generated table information, an analysis step for determining the influence range of the variable by following the substitution and reference relationship of the variable,
In the table generation step, the first table information representing the correspondence relationship between the variable and the sentence in which the variable is assigned is referred to for each variable information generated for each source code. And generating second table information representing a correspondence relationship between the sentence and a third table information representing a correspondence relation between the sentence and a variable assigned thereto.
上記解析ステップでは、上記第1のテーブル情報を起点として、以降上記第2のテーブル情報と上記第3のテーブル情報とを交互にアクセスして上記変数の代入および参照関係を辿ることによって上記変数の影響範囲を求めることを特徴とする請求項5に記載の影響解析方法。  In the analysis step, from the first table information as a starting point, the second table information and the third table information are alternately accessed thereafter, and the substitution of the variables and the reference relationship are traced. The influence analysis method according to claim 5, wherein an influence range is obtained. 解析の対象となる少なくとも1つ以上のソースコード毎に生成された、変数のデータ依存関係に関する少なくとも1つ以上の変数情報を対象として、代入または参照が行われた変数とその存在場所との対応関係を表す複数のテーブル情報を生成するテーブル生成手段と、
上記テーブル生成手段により生成された複数のテーブル情報を用いて、変数の代入および参照関係を辿ることによって変数の影響範囲を求める解析手段としてコンピュータを機能させ、
かつ上記テーブル生成手段にて、それぞれのソースコード毎に生成された各変数情報を対象として、変数とその代入が行われた文との対応関係を表す第1のテーブル情報、変数とその参照が行われた文との対応関係を表す第2のテーブル情報、文とそこで代入が行われた変数との対応関係を表す第3のテーブル情報を生成するためのプログラムを記録したことを特徴とするコンピュータ読み取り可能な記録媒体。
Correspondence between variables that are assigned or referred to at least one or more variable information related to data dependency of variables generated for at least one or more source codes to be analyzed and their locations Table generating means for generating a plurality of table information representing the relationship;
Using the plurality of table information generated by the table generating means, the computer is caused to function as an analyzing means for determining the variable influence range by tracing the variable assignment and the reference relationship,
In the table generation means, the first table information representing the correspondence relationship between the variable and the sentence in which the variable is assigned, for each variable information generated for each source code, the variable and its reference are A program for generating second table information representing a correspondence relationship with a sentence performed and third table information representing a correspondence relationship between the sentence and a variable assigned there is recorded. Computer-readable recording medium.
解析の対象となる少なくとも1つ以上のソースコード毎に生成された、変数のデータ依存関係に関する少なくとも1つ以上の変数情報を対象として、代入または参照が行われた変数とその存在場所との対応関係を表す複数のテーブル情報を生成するテーブル生成手段と、
上記テーブル生成手段により生成された複数のテーブル情報を用いて、変数の代入および参照関係を辿ることによって変数の影響範囲を求める解析手段としてコンピュータを機能させ、
かつ上記テーブル生成手段にて、それぞれのソースコード毎に生成された各変数情報を対象として、変数とその代入が行われた文との対応関係を表す第1のテーブル情報、変数とその参照が行われた文との対応関係を表す第2のテーブル情報、文とそこで代入が行われた変数との対応関係を表す第3のテーブル情報を生成するためのプログラム。
Correspondence between variables that are assigned or referred to at least one or more variable information related to data dependency of variables generated for at least one or more source codes to be analyzed and their locations Table generating means for generating a plurality of table information representing the relationship;
Using the plurality of table information generated by the table generating means, the computer is caused to function as an analyzing means for determining the variable influence range by tracing the variable assignment and the reference relationship,
In the table generation means, the first table information representing the correspondence relationship between the variable and the sentence in which the variable is assigned, for each variable information generated for each source code, the variable and its reference are A program for generating second table information representing a correspondence relationship with a sentence performed, and third table information representing a correspondence relationship between the sentence and a variable subjected to the substitution.
JP2001194829A 2000-06-27 2001-06-27 Impact analysis apparatus and method, recording medium, and program Expired - Lifetime JP4782315B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2001194829A JP4782315B2 (en) 2000-06-27 2001-06-27 Impact analysis apparatus and method, recording medium, and program

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
JP2000193313 2000-06-27
JP2000-193313 2000-06-27
JP2000193313 2000-06-27
JP2001194829A JP4782315B2 (en) 2000-06-27 2001-06-27 Impact analysis apparatus and method, recording medium, and program

Publications (2)

Publication Number Publication Date
JP2002082802A JP2002082802A (en) 2002-03-22
JP4782315B2 true JP4782315B2 (en) 2011-09-28

Family

ID=26594796

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2001194829A Expired - Lifetime JP4782315B2 (en) 2000-06-27 2001-06-27 Impact analysis apparatus and method, recording medium, and program

Country Status (1)

Country Link
JP (1) JP4782315B2 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5151792B2 (en) * 2008-08-07 2013-02-27 富士通株式会社 Distributed development management program
JP5775829B2 (en) * 2012-01-30 2015-09-09 日立オートモティブシステムズ株式会社 Software structure visualization program and system
JP6242707B2 (en) * 2014-02-07 2017-12-06 富士通株式会社 Management program, management method, and management system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3307476B2 (en) * 1993-09-30 2002-07-24 富士通株式会社 Data item definition standardization device
JPH11327879A (en) * 1998-05-15 1999-11-30 Fujitsu Ltd Device and method for retrieving variable number and computer readable recording medium recording variable number retrieving program
JP3857842B2 (en) * 1999-11-16 2006-12-13 富士通株式会社 Program analysis apparatus and recording medium

Also Published As

Publication number Publication date
JP2002082802A (en) 2002-03-22

Similar Documents

Publication Publication Date Title
US7353505B2 (en) Tracing the execution path of a computer program
US20090249307A1 (en) Program analysis apparatus, program analysis method, and program storage medium
US8732676B1 (en) System and method for generating unit test based on recorded execution paths
Zaidman et al. Understanding Ajax applications by connecting client and server-side execution traces
JP2006185211A (en) Program analysis system, test execution device, and analysis method and program thereof
CN107015841B (en) Preprocessing method for program compiling and program compiling device
US8286141B2 (en) Instruction-trace generation program, instruction-trace generating device, and instruction-trace generating method
Schuster et al. Conformance checking for trace fragments using infix and postfix alignments
JP4782315B2 (en) Impact analysis apparatus and method, recording medium, and program
JP7380851B2 (en) Test script generation device, test script generation method and program
Wang et al. Fast reproducing web application errors
US6546526B2 (en) Active trace debugging for hardware description languages
Wang et al. JSTrace: Fast reproducing web application errors
CN112380133B (en) Method and device for simulating instruction set simulator by utilizing function library
CN114356783A (en) Method and device for automatically generating unit test code, storage medium and equipment
JP6878707B2 (en) Test equipment, test methods and test programs
Vasiliev et al. Integration of Business Process Definition, Analysis and Execution Tools Based on Block-structured Approach
GB2397905A (en) Method for automatically generating and ordering test scripts
JP2017041196A (en) Stub object determination device, method, and program
US20140173572A1 (en) Constraint derivation in context following for use with object code insertion
JPH0887417A (en) Compiler device
JP2007133632A (en) Method and program for setting security policy
Lin et al. Quality assurance through rigorous software specification and testing: a case study
CN117573564B (en) Method for automatically identifying differences based on gitlab code submitted log
JP5343840B2 (en) Program analysis apparatus and analysis method

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20080509

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20110308

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20110329

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20110527

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: 20110614

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

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20110707

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

Free format text: PAYMENT UNTIL: 20140715

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

Ref document number: 4782315

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

EXPY Cancellation because of completion of term