JP5578625B2 - Program analysis apparatus, program analysis method, and program - Google Patents
Program analysis apparatus, program analysis method, and program Download PDFInfo
- Publication number
- JP5578625B2 JP5578625B2 JP2011141953A JP2011141953A JP5578625B2 JP 5578625 B2 JP5578625 B2 JP 5578625B2 JP 2011141953 A JP2011141953 A JP 2011141953A JP 2011141953 A JP2011141953 A JP 2011141953A JP 5578625 B2 JP5578625 B2 JP 5578625B2
- Authority
- JP
- Japan
- Prior art keywords
- character string
- exclusion
- program
- regular expression
- source file
- 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.)
- Active
Links
Images
Description
本発明は、プログラムソースファイルの分析を行なうための、プログラム分析装置、プログラム分析方法、及びこれらを実現するためのプログラムに関する。 The present invention relates to a program analysis apparatus, a program analysis method, and a program for realizing these, for analyzing a program source file.
一般に、ソフトウェア開発においては、プログラムの欠陥(バグ)の検出、及び新規のプログラムの作成等のため、プログラムソースファイルの分析を行うことが必要となる場合がある。プログラムソースの分析は、例えば、プログラム言語に用意されている文字列検索コマンドに、対象となる関数名を順番に読み込ませ、プログラムソースファイルから、使用されている関数を抽出することによって行なわれている。 In general, in software development, it may be necessary to analyze a program source file in order to detect a defect (bug) in a program and create a new program. Analysis of the program source is performed, for example, by reading the target function name in order in the character string search command prepared in the program language and extracting the used function from the program source file. Yes.
具体的には、特許文献1は、入力された検索クエリに基づいて、知識データベースを参照しながら、データベースに登録されているプログラムソースファイルを検索するシステムを開示している。知識データベースには、抽出の対象となるソースコードに直接的又は間接的に関連する情報、例えば、プログラムに含まれていたバグに関する情報、変数の依存関係に関する情報等が格納されている。特許文献1に開示されたシステムでは、知識データベースを参照して検索が実行されるので、抽出精度の向上が図られると考えられる。
Specifically,
ところで、プログラムソースファイルから、直接、文字列検索コマンドによって関数名文字列の検索を行なった場合は、目的の関数の抽出精度が低くなる場合がある。例えば、「コメント部分の関数名が抽出された場合」、「文字列の中に抽出したい関数名と同じ文字の並びがあり、この文字列が誤って抽出された場合("111"を抽出したいが、"abc111efg"が抽出されてしまった場合)」等である。 By the way, when the function name character string is searched directly from the program source file by the character string search command, the extraction accuracy of the target function may be lowered. For example, “When the function name in the comment part is extracted”, “When the character string has the same character sequence as the function name to be extracted, and this character string is extracted by mistake (I want to extract“ 111 ” Is "abc111efg" has been extracted).
これに対して、特許文献1に開示されたシステムでは、上述したように、知識データベースを参照して検索が実行されるので、文字列検索コマンドのみを用いて検索を行なう場合に比べて、抽出精度の向上は図られると考えられる。
On the other hand, in the system disclosed in
しかしながら、特許文献1に開示されたシステムでは、抽出精度は、知識データベースに登録されている情報の内容に大きく影響されるので、知識データベースの完成度が低い場合は、誤った関数名が抽出されることがある。更に、誤った関数名が抽出された場合は、誤った関数名もそのまま出力されてしまう。このため、特許文献1に開示されたシステムであっても、依然、抽出精度が低くなる可能性が残っている。
However, in the system disclosed in
本発明の目的の一例は、上記問題を解消し、プログラムソースファイルから関数を抽出する際の抽出精度の向上を図り得る、プログラム分析装置、プログラム分析方法、及びプログラムを提供することにある。 An object of the present invention is to provide a program analysis apparatus, a program analysis method, and a program that can solve the above-described problems and improve the extraction accuracy when a function is extracted from a program source file.
上記目的を達成するため、本発明の一側面におけるプログラム分析装置は、
プログラムソースファイルからの抽出の対象となる関数に、正規表現の文字列を付加して、検索文字列を作成する、正規表現付加部と、
前記プログラムソースファイルに対して、前記正規表現付加部によって作成された前記検索文字列を用いて検索を行い、前記検索文字列を抽出する、ソースファイル検索部と、
抽出の対象となる前記関数又は前記関数とは別の関数に、前記正規表現とは別の排除用の正規表現の文字列を付加して、排除文字列を作成し、前記ソースファイル検索部による抽出の結果から、前記排除文字列に該当する箇所を排除する、文字列排除部と、
を備えている、ことを特徴とする。
In order to achieve the above object, a program analysis apparatus according to one aspect of the present invention provides:
A regular expression adding unit that creates a search string by adding a regular expression character string to a function to be extracted from a program source file;
A search for the program source file using the search character string created by the regular expression adding unit, and extracting the search character string, a source file search unit,
By adding a character string of a regular expression for exclusion different from the regular expression to the function to be extracted or a function different from the function, an exclusion character string is created, and the source file search unit A character string exclusion unit that eliminates a portion corresponding to the exclusion character string from the extraction result;
It is characterized by having.
また、上記目的を達成するため、本発明の一側面におけるプログラム分析方法は、
(a)プログラムソースファイルからの抽出の対象となる関数に、正規表現の文字列を付加して、検索文字列を作成する、ステップと、
(b)前記プログラムソースファイルに対して、前記(a)のステップによって作成された前記検索文字列を用いて検索を行い、前記検索文字列を抽出する、ステップと、
(c)抽出の対象となる前記関数又は前記関数とは別の関数に、前記正規表現とは別の排除用の正規表現の文字列を付加して、排除文字列を作成し、前記(b)のステップによる抽出の結果から、前記排除文字列に該当する箇所を排除する、ステップと、
を有する、ことを特徴とする。
In order to achieve the above object, a program analysis method according to one aspect of the present invention includes:
(A) adding a regular expression character string to a function to be extracted from a program source file to create a search character string; and
(B) searching the program source file using the search character string created by the step (a), and extracting the search character string;
(C) A character string of a regular expression for exclusion different from the regular expression is added to the function to be extracted or a function different from the function to create an exclusion character string; ) From the result of the extraction in step), the step corresponding to the excluded character string is excluded, and
It is characterized by having.
更に、上記目的を達成するため、本発明の一側面におけるプログラムは、
コンピュータに、
(a)プログラムソースファイルからの抽出の対象となる関数に、正規表現の文字列を付加して、検索文字列を作成する、ステップと、
(b)前記プログラムソースファイルに対して、前記(a)のステップによって作成された前記検索文字列を用いて検索を行い、前記検索文字列を抽出する、ステップと、
(c)抽出の対象となる前記関数又は前記関数とは別の関数に、前記正規表現とは別の排除用の正規表現の文字列を付加して、排除文字列を作成し、前記(b)のステップによる抽出の結果から、前記排除文字列に該当する箇所を排除する、ステップと、
を実行させることを特徴とする。
Furthermore, in order to achieve the above object, a program according to one aspect of the present invention is provided.
On the computer,
(A) adding a regular expression character string to a function to be extracted from a program source file to create a search character string; and
(B) searching the program source file using the search character string created by the step (a), and extracting the search character string;
(C) A character string of a regular expression for exclusion different from the regular expression is added to the function to be extracted or a function different from the function to create an exclusion character string; ) From the result of the extraction in step), the step corresponding to the excluded character string is excluded, and
Is executed.
以上のように本発明によれば、プログラムソースファイルから関数を抽出する際の抽出精度の向上を図ることができる。 As described above, according to the present invention, it is possible to improve extraction accuracy when a function is extracted from a program source file.
(実施の形態1)
以下、本発明の実施の形態1における、プログラム分析装置、プログラム分析方法、及びプログラムについて、図1〜図5を参照しながら説明する。
(Embodiment 1)
Hereinafter, a program analysis device, a program analysis method, and a program according to
[装置構成]
最初に、本実施の形態1におけるプログラム分析装置1の構成について図1を用いて説明する。図1は、本発明の実施の形態1におけるプログラム分析装置の構成を示すブロック図である。
[Device configuration]
First, the configuration of the
図1に示す本実施の形態1におけるプログラム分析装置1は、プログラムソースファイルから、そこで使用されている関数を抽出して、プログラムソースファイルの分析を行なう装置である。図1に示すように、プログラム分析装置1は、主に、正規表現付加部10と、ソースファイル検索部20と、文字列排除部40とを備えている。
A
このうち、正規表現付加部10は、プログラムソースファイルからの抽出の対象となる関数に、正規表現の文字列を付加して、検索文字列を作成する。また、ソースファイル検索部20は、プログラムソースファイルに対して、正規表現付加部10によって作成された検索文字列を用いて、検索を行い、プログラムソースファイルから検索文字列を抽出する。
Among these, the regular
また、文字列排除部40は、まず、抽出の対象となる関数、又はこの関数とは別の関数に、上述の正規表現とは別の排除用の正規表現の文字列を付加して、排除文字列を作成する。次に、文字列排除部40は、ソースファイル検索部20による抽出の結果から、排除文字列に該当する箇所を排除する。
In addition, the character
このように、プログラム分析装置1は、正規表現を用いて作成した検索文字列を用いることで、確実に抽出対象となった関数を抽出する。そして、抽出された関数の中に、誤って抽出された関数が含まれていても、プログラム分析装置1は、これらを、排除文字列を用いて排除する。このため、プログラム分析装置1によれば、プログラムソースファイルから関数を抽出する際の抽出精度の向上が図られる。
As described above, the
ここで、本実施の形態1におけるプログラム分析装置1の構成を更に具体的に説明する。図1に示すように、本実施の形態1では、プログラム分析装置1は、上述の正規表現付加部10、ソースファイル検索部20、及び文字列排除部40に加え、抽出結果ファイル出力部30と、最終抽出結果ファイル出力部50とを備えている。
Here, the configuration of the
更に、プログラム分析装置1は、各部による処理によって得られた情報を格納するために、関数格納部61と、正規表現格納部62と、ソースファイル格納部63と、検索文字列格納部64と、抽出結果格納部65と、抽出結果ファイル格納部66と、排除用正規表現格納部71と、排除文字列格納部72と、最終抽出結果格納部73と、最終抽出結果ファイル格納部74とを備えている。
Further, the
また、本実施の形態1では、正規表現付加部10は、関数読込部11と、正規表現読込部12とを備えている。関数読込部11は、検索に用いられる関数のリストを格納している関数格納部61から、検索の対象となる任意の関数(以下「検索関数」と表記する。)を選択し、選択した関数の名称を正規表現読込部12に引き渡す。
In the first embodiment, the regular
正規表現読込部12は、正規表現のリストを格納している正規表現格納部62から、正規表現を読み込み、これを検索関数の名称の前後に付与して、検索文字列を作成する。また、正規表現読込部12は、作成した検索文字列を、検索文字列格納部64に格納する。このとき、正規表現読込部12は、複数パターンの検査文字列を作成することができる。また、本実施の形態1では、後述する実施の形態2とは異なり、使用される正規表現は、予め、開発者によって作成され、正規表現格納部62に格納されている。
The regular
ソースファイル検索部20は、本実施の形態1では、まず、検索文字列格納部64から、検索に用いる検索文字列を読み込み、更に、ソースファイル格納部63が格納しているプログラムソースファイルを読み込む。なお、本実施の形態1において、プログラムソースファイルは、C言語で記述されている。また、ソースファイル格納部63は、予め、複数個のプログラムソースファイルを格納している。
In the first embodiment, the source
そして、ソースファイル検索部20は、1のプログラムソースファイル毎に、読み込んだ検索文字列を用いて、当該プログラムソースファイルに対して検索を実行する。その後、ソースファイル検索部20は、検索によってヒットした行を抽出し、抽出結果を、抽出結果格納部65に格納する。具体的には、ソースファイル検索部20は、抽出結果として、検索文字列、検索文字列を含むプログラムソースファイルの識別子、及び検索文字列が記述された行の番号を特定する情報を、抽出結果格納部65に出力する。
The source
また、ソースファイル検索部20は、複数の検索文字列が作成されている場合は、検索文字列毎に、ソースファイル格納部63に格納されている全プログラムソースファイルを検索する。そして、ソースファイル検索部20は、検索文字列毎に、全プログラムソースファイルからの抽出結果を、抽出結果格納部65に格納する。
Moreover, the source
抽出結果ファイル出力部30は、抽出結果格納部65に格納されている抽出結果を読み込み、読み込んだ抽出結果を、予め設定されたファイル形式に変換して、抽出結果ファイルとする。また、抽出結果ファイル出力部30は、抽出結果ファイルを、抽出結果ファイル格納部66に出力する。
The extraction result
また、文字列排除部40は、排除関数読込部41と、排除用正規表現読込部42と、排除処理部43とを備えている。排除関数読込部41は、誤抽出された関数を排除するため、関数格納部61に格納されている関数のリストから、任意の関数(以下「排除関数」と表記する。)を選択し、選択した排除関数の名称を排除用正規表現読込部42に引き渡す。
Further, the character
このとき、抽出結果から誤抽出の関数を排除する点からは、本実施の形態1では、検索関数として選択された関数が、全て、排除関数としても選択される。また、排除関数は、関数格納部61に格納されている関数のリスト以外のリストに予め用意されていても良く、この場合は、このリストから選択される。
At this time, from the point of eliminating the erroneous extraction function from the extraction result, in the first embodiment, all the functions selected as the search function are also selected as the exclusion function. The exclusion function may be prepared in advance in a list other than the list of functions stored in the
排除用正規表現読込部42は、排除用の正規表現のリストを格納している排除用正規表現格納部71から、排除用正規表現を読み込み、これを排除関数の名称の前後に付与して、排除文字列を作成する。このとき、排除用正規表現読込部42は、選択された排除関数毎に、全排除用正規表現を用いて、排除文字列を作成する。
The exclusion regular
また、排除用正規表現読込部42は、作成した排除文字列を、排除文字列格納部72に格納する。本実施の形態1では、排除用の正規表現も、予め、開発者によって作成され、排除用正規表現格納部71に格納されている。
Further, the exclusion regular
排除処理部43は、まず、抽出結果ファイル格納部66から、抽出結果ファイルを読み込み、更に、排除文字列格納部72から排除文字列を読み込む。そして、排除処理部43は、抽出結果ファイルに対して、排除文字列を用いて検索を実行し、ヒットした行を抽出結果ファイルから取り除く。
The
具体的には、排除処理部43は、排除文字列と抽出結果ファイルとを対比して、排除文字列に一致している検索文字列を特定する。そして、排除処理部43は、抽出結果ファイルから、一致している検索文字列、一致している検索文字列を含むプログラムソースファイルの識別子、及び一致している検索文字列が記述された行の番号を排除する。
Specifically, the
また、排除処理部43は、排除文字列格納部72に格納されている全ての排除文字列を用いて、抽出結果ファイル格納部66に格納されている全抽出結果ファイルを対象として、上記の検索及び排除を実行する。そして、排除処理部43は、排除文字列の排除された抽出結果ファイルを、最終抽出結果として、最終抽出結果格納部73に格納する。
Further, the
最終抽出結果ファイル出力部50は、最終抽出結果格納部73から最終抽出結果を読み込み、読み込んだ最終抽出結果を、設定されたファイル形式に変換して、最終抽出結果ファイルとする。また、最終抽出結果ファイル出力部50は、最終抽出結果ファイルを、最終抽出結果ファイル格納部74に出力する。
The final extraction result
具体的には、最終抽出結果ファイル出力部50は、最終抽出結果に基づいて、プログラムソースファイル毎に、各プログラムソースファイルに存在している関数及びその数を特定するデータを作成し、作成したデータを、最終抽出結果ファイルとして出力する。
Specifically, the final extraction result
[装置動作]
次に、本発明の実施の形態1におけるプログラム分析装置1の動作について図2及び図3を用いて説明する。また、本実施の形態1では、プログラム分析装置1を動作させることによって、プログラム分析方法が実施される。よって、本実施の形態1におけるプログラム分析方法の説明は、以下のプログラム分析装置1の動作説明に代える。
[Device operation]
Next, the operation of the
最初に、図2を用いて、プログラム分析装置における検索処理について説明する。図2は、本発明の実施の形態1におけるプログラム分析装置の検索処理時の動作を示すフロー図である。 First, search processing in the program analysis apparatus will be described with reference to FIG. FIG. 2 is a flowchart showing an operation during the search process of the program analysis apparatus according to the first embodiment of the present invention.
図2に示すように、まず、関数読込部11が、関数格納部61から検索の対象となる検索関数を選択し、選択した関数の名称を正規表現読込部12に引き渡す(ステップA1)。
As shown in FIG. 2, first, the
次に、正規表現読込部12は、正規表現格納部62から正規表現を読み込み、これを検索関数の名称の前後に付与して、検索文字列を作成する(ステップA2)。ステップA2では、正規表現読込部12は、作成した検索文字列を、検索文字列格納部64に格納する。
Next, the regular
次に、ソースファイル検索部20は、ソースファイル格納部63から読み込んだプログラムソースファイル毎に、検索文字列格納部64から読み込んだ検索文字列を用いて、当該プログラムソースファイルに対して検索を実行する(ステップA3)。ステップA3では、ソースファイル検索部20は、更に、検索によってヒットした行を抽出し、抽出結果を、抽出結果格納部65に格納する。
Next, for each program source file read from the source
次に、抽出結果ファイル出力部30は、ステップA3で抽出結果格納部65に格納された抽出結果を読み込み、読み込んだ抽出結果から抽出結果ファイルを作成し、これを抽出結果ファイル格納部66に出力する(ステップA4)。
Next, the extraction result
以上のステップA1〜A4の実行により、検索処理が終了する。また、本実施の形態1では、ステップA1〜A4は、関数格納部61に格納されている全ての関数について繰り返し実行される。
The search process is completed by executing the above steps A1 to A4. In the first embodiment, steps A1 to A4 are repeatedly executed for all functions stored in the
続いて、図3を用いて、プログラム分析装置における排除処理について説明する。図3は、本発明の実施の形態1におけるプログラム分析装置の排除処理時の動作を示すフロー図である。 Next, the exclusion process in the program analysis apparatus will be described with reference to FIG. FIG. 3 is a flowchart showing an operation during the exclusion process of the program analysis apparatus according to the first embodiment of the present invention.
図3に示すように、まず、排除関数読込部41は、関数格納部61に格納されている関数のリストから、任意の排除関数を選択し、選択した排除関数の名称を排除用正規表現読込部42に引き渡す(ステップB1)。
As shown in FIG. 3, first, the exclusion
次に、排除用正規表現読込部42は、排除用正規表現格納部71から排除用正規表現を読み込み、これを排除関数の名称の前後に付与して、排除文字列を作成する(ステップB2)。また、ステップB2は、選択された排除関数毎に、全排除用正規表現を用いて、実行される。
Next, the exclusion regular
次に、排除処理部43は、抽出結果ファイル格納部66から読み込んだ抽出結果ファイルに対して、排除文字列格納部72から読み込んだ排除文字列を用いて、検索を実行し、ヒットした行を抽出結果ファイルから取り除く(ステップB3)。
Next, the
ステップB3は、排除文字列格納部72に格納されている全ての排除文字列を用いて、抽出結果ファイル格納部66に格納されている全ファイルを対象として、実行される。また、排除処理部43は、排除文字列の排除された抽出結果ファイルを、最終抽出結果として、最終抽出結果格納部73に格納する。
Step B3 is executed for all the files stored in the extraction result file storage unit 66 using all the excluded character strings stored in the excluded character
次に、最終抽出結果ファイル出力部50は、最終抽出結果格納部73から最終抽出結果を読み込み、読み込んだ最終抽出結果を用いて、最終抽出結果ファイルを作成し、これを、最終抽出結果ファイル格納部74に出力する(ステップB4)。
Next, the final extraction result
[装置動作:具体例]
ここで、本実施の形態1におけるプログラム分析装置1の動作の具体例を、図4及び図5を用いて説明する。最初に、図4を用いて、正規表現付加部10、ソースファイル検索部20、及び抽出結果ファイル出力部30による検索処理について具体的に説明する。図4は、本実施の形態1におけるプログラム分析装置の検索処理時の具体的動作を説明するための図である。
[Device operation: Specific example]
Here, a specific example of the operation of the
[ステップA1、A2]
図4に示すように、まず、関数読込部11が、関数リスト61aから関数を読み込む。次に、正規表現読込部12が、正規表現リスト62aから正規表現を読み込み、検索関数の名称と正規表現とを組み合わせて、正規表現が付加された検索文字列のリスト64aを作成する。
[Steps A1, A2]
As shown in FIG. 4, first, the
具体的には、図4に示すステップA1及びA2では、各正規表現の”@”マークの部分が、関数リスト61aから取得された関数名に置き換えられている。この置き換えにより、検索文字列が作成されている。
Specifically, in steps A1 and A2 shown in FIG. 4, the part of the “@” mark in each regular expression is replaced with the function name acquired from the
[ステップA3]
次に、ソースファイル検索部20は、プログラムソースファイル群63aを構成する全てのソースファイルに対して、プログラムソースファイル・リスト63bと検索文字列リスト64aとを用いて検索を実行する。
[Step A3]
Next, the source
具体的には、図4に示すステップA3では、ソースファイル検索部20は、プログラムソースファイル毎に、全ての検索文字列について検索を実行する。そして、ソースファイル検索部20は、検索毎に、ソースファイル名、行番号、及びソース本文を抽出し、これらを抽出結果65aとして抽出結果格納部65(図1参照)に格納する。
Specifically, in step A3 shown in FIG. 4, the source
[ステップA4]
次に、抽出結果ファイル出力部30は、抽出結果65aから、重複しているエントリを排除する。その後、抽出結果ファイル出力部30は、抽出結果65aを、予め設定されたファイル形式に変換して、抽出結果ファイル68aを生成し、これを抽出結果ファイル格納部66に出力する。
[Step A4]
Next, the extraction result
具体的には、検索文字列が複数ある場合(検索文字列リスト64a)、抽出結果65aにおいて、重複しているエントリが存在している場合が考えられる。この場合、抽出結果ファイル出力部30は、抽出結果ファイル格納部66への抽出結果ファイルの出力の前に、重複しているエントリを排除する。図4に示すステップA4では、重複しているエントリには、取り消し線が付されている。
Specifically, when there are a plurality of search character strings (search
そして、まだ、処理が行なわれていない検索関数を用いて、再度、ステップA1〜A4が実行される。ステップA1〜A4は、関数格納部61に格納されている全ての関数について繰り返し実行される。
Then, Steps A1 to A4 are executed again using a search function that has not yet been processed. Steps A1 to A4 are repeatedly executed for all the functions stored in the
続いて、図5を用いて、文字列排除部40及び最終抽出結果ファイル出力部50による排除処理について具体的に説明する。図5は、本実施の形態1におけるプログラム分析装置の排除処理時の具体的動作を説明するための図である。
Next, the exclusion process by the character
[ステップB1、B2]
図5に示すように、まず、排除関数読込部41が、関数リスト61aから、排除関数となる関数を読み込む。次に、排除用正規表現読込部42が、排除用正規表現リスト71aから排除用正規表現を読み込み、抽出結果ファイル68aから誤抽出を排除し得る排除文字列を作成する。72aは、排除文字列のリストを示している。
[Steps B1, B2]
As shown in FIG. 5, first, the exclusion
具体的には、図5に示すステップB1及びB2では、排除用正規表現の”@”マークの部分が、関数リスト61aから取得された関数名に置き換えられている。この置き換えにより、排除用文字列が作成されている。
Specifically, in steps B1 and B2 shown in FIG. 5, the part of the “@” mark in the exclusion regular expression is replaced with the function name acquired from the
[ステップB3]
次に、排除処理部43は、抽出結果ファイル群73aを構成する全ての抽出結果ファイルを対象として、誤抽出された行の排除処理を実行する。具体的には、排除処理部43は、排除文字列の種類の数だけ、抽出結果ファイルを対象とする検索を実施して、抽出結果ファイル群68aから誤抽出の行を排除して、最終抽出結果73aを作成する。図5に示すステップB3では、誤抽出の行には、取り消し線が付されている。その後、排除処理部43は、最終抽出結果73aを、最終抽出結果格納部73に格納する。
[Step B3]
Next, the
[ステップB4]
次に、最終抽出結果ファイル出力部50は、最終抽出結果73aに対してレイアウト編集を行ない、レイアウト編集後の最終抽出結果を、最終抽出結果ファイル74aとして出力する。図5の例では、最終抽出結果ファイル出力部50は、縦軸が検索関数名、横軸がプログラムソースファイル名とされたテーブルを作成する。また、最終抽出結果ファイル出力部50は、テーブルの各欄には、検索関数毎の各プログラムソースファイルについての使用回数を配置する。
[Step B4]
Next, the final extraction result
そして、まだ、処理が行なわれていない排除関数を用いて、再度、ステップB1〜B4が実行される。ステップB1〜B4は、関数格納部61に格納されている全ての関数について繰り返し実行される。また、ステップB1〜B4が実行される度に、最終抽出結果ファイル74aに、「行」が追加される。
Then, Steps B1 to B4 are executed again using an exclusion function that has not yet been processed. Steps B1 to B4 are repeatedly executed for all the functions stored in the
また、本実施の形態1におけるプログラムは、コンピュータに、図2に示すステップA1〜A4、図3に示すステップB1〜B4を実行させるプログラムであれば良い。このプログラムをコンピュータにインストールし、実行することによって、本実施の形態1におけるプログラム分析装置1とプログラム分析方法とを実現することができる。
Moreover, the program in this
この場合、コンピュータのCPU(Central Processing Unit)は、正規表現付加部10、ソースファイル検索部20、抽出結果ファイル出力部30、文字列排除部40、及び最終抽出結果ファイル出力部50として機能し、処理を行なう。
In this case, the CPU (Central Processing Unit) of the computer functions as the regular
更に、本実施の形態1では、コンピュータに備えられたハードディスク等の記憶装置が、関数格納部61、正規表現格納部62、ソースファイル格納部63、検索文字列格納部64、抽出結果格納部65、抽出結果ファイル格納部66、排除用正規表現格納部71、排除文字列格納部72、最終抽出結果格納部73、及び最終抽出結果ファイル格納部74として機能する。
Further, in the first embodiment, a storage device such as a hard disk provided in the computer includes a
以上のように本実施の形態1によれば、アプリケーションプログラムで使用されている関数を高精度で抽出して集計可能となる。よって、OS(Operation System)の移行(例えば、UNIX(登録商標)からLinuxへの移行等)、バージョンアップ等において、アプリケーションプログラムの影響範囲(件数、規模)の算出が容易となる。 As described above, according to the first embodiment, the functions used in the application program can be extracted and aggregated with high accuracy. Therefore, in the OS (Operation System) migration (for example, migration from UNIX (registered trademark) to Linux), version upgrade, etc., it is easy to calculate the influence range (number of cases, scale) of the application program.
また、本実施の形態1によれば、各関数がどのアプリケーションプログラムで使用されているかを管理することが容易にできるようになるため、ソフトウェア開発、テストでの進捗指標として利用可能となる。更に、本実施の形態1は、検索対象となる関数の条件、及び正規表現の条件を変更することにより、様々なプログラム言語にも適用することができる。 Further, according to the first embodiment, it is possible to easily manage which application program is used for each function, and therefore, it can be used as a progress indicator in software development and testing. Furthermore, the first embodiment can be applied to various programming languages by changing the condition of the function to be searched and the condition of the regular expression.
(実施の形態2)
次に、本発明の実施の形態2におけるプログラム分析装置、プログラム分析方法、及びプログラムについて、図6〜図8を参照しながら説明する。
(Embodiment 2)
Next, a program analysis device, a program analysis method, and a program according to
[装置構成]
最初に、本実施の形態2におけるプログラム分析装置2の構成について図6及び図7を用いて説明する。図6は、本発明の実施の形態2におけるプログラム分析装置の構成を示すブロック図である。図7は、図6に示した正規表現生成処理部の構成を具体的に示すブロック図である。
[Device configuration]
First, the configuration of the
図6に示すように、本実施の形態2におけるプログラム分析装置2は、図1に示した実施の形態1におけるプログラム分析装置1と異なり、正規表現生成処理部80を備えている。それ以外の点では、本実施の形態2におけるプログラム分析装置2は、実施の形態1におけるプログラム分析装置1と同様に構成されている。
As shown in FIG. 6, the
正規表現生成処理部80は、プログラムソースファイルの行毎に、当該行に含まれる関数の前後に位置する文字列を抽出し、抽出した文字列を用いて、正規表現付加部10で関数に付加する正規表現を作成する。
The regular expression
具体的には、図7に示すように、正規表現生成処理部80は、代表ソースファイル読込部81と、文字列パターン分析部82と、正規表現生成部83と、代表ソースファイル展開部84と、文字列パターン格納部85とを備えている。
Specifically, as shown in FIG. 7, the regular expression
代表ソースファイル読込部81は、検索対象となるプログラムソースファイルを格納しているソースファイル格納部63から、代表となる1又は2以上のプログラムソースファイルを読み込み、読み込んだプログラムソースファイルを代表ソースファイル展開部84に展開する。
The representative source
文字列パターン分析部82は、展開されたプログラムソースファイルを1行ずつ分析して、関数の前後にある文字列パターン、例えば、空白の個数、「(」等の記号の有無、などを特定し、特定した文字列パターンを、文字列パターン格納部85に格納する。このとき、文字列パターン分析部82は、同じ文字列パターンが重複して格納されないようにする。
The character string
正規表現生成部83は、文字列パターン格納部85に格納されている文字列パターンを用いて、正規表現を作成し、これをリストの形式(図4参照)で、正規表現格納部62に出力する。
The regular
[装置動作]
次に、本発明の実施の形態2におけるプログラム分析装置2の動作について図8を用いて説明する。図8は、本発明の実施の形態2におけるプログラム分析装置の正規表現生成処理時の動作を示すフロー図である。なお、本実施の形態2においては、検索処理及び排除処理は、実施の形態1と同様に実行されるので、説明を省略する。
[Device operation]
Next, the operation of the
また、本実施の形態2においても、プログラム分析装置2を動作させることによって、プログラム分析方法が実施される。よって、本実施の形態2におけるプログラム分析方法の説明も、以下のプログラム分析装置2の動作説明に代える。
In the second embodiment, the program analysis method is also implemented by operating the
図8に示すように、まず、代表ソースファイル読込部81が、ソースファイル格納部63から、代表となる1又は2以上のプログラムソースファイルを読み込み、これを代表ソースファイル展開部84に展開する(ステップC1)。
As shown in FIG. 8, first, the representative source
次に、文字列パターン分析部82が、展開されたプログラムソースファイルを1行ずつ分析して、関数の前後にある文字列パターンを特定し、これを文字列パターン格納部85に格納する(ステップC2)。
Next, the character string
次に、正規表現生成部83が、ステップC2で生成された文字列パターンを用いて、正規表現を作成する(ステップC3)。その後、正規表現生成部83は、作成した正規表現を用いて正規表現のリストを作成し、作成したリストを正規表現格納部62に出力する(ステップC3)。
Next, the regular
また、本実施の形態2におけるプログラムは、コンピュータに、図2に示すステップA1〜A4、図3に示すステップB1〜B4、更に、図8に示すステップC1〜C4を実行させるプログラムであれば良い。このプログラムをコンピュータにインストールし、実行することによって、本実施の形態2におけるプログラム分析装置2とプログラム分析方法とを実現することができる。
Moreover, the program in this
この場合、コンピュータのCPU(Central Processing Unit)は、正規表現付加部10、ソースファイル検索部20、抽出結果ファイル出力部30、文字列排除部40、及び最終抽出結果ファイル出力部50、代表ソースファイル読込部81、文字列パターン分析部82、及び正規表現生成部83として機能し、処理を行なう。
In this case, the CPU (Central Processing Unit) of the computer includes a regular
更に、本実施の形態2では、コンピュータに備えられたハードディスク等の記憶装置が、関数格納部61、正規表現格納部62、ソースファイル格納部63、検索文字列格納部64、抽出結果格納部65、抽出結果ファイル格納部66、排除用正規表現格納部71、排除文字列格納部72、最終抽出結果格納部73、最終抽出結果ファイル格納部74、代表ソースファイル展開部84、及び文字列パターン格納部85として機能する。
Further, in the second embodiment, a storage device such as a hard disk provided in the computer includes a
以上のように本実施の形態2によれば、用意されているプログラムソースファイルを用いて、正規表現を作成することができるので、関数の抽出精度をより高める事が可能となる。また、本実施の形態2を用いた場合も、実施の形態1と同様の効果を得ることができる。 As described above, according to the second embodiment, a regular expression can be created using a prepared program source file, so that the accuracy of function extraction can be further increased. In addition, when the second embodiment is used, the same effect as the first embodiment can be obtained.
(実施の形態3)
次に、本発明の実施の形態3におけるプログラム分析装置、プログラム分析方法、及びプログラムについて、図9〜図11を参照しながら説明する。
(Embodiment 3)
Next, a program analysis device, a program analysis method, and a program according to
[装置構成]
最初に、本実施の形態3におけるプログラム分析装置3の構成について図9及び図10を用いて説明する。図9は、本発明の実施の形態3におけるプログラム分析装置の構成を示すブロック図である。図10は、図9に示した関数置換部の構成を具体的に示すブロック図である。
[Device configuration]
First, the configuration of the
図9に示すように、本実施の形態3におけるプログラム分析装置2は、図1に示した実施の形態1におけるプログラム分析装置1と異なり、関数置換部90を備えている。それ以外の点では、本実施の形態3におけるプログラム分析装置3は、実施の形態1におけるプログラム分析装置1と同様に構成されている。
As shown in FIG. 9, the
関数置換部90は、まず、特定の関数と抽出結果ファイル(図4参照)とを対比して、特定の関数を含む検索文字列を特定する。そして、関数置換部90は、特定した検索文字列を含むプログラムソースファイルの識別子、及び特定した検索文字列が記述された行の番号に基づいて、特定した検索文字列を含むプログラムソースファイル中の特定の関数を、他の関数に置き換える。
First, the
具体的には、図10に示すように、関数置換部90は、置換対象関数読込部91と、抽出結果ファイル読込部92と、ソースファイル置換部93と、置換済みソースファイル出力部94と、置換対象関数格納部95と、抽出結果ファイル展開部96と、置換済みソースファイル格納部97とを備えている。
Specifically, as shown in FIG. 10, the
置換対象関数格納部95は、置き換え元の関数と置き換え先の関数とが一対一となった関数セットを格納している。置換対象関数読込部91は、置換対象関数格納部95から、関数セットを1セット読み込み、これを抽出結果ファイル読込部92に引き渡す。
The replacement target
抽出結果ファイル読込部92は、関数セットを参照して、抽出結果ファイル格納部66から、置き換え元の関数を検索文字列として得られた抽出結果ファイルを読み込み、これを、抽出結果ファイル展開部96に展開する。このとき、読み込まれる抽出結果ファイルは、1つに限定されず、2以上であっても良い。
The extraction result
ソースファイル置換部93は、抽出結果展開部96に展開されている抽出結果ファイルから、検索対象となったプログラムソースファイルを特定し、その名称を読み取る。また、名称が読み取られたプログラムソースファイルが関数置換の対象となるので、ソースファイル置換部93は、このプログラムソースファイルを、ソースファイル格納部63から読み取る。
The source
ソースファイル置換部93は、抽出結果ファイルに基づいて、読み取ったプログラムソースファイル内の置き換え元の関数を特定し、これを、置き換え先の関数に置換して、置換済みプログラムソースファイルを生成する。また、ソースファイル置換部93は、生成した置換済みプログラムソースファイルを、置換済みソースファイル格納部97に格納する。
Based on the extraction result file, the source
置換済みソースファイル出力部94は、置換済みソースファイル格納部97に格納されている置換済みプログラムソースファイルを、ソースファイル格納部63に出力する。これにより、ソースファイル格納部63は、特定の関数が別の関数に置換されたプログラムソースファイルを格納することになる。
The replaced source file output unit 94 outputs the replaced program source file stored in the replaced source
[装置動作]
次に、本発明の実施の形態3におけるプログラム分析装置3の動作について図11を用いて説明する。図11は、本発明の実施の形態3におけるプログラム分析装置の関数置換処理時の動作を示すフロー図である。なお、本実施の形態3においては、検索処理及び排除処理は、実施の形態1と同様に実行されるので、説明を省略する。
[Device operation]
Next, the operation of the
また、本実施の形態3においても、プログラム分析装置3を動作させることによって、プログラム分析方法が実施される。よって、本実施の形態3におけるプログラム分析方法の説明も、以下のプログラム分析装置3の動作説明に代える。
Also in the third embodiment, the program analysis method is implemented by operating the
図11に示すように、まず、置換対象関数読込部91が、置換対象関数格納部95から、関数セットを1セット読み込む(ステップD1)。
As shown in FIG. 11, first, the replacement target
次に、抽出結果ファイル読込部92が、関数セットを参照して、抽出結果ファイル格納部66から、置き換え元の関数を検索文字列として得られた抽出結果ファイルを読み込む(ステップD2)。ステップD2において、読み込まれた抽出結果ファイルは、抽出結果ファイル展開部96に展開される。
Next, the extraction result
次に、ソースファイル置換部93が、展開されている抽出結果ファイルに基づいて、ソースファイル格納部63から、関数置換の対象となるプログラムソースファイルを読み取る(ステップD3)。
Next, based on the extracted extraction result file, the source
次に、ソースファイル置換部93が、抽出結果ファイルに基づいて、読み取ったプログラムソースファイル内の置き換え元の関数を、置き換え先の関数に置換して、置換済みプログラムソースファイルを生成する(ステップD4)。
Next, the source
その後、置換済みソースファイル出力部94が、ステップD4で作成された置換済みプログラムソースファイルを、ソースファイル格納部63に出力する(ステップD5)。これにより、関数置換処理は終了する。但し、ステップD3〜D5は、抽出結果ファイル展開部96に展開されているプログラムソースファイルの数だけ、繰り返し実行される。
Thereafter, the replaced source file output unit 94 outputs the replaced program source file created in step D4 to the source file storage unit 63 (step D5). Thereby, the function replacement process ends. However, steps D3 to D5 are repeatedly executed as many times as the number of program source files expanded in the extraction result
また、本実施の形態3におけるプログラムは、コンピュータに、図2に示すステップA1〜A4、図3に示すステップB1〜B4、更に、図11に示すステップD1〜D5を実行させるプログラムであれば良い。このプログラムをコンピュータにインストールし、実行することによって、本実施の形態3におけるプログラム分析装置3とプログラム分析方法とを実現することができる。
Moreover, the program in this
この場合、コンピュータのCPU(Central Processing Unit)は、正規表現付加部10、ソースファイル検索部20、抽出結果ファイル出力部30、文字列排除部40、及び最終抽出結果ファイル出力部50、置換対象関数読込部91、抽出結果ファイル読込部92、ソースファイル置換部93、及び置換済みソースファイル出力部94として機能し、処理を行なう。
In this case, the CPU (Central Processing Unit) of the computer includes a regular
更に、本実施の形態3では、コンピュータに備えられたハードディスク等の記憶装置が、関数格納部61、正規表現格納部62、ソースファイル格納部63、検索文字列格納部64、抽出結果格納部65、抽出結果ファイル格納部66、排除用正規表現格納部71、排除文字列格納部72、最終抽出結果格納部73、最終抽出結果ファイル格納部74、置換対象関数格納部95、抽出結果ファイル展開部96、及び置換済みソースファイル格納部97として機能する。
Further, in the third embodiment, a storage device such as a hard disk provided in the computer includes a
以上のように、本実施の形態3では、抽出結果ファイルから、プログラムソースファイルで使用されている関数の行と位置とを特定できることを利用して、対象となる関数文字列を書き換えることができる。本実施の形態3によれば、関数の自動置換、対象となる関数の引数の自動置換が可能となる。また、本実施の形態3を用いた場合も、実施の形態1と同様の効果を得ることができる。 As described above, in the third embodiment, it is possible to rewrite the target function character string by using the fact that the line and position of the function used in the program source file can be specified from the extraction result file. . According to the third embodiment, automatic replacement of a function and automatic replacement of an argument of a target function can be performed. Further, when the third embodiment is used, the same effect as that of the first embodiment can be obtained.
ここで、実施の形態1〜3におけるプログラムを実行することによって、プログラム分析装置を実現するコンピュータについて図12を用いて説明する。図12は、本発明の実施の形態1〜3におけるプログラム分析装置を実現するコンピュータの一例を示すブロック図である。 Here, a computer that realizes the program analysis apparatus by executing the programs in the first to third embodiments will be described with reference to FIG. FIG. 12 is a block diagram illustrating an example of a computer that implements the program analysis apparatus according to the first to third embodiments of the present invention.
図12に示すように、コンピュータ110は、CPU111と、メインメモリ112と、記憶装置113と、入力インターフェイス114と、表示コントローラ115と、データリーダ/ライタ116と、通信インターフェイス117とを備える。これらの各部は、バス121を介して、互いにデータ通信可能に接続される。
As shown in FIG. 12, the
CPU111は、記憶装置113に格納された、本実施の形態におけるプログラム(コード)をメインメモリ112に展開し、これらを所定順序で実行することにより、各種の演算を実施する。メインメモリ112は、典型的には、DRAM(Dynamic Random Access Memory)等の揮発性の記憶装置である。また、本実施の形態におけるプログラムは、コンピュータ読み取り可能な記録媒体120に格納された状態で提供される。なお、本実施の形態におけるプログラムは、通信インターフェイス117を介して接続されたインターネット上で流通するものであっても良い。
The CPU 111 performs various calculations by developing the program (code) in the present embodiment stored in the
また、記憶装置113の具体例としては、ハードディスクの他、フラッシュメモリ等の半導体記憶装置が挙げられる。入力インターフェイス114は、CPU111と、キーボード及びマウスといった入力機器118との間のデータ伝送を仲介する。表示コントローラ115は、ディスプレイ装置119と接続され、ディスプレイ装置119での表示を制御する。データリーダ/ライタ116は、CPU111と記録媒体120との間のデータ伝送を仲介し、記録媒体120からのプログラムの読み出し、及びコンピュータ110における処理結果の記録媒体120への書き込みを実行する。通信インターフェイス117は、CPU111と、他のコンピュータとの間のデータ伝送を仲介する。
Specific examples of the
また、記録媒体120の具体例としては、CF(Compact Flash)及びSD(Secure Digital)等の汎用的な半導体記憶デバイス、フレキシブルディスク(Flexible Disk)等の磁気記憶媒体、又はCD−ROM(Compact Disk Read Only Memory)などの光学記憶媒体が挙げられる。
Specific examples of the
上述した実施の形態の一部又は全部は、以下に記載する(付記1)〜(付記18)によって表現することができるが、以下の記載に限定されるものではない。 Part or all of the above-described embodiments can be expressed by (Appendix 1) to (Appendix 18) described below, but is not limited to the following description.
(付記1)
プログラムソースファイルからの抽出の対象となる関数に、正規表現の文字列を付加して、検索文字列を作成する、正規表現付加部と、
前記プログラムソースファイルに対して、前記正規表現付加部によって作成された前記検索文字列を用いて検索を行い、前記検索文字列を抽出する、ソースファイル検索部と、
抽出の対象となる前記関数又は前記関数とは別の関数に、前記正規表現とは別の排除用の正規表現の文字列を付加して、排除文字列を作成し、前記ソースファイル検索部による抽出の結果から、前記排除文字列に該当する箇所を排除する、文字列排除部と、
を備えている、ことを特徴とするプログラム分析装置。
(Appendix 1)
A regular expression adding unit that creates a search string by adding a regular expression character string to a function to be extracted from a program source file;
A search for the program source file using the search character string created by the regular expression adding unit, and extracting the search character string, a source file search unit,
By adding a character string of a regular expression for exclusion different from the regular expression to the function to be extracted or a function different from the function, an exclusion character string is created, and the source file search unit A character string exclusion unit that eliminates a portion corresponding to the exclusion character string from the extraction result;
A program analyzer characterized by comprising:
(付記2)
前記プログラムソースファイルの行毎に、当該行に含まれる関数の前後に位置する文字列を抽出し、抽出した前記文字列を用いて、前記抽出の対象となる関数に付加する正規表現を作成する、正規表現生成処理部を更に備えている、
付記1に記載のプログラム分析装置。
(Appendix 2)
For each line of the program source file, a character string located before and after the function included in the line is extracted, and a regular expression to be added to the function to be extracted is created using the extracted character string. , Further comprising a regular expression generation processing unit,
The program analyzer according to
(付記3)
前記ソースファイル検索部が、前記抽出の結果として、前記検索文字列、前記検索文字列を含むプログラムソースファイルの識別子、及び前記検索文字列が記述された行の番号を特定する情報を出力する、
付記1または2に記載のプログラム分析装置。
(Appendix 3)
The source file search unit outputs, as a result of the extraction, information specifying the search character string, an identifier of a program source file including the search character string, and a line number in which the search character string is described.
The program analyzer according to
(付記4)
前記文字列排除部が、前記排除文字列と前記抽出の結果とを対比して、前記排除文字列に一致している前記検索文字列を特定し、前記抽出の結果から、前記一致している前記検索文字列、前記一致している前記検索文字列を含むプログラムソースファイルの識別子、及び前記一致している前記検索文字列が記述された行の番号を排除する、
付記3に記載のプログラム分析装置。
(Appendix 4)
The character string exclusion unit compares the excluded character string with the extraction result, identifies the search character string that matches the excluded character string, and matches the matching result from the extraction result. Eliminating the search character string, the identifier of the program source file containing the matching search character string, and the line number in which the matching search character string is described;
The program analyzer according to
(付記5)
前記文字列排除部によって前記排除文字列に該当する箇所が排除された前記抽出の結果に基づいて、前記プログラムソースファイル毎に、当該プログラムソースファイルに存在している関数及びその数を特定するデータを作成し、作成した前記データを出力する、出力部を更に備えている、
付記4に記載のプログラム分析装置。
(Appendix 5)
Data for specifying the function and the number of functions existing in the program source file for each program source file based on the extraction result in which the portion corresponding to the excluded character string is excluded by the character string exclusion unit And an output unit for outputting the created data.
The program analyzer according to
(付記6)
特定の関数と前記抽出の結果とを対比して、前記特定の関数を含む前記検索文字列を特定し、特定した前記検索文字列を含むプログラムソースファイルの識別子、及び特定した前記検索文字列が記述された行の番号に基づいて、特定した前記検索文字列を含むプログラムソースファイル中の前記特定の関数を、他の関数に置き換える、関数置換部を更に備えている、
付記3〜5のいずれかに記載のプログラム分析装置。
(Appendix 6)
A specific function and the result of the extraction are compared to specify the search character string including the specific function, an identifier of a program source file including the specified search character string, and the specified search character string A function replacing unit that replaces the specific function in the program source file including the specified search character string with another function based on the number of the described line;
The program analyzer according to any one of
(付記7)
(a)プログラムソースファイルからの抽出の対象となる関数に、正規表現の文字列を付加して、検索文字列を作成する、ステップと、
(b)前記プログラムソースファイルに対して、前記(a)のステップによって作成された前記検索文字列を用いて検索を行い、前記検索文字列を抽出する、ステップと、
(c)抽出の対象となる前記関数又は前記関数とは別の関数に、前記正規表現とは別の排除用の正規表現の文字列を付加して、排除文字列を作成し、前記(b)のステップによる抽出の結果から、前記排除文字列に該当する箇所を排除する、ステップと、
を有する、ことを特徴とするプログラム分析方法。
(Appendix 7)
(A) adding a regular expression character string to a function to be extracted from a program source file to create a search character string; and
(B) searching the program source file using the search character string created by the step (a), and extracting the search character string;
(C) A character string of a regular expression for exclusion different from the regular expression is added to the function to be extracted or a function different from the function to create an exclusion character string; ) From the result of the extraction in step), the step corresponding to the excluded character string is excluded, and
A program analysis method characterized by comprising:
(付記8)
(d)前記プログラムソースファイルの行毎に、当該行に含まれる関数の前後に位置する文字列を抽出し、抽出した前記文字列を用いて、前記抽出の対象となる関数に付加する正規表現を作成する、ステップを更に有する、
付記7に記載のプログラム分析方法。
(Appendix 8)
(D) For each line of the program source file, extract a character string located before and after the function included in the line, and use the extracted character string to add a regular expression to the function to be extracted Further comprising the steps of:
The program analysis method according to appendix 7.
(付記9)
前記(b)のステップで、前記抽出の結果として、前記検索文字列、前記検索文字列を含むプログラムソースファイルの識別子、及び前記検索文字列が記述された行の番号を特定する情報を出力する、
付記7または8に記載のプログラム分析方法。
(Appendix 9)
In the step (b), as the result of the extraction, the search character string, the identifier of the program source file including the search character string, and the information specifying the line number in which the search character string is described are output. ,
The program analysis method according to appendix 7 or 8.
(付記10)
前記(c)のステップで、前記排除文字列と前記抽出の結果とを対比して、前記排除文字列に一致している前記検索文字列を特定し、前記抽出の結果から、前記一致している前記検索文字列、前記一致している前記検索文字列を含むプログラムソースファイルの識別子、及び前記一致している前記検索文字列が記述された行の番号を排除する、
付記9に記載のプログラム分析方法。
(Appendix 10)
In the step (c), the searched character string that matches the excluded character string is specified by comparing the excluded character string and the extraction result, and the matching result is determined based on the extracted result. The search character string, the identifier of the program source file including the matching search character string, and the line number in which the matching search character string is described, are excluded.
The program analysis method according to appendix 9.
(付記11)
(e)前記(c)のステップによって前記排除文字列に該当する箇所が排除された前記抽出の結果に基づいて、前記プログラムソースファイル毎に、当該プログラムソースファイルに存在している関数及びその数を特定するデータを作成し、作成した前記データを出力する、ステップを更に有する、
付記10に記載のプログラム分析方法。
(Appendix 11)
(E) Based on the result of the extraction in which the portion corresponding to the excluded character string is excluded by the step (c), for each program source file, the functions existing in the program source file and the number thereof The method further includes the step of creating data for specifying the data and outputting the created data.
The program analysis method according to
(付記12)
(f)特定の関数と前記抽出の結果とを対比して、前記特定の関数を含む前記検索文字列を特定し、特定した前記検索文字列を含むプログラムソースファイルの識別子、及び特定した前記検索文字列が記述された行の番号に基づいて、特定した前記検索文字列を含むプログラムソースファイル中の前記特定の関数を、他の関数に置き換える、ステップを更に有する、
付記9〜11のいずれかに記載のプログラム分析方法。
(Appendix 12)
(F) The search character string including the specific function is specified by comparing the specific function with the extraction result, the identifier of the program source file including the specified search character string, and the specified search Further comprising replacing the specific function in the program source file including the specified search character string with another function based on the line number in which the character string is described.
The program analysis method according to any one of appendices 9 to 11.
(付記13)
コンピュータに、
(a)プログラムソースファイルからの抽出の対象となる関数に、正規表現の文字列を付加して、検索文字列を作成する、ステップと、
(b)前記プログラムソースファイルに対して、前記(a)のステップによって作成された前記検索文字列を用いて検索を行い、前記検索文字列を抽出する、ステップと、
(c)抽出の対象となる前記関数又は前記関数とは別の関数に、前記正規表現とは別の排除用の正規表現の文字列を付加して、排除文字列を作成し、前記(b)のステップによる抽出の結果から、前記排除文字列に該当する箇所を排除する、ステップと、
を実行させるプログラム。
(Appendix 13)
On the computer,
(A) adding a regular expression character string to a function to be extracted from a program source file to create a search character string; and
(B) searching the program source file using the search character string created by the step (a), and extracting the search character string;
(C) A character string of a regular expression for exclusion different from the regular expression is added to the function to be extracted or a function different from the function to create an exclusion character string; ) From the result of the extraction in step), the step corresponding to the excluded character string is excluded, and
A program that executes
(付記14)
(d)前記プログラムソースファイルの行毎に、当該行に含まれる関数の前後に位置する文字列を抽出し、抽出した前記文字列を用いて、前記抽出の対象となる関数に付加する正規表現を作成する、ステップを更に前記コンピュータに実行させる、
付記13に記載のプログラム。
(Appendix 14)
(D) For each line of the program source file, extract a character string located before and after the function included in the line, and use the extracted character string to add a regular expression to the function to be extracted Further causing the computer to execute a step,
The program according to attachment 13.
(付記15)
前記(b)のステップで、前記抽出の結果として、前記検索文字列、前記検索文字列を含むプログラムソースファイルの識別子、及び前記検索文字列が記述された行の番号を特定する情報を出力する、
付記13または14に記載のプログラム。
(Appendix 15)
In the step (b), as the result of the extraction, the search character string, the identifier of the program source file including the search character string, and the information specifying the line number in which the search character string is described are output. ,
The program according to appendix 13 or 14.
(付記16)
前記(c)のステップで、前記排除文字列と前記抽出の結果とを対比して、前記排除文字列に一致している前記検索文字列を特定し、前記抽出の結果から、前記一致している前記検索文字列、前記一致している前記検索文字列を含むプログラムソースファイルの識別子、及び前記一致している前記検索文字列が記述された行の番号を排除する、
付記15に記載のプログラム。
(Appendix 16)
In the step (c), the searched character string that matches the excluded character string is specified by comparing the excluded character string and the extraction result, and the matching result is determined based on the extracted result. The search character string, the identifier of the program source file including the matching search character string, and the line number in which the matching search character string is described, are excluded.
The program according to appendix 15.
(付記17)
(e)前記(c)のステップによって前記排除文字列に該当する箇所が排除された前記抽出の結果に基づいて、前記プログラムソースファイル毎に、当該プログラムソースファイルに存在している関数及びその数を特定するデータを作成し、作成した前記データを出力する、ステップを更に前記コンピュータに実行させる、
付記16に記載のプログラム。
(Appendix 17)
(E) Based on the result of the extraction in which the portion corresponding to the excluded character string is excluded by the step (c), for each program source file, the functions existing in the program source file and the number thereof Generating data for specifying the data, outputting the generated data, and causing the computer to further execute a step.
The program according to appendix 16.
(付記18)
(f)特定の関数と前記抽出の結果とを対比して、前記特定の関数を含む前記検索文字列を特定し、特定した前記検索文字列を含むプログラムソースファイルの識別子、及び特定した前記検索文字列が記述された行の番号に基づいて、特定した前記検索文字列を含むプログラムソースファイル中の前記特定の関数を、他の関数に置き換える、ステップを更に前記コンピュータに実行させる、
付記15〜17のいずれかに記載のプログラム。
(Appendix 18)
(F) The search character string including the specific function is specified by comparing the specific function with the extraction result, the identifier of the program source file including the specified search character string, and the specified search Replacing the specific function in the program source file including the specified search character string with another function based on the line number in which the character string is described, and causing the computer to further execute a step.
The program according to any one of appendices 15 to 17.
以上のように本発明によれば、プログラムソースファイルから関数を抽出する際の抽出精度を向上できる。本発明は、ソフトウェアの開発において、プログラムソースファイルの分析が必要となる場合に有用である。 As described above, according to the present invention, it is possible to improve the extraction accuracy when a function is extracted from a program source file. The present invention is useful when development of software requires analysis of a program source file.
1 プログラム分析装置(実施の形態1)
2 プログラム分析装置(実施の形態2)
3 プログラム分析装置(実施の形態3)
10 正規表現付加部
20 ソースファイル検索部
30 抽出結果ファイル出力部
40 文字列排除部
50 最終抽出結果ファイル出力部
61 関数格納部
62 正規表現格納部
63 ソースファイル格納部
64 検索文字列格納部
65 抽出結果格納部
66 抽出結果ファイル格納部
71 排除用正規表現格納部
72 排除文字列格納部
73 最終抽出結果格納部
74 最終抽出結果ファイル格納部
80 正規表現生成処理部
81 代表ソースファイル読込部
82 文字列パターン分析部
83 正規表現生成部
84 代表ソースファイル展開部
85 文字列パターン格納部
90 関数置換部
91 置換対象関数読込部
92 抽出結果ファイル読込部
93 ソースファイル置換部
94 置換済みソースファイル出力部
95 置換対象関数格納部
96 抽出結果ファイル展開部
97 置換済みソースファイル格納部
110 コンピュータ
111 CPU
112 メインメモリ
113 記憶装置
114 入力インターフェイス
115 表示コントローラ
116 データリーダ/ライタ
117 通信インターフェイス
118 入力機器
119 ディスプレイ装置
120 記録媒体
121 バス
1 Program analyzer (Embodiment 1)
2 Program analyzer (Embodiment 2)
3 Program analyzer (Embodiment 3)
DESCRIPTION OF
112
Claims (8)
前記プログラムソースファイルに対して、前記正規表現付加部によって作成された前記検索文字列を用いて検索を行い、前記検索文字列を抽出する、ソースファイル検索部と、
前記正規表現とは別の排除用の正規表現のリストから、前記排除用の正規表現の文字列を抽出し、そして、抽出した前記排除用の正規表現の文字列毎に、抽出の対象となる前記関数に、当該排除用の正規表現の文字列を付加して、排除文字列を作成し、前記ソースファイル検索部による抽出の結果から、前記排除文字列に該当する箇所を排除する、文字列排除部と、
を備えている、ことを特徴とするプログラム分析装置。 A regular expression adding unit that creates a search string by adding a regular expression character string to a function to be extracted from a program source file;
A search for the program source file using the search character string created by the regular expression adding unit, and extracting the search character string, a source file search unit,
A character string of the regular expression for exclusion is extracted from a list of regular expressions for exclusion different from the regular expression, and each character string of the extracted regular expression for exclusion is subject to extraction. the function number, and adds the string of a regular expression for the exclusion, to create an exclusion string, the result of extraction by the source file search unit, eliminating the portion corresponding to the exclusion string, character A column exclusion section;
A program analyzer characterized by comprising:
請求項1に記載のプログラム分析装置。 For each line of the program source file, a character string located before and after the function included in the line is extracted, and a regular expression to be added to the function to be extracted is created using the extracted character string. , Further comprising a regular expression generation processing unit,
The program analysis apparatus according to claim 1.
請求項1または2に記載のプログラム分析装置。 The source file search unit outputs, as a result of the extraction, information specifying the search character string, an identifier of a program source file including the search character string, and a line number in which the search character string is described.
The program analysis apparatus according to claim 1 or 2.
請求項3に記載のプログラム分析装置。 The character string exclusion unit compares the excluded character string with the extraction result, identifies the search character string that matches the excluded character string, and matches the matching result from the extraction result. Eliminating the search character string, the identifier of the program source file containing the matching search character string, and the line number in which the matching search character string is described;
The program analysis apparatus according to claim 3.
請求項4に記載のプログラム分析装置。 Data for specifying the function and the number of functions existing in the program source file for each program source file based on the extraction result in which the portion corresponding to the excluded character string is excluded by the character string exclusion unit And an output unit for outputting the created data.
The program analysis apparatus according to claim 4.
請求項3〜5のいずれかに記載のプログラム分析装置。 A specific function and the result of the extraction are compared to specify the search character string including the specific function, an identifier of a program source file including the specified search character string, and the specified search character string A function replacing unit that replaces the specific function in the program source file including the specified search character string with another function based on the number of the described line;
The program analysis apparatus according to claim 3.
(b)前記プログラムソースファイルに対して、前記(a)のステップによって作成された前記検索文字列を用いて検索を行い、前記検索文字列を抽出する、ステップと、
(c)前記正規表現とは別の排除用の正規表現のリストから、前記排除用の正規表現の文字列を抽出し、そして、抽出した前記排除用の正規表現の文字列毎に、抽出の対象となる前記関数に、当該排除用の正規表現の文字列を付加して、排除文字列を作成し、前記(b)のステップによる抽出の結果から、前記排除文字列に該当する箇所を排除する、ステップと、
を有する、ことを特徴とするプログラム分析方法。 (A) adding a regular expression character string to a function to be extracted from a program source file to create a search character string; and
(B) searching the program source file using the search character string created by the step (a), and extracting the search character string;
(C) Extracting a character string of the regular expression for exclusion from a list of regular expressions for exclusion different from the regular expression, and extracting each extracted character string of the regular expression for exclusion the functions that the target, by adding a string of a regular expression for the exclusion, to create an exclusion strings, the results of extraction by step (b), the portion corresponding to the exclusion string Eliminate, step, and
A program analysis method characterized by comprising:
(a)プログラムソースファイルからの抽出の対象となる関数に、正規表現の文字列を付加して、検索文字列を作成する、ステップと、
(b)前記プログラムソースファイルに対して、前記(a)のステップによって作成された前記検索文字列を用いて検索を行い、前記検索文字列を抽出する、ステップと、
(c)前記正規表現とは別の排除用の正規表現のリストから、前記排除用の正規表現の文字列を抽出し、そして、抽出した前記排除用の正規表現の文字列毎に、抽出の対象となる前記関数に、当該排除用の正規表現の文字列を付加して、排除文字列を作成し、前記(b)のステップによる抽出の結果から、前記排除文字列に該当する箇所を排除する、ステップと、
を実行させるプログラム。
On the computer,
(A) adding a regular expression character string to a function to be extracted from a program source file to create a search character string; and
(B) searching the program source file using the search character string created by the step (a), and extracting the search character string;
(C) Extracting a character string of the regular expression for exclusion from a list of regular expressions for exclusion different from the regular expression, and extracting each extracted character string of the regular expression for exclusion the functions that the target, by adding a string of a regular expression for the exclusion, to create an exclusion strings, the results of extraction by step (b), the portion corresponding to the exclusion string Eliminate, step, and
A program that executes
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2011141953A JP5578625B2 (en) | 2011-06-27 | 2011-06-27 | Program analysis apparatus, program analysis method, and program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2011141953A JP5578625B2 (en) | 2011-06-27 | 2011-06-27 | Program analysis apparatus, program analysis method, and program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2013008304A JP2013008304A (en) | 2013-01-10 |
JP5578625B2 true JP5578625B2 (en) | 2014-08-27 |
Family
ID=47675579
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2011141953A Active JP5578625B2 (en) | 2011-06-27 | 2011-06-27 | Program analysis apparatus, program analysis method, and program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP5578625B2 (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10133657B2 (en) * | 2016-02-23 | 2018-11-20 | Fujitsu Limited | Textual similarity based software program repair |
JPWO2021214982A1 (en) * | 2020-04-24 | 2021-10-28 |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH04373020A (en) * | 1991-06-24 | 1992-12-25 | Mitsubishi Electric Corp | Function correspondence table preparing device |
JPH08185409A (en) * | 1994-12-28 | 1996-07-16 | Canon Inc | Method and device for processing information |
JP2000020293A (en) * | 1998-07-03 | 2000-01-21 | Ffc:Kk | Method for retrieving specified function in program source |
JP2005063470A (en) * | 2000-01-05 | 2005-03-10 | Mitsubishi Electric Corp | Keyword extracting device |
JP2006277330A (en) * | 2005-03-29 | 2006-10-12 | Toshiba Corp | Source code editing device and source code editing method |
JP4972970B2 (en) * | 2006-03-17 | 2012-07-11 | 富士通株式会社 | Function call abnormal pattern detection program in source program |
JP2008117280A (en) * | 2006-11-07 | 2008-05-22 | Matsushita Electric Ind Co Ltd | Software source code-retrieval method and system |
JP4929121B2 (en) * | 2007-10-16 | 2012-05-09 | 株式会社東芝 | Source program analysis apparatus, source program analysis method, and computer program |
-
2011
- 2011-06-27 JP JP2011141953A patent/JP5578625B2/en active Active
Also Published As
Publication number | Publication date |
---|---|
JP2013008304A (en) | 2013-01-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9389849B2 (en) | Test case pattern matching | |
JP6070847B2 (en) | Verification method, verification apparatus, and verification program | |
JP6440895B2 (en) | Software analysis apparatus and software analysis method | |
US10628140B2 (en) | Program code generation apparatus | |
JPWO2020008991A1 (en) | Verification automation equipment, verification automation methods, and programs | |
JP5578625B2 (en) | Program analysis apparatus, program analysis method, and program | |
JP2009205523A (en) | Automatic property generator | |
JP6651974B2 (en) | Information processing apparatus, compiling method and compiler program | |
WO2019225366A1 (en) | Screen discrimination device, screen discrimination method, and program | |
JP7380851B2 (en) | Test script generation device, test script generation method and program | |
JP6217440B2 (en) | Symbolic execution program, symbolic execution method, and symbolic execution device | |
JP6116983B2 (en) | Entry point extraction device | |
JP2018022433A (en) | Control program, apparatus, and method | |
JP6748357B2 (en) | Analysis device, analysis program, and analysis method | |
JP2009053767A (en) | Program analysis device and program analysis method | |
JP7456843B2 (en) | Program modification device, program modification method, and program modification program | |
JP2016051367A (en) | Data analysis device, data analysis method, and program | |
CN110245333A (en) | Font type detection method, device, electronic equipment and storage medium | |
JP6547345B2 (en) | Test case generation program, test case generation method and test case generation apparatus | |
JP7261101B2 (en) | Defect detection device, defect detection method, and defect detection program | |
JP2011113298A (en) | Shared source code analysis system, program, and recording medium | |
JP2018147114A (en) | Test case generation method, computer, and program | |
JP6556091B2 (en) | System specification verification support apparatus and system specification verification support method | |
JP2018116517A (en) | Development support device, development support method, and program | |
JP2024003945A (en) | Program correction device, program correction method, and program correction program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20121001 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20130605 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20130619 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20130808 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20130815 |
|
A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20140219 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20140515 |
|
A911 | Transfer of reconsideration by examiner before appeal (zenchi) |
Free format text: JAPANESE INTERMEDIATE CODE: A911 Effective date: 20140522 |
|
TRDD | Decision of grant or rejection written | ||
A711 | Notification of change in applicant |
Free format text: JAPANESE INTERMEDIATE CODE: A712 Effective date: 20140609 |
|
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20140611 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20140703 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 5578625 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |