JP2017142712A - Call graph difference extraction method, call graph difference extraction program, and information processing device - Google Patents
Call graph difference extraction method, call graph difference extraction program, and information processing device Download PDFInfo
- Publication number
- JP2017142712A JP2017142712A JP2016024514A JP2016024514A JP2017142712A JP 2017142712 A JP2017142712 A JP 2017142712A JP 2016024514 A JP2016024514 A JP 2016024514A JP 2016024514 A JP2016024514 A JP 2016024514A JP 2017142712 A JP2017142712 A JP 2017142712A
- Authority
- JP
- Japan
- Prior art keywords
- edge
- edges
- difference
- target
- distance
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Abstract
Description
本発明は、コールグラフ差分抽出方法、コールグラフ差分抽出プログラム、および情報処理装置に関する。 The present invention relates to a call graph difference extraction method, a call graph difference extraction program, and an information processing apparatus.
コンピュータに実行させるプログラムでは、サブルーチンとしての別のプログラムの呼び出しが定義されていることがある。大規模なソフトウェアでは、このようなプログラム間の呼び出し関係が複雑に絡み合う。そこで、ソフトウェアに含まれるプログラム間の呼び出し関係が視覚的に把握できるように、プログラム間の呼び出し関係をグラフで表すことがある。このようなプログラム間の呼び出し関係を表すグラフは、コールグラフと呼ばれる。 A program to be executed by a computer may define a call for another program as a subroutine. In a large-scale software, such a calling relationship between programs is complicatedly intertwined. Therefore, the call relationship between programs may be represented by a graph so that the call relationship between programs included in software can be visually grasped. Such a graph representing a call relationship between programs is called a call graph.
コールグラフは、プログラムを表すノードの集合と、プログラム間の呼び出し関係を表すエッジの集合とで構成される有向グラフである。コールグラフにおいて、エッジは、呼び出し元のプログラムに対応するノードから呼び出し先のプログラムに対応するノードへの方向性を有する線で表される。 The call graph is a directed graph composed of a set of nodes representing programs and a set of edges representing call relationships between programs. In the call graph, an edge is represented by a line having directionality from a node corresponding to a calling source program to a node corresponding to a calling destination program.
このようなコールグラフは、ソフトウェアの一部のプログラムが修正されたことによる、他のプログラムの影響の有無の把握に利用できる。例えば、修正前のソフトウェアの呼び出し関係を示すコールグラフと、修正後のソフトウェアの呼び出し関係を示すコールグラフとを比較すれば、サブルーチンの呼び出し元が変更されたことなどを把握できる。このとき、サブルーチンが呼び出し元に依存する処理を含んでいる場合、そのサブルーチンのプログラムについても修正を要することが分かる。 Such a call graph can be used to grasp the influence of other programs due to the modification of a part of the software program. For example, by comparing a call graph indicating a call relationship of software before correction with a call graph indicating a call relationship of software after correction, it is possible to grasp that the caller of the subroutine has been changed. At this time, if the subroutine includes a process that depends on the caller, it is understood that the subroutine program needs to be corrected.
グラフを用いてプログラムの構造を把握する技術としては、例えば、コンピュータ・プログラムの構造を、有向グラフで簡潔に表示する階層的グラフ解析方法がある。またアプリケーションに障害が発生した際、障害の根本的な原因となる処理を行っている箇所を特定するためにコールグラフを利用した、アプリケーションの障害原因の特定作業支援システムも考えられている。さらに、ソースコードの等価性を検証する際に、ソースコードを解析した構造グラフによる構造比較を行うソースコード等価性検証装置も考えられている。 As a technique for grasping the structure of a program using a graph, for example, there is a hierarchical graph analysis method for simply displaying the structure of a computer program in a directed graph. In addition, when a failure occurs in an application, an application failure cause identification work support system that uses a call graph to identify a location where processing that is the root cause of the failure is performed is also considered. Furthermore, a source code equivalence verification apparatus that performs structure comparison using a structure graph obtained by analyzing the source code when verifying the equivalence of the source code is also considered.
しかし、2つのコールグラフを比較し、エッジの差異を検出するとき、2つのコールグラフがどちらにも多数のエッジがある場合、実用的な時間内で比較処理を完了させることが困難となる。例えば、一方のコールグラフ内の各エッジを他方のコールグラフ内の全エッジと総当たりで比較した場合、それぞれのコールグラフのエッジ数同士を乗算した回数分のエッジの同一性判定処理が行われる。OS(Operating System)のような規模の大きなソフトウェアでは、コールグラフに含まれるエッジ数が百万個に及ぶ場合もあり、エッジの同一性判定処理の繰り返し回数が膨大になる。その結果、2つのコールグラフの比較に時間がかかっている。 However, when two call graphs are compared and edge differences are detected, if both of the two call graphs have a large number of edges, it is difficult to complete the comparison process within a practical time. For example, when each edge in one call graph is compared with all the edges in the other call graph in a brute force manner, edge identity determination processing is performed for the number of times obtained by multiplying the number of edges in each call graph. . In a large-scale software such as an OS (Operating System), the number of edges included in a call graph may reach 1 million, and the number of repetitions of edge identity determination processing becomes enormous. As a result, it takes time to compare the two call graphs.
1つの側面では、本件は、エッジの差分を効率的に抽出できるようにすることを目的とする。 In one aspect, the object is to enable efficient extraction of edge differences.
1つの案では、コンピュータが以下の処理を実行するコールグラフ差分抽出方法が提供される。
このコールグラフ差分抽出方法では、コンピュータは、起点プログラムモジュールが指定されると、起点プログラムモジュールを含む第1ソフトウェア内の複数の第1プログラムモジュール間での呼び出し関係を、複数の第1プログラムモジュールを示す複数の第1ノード間を接続する複数の第1エッジによって表した第1コールグラフに基づいて、起点プログラムモジュールに対応する第1ノードから呼び出し関係を辿って複数の第1エッジそれぞれに到達するまでの距離により、第1コールグラフ内の複数の第1エッジを距離ごとのカテゴリに分類する。またコンピュータは、起点プログラムモジュールを含む第2ソフトウェア内の複数の第2プログラムモジュール間での呼び出し関係を、複数の第2プログラムモジュールを示す複数の第2ノード間を接続する複数の第2エッジによって表した第2コールグラフに基づいて、起点プログラムモジュールに対応する第2ノードから呼び出し関係を辿って複数の第2エッジそれぞれに到達するまでの距離により、複数の第2エッジを距離ごとのカテゴリに分類する。次にコンピュータは、複数の第1エッジそれぞれを対象とし、対象第1エッジと同じカテゴリに属する第2エッジのなかに、呼び出し元と呼び出し先とのプログラムモジュールの組が該対象第1エッジと共通の第2エッジが存在しない場合、該対象第1エッジを差分候補第1エッジとして特定する。またコンピュータは、複数の第2エッジそれぞれを対象とし、対象第2エッジと同じカテゴリに属する第1エッジのなかに、呼び出し元と呼び出し先とのプログラムモジュールの組が該対象第2エッジと共通の第1エッジが存在しない場合、該対象第2エッジを差分候補第2エッジとして特定する。さらにコンピュータは、差分候補第1エッジのうち、呼び出し元と呼び出し先とのプログラムモジュールの組が共通となる差分候補第2エッジが存在しない差分第1エッジを抽出する。またコンピュータは、差分候補第2エッジのうち、呼び出し元と呼び出し先とのプログラムモジュールの組が共通となる差分候補第1エッジが存在しない差分第2エッジを抽出する。
In one proposal, a call graph difference extraction method is provided in which a computer performs the following processing.
In this call graph difference extraction method, when a starting point program module is designated, the computer displays a calling relationship among a plurality of first program modules in the first software including the starting point program module by using the plurality of first program modules. Based on the first call graph represented by the plurality of first edges connecting the plurality of first nodes shown, the call relation is traced from the first node corresponding to the origin program module to reach each of the plurality of first edges. The plurality of first edges in the first call graph are classified into categories for each distance. In addition, the computer uses a plurality of second edges connecting a plurality of second nodes indicating a plurality of second program modules to establish a calling relationship between the plurality of second program modules in the second software including the starting program module. Based on the expressed second call graph, the plurality of second edges are classified into categories for each distance according to the distance from the second node corresponding to the starting program module to the call relationship and reaching each of the plurality of second edges. Classify. Next, the computer targets each of the plurality of first edges, and among the second edges belonging to the same category as the target first edge, the program module pair of the caller and the callee is common to the target first edge. If the second edge does not exist, the target first edge is specified as the difference candidate first edge. In addition, the computer targets each of the plurality of second edges, and among the first edges belonging to the same category as the target second edge, the set of program modules of the caller and the callee is the same as the target second edge. When the first edge does not exist, the target second edge is specified as the difference candidate second edge. Further, the computer extracts a first difference edge that does not have a second difference candidate edge that has a common program module set of the caller and the callee among the first difference candidates. Further, the computer extracts a difference second edge that does not include a difference candidate first edge that has a common set of program modules of the caller and the callee among the difference candidate second edges.
1態様によれば、エッジの差分を効率的に抽出できるようになる。 According to one aspect, the difference between edges can be efficiently extracted.
以下、本実施の形態について図面を参照して説明する。なお各実施の形態は、矛盾のない範囲で複数の実施の形態を組み合わせて実施することができる。
〔第1の実施の形態〕
まず、第1の実施の形態について説明する。
Hereinafter, the present embodiment will be described with reference to the drawings. Each embodiment can be implemented by combining a plurality of embodiments within a consistent range.
[First Embodiment]
First, the first embodiment will be described.
図1は、第1の実施の形態に係る情報処理装置の構成例を示す図である。情報処理装置10は、記憶部11と演算部12とを有する。
記憶部11は、第1コールグラフ1と第2コールグラフ2とを記憶する。第1コールグラフ1は、第1ソフトウェア内の複数の第1プログラムモジュール間での呼び出し関係を、複数の第1プログラムモジュールを示す複数の第1ノード1a〜1d間を接続する複数の第1エッジ1e〜1gによって表した有向グラフである。第2コールグラフ2は、第2ソフトウェア内の複数の第2プログラムモジュール間での呼び出し関係を、複数の第2プログラムモジュールを示す複数の第2ノード2a〜2e間を接続する複数の第2エッジ2f〜2iによって表した有向グラフである。なお、第1ソフトウェアの識別子は「1」、第2ソフトウェアの識別子は「2」であるものとする。
FIG. 1 is a diagram illustrating a configuration example of an information processing apparatus according to the first embodiment. The
The
演算部12は、分類部12a、特定部12b、および抽出部12cを有する。
分類部12aは、第1ソフトウェアと第2ソフトウェアとの両方に含まれる起点プログラムモジュールが指定されると、第1コールグラフ1と第2コールグラフ2とのそれぞれに含まれる第1エッジ1e〜1gと第2エッジ2f〜2iとを複数のカテゴリに分類する。例えば分類部12aは、第1コールグラフ1に基づいて、起点プログラムモジュールに対応する第1ノード1aを特定する。そして分類部12aは、特定した第1ノード1aから呼び出し関係を辿って複数の第1エッジ1e〜1gそれぞれに到達するまでの距離により、複数の第1エッジ1e〜1gを距離ごとのカテゴリに分類する。例えば分類部12aは、複数の第1エッジ1e〜1gをカテゴリごとに分けて、第1距離別エッジリスト3に格納する。なお、第1距離別エッジリスト3に登録されているエッジは、対応する呼び出し関係における呼び出し元のプログラムモジュールの名称と呼び出し先のプログラムモジュールの名称との組(プログラム名対)で表されている。
The
When the start program module included in both the first software and the second software is designated, the
また分類部12aは、第2コールグラフ2に基づいて、起点プログラムモジュールに対応する第2ノード2aを特定する。そして分類部12aは、特定した第2ノード2aから呼び出し関係を辿って複数の第2エッジ2f〜2iそれぞれに到達するまでの距離により、複数の第2エッジ2f〜2iを距離ごとのカテゴリに分類する。例えば分類部12aは、複数の第2エッジ2f〜2iをカテゴリごとに分けて、第2距離別エッジリスト4に格納する。なお、第2距離別エッジリスト4に登録されているエッジは、対応する呼び出し関係における呼び出し元のプログラムモジュールの名称と呼び出し先のプログラムモジュールの名称との組(プログラム名対)で表されている。
Further, the
特定部12bは、複数の第1エッジ1e〜1gそれぞれを対象とする。そして特定部12bは、対象第1エッジと同じカテゴリに属する第2エッジのなかに、呼び出し元と呼び出し先とのプログラムモジュールの組が該対象第1エッジと共通の第2エッジが存在しない場合、その対象第1エッジを差分候補第1エッジとして特定する。
The specifying
また特定部12bは、複数の第2エッジ2f〜2iそれぞれを対象とする。そして特定部12bは、対象第2エッジと同じカテゴリに属する第1エッジのなかに、呼び出し元と呼び出し先とのプログラムモジュールの組が該対象第2エッジと共通の第1エッジが存在しない場合、その対象第2エッジを差分候補第2エッジとして特定する。
The specifying
例えば特定部12bは、第1距離別エッジリスト3と第2距離別エッジリスト4との、同一カテゴリ内の第1エッジと第2エッジを比較する。そして特定部12bは、同一カテゴリのなかに、同じプログラム名対で表されている第2エッジが存在しない第1エッジを、差分候補第1エッジとして第1差分エッジリスト5に格納する。また、特定部12bは、同一カテゴリのなかに、同じプログラム名対で表されている第1エッジが存在しない第2エッジを、差分候補第2エッジとして第2差分エッジリスト6に格納する。
For example, the specifying
抽出部12cは、差分候補第1エッジのうち、呼び出し元と呼び出し先とのプログラムモジュールの組が共通となる差分候補第2エッジが存在しない差分第1エッジを抽出する。また抽出部12cは、差分候補第2エッジのうち、呼び出し元と呼び出し先とのプログラムモジュールの組が共通となる差分候補第1エッジが存在しない差分第2エッジを抽出する。
The
例えば抽出部12cは、第1差分エッジリスト5内の差分候補第1エッジと第2差分エッジリスト6内の差分候補第2エッジとを、総当たりで比較する。そして抽出部12cは、比較相手のいずれともプログラム名対が異なる差分候補第1エッジを、第1ソフトウェアの識別子に対応付けて、最終差分エッジリスト7に格納する。またそして抽出部12cは、比較相手のいずれともプログラム名対が異なる差分候補第1エッジを、第2ソフトウェアの識別子に対応付けて、最終差分エッジリスト7に格納する。
For example, the
このような情報処理装置10によれば、起点プログラムモジュールが指定されると、第1コールグラフ1と第2コールグラフ2とのエッジが、起点ノード1a,2aからの距離に応じたカテゴリに分類される。次に分類部12aによって、同じカテゴリの第1エッジと第2エッジとの比較により、差分候補第1エッジと差分候補第2エッジとが特定される。そして、抽出部12cにより、差分候補第1エッジと差分候補第2エッジとのなかから、第1コールグラフ1と第2コールグラフ2との一方にのみ存在する差分第1エッジおよび差分第2エッジが抽出される。
According to such an
第1の実施の形態では、特定部12bによって抽出するエッジの候補を絞り込み、候補となったエッジから差分第1エッジおよび差分第2エッジを抽出するため、効率的に差分エッジを抽出できる。その結果、コールグラフ間の差分抽出に要する時間が短縮される。
In the first embodiment, the candidate for edge to be extracted is narrowed down by the specifying
なお演算部12は、差分候補第1エッジと差分候補第2エッジとのハッシュ値を用いて、抽出部12cによる抽出処理の効率化を図ることもできる。その場合、特定部12bは、差分候補第1エッジのハッシュ値が登録された第1存在エッジリストと、差分候補第2エッジのハッシュ値が登録された第2存在エッジリストとを生成する。ハッシュ値は、差分候補第1エッジまたは差分候補第2エッジのプログラム名対を、所定のハッシュ関数で演算して求めることができる。抽出部12cは、第2存在エッジリストに登録されているハッシュ値とは異なるハッシュ値が得られる差分候補第1エッジを、差分第1エッジとして抽出する。また抽出部12cは、第1存在エッジリストに登録されているハッシュ値とは異なるハッシュ値が得られる差分候補第2エッジを、差分第2エッジとして抽出する。
Note that the
このようにハッシュ値を用いることで、非常に長いプログラム名対を短いデータに圧縮することができ、少ない量のメモリ使用による効率的な処理が可能となる。
また演算部12は、分類されたカテゴリ内で第1エッジおよび第2エッジをソート(並べ替え)することで、差分候補第1エッジと差分候補第2エッジとの特定処理をさらに効率化することができる。その場合、特定部12bは、分類されたカテゴリにごとに第1エッジと第2エッジとを所定の基準でソートする。次に特定部12bは、同じ距離のカテゴリに分類された第1エッジ群と第2エッジ群とを比較対象とする。さらに特定部12bは、第1エッジ群の上位から順に対象第1エッジを選択し、第2エッジ群の上位から順に対象第2エッジを選択する。そして特定部12bは、対象第1エッジと対象第2エッジとにおける呼び出し元と呼び出し先とのプログラムモジュールの組が共通か否かを判断する。共通ではないとき、特定部12bは、対象第1エッジと対象第2エッジとのうち、所定の基準でソートしたときに上位となる方を、差分候補第1エッジまたは差分候補第2エッジとして特定する。
By using a hash value in this way, a very long program name pair can be compressed into short data, and efficient processing using a small amount of memory becomes possible.
Further, the
特定部12bは、差分候補第1エッジを特定した場合、対象第1エッジを、第1エッジ群内の次の第1エッジに変更する。また特定部12bは、差分候補第2エッジを特定した場合、対象第2エッジを、第2エッジ群内の次の第2エッジに変更する。呼び出し元と呼び出し先とのプログラムモジュールの組が共通と判断した場合、特定部12bは、対象第1エッジを、第1エッジ群内の次の第1エッジに変更すると共に、対象第2エッジを、第2エッジ群内の次の第2エッジに変更する。
When specifying the difference candidate first edge, the specifying
このように、カテゴリ内で第1エッジおよび第2エッジをソートした上で同一性の比較を行うことで、総当たりで比較する場合に比べ比較処理の回数を削減できる。その結果、処理の効率化が図れる。 Thus, by comparing the identities after sorting the first edge and the second edge within the category, it is possible to reduce the number of comparison processes compared to the case where comparison is made brute force. As a result, processing efficiency can be improved.
なお、演算部12は、例えば情報処理装置10が有するプロセッサにより実現することができる。また、記憶部11は、例えば情報処理装置10が有するメモリまたはストレージ装置により実現することができる。演算部12内の分類部12a、特定部12b、および抽出部12cは、例えば演算部12にプログラムを実行させることで実現できる。その際、第1距離別エッジリスト3、第2距離別エッジリスト4、第1差分エッジリスト5、第2差分エッジリスト6、および最終差分エッジリスト7は、例えば情報処理装置10が有するメモリまたはストレージ装置に一時的に格納される。
In addition, the calculating
以上が第1の実施の形態についての説明である。
〔第2の実施の形態〕
次に第2の実施の形態について説明する。第2の実施の形態では、オブジェクト指向プログラミングにより作成された2つのソフトウェアそれぞれから作成されたコールグラフのエッジの差分の抽出を、コンピュータを用いて効率的に実施するものである。なお、オブジェクト指向プログラミングにより作成された2つのソフトウェアのコールグラフでは、ソフトウェアを構成する複数のメソッドがノードで表され、メソッド間の呼び出し関係が、エッジで表される。すなわちメソッドは、第1の実施の形態に示すプログラムモジュールの一例である。
The above is the description of the first embodiment.
[Second Embodiment]
Next, a second embodiment will be described. In the second embodiment, the extraction of the difference between the edges of the call graph created from each of two pieces of software created by object-oriented programming is efficiently performed using a computer. In the call graph of two software created by object-oriented programming, a plurality of methods constituting the software are represented by nodes, and the call relationship between methods is represented by edges. That is, the method is an example of a program module shown in the first embodiment.
図2は、コールグラフの生成例を示す図である。図2に示すように、ソースコード31を解析することで、メソッド間の呼び出し関係を示すコールグラフ32が得られる。
例えば、ソースコード31を解析すると、「Tranceiver.transmit()」・「Transformer.encode()」・「Protocol.makeHeader()」・「Tranceiver.send()」というメソッドが存在していることが分かる。そこで、コールグラフ32内に、各メソッドに対応するノード32a〜32dが生成される。また、ソースコード31を解析すると、メソッド「Tranceiver.transmit()」が、他の3つのメソッド「Transformer.encode()」・「Protocol.makeHeader()」・「Tranceiver.send()」を呼び出していることが分かる。そこで、メソッド「Tranceiver.transmit()」に対応するノード32aと他の3つのノード32b〜32dとを接続するエッジ32e〜32gが生成される。エッジ32e〜32gは、呼び出し元のメソッドに対応するノード32aから、呼び出し先のメソッドに対応するノード32b〜32dを指し示す矢印である。
FIG. 2 is a diagram illustrating an example of generating a call graph. As shown in FIG. 2, by analyzing the source code 31, a call graph 32 showing a calling relationship between methods is obtained.
For example, when the source code 31 is analyzed, it can be seen that the methods "Tranceiver.transmit ()", "Transformer.encode ()", "Protocol.makeHeader ()", and "Tranceiver.send ()" exist. . Therefore,
このようにして、ノード32a〜32dによりメソッドを表し、エッジ32e〜32gによりメソッド間の呼び出し関係を表すコールグラフ32が生成される。コールグラフ32の各エッジ32e〜32gは、文字列の2つ組で表現できる。
In this manner, a call graph 32 is generated that represents a method by the
図3は、コールグラフのエッジのデータ構造の一例を示す図である。各エッジ32e〜32gは、呼び出し元メソッドの完全修飾名文字列と、呼び出し先メソッドの完全修飾名文字列とを含んでいる。左側の文字列が呼び出し元メソッドの完全修飾名であり、右側の文字列が呼び出し先メソッドの完全修飾名である。このような文字列の2つ組によって、エッジが特定される。換言すると、文字列の2つ組が同じエッジは、同一の呼び出し関係を示すエッジであると判断できる。
FIG. 3 is a diagram illustrating an example of a data structure of an edge of a call graph. Each
なお、エッジ32e〜32gを表す文字列としてノード32a〜32dを示すメソッドの完全修飾名が含まれている。そのため、エッジ32e〜32gの情報があれば、ノード32a〜32dを含め、コールグラフ32の全体を生成できる。
Note that the fully qualified names of the methods indicating the
また、複数のエッジは、データ構造に含まれる文字列により、同一、および大小を比較することができる。例えば、図3に示すように呼び出し元メソッドを示す文字列と、呼び出し先メソッドを示す文字列との組で表される2つのエッジ(N1,N2),(N3,N4)があるものとする。ここで、N1,N2,N3,N4は、文字列である。このとき、各エッジそれらが同一であるかは以下の条件で判定できる。
(N1,N2)=(N3,N4)⇔N1=N3かつN2=N4
さらに2つのエッジは次のように大小比較できる。
(N1,N2)<(N3,N4)⇔N1<N3または{N1=N3かつN2<N4}
(N1,N2)≦(N3,N4)⇔N1≦N3または{N1=N3かつN2≦N4}
なお、文字列同士の大小関係は、例えばアルファベット順とする。その場合、「A」が最も小さい値となり、「Z」が最も大きな値となる。この比較方法を使って一意の順序にエッジをソートできる。
In addition, the plurality of edges can be compared in size and in size by using character strings included in the data structure. For example, as shown in FIG. 3, there are two edges (N1, N2) and (N3, N4) represented by a combination of a character string indicating a caller method and a character string indicating a callee method. . Here, N1, N2, N3, and N4 are character strings. At this time, whether or not each edge is the same can be determined under the following conditions.
(N1, N2) = (N3, N4) ⇔N1 = N3 and N2 = N4
Two edges can be compared in size as follows.
(N1, N2) <(N3, N4) ⇔N1 <N3 or {N1 = N3 and N2 <N4}
(N1, N2) ≦ (N3, N4) ⇔N1 ≦ N3 or {N1 = N3 and N2 ≦ N4}
The magnitude relationship between character strings is, for example, in alphabetical order. In that case, “A” is the smallest value and “Z” is the largest value. This comparison method can be used to sort edges in a unique order.
このようなコールグラフ32は、ソフトウェア開発時に利用される。例えばソフトウェア開発過程での版数の異なる複数のソースコードそれぞれから生成した複数のコールグラフにおけるエッジの差分抽出を行うことがある。コールグラフ間のエッジの差分抽出は、大規模なソフトウェアの一部を修正した場合における、その修正の影響範囲の把握に有用である。例えば、ソフトウェアの開発にあたり、OSS(Open Source Software)など第三者が作成したソースコードセットの呼び出しを含むソフトウェアが作成されることがある。または第三者が作成したソースコードセットを改変したり、機能を追加したりして、ソフトウェアを完成させることもある。 Such a call graph 32 is used during software development. For example, edge differences may be extracted from a plurality of call graphs generated from a plurality of source codes having different versions in the software development process. Extracting edge differences between call graphs is useful for grasping the range of influence of a modification when a part of a large-scale software is modified. For example, in developing software, software including calling a source code set created by a third party such as OSS (Open Source Software) may be created. Or the source code set created by a third party may be modified or functions may be added to complete the software.
このようにして作成されたソフトウェアにおいて、呼び出されるソースコードセットが更新された場合、開発者は過去の版で呼び出したり改変したりしたメソッド(開発者が着目しているメソッド)が更新の影響を受けているか確認する。以下、開発者が着目しているメソッドに対応するノードを、起点ノードと呼ぶ。2つのコールグラフそれぞれから、起点ノードを起点として呼び出し関係を追跡し、追跡された呼び出し関係を比較して差分を抽出することにより、例えば更新の影響が起点メソッドに及ぶか否かを判断できる。また、その他に精査するメソッドを特定することもできる。 In the software created in this way, when the source code set to be called is updated, the method that the developer called or modified in the previous version (the method that the developer focuses on) has an effect on the update. Check if you are receiving. Hereinafter, a node corresponding to a method focused on by the developer is referred to as a starting node. From each of the two call graphs, it is possible to determine whether or not the influence of the update affects the starting point method, for example, by tracking the calling relationship from the starting point node and comparing the tracked calling relationship and extracting the difference. You can also specify other methods to scrutinize.
第2の実施の形態では、このような呼び出し関係の差分抽出をコンピュータ処理によって高速に実施できるようにする。そのため第2の実施の形態では、コールグラフ内のエッジが、起点ノードからの距離で分類される。 In the second embodiment, such call-related difference extraction can be performed at high speed by computer processing. Therefore, in the second embodiment, the edges in the call graph are classified by the distance from the starting node.
図4は、コールグラフ上のエッジの距離の例を示す図である。図4に示すコールグラフ40は、ノード41a〜41kとエッジ42a〜42kを含んでいる。コールグラフ40上の起点ノードからd個(dは0以上の整数)のエッジを同一方向に辿って別のあるノードに到達できるとき、2のノードの距離をdと定義する。このときのエッジを辿る方向(探索方向)は、呼び出し元から呼び出し先へ向かう方向(呼び出し先方向)の場合と、逆に、呼び出し先から呼び出し元へ向かう方向(呼び出し元方向)の場合とがある。なお、起点ノードから、その起点ノードまでの距離は0と定義する。
FIG. 4 is a diagram illustrating an example of edge distance on the call graph. The call graph 40 shown in FIG. 4 includes
そしてノード間の距離を用いて、起点ノードに対するエッジの距離を定義できる。例えば、起点ノードからみて距離(d−1)の位置にあるノードと距離dの位置にあるノードを結ぶエッジは、起点ノードからの距離をdと定義する。 And the distance of the edge with respect to the origin node can be defined using the distance between nodes. For example, an edge connecting a node located at a distance (d−1) from a starting node and a node located at a distance d defines the distance from the starting node as d.
図4の例では、「メソッドg」に対応するノード41gが起点ノードである。起点ノードから「メソッドd」に対応するノード41dまでの距離は「1」である。そして、起点ノードであるノード41gとノード「メソッドd」に対応するノード41dとを接続するエッジ42hの距離は「1」である。
In the example of FIG. 4, the
起点ノードから「メソッドf」に対応するノード41fまでの距離は「2」である。そして、起点ノードから距離「1」にあるノード41dとノード「メソッドf」に対応するノード41fとを接続するエッジ42dの距離は「2」である。
The distance from the starting node to the
ここで、図4に示したコールグラフ40の生成元となったソースコードが更新された場合を想定する。この場合、更新後のソースコードについてもコールグラフを生成することで、そのコールグラフにより、更新後のソースコードにおけるメソッド間の呼び出し関係が表される。 Here, it is assumed that the source code that is the generation source of the call graph 40 illustrated in FIG. 4 is updated. In this case, by generating a call graph for the updated source code, the call relationship between the methods in the updated source code is represented by the call graph.
図5は、更新後のソースコードのコールグラフの例を示す図である。図5の例では、更新後のソースコードのコールグラフ40aを、図4に示す更新前のコールグラフ40と比較すると、ノード41kが削除され、ノード41lが追加されている。ノード41dとノード41fとを接続するエッジ42dは削除され、ノード41dとノード41lを接続するエッジ42lおよびノード41lとノード41fを接続するエッジ42mが追加されている。
FIG. 5 is a diagram illustrating an example of a call graph of the updated source code. In the example of FIG. 5, when the call graph 40a of the updated source code is compared with the call graph 40 before the update shown in FIG. 4, the
以下、図4、図5に示した2つのコールグラフ40,40a間のエッジの差分抽出処理を高速に行うコンピュータについて、詳細に説明する。
<ハードウェア構成>
図6は、第2の実施の形態に用いるコンピュータのハードウェアの一構成例を示す図である。コンピュータ100は、プロセッサ101によって装置全体が制御されている。プロセッサ101には、バス109を介してメモリ102と複数の周辺機器が接続されている。プロセッサ101は、マルチプロセッサであってもよい。プロセッサ101は、例えばCPU(Central Processing Unit)、MPU(Micro Processing Unit)、またはDSP(Digital Signal Processor)である。プロセッサ101がプログラムを実行することで実現する機能の少なくとも一部を、ASIC(Application Specific Integrated Circuit)、PLD(Programmable Logic Device)などの電子回路で実現してもよい。
Hereinafter, a computer that performs high-speed edge difference extraction processing between the two call graphs 40 and 40a illustrated in FIGS. 4 and 5 will be described in detail.
<Hardware configuration>
FIG. 6 is a diagram illustrating a configuration example of hardware of a computer used in the second embodiment. The computer 100 is entirely controlled by a
メモリ102は、コンピュータ100の主記憶装置として使用される。メモリ102には、プロセッサ101に実行させるOSのプログラムやアプリケーションプログラムの少なくとも一部が一時的に格納される。また、メモリ102には、プロセッサ101による処理に必要な各種データが格納される。メモリ102としては、例えばRAM(Random Access Memory)などの揮発性の半導体記憶装置が使用される。
The
バス109に接続されている周辺機器としては、ストレージ装置103、グラフィック処理装置104、入力インタフェース105、光学ドライブ装置106、機器接続インタフェース107およびネットワークインタフェース108がある。
Peripheral devices connected to the bus 109 include a
ストレージ装置103は、内蔵した記憶媒体に対して、電気的または磁気的にデータの書き込みおよび読み出しを行う。ストレージ装置103は、コンピュータの補助記憶装置として使用される。ストレージ装置103には、OSのプログラム、アプリケーションプログラム、および各種データが格納される。なお、ストレージ装置103としては、例えばHDD(Hard Disk Drive)やSSD(Solid State Drive)を使用することができる。
The
グラフィック処理装置104には、モニタ21が接続されている。グラフィック処理装置104は、プロセッサ101からの命令に従って、画像をモニタ21の画面に表示させる。モニタ21としては、CRT(Cathode Ray Tube)を用いた表示装置や液晶表示装置などがある。
A
入力インタフェース105には、キーボード22とマウス23とが接続されている。入力インタフェース105は、キーボード22やマウス23から送られてくる信号をプロセッサ101に送信する。なお、マウス23は、ポインティングデバイスの一例であり、他のポインティングデバイスを使用することもできる。他のポインティングデバイスとしては、タッチパネル、タブレット、タッチパッド、トラックボールなどがある。
A
光学ドライブ装置106は、レーザ光などを利用して、光ディスク24に記録されたデータの読み取りを行う。光ディスク24は、光の反射によって読み取り可能なようにデータが記録された可搬型の記録媒体である。光ディスク24には、DVD(Digital Versatile Disc)、DVD−RAM、CD−ROM(Compact Disc Read Only Memory)、CD−R(Recordable)/RW(ReWritable)などがある。
The
機器接続インタフェース107は、コンピュータ100に周辺機器を接続するための通信インタフェースである。例えば機器接続インタフェース107には、メモリ装置25やメモリリーダライタ26を接続することができる。メモリ装置25は、機器接続インタフェース107との通信機能を搭載した記録媒体である。メモリリーダライタ26は、メモリカード27へのデータの書き込み、またはメモリカード27からのデータの読み出しを行う装置である。メモリカード27は、カード型の記録媒体である。
The
ネットワークインタフェース108は、ネットワーク20に接続されている。ネットワークインタフェース108は、ネットワーク20を介して、他のコンピュータまたは通信機器との間でデータの送受信を行う。
The
以上のようなハードウェア構成によって、第2の実施の形態の処理機能を実現することができる。なお、第1の実施の形態に示した情報処理装置10も、図6に示したコンピュータ100と同様のハードウェアにより実現することができる。
With the hardware configuration described above, the processing functions of the second embodiment can be realized. The
コンピュータ100は、例えばコンピュータ読み取り可能な記録媒体に記録されたプログラムを実行することにより、第2の実施の形態の処理機能を実現する。コンピュータ100に実行させる処理内容を記述したプログラムは、様々な記録媒体に記録しておくことができる。例えば、コンピュータ100に実行させるプログラムをストレージ装置103に格納しておくことができる。プロセッサ101は、ストレージ装置103内のプログラムの少なくとも一部をメモリ102にロードし、プログラムを実行する。またコンピュータ100に実行させるプログラムを、光ディスク24、メモリ装置25、メモリカード27などの可搬型記録媒体に記録しておくこともできる。可搬型記録媒体に格納されたプログラムは、例えばプロセッサ101からの制御により、ストレージ装置103にインストールされた後、実行可能となる。またプロセッサ101が、可搬型記録媒体から直接プログラムを読み出して実行することもできる。
The computer 100 implements the processing functions of the second embodiment by executing a program recorded on a computer-readable recording medium, for example. A program describing the processing content to be executed by the computer 100 can be recorded in various recording media. For example, a program to be executed by the computer 100 can be stored in the
<処理機能>
コンピュータ100は、2つのソースコードセットそれぞれから作成されたコールグラフを比較し、エッジの差分を検出する。コールグラフ比較処理のためにコンピュータ100が有する機能を図7に示す。
<Processing function>
The computer 100 compares call graphs created from each of the two source code sets and detects an edge difference. The functions of the computer 100 for the call graph comparison process are shown in FIG.
図7は、コールグラフ比較のためのコンピュータの機能を示すブロック図である。コンピュータ100は、第1コールグラフ記憶部111、第2コールグラフ記憶部112、要求受付部120、距離別エッジ分類部130、第1距離別エッジリスト記憶部141、第2距離別エッジリスト記憶部142、同一距離間エッジ比較部150、第1差分エッジ記憶部161、第2差分エッジ記憶部162、第1存在エッジ記憶部163、第2存在エッジ記憶部164、差分エッジ抽出部170、差分抽出結果記憶部180、および結果返答部190を有する。このうち距離別エッジ分類部130は、第1の実施の形態における分類部12aの一例である。また同一距離間エッジ比較部150は、第1の実施の形態における特定部12bの一例である。さらに差分エッジ抽出部170は、第1の実施の形態における抽出部12cの一例である。
FIG. 7 is a block diagram illustrating functions of a computer for call graph comparison. The computer 100 includes a first call
第1コールグラフ記憶部111は、比較対象の2つのコールグラフのうちの一つを記憶する。例えば第1コールグラフ記憶部111は、改変前の版数のソフトウェアにおけるメソッド間の呼び出し関係を示すコールグラフを記憶する。
The first call
第2コールグラフ記憶部112は、比較対象の2つのコールグラフのうちの他の一つを記憶する。例えば第2コールグラフ記憶部112は、改変後の版数のソフトウェアにおけるメソッド間の呼び出し関係を示すコールグラフを記憶する。
The second call
要求受付部120は、開発者による差分抽出要求の入力を受け付ける。差分抽出要求には、着目するメソッドを指定する情報と、探索方向を指定する情報とが含まれる。要求受付部120は、受け付けた差分抽出要求を、距離別エッジ分類部130に送信する。
The
距離別エッジ分類部130は、第1コールグラフ記憶部111と第2コールグラフ記憶部112とに記憶されている2つのコールグラフそれぞれのエッジを、着目するメソッドに対応するノードからの距離により分類する。具体的には、距離別エッジ分類部130は、着目するメソッドからの距離ごとのカテゴリを生成する。そして距離別エッジ分類部130は、第1コールグラフ記憶部111に記憶されているコールグラフを読み出し、そのコールグラフ内のエッジが属するカテゴリを判断し、各エッジをカテゴリごとに第1距離別エッジリスト記憶部141に格納する。同様に、距離別エッジ分類部130は、第2コールグラフ記憶部112に記憶されているコールグラフを読み出し、そのコールグラフ内のエッジが属するカテゴリを判断し、各エッジをカテゴリごとに第2距離別エッジリスト記憶部142に格納する。
The edge classification unit by distance classifies the edges of each of the two call graphs stored in the first call
第1距離別エッジリスト記憶部141は、第1コールグラフ記憶部111内のコールグラフに含まれるエッジを、着目するメソッドからの距離に応じたカテゴリに分類して記憶する。
The first distance-specific edge
第2距離別エッジリスト記憶部142は、第2コールグラフ記憶部112内のコールグラフに含まれるエッジを、着目するメソッドからの距離に応じたカテゴリに分類して記憶する。
The second distance-specific edge
同一距離間エッジ比較部150は、第1距離別エッジリスト記憶部141と第2距離別エッジリスト記憶部142との同じカテゴリに分類されたエッジ同士を比較し、同じエッジの有無を判断する。そして同一距離間エッジ比較部150は、第1距離別エッジリスト記憶部141内のあるカテゴリに記憶されているが、第2距離別エッジリスト記憶部142内の同一カテゴリに記憶されていないエッジを、第1差分エッジ記憶部161に格納する。また同一距離間エッジ比較部150は、第2距離別エッジリスト記憶部142内のあるカテゴリに記憶されているが、第1距離別エッジリスト記憶部141内の同一カテゴリに記憶されていないエッジを、第2差分エッジ記憶部162に格納する。
The same distance
さらに同一距離間エッジ比較部150は、第1差分エッジ記憶部161に格納したエッジのハッシュ値を算出し、得られたハッシュ値を第1存在エッジ記憶部163に格納する。また同一距離間エッジ比較部150は、第2差分エッジ記憶部162に格納したエッジのハッシュ値を算出し、得られたハッシュ値を第2存在エッジ記憶部164に格納する。
Further, the same distance
第1差分エッジ記憶部161は、第1距離別エッジリスト記憶部141内のあるカテゴリに記憶されているが、第2距離別エッジリスト記憶部142内の同一カテゴリに記憶されていないエッジを記憶する。
The first differential
第2差分エッジ記憶部162は、第2距離別エッジリスト記憶部142内のあるカテゴリに記憶されているが、第1距離別エッジリスト記憶部141内の同一カテゴリに記憶されていないエッジを記憶する。
The second difference
第1存在エッジ記憶部163は、第1差分エッジ記憶部161に格納されたエッジのハッシュ値を記憶する。
第2存在エッジ記憶部164は、第2差分エッジ記憶部162に格納されたエッジのハッシュ値を記憶する。
The first existence
The second existence
差分エッジ抽出部170は、第1差分エッジ記憶部161と第2差分エッジ記憶部162とから、比較対象の2つのコールグラフの一方にのみ含まれるエッジを抽出する。具体的には、差分エッジ抽出部170は、第1差分エッジ記憶部161に記憶されているエッジのハッシュ値と同一のハッシュ値が、第2存在エッジ記憶部164に格納されているか否かを判断する。差分エッジ抽出部170は、該当するハッシュ値が格納されていなければ、ハッシュ値の生成元であるエッジを第1差分エッジ記憶部161から抽出し、差分抽出結果記憶部180に格納する。また差分エッジ抽出部170は、第2差分エッジ記憶部162に記憶されているエッジのハッシュ値と同一のハッシュ値が、第1存在エッジ記憶部163に格納されているか否かを判断する。差分エッジ抽出部170は、該当するハッシュ値が格納されていなければ、ハッシュ値の生成元であるエッジを第2差分エッジ記憶部162から抽出し、差分抽出結果記憶部180に格納する。
The difference
差分抽出結果記憶部180は、第1コールグラフ記憶部111と第2コールグラフ記憶部112とのいずれか一方に格納されているコールグラフにのみ含まれるエッジの抽出結果を記憶する。
The difference extraction
結果返答部190は、差分抽出要求に対する応答として、差分抽出結果記憶部180に記憶されているエッジの情報を出力する。
なお、図7に示した各要素間を接続する線は通信経路の一部を示すものであり、図示した通信経路以外の通信経路も設定可能である。また、図7に示した各要素の機能は、例えば、その要素に対応するプログラムモジュールをコンピュータに実行させることで実現することができる。
The
In addition, the line which connects between each element shown in FIG. 7 shows a part of communication path, and communication paths other than the illustrated communication path can also be set. Moreover, the function of each element shown in FIG. 7 can be realized, for example, by causing a computer to execute a program module corresponding to the element.
<データ構造>
次に、図8〜図12を参照し、コンピュータ100内の各記憶部に格納されるデータについて具体的に説明する。
<Data structure>
Next, data stored in each storage unit in the computer 100 will be described in detail with reference to FIGS.
図8は、第1・第2コールグラフ記憶部内のデータの例を示す図である。第1コールグラフ記憶部111には、コールグラフ40を示すコールグラフデータ111aが格納されている。コールグラフデータ111aには、コールグラフ40に含まれる複数のエッジ42a〜42kそれぞれを示す文字列の2つ組が含まれる。第2コールグラフ記憶部112には、コールグラフ40aを示すコールグラフデータ112aが格納されている。コールグラフデータ112aには、コールグラフ40aに含まれる複数のエッジ42a〜42c,42e〜42k,42l,42mそれぞれを示す文字列の2つ組が含まれる。
FIG. 8 is a diagram illustrating an example of data in the first and second call graph storage units. The first call
図9は、第1・第2距離別エッジリスト記憶部内のデータの例を示す図である。第1距離別エッジリスト記憶部141には、起点ノードからの距離による、コールグラフ40内のエッジの分類結果を示す第1距離別エッジリスト141aが格納されている。第2距離別エッジリスト記憶部142には、起点ノードからの距離による、コールグラフ40a内のエッジの分類結果を示す第2距離別エッジリスト142aが格納されている。
FIG. 9 is a diagram illustrating an example of data in the first and second distance-specific edge list storage units. The first distance-specific edge
第1距離別エッジリスト141aおよび第2距離別エッジリスト142aは、記憶領域が、距離によってカテゴライズされたブロックに分けられている。各ブロックには、起点ノードからの距離が、そのブロックに設定された距離と同じであるエッジが登録される。例えば「距離1」の欄には、起点ノードからの距離が「1」であるエッジが登録される。
In the first distance-specific edge list 141a and the second distance-specific edge list 142a, the storage area is divided into blocks categorized by distance. In each block, an edge whose distance from the starting node is the same as the distance set in the block is registered. For example, in the “
図10は、第1・第2差分エッジ記憶部内のデータの例を示す図である。第1差分エッジ記憶部161には、第1差分エッジリスト161aが格納されている。第1差分エッジリスト161aは、第1距離別エッジリスト141a内のある距離の欄には登録されているが、第2距離別エッジリスト142a内の同一距離の欄には登録されていないエッジの集合を示す。第2差分エッジ記憶部162には、第2差分エッジリスト162aが格納されている。第2差分エッジリスト162aは、第2距離別エッジリスト142a内のある距離の欄には登録されているが、第1距離別エッジリスト141a内の同一距離の欄には登録されていないエッジの集合を示す。
FIG. 10 is a diagram illustrating an example of data in the first and second differential edge storage units. The first differential
図11は、第1・第2存在エッジ記憶部内のデータの例を示す図である。第1存在エッジ記憶部163には、第1存在エッジリスト163aが格納されている。第1存在エッジリスト163aは、第1差分エッジリスト161a内の複数のエッジそれぞれのハッシュ値を示すデータである。第2存在エッジ記憶部164には、第2存在エッジリスト164aが格納されている。第2存在エッジリスト164aは、第2差分エッジリスト162a内の複数のエッジそれぞれのハッシュ値を示すデータである。
FIG. 11 is a diagram illustrating an example of data in the first and second existence edge storage units. The first existing
図12は、差分抽出結果記憶部内のデータの例を示す図である。差分抽出結果記憶部180には、2つのコールグラフ40,40aの一方にのみ含まれるエッジの集合を示す最終差分エッジリスト181が格納されている。最終差分エッジリスト181には、エッジごとに、エッジを表す文字列の2つ組と、そのエッジが含まれていたコールグラフの識別番号とが設定されている。例えばコールグラフ40の識別番号を「1」、コールグラフ40aの識別番号を「2」とする。この場合、コールグラフ40に存在し、コールグラフ40aに存在しないエッジ42k(文字列の2つ組(“g”,“k”)には、コールグラフ40の識別番号「1」が付与される。
FIG. 12 is a diagram illustrating an example of data in the difference extraction result storage unit. The difference extraction
<処理手順>
コンピュータ100は、以上のようなデータを用いて、2つのコールグラフ40,40aの差分エッジ抽出処理を行う。以下、差分エッジ抽出処理について詳細に説明する。
<Processing procedure>
The computer 100 performs differential edge extraction processing of the two call graphs 40 and 40a using the above data. Hereinafter, the differential edge extraction process will be described in detail.
図13は、差分エッジ抽出処理の手順を示すフローチャートである。以下、図13に示す処理をステップ番号に沿って説明する。なお差分エッジ抽出処理は、差分抽出要求が入力されたときに実行される。 FIG. 13 is a flowchart illustrating a procedure of differential edge extraction processing. In the following, the process illustrated in FIG. 13 will be described in order of step number. The difference edge extraction process is executed when a difference extraction request is input.
[ステップS101]差分抽出要求を受け付けた要求受付部120は、その差分抽出要求を、距離別エッジ分類部130に送信する。その後、ステップS102とステップS103の処理が並列に実行される。
[Step S101] Upon receiving the difference extraction request, the
[ステップS102]距離別エッジ分類部130は、差分抽出要求を取得すると、2つのスレッドを立ち上げる。そして距離別エッジ分類部130は、1つ目のスレッドにより、第1コールグラフ記憶部111内のコールグラフデータ111aに対する距離別エッジ分類処理を実行する。これにより、第1距離別エッジリスト記憶部141に、第1距離別エッジリスト141aが記憶される。
[Step S <b> 102] The edge-by-
[ステップS103]距離別エッジ分類部130は、2つ目のスレッドにより、第2コールグラフ記憶部112内のコールグラフデータ112aに対する距離別エッジ分類処理を実行する。これにより、第2距離別エッジリスト記憶部142に、第2距離別エッジリスト142aが記憶される。
[Step S103] The edge-by-
ステップS102,S103の距離別エッジ分類処理は、コールグラフ内のエッジを、起点ノードからの距離で分類する処理である。距離別エッジ分類処理の詳細は後述する(図14参照)。ステップS102とステップS103の両方の処理が終了すると、処理がステップS104に進められる。 The distance-based edge classification processing in steps S102 and S103 is processing for classifying the edges in the call graph by the distance from the starting node. Details of the distance-based edge classification processing will be described later (see FIG. 14). When the processes in both step S102 and step S103 are completed, the process proceeds to step S104.
[ステップS104]距離別エッジ分類部130は、同一距離間エッジ比較処理を実行する。同一距離間エッジ比較処理では、第1距離別エッジリスト141aと第2距離別エッジリスト142aそれぞれにおける、起点ノードからの距離が同じカテゴリ内のエッジ集合同士が比較され、同一のエッジの有無が判断される。同一距離間エッジ比較処理により、第1差分エッジ記憶部161に第1差分エッジリスト161aが格納され、第2差分エッジ記憶部162に第2差分エッジリスト162aが格納される。また同一距離間エッジ比較処理により、第1存在エッジ記憶部163に第1存在エッジリスト163aが格納され、第2存在エッジ記憶部164に第2存在エッジリスト164aが格納される。同一距離間エッジ比較処理の詳細は後述する(図15参照)。同一距離間エッジ比較処理が終了すると、ステップS105とステップS106との処理が並列で実行される。
[Step S104] The edge-by-
[ステップS105]差分エッジ抽出部170は、2つのスレッドを立ち上げる。そして差分エッジ抽出部170は、1つ目のスレッドにより、第1差分エッジリスト161aを対象として、距離違いエッジ存在確認処理を実行する。この距離違いエッジ存在確認処理では、第1差分エッジリスト161aに含まれているが第2差分エッジリスト162aには含まれていないエッジが特定される。
[Step S105] The differential
[ステップS106]差分エッジ抽出部170は、2つ目のスレッドにより、第2差分エッジリスト162aを対象として、距離違いエッジ存在確認処理を実行する。この距離違いエッジ存在確認処理では、第2差分エッジリスト162aに含まれているが第1差分エッジリスト161aには含まれていないエッジが特定される。
[Step S106] The difference
ステップS105,S106の距離違いエッジ存在確認処理の詳細は後述する(図16参照)。ステップS105,S106の距離違いエッジ存在確認処理により、差分抽出結果記憶部180内に最終差分エッジリスト181が格納される。ステップS105とステップS106の両方の処理が終了すると、処理がステップS107に進められる。
Details of the difference edge existence confirmation processing in steps S105 and S106 will be described later (see FIG. 16). The final difference edge list 181 is stored in the difference extraction
[ステップS107]結果返答部190は、差分抽出処理の結果を示す最終差分エッジリスト181を、差分抽出要求への応答として出力する。
以上のような手順で、2つのコールグラフ40,40a間の差分エッジを抽出することができる。以下、距離別エッジ分類処理(ステップS102,S103)、同一距離間エッジ比較処理(ステップS104)、および距離違いエッジ存在確認処理(ステップS105,S106)について、図14〜図16を参照して詳細に説明する。
[Step S107] The
The difference edge between the two call graphs 40 and 40a can be extracted by the procedure as described above. Hereinafter, the distance-based edge classification processing (steps S102 and S103), the same distance edge comparison processing (step S104), and the distance difference edge presence confirmation processing (steps S105 and S106) will be described in detail with reference to FIGS. Explained.
図14は、距離別エッジ分類処理の手順の一例を示すフローチャートである。以下、第1コールグラフ記憶部111内のコールグラフデータ111aを処理対象とする場合を例に取り、図14に示す処理をステップ番号に沿って説明する。
FIG. 14 is a flowchart illustrating an example of a procedure of distance-based edge classification processing. In the following, the process shown in FIG. 14 will be described in order of step numbers, taking as an example the case where the call graph data 111a in the first call
[ステップS111]距離別エッジ分類部130は、差分抽出要求で指定された、着目するメソッドに対応するノードを起点ノードとし、起点ノードの識別子のみが要素として登録された現ノードリストを生成する。現ノードリストに登録されるノードの識別子は、例えばそのノードに対応するメソッドのメソッド名である。生成された現ノードリストは、例えばメモリ102内に格納される。
[Step S111] The edge-by-
[ステップS112]距離別エッジ分類部130は、比較対象の距離dに「1」を設定する。
[ステップS113]距離別エッジ分類部130は、内容が空の次ノードリストを生成する。生成された次ノードリストは、例えばメモリ102内に格納される。
[Step S112] The
[Step S113] The edge-by-
[ステップS114]距離別エッジ分類部130は、コールグラフデータ111aに含まれるすべてのエッジを、未探索の状態に設定する。例えば、距離別エッジ分類部130は、コールグラフデータ111a内のエッジに「探索済」を示すフラグが設定されていた場合、そのフラグを削除する。
[Step S114] The
[ステップS115]距離別エッジ分類部130は、現ノードリストに登録されている要素を、現在ノードとして1つ選択する。
[ステップS116]距離別エッジ分類部130は、現在ノードから探索方向に接続された、「探索済」のフラフが付与されていないエッジの1つを、探索対象として選択する。なお、探索方向は差分抽出要求において指定されている。探索方向が、呼び出し先方向であれば、距離別エッジ分類部130は、コールグラフデータ111aから、現在ノードを呼び出し元とするエッジを1つ選択する。探索方向が、呼び出し元方向であれば、距離別エッジ分類部130は、コールグラフデータ111aから、現在ノードを呼び出し先とするエッジを1つ選択する。
[Step S115] The edge-based
[Step S116] The edge-by-
[ステップS117]距離別エッジ分類部130は、選択したエッジを、第1距離別エッジリスト141aの距離dのブロックに格納する。そして距離別エッジ分類部130は、コールグラフデータ111aの選択したエッジに「探索済」のフラグを設定する。
[Step S117] The edge-by-
[ステップS118]距離別エッジ分類部130は、次ノードリストに、選択したエッジで接続される2つのノードのうち、現在ノード以外のノードを、次ノードリストに追加する。探索方向が呼び出し先方向であれば、選択したエッジの呼び出し先のノードが、次ノードリストに追加される。探索方向が呼び出し元方向であれば、選択したエッジの呼び出し元のノードが、次ノードリストに追加される。
[Step S118] The edge-by-
[ステップS119]距離別エッジ分類部130は、現在ノードから探索方向に接続されたすべてのエッジを探索対象としたか否かを判断する。すべてのエッジを探索対象とした場合、処理がステップS120に進められる。探索対象としてないエッジがある場合、処理がステップS116に進められる。
[Step S119] The edge-by-
[ステップS120]距離別エッジ分類部130は、現ノードリスト内のすべてのノードを処理したか否かを判断する。すべてのノードの処理が完了していれば、距離別エッジ分類処理が終了する。未処理のノードがあれば、処理がステップS121に進められる。
[Step S120] The edge-by-
[ステップS121]距離別エッジ分類部130は、現ノードリストの内容を、次ノードリストの内容と一致させる。例えば距離別エッジ分類部130は、現ノードリストの内容をすべて削除した後、次ノードリストに登録されているすべてのノードを、現ノードリストに登録する。
[Step S121] The edge-by-
[ステップS122]距離別エッジ分類部130は、次ノードリスト内の全ノードを削除し、次ノードリストを空にする。その後、処理がステップS115に進められる。
このようにして、コールグラフ40に含まれるエッジ42a〜42kが、距離によってカテゴライズされ、第1距離別エッジリスト141aに登録される。同様に、第2コールグラフ記憶部112内のコールグラフデータ112aを処理対象として、図14の距離別エッジ分類処理を実行すれば、コールグラフ40aに含まれるエッジ42a〜42c,42e〜42j,42l,42mが、距離によって分類される。そして各エッジ42a〜42c,42e〜42j,42l,42mが、距離ごとのカテゴリに分けて第2距離別エッジリスト142aに登録される。その後、同一距離間エッジ比較部150により、同一距離間エッジ比較処理が実行される。
[Step S122] The edge-based
In this way, the
図15は、同一距離間エッジ比較処理の手順の一例を示すフローチャートである。以下、図15に示す処理をステップ番号に沿って説明する。
[ステップS131]同一距離間エッジ比較部150は、距離dに1を設定する。
FIG. 15 is a flowchart illustrating an example of the same distance edge comparison process. In the following, the process illustrated in FIG. 15 will be described in order of step number.
[Step S131] The same distance
[ステップS132]同一距離間エッジ比較部150は、第1距離別エッジリスト141aの距離dのブロックに格納されたエッジを、所定の基準でソートする。例えば同一距離間エッジ比較部150は、エッジを表す2つ組の文字列に基づいて、アルファベット順で、同一の距離にカテゴライズされたエッジをソートする。そして同一距離間エッジ比較部150は、ソート後のエッジの配列を、第1リストとする。
[Step S132] The
[ステップS133]同一距離間エッジ比較部150は、第2距離別エッジリスト142aの距離dのブロックに格納されたエッジを、ステップS132と同様の基準でソートする。そして同一距離間エッジ比較部150は、ソート後のエッジの配列を、第2リストとする。
[Step S133] The
[ステップS134]同一距離間エッジ比較部150は、第1リストの先頭エッジを、第1リストの着目点とする。同様に同一距離間エッジ比較部150は、第2リストの先頭エッジを、第2リストの着目点とする。
[Step S134] The same distance
[ステップS135]同一距離間エッジ比較部150は、第1リストの着目点のエッジと、第2リストの着目点のエッジとが同一か否かを判断する。エッジが同一であれば、処理がステップS136に進められる。エッジが同一でなければ、処理がステップS137に進められる。
[Step S135] The same distance
[ステップS136]同一距離間エッジ比較部150は、第1リストの着目点を、第1リストの現在の着目点のエッジの次のエッジに移動する。また同一距離間エッジ比較部150は、第2リストの着目点を、第2リストの現在の着目点のエッジの次のエッジに移動する。その後、処理がステップS144に進められる。
[Step S136] The same distance
[ステップS137]同一距離間エッジ比較部150は、第1リストの着目点のエッジと第2リストの着目点のエッジとについて、ステップS132,S133のソート条件に基づく大小を比較する。例えば同一距離間エッジ比較部150は、ソート条件において上位になるエッジほど、小さいエッジであると判断する。第1リストの着目点のエッジの方が小さければ、処理がステップS138に進められる。第2リストの着目点のエッジの方が小さければ、処理がステップS141に進められる。
[Step S137] The same distance
[ステップS138]同一距離間エッジ比較部150は、第1差分エッジリスト161aに、第1リストの着目点のエッジを追加する。
[ステップS139]同一距離間エッジ比較部150は、第1存在エッジリスト163aに、第1リストの着目点のエッジのハッシュ値を追加する。
[Step S138] The same-distance
[Step S139] The
[ステップS140]同一距離間エッジ比較部150は、第1リストの着目点を、第1リストの現在の着目点のエッジの次のエッジに移動する。その後、処理がステップS144に進められる。
[Step S140] The same distance
[ステップS141]同一距離間エッジ比較部150は、第2差分エッジリスト162aに、第2リストの着目点のエッジを追加する。
[ステップS142]同一距離間エッジ比較部150は、第2存在エッジリスト164aに、第2リストの着目点のエッジのハッシュ値を追加する。
[Step S141] The same distance
[Step S142] The same-distance
[ステップS143]同一距離間エッジ比較部150は、第2リストの着目点を、第2リストの現在の着目点のエッジの次のエッジに移動する。
[ステップS144]同一距離間エッジ比較部150は、第1リストと第2リストとの両方において、すべてのエッジを比較済みか否かを判断する。すべてのエッジを比較済みであれば、処理がステップS145に進められる。第1リストと第2リストとの少なくとも一方に、比較していないエッジ(着目点になっていないエッジ)があれば、処理がステップS135に進められる。
[Step S143] The same distance
[Step S144] The same distance
なお、第1リストと第2リストの一方において、すべてのエッジが比較済みとなっている場合、比較対象として残存しているエッジは、同一または大小の比較の相手が存在しない。その場合、比較対象として残存しているエッジについて、ステップS135の同一性判定では「NO」と判断される。またステップS137の大小判定では、比較対象として残存しているエッジの方が小さいと判定される。 In addition, when all the edges have been compared in one of the first list and the second list, the same or larger comparison partner does not exist for the remaining edges as comparison targets. In this case, the edge remaining as the comparison target is determined as “NO” in the identity determination in step S135. In the size determination in step S137, it is determined that the remaining edge as a comparison target is smaller.
[ステップS145]同一距離間エッジ比較部150は、カテゴリとして存在するすべての距離dについて処理を実施したか否かを判断する。すべての距離dについて処理が完了した場合、同一距離間エッジ比較処理が終了する。未処理の距離があれば、処理がステップS146に進められる。
[Step S145] The same distance
[ステップS146]同一距離間エッジ比較部150は、距離dの値に1を加算し、処理をステップS132に進める。
このようにして、第1差分エッジリスト161a、第2差分エッジリスト162a、第1存在エッジリスト163a、および第2存在エッジリスト164aが生成される。その後、差分エッジ抽出部170により、距離違いエッジ存在確認処理(ステップS105,S106)が実行される。
[Step S146] The same distance
In this way, the first differential edge list 161a, the second differential edge list 162a, the first existing edge list 163a, and the second existing edge list 164a are generated. Thereafter, the difference
図16は、距離違いエッジ存在確認処理の手順の一例を示すフローチャートである。以下、第1差分エッジ記憶部161内の第1差分エッジリスト161aを、エッジの抽出元として処理を実行する場合を例に取り、図16に示す処理をステップ番号に沿って説明する。
FIG. 16 is a flowchart illustrating an example of the procedure of the difference distance edge presence confirmation process. In the following, the process shown in FIG. 16 will be described in order of step number, taking as an example the case where the first differential edge list 161a in the first differential
[ステップS151]差分エッジ抽出部170は、第1差分エッジリスト161aから未処理のエッジを1つ選択する。
[ステップS152]差分エッジ抽出部170は、選択したエッジのハッシュ値を計算し、そのハッシュ値が第2存在エッジリスト164a内に存在するか否かを判断する。ハッシュ値が存在する場合、処理がステップS154に進められる。ハッシュ値が存在しなければ、処理がステップS153に進められる。
[Step S151] The differential
[Step S152] The differential
[ステップS153]差分エッジ抽出部170は、選択したエッジに、そのエッジの抽出元のソースコードの識別子を付与し、差分抽出結果記憶部180内の最終差分エッジリスト181に追加する。
[Step S153] The difference
[ステップS154]差分エッジ抽出部170は、第1差分エッジリスト161a内のすべてのエッジを処理したか否かを判断する。すべてのエッジの処理が完了した場合、距離違いエッジ存在確認処理が終了する。未処理のエッジがあれば、処理がステップS151に進められる。
[Step S154] The differential
このようにして、起点ノードからの距離違いエッジ間で、同一エッジが他方のコールグラフに存在しているかどうかが確認され、存在していないエッジのみが、最終差分エッジリスト181に格納される。そして、最終差分エッジリスト181内のエッジが、差分抽出要求に対する応答として出力される。 In this way, it is confirmed whether or not the same edge exists in the other call graph between the edges with different distances from the origin node, and only the nonexistent edges are stored in the final difference edge list 181. Then, the edge in the final difference edge list 181 is output as a response to the difference extraction request.
<第2の実施の形態の効果>
以上説明したように、第2の実施の形態によれば、起点ノードから距離で分類し、最初に同一距離のエッジ間で差分を抽出するようにしたことで、各エッジについての同一エッジの存否確認が容易となる。その結果、処理が高速化される。
<Effects of Second Embodiment>
As described above, according to the second embodiment, the existence of the same edge for each edge is determined by classifying the distance from the starting node and extracting the difference between the edges having the same distance first. Confirmation is easy. As a result, the processing is speeded up.
ここで、第2の実施の形態に示した差分抽出処理の処理時間を、他の差分抽出処理による処理時間と比較する。比較対象の差分抽出方法として、以下の2つの参考手法を想定する。 Here, the processing time of the difference extraction processing shown in the second embodiment is compared with the processing time of other difference extraction processing. The following two reference methods are assumed as a difference extraction method to be compared.
[第1参考手法]一方のコールグラフ内の各エッジを他方のコールグラフ内の全エッジと総当たりで比較する手法である。この手法では、一致したエッジは双方のコールグラフにあり、一致しなかったエッジは一方のコールグラフのみにあることが検出される。 [First Reference Method] In this method, each edge in one call graph is compared with all the edges in the other call graph. In this approach, it is detected that the matched edge is in both call graphs and the unmatched edge is in only one call graph.
[第2参考手法]それぞれのコールグラフ内のエッジ群をソートし、ソート後のエッジのリスト同士を比較し、相違するエッジを抽出する方法である。この手法では、コールグラフごとにエッジをソートした後、2つのソート済みエッジリストを先頭から順に着目点を移動させながら比較するものである。一致した場合は,双方のリストで着目点が次エッジに移され、不一致の場合、比較して小さい方のエッジがあるリストのみ次のエッジに着目点が移される。一致したエッジは双方のコールグラフにあり、一致しないエッジは比較して小さい方のエッジが一方のコールグラフのみにあると判定される。この第2参考手法は、第2の実施の形態の手法から、距離別エッジ分類処理を除外したものである。 [Second Reference Method] This is a method of sorting the edge groups in each call graph, comparing the sorted lists of edges, and extracting different edges. In this method, after sorting the edges for each call graph, the two sorted edge lists are compared while moving the point of interest sequentially from the top. If they match, the point of interest is moved to the next edge in both lists, and if they do not match, the point of interest is moved to the next edge only in a list that has a smaller edge. A matching edge is found in both call graphs, and a non-matching edge is determined to have a smaller edge in only one call graph. This second reference method is obtained by excluding distance-based edge classification processing from the method of the second embodiment.
以下、図17、図18を参照し、第1・第2参考手法それぞれと、第2の実施の形態に係る手法との差分抽出処理の時間を比較する。なお以下の説明では、変数M、N、k、r、nを用いて、所要時間を計算する。各変数の意味は、以下の通りである。
M,N:それぞれのコールグラフに含まれるエッジの数
k:対象範囲の半径(起点メソッドから呼び出し元・先のメソッドの距離の最大値)
r:2つのコールグラフの元となった2つのソースコードセットの間の違いのある割合(違いのある箇所数/(違いのある箇所数+違いのない箇所数))
n:1つのメソッドを呼び出す(または呼び出される)メソッドの数
<<第1参考手法との比較>>
第1参考手法では、エッジ間の一致判定が総当たりで行われる。ここで、2つのエッジの比較1回当たりの所要時間を単位時間として、その単位時間の何倍の時間で差分抽出処理が完了するのかを計算する。第1参考手法の場合、差分抽出に要する時間rt0は、以下の式で表される。
rt0=MN ・・・(1)
一方、第2の実施の形態に示す手法で差分抽出処理を行う場合の所要時間rt2は、以下の式で表すことができる。
rt2=Mlog2(M/k)+Nlog2(N/k)+M+N+rM+rN
・・・(2)
式(2)の右辺の第1項「Mlog2(M/k)」は、2つのコールグラフのうちの一方のコールグラフの1つのカテゴリ(距離)に属するエッジのソートに要する時間を示している。1つのカテゴリのソートに「(M/k)log2(M/k)」の時間を要し、その時間にカテゴリ数kを乗算することで「Mlog2(M/k)」が得られる。第2項「Nlog2(N/k)」は、他方のコールグラフの1つのカテゴリに属するエッジのソートに要する時間を示している。
Hereinafter, with reference to FIGS. 17 and 18, the time of difference extraction processing between each of the first and second reference techniques and the technique according to the second embodiment is compared. In the following description, the required time is calculated using the variables M, N, k, r, and n. The meaning of each variable is as follows.
M, N: Number of edges included in each call graph k: Radius of target range (maximum distance between calling method and calling method)
r: Ratio of difference between two source code sets that are the basis of two call graphs (number of differences / (number of differences + number of differences))
n: Number of methods calling (or called) one method << Comparison with the first reference method >>
In the first reference method, matching between edges is determined brute force. Here, the time required for one comparison of two edges is set as a unit time, and how many times the unit time is completed is calculated as the unit time. In the case of the first reference method, the time rt0 required for difference extraction is expressed by the following equation.
rt0 = MN (1)
On the other hand, the required time rt2 when the difference extraction process is performed by the method shown in the second embodiment can be expressed by the following equation.
rt2 = Mlog 2 (M / k) + Nlog 2 (N / k) + M + N + rM + rN
... (2)
The first term “Mlog 2 (M / k)” on the right side of Equation (2) indicates the time required to sort the edges belonging to one category (distance) of one of the two call graphs. Yes. A time of “(M / k) log 2 (M / k)” is required to sort one category, and “Mlog 2 (M / k)” is obtained by multiplying the time by the number of categories k. The second term “Nlog 2 (N / k)” indicates the time required to sort the edges belonging to one category of the other call graph.
第3項「M」と第4項「N」とは、同一カテゴリのエッジ間での比較に要する時間である。1つのカテゴリについての比較に要する時間は「(M/k)+(N/k)」であり、その時間にカテゴリ数kを乗算することで「M+N」が得られる。 The third term “M” and the fourth term “N” are times required for comparison between edges of the same category. The time required for comparison for one category is “(M / k) + (N / k)”, and “M + N” is obtained by multiplying the time by the number of categories k.
第5項「rM」と第6項「rN」とは、同一カテゴリのエッジ間の比較で、同じエッジが見つからなかった差分エッジについて、異なるカテゴリのエッジとの比較に要する時間である。 The fifth term “rM” and the sixth term “rN” are the time required to compare the difference edge, for which the same edge is not found in the comparison between edges of the same category, with the edge of a different category.
ここで、2つのコールグラフの元となった2つのソースコードセットの間に、微小な違いしかない場合、1つのメソッドを呼び出す(または呼び出される)メソッドの数nを用いて、以下の近似が可能である(以下の「〜」は近似記号)。 Here, if there is only a small difference between the two source code sets that are the basis of the two call graphs, the following approximation can be made using the number n of methods that call (or are called) one method: It is possible ("~" below is an approximate symbol).
この場合、rt0とrt2は、以下のようになる。
rt0〜M2〜n2k ・・・(4)
rt2〜2M(log2(M/k)+1+r)〜2nk(klog2d−log2k+1+r) ・・・(5)
多くの場合n〜5となる。また様々なシステムのOSのマイナーバージョンアップでは、r〜0.01程度である。このような条件で改善率を計算すると、図17に示すようになる。
In this case, rt0 and rt2 are as follows.
rt0~M 2 ~n 2k ··· (4)
rt2 to 2M (log 2 (M / k) + 1 + r) to 2n k (klog 2 d-log 2 k + 1 + r) (5)
In many cases, it is n-5. In addition, the minor version upgrade of OS of various systems is about r to 0.01. When the improvement rate is calculated under such conditions, it is as shown in FIG.
図17は、第1参考手法と第2の実施の形態に係る手法との比較例を示す図である。図17には、起点ノードからの距離の最大値に応じた、差分抽出時間の改善率を示している。改善率は以下の式で計算される。
改善率=(rt0−rt2)/rt0) ・・・(6)
なお図17では、改善率をパーセントで表記している(式(6)の値×100)。この例では、k=2以上の場合、49%以上の高速化が図れることが分かる。
FIG. 17 is a diagram illustrating a comparative example between the first reference method and the method according to the second embodiment. FIG. 17 shows the improvement rate of the difference extraction time according to the maximum value of the distance from the starting node. The improvement rate is calculated by the following formula.
Improvement rate = (rt0−rt2) / rt0) (6)
In FIG. 17, the improvement rate is expressed as a percentage (value of equation (6) × 100). In this example, it can be seen that when k = 2 or more, the speed can be increased by 49% or more.
<<第2参考手法との比較>>
第2参考手法の場合、差分抽出に要する時間rt1は、以下の式で表すことができきる。
rt1=Mlog2M+Nlog2N+M+N ・・・(7)
式(7)の右辺の第1項「Mlog2M」は、一方のコールグラフのエッジのソートに要する時間を表している。第2項「Nlog2N」は、他方のコールグラフのエッジのソートに要する時間を表している。第3項「M」と第4項「N」は、ソート済みのリスト内のエッジ同士を比較する時間である。
<< Comparison with the second reference method >>
In the case of the second reference method, the time rt1 required for difference extraction can be expressed by the following equation.
rt1 = Mlog 2 M + Nlog 2 N + M + N (7)
The first term “Mlog 2 M” on the right side of Equation (7) represents the time required to sort the edges of one call graph. The second term “Nlog 2 N” represents the time required to sort the edges of the other call graph. The third term “M” and the fourth term “N” are times for comparing edges in the sorted list.
式(3)に示した近似を行うと、rt1は以下のようになる。
rt1〜2M(log2M+1)〜2nk(klog2d+1) ・・・(8)
ここで、n〜5、r〜0.01という条件で改善率を計算すると、図18に示すようになる。
When the approximation shown in Expression (3) is performed, rt1 is as follows.
rt1 to 2M (log 2 M + 1) to 2n k (klog 2 d + 1) (8)
Here, when the improvement rate is calculated under the conditions of n to 5 and r to 0.01, it is as shown in FIG.
図18は、第2参考手法と第2の実施の形態に係る手法との比較例を示す図である。図18には、起点ノードからの距離の最大値に応じた、差分抽出時間の改善率を示している。改善率は以下の式で計算される。
改善率=(rt1−rt2)/rt1) ・・・(9)
なお図18では、改善率をパーセントで表記している(式(9)の値×100)。この例では、k=2以上の場合、20%程度の高速化が図れることが分かる。
FIG. 18 is a diagram illustrating a comparative example between the second reference method and the method according to the second embodiment. FIG. 18 shows the improvement rate of the difference extraction time according to the maximum value of the distance from the starting node. The improvement rate is calculated by the following formula.
Improvement rate = (rt1-rt2) / rt1) (9)
In FIG. 18, the improvement rate is expressed as a percentage (value of equation (9) × 100). In this example, it can be seen that when k = 2 or more, the speed can be increased by about 20%.
このように、第2の実施の形態では、起点ノードからの距離に応じたエッジの分類と、同一距離に属するエッジをソートした上での比較とを行うことで、高速な差分抽出処理が可能となっている。 Thus, in the second embodiment, high-speed differential extraction processing is possible by performing classification of edges according to the distance from the starting node and comparison after sorting edges belonging to the same distance. It has become.
<<その他の効果>>
第2の実施の形態では、コンピュータ100は、同一距離間エッジ比較の結果差分として抽出されたエッジのハッシュ値を計算し、第1存在エッジリスト163aと第2存在エッジリスト164aとを生成している。そして第1存在エッジリスト163aと第2存在エッジリスト164aとを、距離違いエッジ存在確認時の検索対象としている。このように、ハッシュ値によってエッジ存在確認を行うことで、処理が効率化される。例えば、エッジを示す、メソッドの完全修飾名を表す2つの文字列の組の比較をすると、比較対象の文字列が長いことから、メモリ消費量が多くなるとともに、比較にも時間がかかる。MD5(Message Digest 5)などのハッシュ値に変換して比較をすれば、比較対象の文字列が短くなり、メモリ容量が少なくて済むと共に、処理時間も短縮される。
<< Other effects >>
In the second embodiment, the computer 100 calculates the hash value of the edge extracted as the difference as a result of the edge comparison between the same distances, and generates the first existence edge list 163a and the second existence edge list 164a. Yes. Then, the first existence edge list 163a and the second existence edge list 164a are set as search targets when the existence of different distance edges is confirmed. In this way, the processing is streamlined by performing the edge existence confirmation using the hash value. For example, when comparing a pair of two character strings representing the fully qualified name of a method indicating an edge, the comparison target character string is long, so that the memory consumption increases and the comparison also takes time. If the comparison is performed by converting the hash value into MD5 (Message Digest 5) or the like, the character string to be compared is shortened, the memory capacity is reduced, and the processing time is shortened.
例えば、スマートフォンやタブレット端末などの携帯情報端末機器用のOSでは、メソッドの完全修飾名として、以下のような名前が用いられている。なお、以下に示す名前に使用されている文字は、半角文字であるものとする。
・google.protobuf.compiler.StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto.StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto (172文字)
・__gnu_pbds.detail.left_child_next_sibling_heap_node_point_const_iterator_.left_child_next_sibling_heap_node_point_const_iterator_ (129文字)
・extensions.FileBrowserPrivateLogoutUserForReauthenticationFunction.FileBrowserPrivateLogoutUserForReauthenticationFunction (122文字)
・line_map.tree_base.tree_decl_common.tree_decl_with_vis.tree_function_decl.VEC_call_site_record_base_unordered_remove (116文字)
当該OSでは約60万のメソッドがあり、完全修飾名の最長が279文字、最短が5文字、平均が46.2文字、標準偏差は15.6文字である。エッジのデータ構造には、このような長いメソッド名の2つ組が含まれる。
For example, in the OS for portable information terminal devices such as smartphones and tablet terminals, the following names are used as fully qualified names of methods. In addition, the character used for the name shown below shall be a half-width character.
・ Google.protobuf.compiler.StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto.StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto (172 characters)
-__Gnu_pbds.detail.left_child_next_sibling_heap_node_point_const_iterator_.left_child_next_sibling_heap_node_point_const_iterator_ (129 characters)
・ Extensions.FileBrowserPrivateLogoutUserForReauthenticationFunction.FileBrowserPrivateLogoutUserForReauthenticationFunction (122 characters)
・ Line_map.tree_base.tree_decl_common.tree_decl_with_vis.tree_function_decl.VEC_call_site_record_base_unordered_remove (116 characters)
The OS has about 600,000 methods. The longest fully qualified name is 279 characters, the shortest is 5 characters, the average is 46.2 characters, and the standard deviation is 15.6 characters. The edge data structure includes a pair of such long method names.
エッジを示す文字列を例えばMD5のハッシュ値に変換すると128ビット長となる。128ビットは、ASCIIコード(7ビット)でエンコードした文字だと約18文字相当である。すると、上記平均長の完全修飾名の2つ組の長さ(約93文字)方が(標準偏差を考慮しても)、ハッシュ値よりも十分長い。 When a character string indicating an edge is converted into, for example, an MD5 hash value, the length becomes 128 bits. 128 bits are equivalent to about 18 characters when encoded with ASCII code (7 bits). Then, the length (about 93 characters) of the above-mentioned fully qualified name with the average length is sufficiently longer than the hash value (even if the standard deviation is taken into consideration).
従って、エッジのハッシュ値を用いて同一距離間エッジ比較処理を行うことで、少ないデータ量による効率的な処理が可能となる。
以上が第2の実施の形態についての説明である。
Therefore, efficient processing with a small amount of data can be performed by performing edge comparison processing for the same distance using the hash value of the edge.
The above is the description of the second embodiment.
〔その他の実施の形態〕
第2の実施の形態では、第1存在エッジリスト163aと第2存在エッジリスト164aとを用いて距離違いエッジ存在確認を行っているが、第1存在エッジリスト163aと第2存在エッジリスト164aとを用いずに距離違いエッジ存在確認を行ってもよい。その場合、第1差分エッジリスト161a内のエッジのうち、第2差分エッジリスト162aに同一エッジが存在しないエッジが抽出され、最終差分エッジリスト181に登録される。同様に第2差分エッジリスト162a内のエッジのうち、第1差分エッジリスト161aに同一エッジが存在しないエッジが抽出され、最終差分エッジリスト181に登録される。
[Other Embodiments]
In the second embodiment, the distance difference edge existence confirmation is performed using the first existence edge list 163a and the second existence edge list 164a, but the first existence edge list 163a, the second existence edge list 164a, It is also possible to perform edge existence confirmation at different distances without using. In that case, of the edges in the first differential edge list 161 a, an edge that does not have the same edge in the second differential edge list 162 a is extracted and registered in the final differential edge list 181. Similarly, of the edges in the second differential edge list 162a, an edge that does not have the same edge in the first differential edge list 161a is extracted and registered in the final differential edge list 181.
このように、第1差分エッジリスト161aと第2差分エッジリスト162aとを検索対象とする場合、エッジを、各エッジの文字列の2つ組をキー(配列の添え字)とした連想配列で保持してもよい。このとき、キーに応じた連想配列の値(value)は、空欄あるいは「0」などの所定値でよい。すなわち、処理対象のエッジの2つ組の文字列をキーとして連想配列を読み出したとき、対応する値が読み出されれば、そのエッジと同一のエッジが存在することとなり、エラーとなれば、そのエッジと同一のエッジが存在しないこととなる。このように、エッジを示す2つ組の文字列を連想配列に格納することで、第1差分エッジリスト161aと第2差分エッジリスト162aとの一方に存在するエッジが、他方に存在するか否かの検索を効率的に実施することができる。 As described above, when the first differential edge list 161a and the second differential edge list 162a are to be searched, the edge is an associative array using a pair of character strings of each edge as a key (array subscript). It may be held. At this time, the value (value) of the associative array corresponding to the key may be a blank or a predetermined value such as “0”. In other words, when an associative array is read using a pair of character strings of the processing target edge as a key, if the corresponding value is read, the same edge as that edge exists, and if an error occurs, that edge The same edge does not exist. In this way, by storing two sets of character strings indicating edges in the associative array, whether or not an edge that exists in one of the first differential edge list 161a and the second differential edge list 162a exists in the other. Such a search can be carried out efficiently.
また各エッジのハッシュ値を配列のキーとして、第1存在エッジリスト163aと第2存在エッジリスト164aとを保持することも可能である。これにより、第1存在エッジリスト163aと第2存在エッジリスト164aに基づくエッジの存在確認を高速に行うことができる。 It is also possible to hold the first existence edge list 163a and the second existence edge list 164a using the hash value of each edge as an array key. As a result, the presence check of the edge based on the first existence edge list 163a and the second existence edge list 164a can be performed at high speed.
以上、実施の形態を例示したが、実施の形態で示した各部の構成は同様の機能を有する他のものに置換することができる。また、他の任意の構成物や工程が付加されてもよい。さらに、前述した実施の形態のうちの任意の2以上の構成(特徴)を組み合わせたものであってもよい。 As mentioned above, although embodiment was illustrated, the structure of each part shown by embodiment can be substituted by the other thing which has the same function. Moreover, other arbitrary structures and processes may be added. Further, any two or more configurations (features) of the above-described embodiments may be combined.
1 第1コールグラフ
1a〜1d 第1ノード
1e〜1g 第1エッジ
2 第2コールグラフ
2a〜2e 第2ノード
2f〜2i 第2エッジ
3 第1距離別エッジリスト
4 第2距離別エッジリスト
5 第1差分エッジリスト
6 第2差分エッジリスト
7 最終差分エッジリスト
10 情報処理装置
11 記憶部
12 演算部
12a 分類部
12b 特定部
12c 抽出部
DESCRIPTION OF
Claims (5)
起点プログラムモジュールが指定されると、前記起点プログラムモジュールを含む第1ソフトウェア内の複数の第1プログラムモジュール間での呼び出し関係を、前記複数の第1プログラムモジュールを示す複数の第1ノード間を接続する複数の第1エッジによって表した第1コールグラフに基づいて、前記起点プログラムモジュールに対応する第1ノードから呼び出し関係を辿って前記複数の第1エッジそれぞれに到達するまでの距離により、前記複数の第1エッジを距離ごとのカテゴリに分類し、
前記起点プログラムモジュールを含む第2ソフトウェア内の複数の第2プログラムモジュール間での呼び出し関係を、前記複数の第2プログラムモジュールを示す複数の第2ノード間を接続する複数の第2エッジによって表した第2コールグラフに基づいて、前記起点プログラムモジュールに対応する第2ノードから呼び出し関係を辿って前記複数の第2エッジそれぞれに到達するまでの距離により、前記複数の第2エッジを距離ごとのカテゴリに分類し、
前記複数の第1エッジそれぞれを対象とし、対象第1エッジと同じカテゴリに属する第2エッジのなかに、呼び出し元と呼び出し先とのプログラムモジュールの組が該対象第1エッジと共通の第2エッジが存在しない場合、該対象第1エッジを差分候補第1エッジとして特定し、
前記複数の第2エッジそれぞれを対象とし、対象第2エッジと同じカテゴリに属する第1エッジのなかに、呼び出し元と呼び出し先とのプログラムモジュールの組が該対象第2エッジと共通の第1エッジが存在しない場合、該対象第2エッジを差分候補第2エッジとして特定し、
前記差分候補第1エッジのうち、呼び出し元と呼び出し先とのプログラムモジュールの組が共通となる前記差分候補第2エッジが存在しない差分第1エッジを抽出し、
前記差分候補第2エッジのうち、呼び出し元と呼び出し先とのプログラムモジュールの組が共通となる前記差分候補第1エッジが存在しない差分第2エッジを抽出する、
コールグラフ差分抽出方法。 Computer
When a starting point program module is specified, a calling relationship between a plurality of first program modules in the first software including the starting point program module is connected between a plurality of first nodes indicating the plurality of first program modules. Based on the first call graph represented by the plurality of first edges, the plurality of the plurality of the plurality of the plurality of the plurality of the plurality of the plurality of the plurality of the plurality of the plurality of first edges by the distance from the first node corresponding to the starting program module to the respective first edges. Categorize the first edge of
A calling relationship between a plurality of second program modules in the second software including the starting program module is represented by a plurality of second edges connecting a plurality of second nodes indicating the plurality of second program modules. Based on the second call graph, the plurality of second edges are classified into categories for each distance according to the distance from the second node corresponding to the origin program module to the respective second edges following the calling relationship. Classified into
Each of the plurality of first edges is a second edge that belongs to the same category as the target first edge, and a set of program modules of a caller and a callee is a second edge that is common to the target first edge If the target edge does not exist, the target first edge is specified as the difference candidate first edge,
A first edge that is a target of each of the plurality of second edges, and a set of program modules of a caller and a callee is common to the target second edge, among the first edges belonging to the same category as the target second edge If the target second edge does not exist, the target second edge is specified as the difference candidate second edge,
From the difference candidate first edge, extract a difference first edge that does not have the difference candidate second edge where a set of program modules of a caller and a callee is common,
Extracting the difference second edge in which the pair of program modules of the caller and the callee is common, and the difference candidate first edge does not exist among the difference candidate second edges,
Call graph difference extraction method.
前記差分候補第1エッジのハッシュ値が登録された第1存在エッジリストと、前記差分候補第2エッジのハッシュ値が登録された第2存在エッジリストとを生成し、
前記差分第1エッジの抽出では、前記第2存在エッジリストに登録されているハッシュ値とは異なるハッシュ値が得られる前記差分候補第1エッジを、前記差分第1エッジとして抽出し、
前記差分第2エッジの抽出では、前記第1存在エッジリストに登録されているハッシュ値とは異なるハッシュ値が得られる前記差分候補第2エッジを、前記差分第2エッジとして抽出する、
請求項1記載のコールグラフ差分抽出方法。 The computer further comprises:
Generating a first existing edge list in which a hash value of the difference candidate first edge is registered and a second existing edge list in which a hash value of the difference candidate second edge is registered;
In the extraction of the difference first edge, the difference candidate first edge from which a hash value different from the hash value registered in the second existence edge list is obtained is extracted as the difference first edge;
In the extraction of the difference second edge, the difference candidate second edge from which a hash value different from the hash value registered in the first existence edge list is obtained is extracted as the difference second edge.
The call graph difference extraction method according to claim 1.
請求項1または2記載のコールグラフ差分抽出方法。 In the identification of the difference candidate first edge and the difference candidate second edge, the first edge and the second edge are sorted according to a predetermined criterion for each classified category, and are classified into categories of the same distance. Selecting the target first edge in order from the top of the first edge group, selecting the target second edge in order from the top of the second edge group, and comparing the edge group and the second edge group, When the set of program modules of the call source and the call destination at the target first edge and the target second edge is not common, the target first edge and the target second edge are sorted according to the predetermined criterion The higher one is specified as the difference candidate first edge or the difference candidate second edge,
The call graph difference extraction method according to claim 1 or 2.
起点プログラムモジュールが指定されると、前記起点プログラムモジュールを含む第1ソフトウェア内の複数の第1プログラムモジュール間での呼び出し関係を、前記複数の第1プログラムモジュールを示す複数の第1ノード間を接続する複数の第1エッジによって表した第1コールグラフに基づいて、前記起点プログラムモジュールに対応する第1ノードから呼び出し関係を辿って前記複数の第1エッジそれぞれに到達するまでの距離により、前記複数の第1エッジを距離ごとのカテゴリに分類し、
前記起点プログラムモジュールを含む第2ソフトウェア内の複数の第2プログラムモジュール間での呼び出し関係を、前記複数の第2プログラムモジュールを示す複数の第2ノード間を接続する複数の第2エッジによって表した第2コールグラフに基づいて、前記起点プログラムモジュールに対応する第2ノードから呼び出し関係を辿って前記複数の第2エッジそれぞれに到達するまでの距離により、前記複数の第2エッジを距離ごとのカテゴリに分類し、
前記複数の第1エッジそれぞれを対象とし、対象第1エッジと同じカテゴリに属する第2エッジのなかに、呼び出し元と呼び出し先とのプログラムモジュールの組が該対象第1エッジと共通の第2エッジが存在しない場合、該対象第1エッジを差分候補第1エッジとして特定し、
前記複数の第2エッジそれぞれを対象とし、対象第2エッジと同じカテゴリに属する第1エッジのなかに、呼び出し元と呼び出し先とのプログラムモジュールの組が該対象第2エッジと共通の第1エッジが存在しない場合、該対象第2エッジを差分候補第2エッジとして特定し、
前記差分候補第1エッジのうち、呼び出し元と呼び出し先とのプログラムモジュールの組が共通となる前記差分候補第2エッジが存在しない差分第1エッジを抽出し、
前記差分候補第2エッジのうち、呼び出し元と呼び出し先とのプログラムモジュールの組が共通となる前記差分候補第1エッジが存在しない差分第2エッジを抽出する、
処理を実行させるコールグラフ差分抽出プログラム。 On the computer,
When a starting point program module is specified, a calling relationship between a plurality of first program modules in the first software including the starting point program module is connected between a plurality of first nodes indicating the plurality of first program modules. Based on the first call graph represented by the plurality of first edges, the plurality of the plurality of the plurality of the plurality of the plurality of the plurality of the plurality of the plurality of the plurality of the plurality of first edges by the distance from the first node corresponding to the starting program module to the respective first edges. Categorize the first edge of
A calling relationship between a plurality of second program modules in the second software including the starting program module is represented by a plurality of second edges connecting a plurality of second nodes indicating the plurality of second program modules. Based on the second call graph, the plurality of second edges are classified into categories for each distance according to the distance from the second node corresponding to the origin program module to the respective second edges following the calling relationship. Classified into
Each of the plurality of first edges is a second edge that belongs to the same category as the target first edge, and a set of program modules of a caller and a callee is a second edge that is common to the target first edge If the target edge does not exist, the target first edge is specified as the difference candidate first edge,
A first edge that is a target of each of the plurality of second edges, and a set of program modules of a caller and a callee is common to the target second edge, among the first edges belonging to the same category as the target second edge If the target second edge does not exist, the target second edge is specified as the difference candidate second edge,
From the difference candidate first edge, extract a difference first edge that does not have the difference candidate second edge where a set of program modules of a caller and a callee is common,
Extracting the difference second edge in which the pair of program modules of the caller and the callee is common, and the difference candidate first edge does not exist among the difference candidate second edges,
Call graph difference extraction program that executes processing.
前記第1ソフトウェアと前記第2ソフトウェアとの両方に含まれる起点プログラムモジュールが指定されると、前記第1コールグラフに基づいて、前記起点プログラムモジュールに対応する第1ノードから呼び出し関係を辿って前記複数の第1エッジそれぞれに到達するまでの距離により、前記複数の第1エッジを距離ごとのカテゴリに分類し、前記第2コールグラフに基づいて、前記起点プログラムモジュールに対応する第2ノードから呼び出し関係を辿って前記複数の第2エッジそれぞれに到達するまでの距離により、前記複数の第2エッジを距離ごとのカテゴリに分類する分類部と、
前記複数の第1エッジそれぞれを対象とし、対象第1エッジと同じカテゴリに属する第2エッジのなかに、呼び出し元と呼び出し先とのプログラムモジュールの組が該対象第1エッジと共通の第2エッジが存在しない場合、該対象第1エッジを差分候補第1エッジとして特定し、前記複数の第2エッジそれぞれを対象とし、対象第2エッジと同じカテゴリに属する第1エッジのなかに、呼び出し元と呼び出し先とのプログラムモジュールの組が該対象第2エッジと共通の第1エッジが存在しない場合、該対象第2エッジを差分候補第2エッジとして特定する特定部と、
前記差分候補第1エッジのうち、呼び出し元と呼び出し先とのプログラムモジュールの組が共通となる前記差分候補第2エッジが存在しない差分第1エッジを抽出し、前記差分候補第2エッジのうち、呼び出し元と呼び出し先とのプログラムモジュールの組が共通となる前記差分候補第1エッジが存在しない差分第2エッジを抽出する抽出部と、
を有する情報処理装置。 A first call graph representing a call relationship between a plurality of first program modules in the first software by a plurality of first edges connecting a plurality of first nodes indicating the plurality of first program modules; A second call graph representing a calling relationship between a plurality of second program modules in the second software by a plurality of second edges connecting the plurality of second nodes indicating the plurality of second program modules; A storage unit for storing;
When a starting point program module included in both the first software and the second software is specified, the calling relationship is traced from the first node corresponding to the starting point program module based on the first call graph. The plurality of first edges are classified into categories for each distance according to distances to reach each of the plurality of first edges, and are called from the second node corresponding to the origin program module based on the second call graph. A classification unit that classifies the plurality of second edges into categories for each distance according to distances that follow the relationship and reach each of the plurality of second edges;
Each of the plurality of first edges is a second edge that belongs to the same category as the target first edge, and a set of program modules of a caller and a callee is a second edge that is common to the target first edge If the target first edge is specified as a difference candidate first edge, each of the plurality of second edges is targeted, and the first edge belonging to the same category as the target second edge A specific unit that identifies the target second edge as a difference candidate second edge when the set of program modules with the callee does not have a first edge common to the target second edge;
The difference candidate first edge is extracted from the difference candidate first edge, and the difference candidate second edge in which the pair of program modules of the caller and the callee is common does not exist, and of the difference candidate second edge, An extraction unit that extracts a difference second edge in which a pair of program modules of a caller and a callee is common, and the difference candidate first edge does not exist;
An information processing apparatus.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2016024514A JP2017142712A (en) | 2016-02-12 | 2016-02-12 | Call graph difference extraction method, call graph difference extraction program, and information processing device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2016024514A JP2017142712A (en) | 2016-02-12 | 2016-02-12 | Call graph difference extraction method, call graph difference extraction program, and information processing device |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2017142712A true JP2017142712A (en) | 2017-08-17 |
Family
ID=59629155
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2016024514A Pending JP2017142712A (en) | 2016-02-12 | 2016-02-12 | Call graph difference extraction method, call graph difference extraction program, and information processing device |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2017142712A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112099838A (en) * | 2019-06-17 | 2020-12-18 | 腾讯科技(深圳)有限公司 | Method, device and storage medium for determining version difference |
-
2016
- 2016-02-12 JP JP2016024514A patent/JP2017142712A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112099838A (en) * | 2019-06-17 | 2020-12-18 | 腾讯科技(深圳)有限公司 | Method, device and storage medium for determining version difference |
CN112099838B (en) * | 2019-06-17 | 2023-08-15 | 腾讯科技(深圳)有限公司 | Method, device and storage medium for determining version difference |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110837550B (en) | Knowledge graph-based question answering method and device, electronic equipment and storage medium | |
CN112199375B (en) | Cross-modal data processing method and device, storage medium and electronic device | |
CN109918673B (en) | Semantic arbitration method and device, electronic equipment and computer-readable storage medium | |
EP3311311A1 (en) | Automatic entity resolution with rules detection and generation system | |
TW200900958A (en) | Link spam detection using smooth classification function | |
Hariharakrishnan et al. | Survey of pre-processing techniques for mining big data | |
US11651014B2 (en) | Source code retrieval | |
CN110009045A (en) | The recognition methods of internet-of-things terminal and device | |
CN105790967B (en) | Network log processing method and device | |
CN115830649A (en) | Network asset fingerprint feature identification method and device and electronic equipment | |
CN110188207B (en) | Knowledge graph construction method and device, readable storage medium and electronic equipment | |
CN104573683A (en) | Character string recognizing method and device | |
JP6563350B2 (en) | Data classification apparatus, data classification method, and program | |
CN109241360B (en) | Matching method and device of combined character strings and electronic equipment | |
CN106156107B (en) | Method for discovering news hotspots | |
CN116881430A (en) | Industrial chain identification method and device, electronic equipment and readable storage medium | |
CN111488400B (en) | Data classification method, device and computer readable storage medium | |
JP2017142712A (en) | Call graph difference extraction method, call graph difference extraction program, and information processing device | |
CN114444514A (en) | Semantic matching model training method, semantic matching method and related device | |
KR102474042B1 (en) | Method for analyzing association of diseases using data mining | |
CN113742485A (en) | Method and device for processing text | |
CN110059272B (en) | Page feature recognition method and device | |
CN109344254B (en) | Address information classification method and device | |
CN112214615A (en) | Policy document processing method and device based on knowledge graph and storage medium | |
US11210605B1 (en) | Dataset suitability check for machine learning |