JP2009193335A - Automatic annotation insertion method of static verification tool - Google Patents

Automatic annotation insertion method of static verification tool Download PDF

Info

Publication number
JP2009193335A
JP2009193335A JP2008033324A JP2008033324A JP2009193335A JP 2009193335 A JP2009193335 A JP 2009193335A JP 2008033324 A JP2008033324 A JP 2008033324A JP 2008033324 A JP2008033324 A JP 2008033324A JP 2009193335 A JP2009193335 A JP 2009193335A
Authority
JP
Japan
Prior art keywords
annotation
source code
indication
static verification
function call
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.)
Granted
Application number
JP2008033324A
Other languages
Japanese (ja)
Other versions
JP4915362B2 (en
Inventor
Hiroki Tokuoka
宏樹 徳岡
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP2008033324A priority Critical patent/JP4915362B2/en
Publication of JP2009193335A publication Critical patent/JP2009193335A/en
Application granted granted Critical
Publication of JP4915362B2 publication Critical patent/JP4915362B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)
  • Debugging And Monitoring (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To save power in detecting an error position when automatic annotation insertion is executed by using a static verification tool and an annotation. <P>SOLUTION: An automatic annotation insertion program is provided with: a source code input means 31, a static verification execution means 32 for executing static verification of a source code; a pointed-out function call item extraction means 33 for extracting an item concerned with a function call from an item which is warned by static verification as a pointed-out function call item; an annotation rule storage means 44 for storing a table for associating a kind of the pointed-out function call item with an annotation corresponding to the kind; an annotation derivation means 34 for deriving the annotation corresponding to the pointed-out function call item; and an annotation insertion means 35 for inserting the annotation derived by the annotation derivation means 34 into the source code. Consequently, the annotation is automatically inserted according to a warning output by the static verification tool concerned with the function call. <P>COPYRIGHT: (C)2009,JPO&INPIT

Description

本発明は、コンピュータプログラムの静的検証に関する。   The present invention relates to static verification of computer programs.

プログラムの記述内容の適切さをチェックするために静的検証ツールが用いられている。静的検証ツールは、関数呼出においてなんらかの前提条件を置いた上でソースコードの検証を実施する。一般的に静的検証ツールは、アノテーションと呼ばれる特殊な記述を行う事で、この前提条件を変更する機能を備えている。   Static verification tools are used to check the adequacy of program descriptions. The static verification tool performs source code verification after setting some preconditions in the function call. Generally, a static verification tool has a function for changing this precondition by performing a special description called annotation.

例えば、静的検証ツールSPlint(非特許文献1参照)であれば、/*@null@*/というアノテーションを指定する事で、「引数にはNULLが渡されない」という前提を無効化する事ができる。また同様に、/*@out@*/というアノテーションを指定する事で、「引数には未初期化の値が渡されない」という前提を無効化する事ができる。   For example, in the case of the static verification tool SPlint (see Non-Patent Document 1), it is possible to invalidate the premise that “NULL is not passed to the argument” by specifying the annotation “/ * @ null @ * /”. it can. Similarly, by specifying the annotation / * @ out @ * /, it is possible to invalidate the premise that “an uninitialized value is not passed to the argument”.

アノテーションの効果を、図4を例として説明する。図4の4行目において、関数f2の第1引数に対して、/*@null@*/のアノテーションが挿入されている。この結果、12行目においてf2にNULLを渡しているという指摘は発生しない。関数f2にNULLを渡し得るが、それは4行目のアノテーション/*@null@*/により許可されているためである。逆に、21行目においてはNULLポインタ参照の指摘が発生し、この箇所において実行時エラーが発生しうる事がわかる。4行目のアノテーション/*@null@*/により、引数p1にNULLが渡される可能性が考慮されるからである。   The effect of annotation will be described with reference to FIG. In the fourth line of FIG. 4, an annotation of / * @ null @ * / is inserted for the first argument of the function f2. As a result, there is no indication that NULL is passed to f2 in the 12th line. NULL can be passed to the function f2 because it is permitted by the annotation / * @ null @ * / on the fourth line. Conversely, in the 21st line, a NULL pointer reference is pointed out, and it can be seen that a runtime error may occur at this location. This is because the possibility that NULL is passed to the argument p1 is considered by the annotation / * @ null @ * / on the fourth line.

同じ例の3行目において、関数f1の第1引数に対して、/*@out@*/のアノテーションが挿入されている。この結果、11行目においてf1に未初期化値を渡しているという指摘は発生しない。16行目から定義される関数f1においても、未初期化値を渡されても問題ないように作られており、指摘は発生しない。   In the third line of the same example, an annotation of / * @ out @ * / is inserted for the first argument of the function f1. As a result, there is no indication that the uninitialized value is passed to f1 in the eleventh line. The function f1 defined from the 16th line is also created so that there is no problem even if an uninitialized value is passed, and no indication occurs.

以上のように、アノテーションを利用する事で関数呼出時の前提条件を変更することにより、関数呼出に関する前提条件に反する箇所における欠陥ではなく、実行時エラーが発生しうる箇所を静的検証ツールに指摘させる事ができる。   As described above, by using annotations to change the preconditions at the time of function call, not the defects in the parts that violate the preconditions related to function calls, but the places where error can occur at the time of the static verification tool. It can be pointed out.

ここで、前提条件に反する箇所における欠陥ではなく、実行時エラーが発生しうる箇所の指摘が欲しいという視点に立って考える。この場合、静的検証ツール自身によって「その前提が守られない」旨が指摘された関数呼出の前提条件については、その前提条件が無効化された状態での検証結果が得られる事が望ましい。   Here, it is considered from the viewpoint of wanting to point out a point where a run-time error may occur, not a defect at a point that violates the precondition. In this case, with respect to the preconditions for function calls for which it was pointed out that “the premise is not observed” by the static verification tool itself, it is desirable to obtain a verification result in a state where the precondition is invalidated.

例で説明すると、図3に示すソースコードを前述のSPlintで検証した場合、12行目においてf2の第1引数にNULLを渡す可能性があると指摘される。そうであるなら、関数f2の検証についてもNULLを「受け取る」という前提の上での検証結果が得られる事が望ましい。すなわち、図3の4行目に示す/*@null@*/が追加された上で、12行目においてf2の第1引数にNULLを渡す可能性があるという指摘が抑制され、21行目においてNULLポインタ参照という実行時エラーの指摘が発生する方が望ましい。   For example, when the source code shown in FIG. 3 is verified by the above-mentioned SPint, it is pointed out that NULL may be passed to the first argument of f2 on the 12th line. If so, it is desirable to obtain a verification result on the premise that NULL is received for the verification of the function f2. That is, after adding / * @ null @ * / shown in the 4th line of FIG. 3, the indication that NULL may be passed to the first argument of f2 in the 12th line is suppressed, and the 21st line It is desirable that a run-time error indicating a NULL pointer reference occurs.

以下、出願人が知り得た文献公知発明について記載する。特許文献1には、ソフトウェア静的解析における問題箇所の検出精度を向上させることを目的とするソースコード問題予測技術が記載されている。   The following describes known inventions known to the applicant. Patent Document 1 describes a source code problem prediction technique for the purpose of improving the detection accuracy of a problem location in software static analysis.

特許文献2には、プログラム言語の規則違反を、利用者が修正しなくても、自動的に修正可能なエラー検出装置、エラー検出方法およびエラー検出用プログラムを提供することを目的とする技術が記載されている。   Patent Document 2 discloses a technique for providing an error detection device, an error detection method, and an error detection program that can automatically correct a programming language rule violation without correction by a user. Are listed.

特許文献3には、プログラムコードにおける1つ以上の動的なチェックに関する情報を静的に検証するステップであって、プログラムコードにおける1つ以上の動的なチェックの各々がプログラムコードにおけるオペレーションをチェックするようなステップを備えた、プログラムコードについてチェックを行う方法が記載されている。
特開2007−179488号公報 特開平11−296366号公報 特表2007−516538号公報 IEEE SOFTWARE January/February2002 Improving Security Using Extensible Lightweight Static Analysis
Patent Document 3 includes a step of statically verifying information relating to one or more dynamic checks in a program code, each of the one or more dynamic checks in the program code checking an operation in the program code. There is described a method for checking program code, comprising the steps of:
JP 2007-179488 A Japanese Patent Laid-Open No. 11-296366 Special table 2007-516538 gazette IEEE SOFTWARE January / February 2002 Improving Security Using Extensible Lightweight Static Analysis

従来の静的検証ツールでは、上記のように、静的検証ツール自身の指摘に基づいて関数呼出の前提条件を変更し、その上での検証結果を得るには、前提条件を変更するアノテーションをユーザが手動で追加していた。   In the conventional static verification tool, as described above, to change the function call precondition based on the indication of the static verification tool itself, and to obtain the verification result on that, the annotation to change the precondition is added. User added manually.

静的検証ツールとアノテーションを用いた実行時エラー発生箇所の検出作業を省力化することが望まれる。   It is desirable to save labor in detecting errors at runtime using static verification tools and annotations.

本発明の実施の一形態によるアノテーション自動挿入プログラムは、ソースコードを読み込むソースコード入力手段と、静的検証ツールによってソースコードの静的検証を実行する静的検証実行手段と、静的検証によって警告が発せられた事項である指摘事項を記憶する指摘事項記憶手段と、指摘事項から関数呼出に関する事項を関数呼出指摘事項として抜き出す関数呼出指摘事項抽出手段と、関数呼出指摘事項の種類と、種類に対応するアノテーションとを対応づけるテーブルを記憶するアノテーションルール記憶手段と、テーブルにおいて、関数呼出指摘事項抽出手段によって抜き出された関数呼出指摘事項に対応するアノテーションを導出するアノテーション導出手段と、アノテーション導出手段が導出したアノテーションをソースコードに挿入してアノテーション挿入ソースコードを生成するアノテーション挿入手段と、アノテーション挿入ソースコードを出力する結果出力手段とを備える。   An automatic annotation insertion program according to an embodiment of the present invention includes a source code input unit that reads a source code, a static verification execution unit that performs static verification of a source code by a static verification tool, and a warning by static verification. Indication item storage means for memorizing indication items that are issued, function call indication item extraction means for extracting items related to function calls from indication items as function call indication items, types of function call indication items, and types Annotation rule storage means for storing a table for associating corresponding annotations, annotation derivation means for deriving annotations corresponding to function call indication items extracted by the function call indication matter extraction means in the table, and annotation derivation means The annotations derived by Provided and annotations inserting means for generating annotations inserted source code is inserted into the de, and result output means for outputting annotation insertion source code.

本発明の実施の一形態によるアノテーション自動挿入プログラムは、読み込まれたソースコードに対して静的検証ツールによって静的検証を実行する静的検証実行手段と、静的検証ツールによって警告が発せられた事項に対して静的検証ツールが警告を発することを止めるためのアノテーションをソースコードに挿入するアノテーション挿入手段とを備える。   In the automatic annotation insertion program according to the embodiment of the present invention, a static verification execution unit that performs static verification on a loaded source code by a static verification tool, and a warning is issued by the static verification tool An annotation insertion means for inserting an annotation for stopping a warning from being issued by the static verification tool into the source code.

本発明により、静的検証ツールとアノテーションを用いた実行時エラー発生箇所の検出作業を省力化することが可能となる。   According to the present invention, it is possible to save labor for detecting a location where an error occurs at runtime using a static verification tool and an annotation.

次に、本発明の実施の一形態の構成について図面を参照して詳細に説明する。図1を参照すると、本実施の形態におけるシステムは、静的検証ツール1と、入力ソースコード2と、プログラム制御により動作する処理装置3と、情報を記憶する記憶装置4と、出力ソースコード5と、出力指摘事項6とを含む。静的検証ツール1はコンピュータによって実行されるソフトウェアプロダクトである。出力ソースコード5と出力指摘事項6とはコンピュータが出力するテキスト情報である。   Next, the configuration of an embodiment of the present invention will be described in detail with reference to the drawings. Referring to FIG. 1, the system according to the present embodiment includes a static verification tool 1, an input source code 2, a processing device 3 that operates under program control, a storage device 4 that stores information, and an output source code 5. And output indication item 6. The static verification tool 1 is a software product executed by a computer. The output source code 5 and the output indication item 6 are text information output by the computer.

静的検証ツール1としては、従来技術の静的検証ツールを適用することができる。本実施の形態ではhttp://www.splint.org/にて公開されているSPlintを想定する。   As the static verification tool 1, a conventional static verification tool can be applied. In the present embodiment, http: // www. splint. Suppose SPlint published at org /.

入力ソースコード2は、本システムを適用する対象であるソースコードである。図5にその一例を示す。   The input source code 2 is source code to which the present system is applied. An example is shown in FIG.

処理装置3は、ソースコード入力手段31と、静的検証実行手段32と、関数呼出指摘事項抽出手段33と、アノテーション導出手段34と、アノテーション挿入手段35と、結果出力手段36とを備えている。これらの手段は、記憶装置に格納され、演算制御装置によって読み出されて実行されるソフトウェアプロダクトである。   The processing device 3 includes source code input means 31, static verification execution means 32, function call indication item extraction means 33, annotation derivation means 34, annotation insertion means 35, and result output means 36. . These means are software products that are stored in the storage device and read and executed by the arithmetic control device.

これらの手段は、それぞれ概略つぎのように動作する。ソースコード入力手段31は、入力ソースコード2を読み込み、ソースコード記憶部41に格納する。   Each of these means generally operates as follows. The source code input unit 31 reads the input source code 2 and stores it in the source code storage unit 41.

静的検証実行手段32は、静的検証ツール1を利用してソースコード記憶部41に格納されたソースコードを検証する。静的検証ツール1が構文エラー等の箇所を発見して警告メッセージを発した場合、その警告の種類と警告の対象となったソースコードの場所とを含む指摘事項が指摘事項記憶部42に格納される。   The static verification execution unit 32 verifies the source code stored in the source code storage unit 41 using the static verification tool 1. When the static verification tool 1 finds a location such as a syntax error and issues a warning message, the indication items including the type of the warning and the location of the source code targeted for the warning are stored in the indication item storage unit 42. Is done.

関数呼出指摘事項抽出手段33は、指摘事項記憶部42に格納された指摘事項から、関数呼出に関係する指摘事項のみを抜き出し、関数呼出指摘事項記憶部43に格納する。   The function call indication item extraction unit 33 extracts only indication items related to the function call from the indication items stored in the indication item storage unit 42 and stores them in the function call indication item storage unit 43.

アノテーション導出手段34は、関数呼出指摘事項記憶部43に格納された指摘事項と、アノテーションルール記憶部44に格納されているルールを利用し、追加すべきアノテーションを導出し、追加アノテーション記憶部45に格納する。アノテーション挿入手段35は、追加アノテーション記憶部45に格納されたアノテーションを、ソースコード記憶部41に格納されたソースコードに挿入する。結果出力手段36は、ソースコード記憶部41に格納されたソースコードと、指摘事項記憶部42に格納された指摘事項を、出力ソースコード5及び出力指摘事項6として出力する。   The annotation deriving means 34 derives the annotation to be added using the indication items stored in the function call indication item storage unit 43 and the rules stored in the annotation rule storage unit 44, and stores them in the additional annotation storage unit 45. Store. The annotation insertion unit 35 inserts the annotation stored in the additional annotation storage unit 45 into the source code stored in the source code storage unit 41. The result output means 36 outputs the source code stored in the source code storage unit 41 and the indication item stored in the indication item storage unit 42 as the output source code 5 and the output indication item 6.

記憶装置4は、ソースコード記憶部41と、指摘事項記憶部42と、関数呼出指摘事項記憶部43と、アノテーションルール記憶部44と、追加アノテーション記憶部45とを備えている。   The storage device 4 includes a source code storage unit 41, an indication item storage unit 42, a function call indication item storage unit 43, an annotation rule storage unit 44, and an additional annotation storage unit 45.

これらの各記憶部は、概略次のような情報を保持する。ソースコード記憶部41は、ソースコード入力手段31により読み込まれた静的検証対象となる入力ソースコード2を保持する。   Each of these storage units generally holds the following information. The source code storage unit 41 holds the input source code 2 to be statically verified, which is read by the source code input unit 31.

指摘事項記憶部42は、指摘箇所(静的検証ツール1が警告した問題箇所)の各々について、指摘事項を保持する。保持する内容は、ソースコード上の指摘位置、指摘内容、当該指摘事項が関数呼出に関するものか否か、呼び出された関数、引数である。例を図9に示す。   The indication item storage unit 42 holds an indication item for each of the indication points (problem points warned by the static verification tool 1). The contents to be held are the pointed position in the source code, the pointed content, whether or not the pointed item is related to the function call, the called function, and the argument. An example is shown in FIG.

関数呼出指摘事項記憶部43は、静的検証ツールからの指摘事項のうち、関数呼出に関するもののみを保持する。保持する内容は、指摘位置、指摘内容、呼び出された関数、引数である。例を図10に示す。   The function call indication item storage unit 43 holds only items relating to function calls among indication items from the static verification tool. The contents to be held are the indication position, the indication content, the called function, and the argument. An example is shown in FIG.

アノテーションルール記憶部44は、指摘内容と、その指摘内容に対応して挿入すべきアノテーションを対応付けるルールを保持する。その内容の一例が図8に示されている。本実施の形態の説明を通じて、図8に示された例が用いられる。アノテーションルール記憶部44は、静的検証ツールが出力する可能性のある指摘内容のリストである。アノテーションルール記憶部44は、各指摘内容ごとにアノテーションを保持し、アノテーション挿入手段35が指摘内容に応じてソースコードに挿入すべきアノテーションを決定する際に利用される。この内容の一例が図8で、事前に人手により定義され、本実施の形態を通じて変更されない。   The annotation rule storage unit 44 holds a rule for associating the indication content with the annotation to be inserted corresponding to the indication content. An example of the contents is shown in FIG. The example shown in FIG. 8 is used throughout the description of the present embodiment. The annotation rule storage unit 44 is a list of indication contents that the static verification tool may output. The annotation rule storage unit 44 holds an annotation for each indication content, and is used when the annotation insertion unit 35 determines an annotation to be inserted into the source code according to the indication content. An example of this content is manually defined in advance in FIG. 8, and is not changed throughout this embodiment.

追加アノテーション記憶部45は、本システムにより挿入すべきと判断したアノテーションを保持する。追加アノテーション記憶部45は、アノテーションを追加する対象となる関数である追加対象関数と、各々の追加対象関数の引数のうちアノテーションが追加される対象となる引数と、追加アノテーションとの関係を格納する。例を図11に示す。   The additional annotation storage unit 45 holds annotations determined to be inserted by the present system. The additional annotation storage unit 45 stores a relationship between an addition target function that is a function to which annotation is added, an argument to which an annotation is added among arguments of each additional target function, and the additional annotation. . An example is shown in FIG.

次に、図1及び図2を参照して、本実施の形態の動作について詳細に説明する。ソースコード入力手段31が、入力ソースコード2を読み込み、ソースコード記憶部41に格納する(図2のステップA1)。ソースコード記憶部41に格納されたソースコードの例を、図5に示す。   Next, the operation of the present embodiment will be described in detail with reference to FIG. 1 and FIG. The source code input means 31 reads the input source code 2 and stores it in the source code storage unit 41 (step A1 in FIG. 2). An example of the source code stored in the source code storage unit 41 is shown in FIG.

次に、静的検証実行手段32が、従来技術である静的検証ツール1を用いて、ソースコード記憶部41に格納されたソースコードを検証し、得られた指摘事項を指摘事項記憶部42に格納する(図2のステップA2)。この際、指摘位置(指摘事項の発生箇所)及び指摘内容を格納する。関数呼出箇所での指摘事項については、呼び出された関数及び指摘の対象となった引数についても記録する。   Next, the static verification execution means 32 verifies the source code stored in the source code storage unit 41 using the static verification tool 1 which is a conventional technique, and the obtained indication items are indicated to the indication item storage unit 42. (Step A2 in FIG. 2). At this time, the pointed position (the occurrence point of the pointed item) and the pointed content are stored. As for the items to be pointed out at the function call location, the called function and the argument to be pointed out are also recorded.

例として、この時点でソースコード記憶部41に格納されたソースコードの例が図5に示したものであるとするならば、指摘事項記憶部42に格納される指摘事項は図9に示された内容である。一例について説明すると、図9の指摘11は、図5のmain関数の11行目における関数呼出f1(&j)において、第1引数である&jに「未初期化値を渡している」旨の指摘である。これは関数呼出に関する指摘であるから、「関数呼出箇所での指摘」列はYesとなる。   As an example, if the example of the source code stored in the source code storage unit 41 at this time is the one shown in FIG. 5, the indication items stored in the indication item storage unit 42 are shown in FIG. Contents. To explain an example, the indication 11 in FIG. 9 is an indication that “uninitialized value is passed” to & j as the first argument in the function call f1 (& j) on the 11th line of the main function in FIG. It is. Since this is an indication relating to a function call, the “Indication at a function call location” column is Yes.

次に、関数呼出指摘事項抽出手段33が、指摘事項記憶部42に格納された指摘事項のうち、「関数呼出箇所での指摘」列がYesであるものが存在するかを確認し(図2のステップA3)、存在する場合には関数呼出箇所での指摘事項のみを取り出し、関数呼出指摘事項記憶部43に格納する(図2のステップA4)。存在しない場合には、ステップA7へと進む。   Next, the function call indication item extraction means 33 confirms whether there is an indication item in which the “indication at function call location” column is Yes among the indication items stored in the indication item storage unit 42 (FIG. 2). Step A3), if it exists, only the indication item at the function call location is taken out and stored in the function call indication item storage unit 43 (Step A4 in FIG. 2). If not, the process proceeds to step A7.

例として、指摘事項記憶部42に図9に示されたような内容が格納されている場合、すべての項目が関数呼出箇所での指摘であるので、指摘11,12,13すべての項目が関数呼出指摘事項記憶部43に格納される。従って、関数呼出指摘事項記憶部43の内容は図10に示すものとなる。   As an example, when the contents shown in FIG. 9 are stored in the indication item storage unit 42, since all items are indications at the function call location, all indications 11, 12, and 13 are functions. It is stored in the call indication item storage unit 43. Therefore, the contents of the function call indication item storage unit 43 are as shown in FIG.

次に、アノテーション導出手段34が、関数呼出指摘事項記憶部43の各指摘項目に対して、アノテーションルール記憶部44に格納されたルールから指摘内容の列が一致するものを取り出し、追加アノテーション記憶部45に対して格納する(図2のステップA5)。この際、関数呼出指摘事項記憶部43の「呼び出された関数」列及び「引数」列は、それぞれ追加アノテーション記憶部45の「追加対象関数」列及び「引数」列に格納される。また、アノテーションルール記憶部44のアノテーション列は、追加アノテーション記憶部45の「追加アノテーション」列に格納される。   Next, the annotation deriving means 34 extracts the items in which the indication content matches from the rules stored in the annotation rule storage unit 44 for each indication item in the function call indication item storage unit 43, and adds the additional annotation storage unit 45 (step A5 in FIG. 2). At this time, the “called function” column and the “argument” column of the function call indication item storage unit 43 are stored in the “addition target function” column and the “argument” column of the additional annotation storage unit 45, respectively. The annotation string in the annotation rule storage unit 44 is stored in the “additional annotation” column in the additional annotation storage unit 45.

例として、関数呼出指摘事項記憶部43に図10に示す内容が格納されており、アノテーションルール記憶部44に図8の内容が格納されていたとすれば、追加アノテーション記憶部45の内容は図11の内容となる。一例について説明すると、図10に示す指摘11は、「指摘内容」列が「未初期化値を渡している」となっている。図8において「指摘内容」列が「未初期化値を渡している」となっているのはルール1であるから、指摘11は、ルール1と対応付けられる。両者から生成されるのが図11の追加11である。   As an example, assuming that the content shown in FIG. 10 is stored in the function call indication item storage unit 43 and the content of FIG. 8 is stored in the annotation rule storage unit 44, the content of the additional annotation storage unit 45 is as shown in FIG. It becomes the contents of. To explain an example, the indication 11 shown in FIG. 10 has an “indication content” column “passes an uninitialized value”. In FIG. 8, it is rule 1 that the “pointed content” column is “passing an uninitialized value”, so that point 11 is associated with rule 1. The addition 11 of FIG. 11 is generated from both.

なお、このステップの主旨は、静的検証ツールによる指摘事項をもとに、静的検証ツールに与えるアノテーションを決定する事にある。この主旨について、ここで用いた例を利用して説明する。   The main purpose of this step is to determine the annotation to be given to the static verification tool based on the items pointed out by the static verification tool. This gist will be described using the example used here.

本実施の形態で利用している静的検証ツール1であるSPlintは、特段の指定がなければ関数は未初期化値を受け取らない、という前提条件の上で検証を実施している。しかしながら、図10に示す指摘11のように、静的検証ツール1は、関数f1の第1引数に未初期化値を渡す、と結論付けている。従って、これ以降関数f1の検証を実施する際には、第1引数に関しては「未初期化値を受け取らない」という前提条件を無効とすべきであり、すなわち/*@out@*/というアノテーションを関数f1の第1引数に対して挿入すべきである。   SPlint, which is the static verification tool 1 used in the present embodiment, performs verification on the precondition that the function does not receive an uninitialized value unless otherwise specified. However, as indicated by the indication 11 shown in FIG. 10, the static verification tool 1 concludes that an uninitialized value is passed to the first argument of the function f1. Accordingly, when the function f1 is verified thereafter, the precondition that “uninitialized value is not received” should be invalidated for the first argument, that is, the annotation / * @ out @ * / Should be inserted into the first argument of the function f1.

これを実現するために、得られた指摘と対応するアノテーションの情報を図8に保持しておき、このステップで挿入するアノテーションを決める。   In order to realize this, the annotation information corresponding to the obtained indication is retained in FIG. 8, and the annotation to be inserted is determined in this step.

次に、アノテーション挿入手段35により、追加アノテーション記憶部45に示されたアノテーションを、ソースコード記憶部41に格納されたソースコードに挿入し、結果をソースコード記憶部41に書き戻す(図2のステップA6)。より具体的には、追加アノテーション記憶部45の「追加対象関数」列で指定された関数の、「引数」列で指定された引数に対し、「追加アノテーション」列で指定されたアノテーションが挿入される。   Next, the annotation shown in the additional annotation storage unit 45 is inserted into the source code stored in the source code storage unit 41 by the annotation insertion unit 35, and the result is written back to the source code storage unit 41 (FIG. 2). Step A6). More specifically, the annotation specified in the “addition annotation” column is inserted into the argument specified in the “argument” column of the function specified in the “addition target function” column of the additional annotation storage unit 45. The

例として、追加アノテーション記憶部45に図11に示される内容が格納されており、ソースコード記憶部41に図5に示される内容が格納されている場合、アノテーションが挿入された内容は図6に示されるものとなり、この内容がソースコード記憶部41に書き戻される。一例について説明すると、追加アノテーション記憶部45のNo11により、関数f1の第1引数に対し、/*@out@*/というアノテーションを挿入する。この結果が図6の03行目における/*@out@*/である。   As an example, when the content shown in FIG. 11 is stored in the additional annotation storage unit 45 and the content shown in FIG. 5 is stored in the source code storage unit 41, the content in which the annotation is inserted is shown in FIG. This content is displayed, and this content is written back to the source code storage unit 41. Explaining an example, the annotation “/ * @ out @ * /” is inserted into the first argument of the function f1 by No11 of the additional annotation storage unit 45. This result is / * @ out @ * / in the 03rd line of FIG.

以上のように図2のステップA6が終了すると、処理は図2のステップA2に戻る。次に、図2のステップA2が再度実行される。例のみを説明すると、ソースコード記憶部41に図6の内容が格納されていた場合、指摘事項記憶部42に格納される内容は図12のようになる。一度目のステップA2実行とは違う内容が指摘事項記憶部42に格納される事になるが、これはアノテーション挿入の効果である。一例として、図12のNo21は、図6の21行目にて、未初期化値を参照している旨の指摘をうけている。これは、04行目において関数f2の第2引数に/*@out@*/というアノテーションが挿入された事により、静的検証ツールにより関数f2の第2引数に未初期化値が渡される可能性を考慮した検証が実施された結果、指摘されたものである。   As described above, when step A6 in FIG. 2 ends, the processing returns to step A2 in FIG. Next, step A2 in FIG. 2 is executed again. Explaining only an example, when the contents of FIG. 6 are stored in the source code storage unit 41, the contents stored in the indication item storage unit 42 are as shown in FIG. The contents different from the first execution of step A2 are stored in the indication item storage unit 42, which is an effect of the annotation insertion. As an example, No. 21 in FIG. 12 receives an indication that an uninitialized value is referenced on the 21st line in FIG. This is because an uninitialized value can be passed to the second argument of the function f2 by the static verification tool because the annotation / * @ out @ * / is inserted into the second argument of the function f2 on the 04th line. It was pointed out as a result of the verification that considered the nature.

次に、図2のステップA3,A4が再度実行される。例のみを説明すると、指摘事項記憶部42に図12に示されたような内容が格納されている場合、「関数呼出箇所での指摘」がYesであるのは指摘22であるので、指摘22のみが抽出され、関数呼出指摘事項記憶部43に格納される。この結果、関数呼出指摘事項記憶部43の内容は図13に示すように、指摘22のみを格納した内容となる。   Next, steps A3 and A4 in FIG. 2 are executed again. Explaining only the example, when the contents as shown in FIG. 12 are stored in the indication item storage unit 42, it is the indication 22 that the “indication at the function call location” is Yes. Are extracted and stored in the function call indication item storage unit 43. As a result, as shown in FIG. 13, the content of the function call indication matter storage unit 43 is the content storing only the indication 22.

次に、図2のステップA5が再度実行される。例のみを説明すると、関数呼出指摘事項記憶部43に図13に示す内容が格納されており、アノテーションルール記憶部44に図8の内容が格納されていたとすれば、追加アノテーション記憶部45の内容は図14の内容となる。一例について説明すると、図13に示す指摘22は、「指摘内容」列が「NULLを渡している」となっている。図8において「指摘内容」列が「NULLを渡している」となっているのはルール1であるから、指摘22は、ルール1と対応付けられる。両者から生成されるのが図14の追加22である。   Next, step A5 in FIG. 2 is executed again. Explaining only the example, if the content shown in FIG. 13 is stored in the function call indication item storage unit 43 and the content of FIG. 8 is stored in the annotation rule storage unit 44, the content of the additional annotation storage unit 45 is stored. Is the contents of FIG. Explaining an example, the indication 22 shown in FIG. 13 has the “content of indication” column “passing NULL”. In FIG. 8, it is rule 1 that the “pointing content” column is “passing NULL”, and thus point 22 is associated with rule 1. The addition 22 of FIG. 14 is generated from both.

次に、図2のステップA6が再度実行される。例のみを説明すると、追加アノテーション記憶部45に図14に示される内容が格納されており、ソースコード記憶部41に図6に示される内容が格納されている場合、アノテーションが挿入された内容は図7に示されるものとなり、ソースコード記憶部41に書き戻される。図14の追加22により、関数f3の第1引数に対し、/*@null@*/というアノテーションが挿入される。この結果が図7の05行目における/*@null@*/である。   Next, step A6 in FIG. 2 is executed again. Explaining only the example, when the content shown in FIG. 14 is stored in the additional annotation storage unit 45 and the content shown in FIG. 6 is stored in the source code storage unit 41, the content in which the annotation is inserted is It becomes what is shown in FIG. 7 and is written back to the source code storage unit 41. With the addition 22 in FIG. 14, the annotation / * @ null @ * / is inserted into the first argument of the function f3. This result is / * @ null @ * / in the 05th line of FIG.

図2のステップA6が終了したため、処理は再び図2のステップA2に戻る。次に、図2のステップA2が再度実行される。例のみを説明すると、ソースコード記憶部41に図7の内容が格納されていた場合、指摘事項記憶部42に格納される内容は図15のとおりとなる。   Since step A6 in FIG. 2 is completed, the process returns to step A2 in FIG. 2 again. Next, step A2 in FIG. 2 is executed again. Explaining only an example, when the contents of FIG. 7 are stored in the source code storage unit 41, the contents stored in the indication item storage unit 42 are as shown in FIG.

次に、図2のステップA3が再度実行される。例のみを説明すると、指摘事項記憶部42に図15に示されたような内容が格納されている場合、「関数呼出箇所での指摘」がYesであるものは存在しない。従って、ステップA7へと進む。   Next, step A3 in FIG. 2 is executed again. Explaining only an example, when the contents as shown in FIG. 15 are stored in the indication item storage unit 42, there is no case where “indication at a function call location” is Yes. Accordingly, the process proceeds to step A7.

次に、結果出力手段36が、指摘事項記憶部42に格納された指摘事項を出力指摘事項6として出力し、またソースコード記憶部41に格納されたソースコードを出力ソースコード5として、特に加工せず、そのままの形で出力する(図2のステップA7)。   Next, the result output means 36 outputs the indication item stored in the indication item storage unit 42 as the output indication item 6, and the source code stored in the source code storage unit 41 as the output source code 5 is particularly processed. And output as it is (step A7 in FIG. 2).

例として、指摘事項記憶部42に図15に示されたような内容が格納されており、ソースコード記憶部41に図7に示されたような内容が格納されていたとすると、そのままの内容が出力される。すなわち、出力指摘事項6として図15の内容を、出力ソースコード5として図7の内容が出力される。   For example, if the indication item storage unit 42 stores the contents as shown in FIG. 15 and the source code storage unit 41 stores the contents as shown in FIG. Is output. That is, the content of FIG. 15 is output as the output indication item 6 and the content of FIG. 7 is output as the output source code 5.

図15に示された指摘事項すなわち指摘31,32は、双方とも関数呼出箇所での指摘ではなく、未初期化値が参照される(指摘31)、NULLが参照される(指摘32)といった、実行時にエラーが出る事に対する指摘である。また、図7の内容により、どのようなアノテーションが追加された結果として、指摘事項が得られたかを確認する事ができる。以上により、本システムのユーザは、アノテーション挿入作業を実施する事なく、実行時エラー発生箇所の指摘を得る事ができる。本発明の一実施形態の動作の説明は以上である。   The indication items shown in FIG. 15, that is, indications 31 and 32 are not indicated at the function call location, but are referred to an uninitialized value (indication 31) or NULL (indication 32). This is an indication that an error occurs during execution. Further, according to the contents of FIG. 7, it is possible to confirm what annotations have been obtained as a result of adding annotations. As described above, the user of this system can obtain the point where the runtime error occurs without performing the annotation insertion work. The operation of the embodiment of the present invention has been described above.

アノテーション自動挿入プログラムが適用されるシステムの構成を示す。The system configuration to which the automatic annotation insertion program is applied is shown. アノテーション自動挿入プログラムの動作を示す。The operation of the automatic annotation insertion program is shown. 静的検証が適用されるソースコードの一例である。It is an example of the source code to which static verification is applied. アノテーションを説明するためのソースコードの一例である。It is an example of the source code for demonstrating an annotation. アノテーション自動挿入プログラムが適用されるソースコードの一例である。It is an example of source code to which an annotation automatic insertion program is applied. アノテーションが挿入されたソースコードの一例である。It is an example of the source code in which the annotation is inserted. アノテーションが挿入されたソースコードの一例である。It is an example of the source code in which the annotation is inserted. アノテーションルール記憶部に格納されるデータを示す。Data stored in the annotation rule storage unit is shown. 指摘事項記憶部に格納される指摘事項を示す。Indicates the indication items stored in the indication item storage unit. 関数呼出指摘事項記憶部に格納されるデータを示す。Data stored in the function call indication item storage unit is shown. 追加アノテーション記憶部に格納されるデータを示す。The data stored in an additional annotation memory | storage part are shown. 指摘事項記憶部に格納されるデータを示す。Data stored in the indication item storage unit is shown. 関数呼出指摘事項記憶部に格納されるデータを示す。Data stored in the function call indication item storage unit is shown. 追加アノテーション記憶部に格納されるデータを示す。The data stored in an additional annotation memory | storage part are shown. 指摘事項記憶部に格納されるデータを示す。Data stored in the indication item storage unit is shown.

符号の説明Explanation of symbols

1 静的検証ツール
2 入力ソースコード
3 処理装置
4 記憶装置
5 出力ソースコード
6 出力指摘事項
31 ソースコード入力手段
32 静的検証実行手段
33 関数呼出指摘事項抽出手段
34 アノテーション導出手段
35 アノテーション挿入手段
36 結果出力手段
DESCRIPTION OF SYMBOLS 1 Static verification tool 2 Input source code 3 Processing apparatus 4 Memory | storage device 5 Output source code 6 Output indication 31 Source code input means 32 Static verification execution means 33 Function call indication extraction means 34 Annotation derivation means 35 Annotation insertion means 36 Result output means

Claims (3)

ソースコードを読み込むソースコード入力手段と、
静的検証ツールによって前記ソースコードの静的検証を実行する静的検証実行手段と、
前記静的検証によって警告が発せられた事項である指摘事項を記憶する指摘事項記憶手段と、
前記指摘事項から関数呼出に関する事項を関数呼出指摘事項として抜き出す関数呼出指摘事項抽出手段と、
前記関数呼出指摘事項の種類と、前記種類に対応するアノテーションとを対応づけるテーブルを記憶するアノテーションルール記憶手段と、
前記テーブルにおいて、前記関数呼出指摘事項抽出手段によって抜き出された前記関数呼出指摘事項に対応する前記アノテーションを導出するアノテーション導出手段と、
前記アノテーション導出手段が導出した前記アノテーションを前記ソースコードに挿入してアノテーション挿入ソースコードを生成するアノテーション挿入手段と、
前記アノテーション挿入ソースコードを出力する結果出力手段
とを具備するアノテーション自動挿入プログラム。
Source code input means for reading source code;
Static verification execution means for executing static verification of the source code by a static verification tool;
An indication item storage means for storing an indication item which is an item for which a warning is issued by the static verification;
A function call indication extracting means for extracting a function call indication from the indication as a function call indication;
Annotation rule storage means for storing a table associating the types of the function call indication items with the annotations corresponding to the types;
In the table, annotation derivation means for deriving the annotation corresponding to the function call indication matter extracted by the function call indication matter extraction means;
Annotation insertion means for generating the annotation insertion source code by inserting the annotation derived by the annotation derivation means into the source code;
An annotation automatic insertion program comprising: a result output means for outputting the annotation insertion source code.
請求項1に記載されたアノテーション自動挿入プログラムであって、
前記アノテーションは、前記静的検証ツールによって警告が発せられた事項に対して、前記静的検証ツールが警告を発することを止めるための記述である
アノテーション自動挿入プログラム。
An annotation automatic insertion program according to claim 1,
The annotation is a description for stopping the static verification tool from issuing a warning with respect to a matter for which a warning has been issued by the static verification tool.
読み込まれたソースコードに対して静的検証ツールによって静的検証を実行する静的検証実行手段と、
前記静的検証ツールによって警告が発せられた事項に対して前記静的検証ツールが前記警告を発することを止めるためのアノテーションを前記ソースコードに挿入するアノテーション挿入手段
とを具備するアノテーション自動挿入プログラム。
Static verification execution means for executing static verification by a static verification tool on the loaded source code,
An annotation automatic insertion program comprising: annotation insertion means for inserting an annotation for stopping the warning from being issued by the static verification tool to the source code with respect to an item for which a warning has been issued by the static verification tool.
JP2008033324A 2008-02-14 2008-02-14 Annotation automatic insertion method of static verification tool Expired - Fee Related JP4915362B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2008033324A JP4915362B2 (en) 2008-02-14 2008-02-14 Annotation automatic insertion method of static verification tool

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2008033324A JP4915362B2 (en) 2008-02-14 2008-02-14 Annotation automatic insertion method of static verification tool

Publications (2)

Publication Number Publication Date
JP2009193335A true JP2009193335A (en) 2009-08-27
JP4915362B2 JP4915362B2 (en) 2012-04-11

Family

ID=41075289

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2008033324A Expired - Fee Related JP4915362B2 (en) 2008-02-14 2008-02-14 Annotation automatic insertion method of static verification tool

Country Status (1)

Country Link
JP (1) JP4915362B2 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011133966A (en) * 2009-12-22 2011-07-07 Fujitsu Ltd Device and method for analyzing program
WO2013186642A1 (en) * 2012-06-13 2013-12-19 International Business Machines Corporation Instantiating a coding competition to develop a program module in a networked computing environment
US9336114B2 (en) 2012-07-24 2016-05-10 Samsung Electronics Co., Ltd. Apparatus and method for detecting error
CN106681708A (en) * 2016-11-16 2017-05-17 中国科学院软件研究所 Automatic source code annotation generation method based on data mining
WO2022114486A1 (en) * 2020-11-24 2022-06-02 주식회사 비투엔 Automated annotation examination system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11134187A (en) * 1997-10-27 1999-05-21 Fujitsu Ltd Source program analysis device and its program storage medium
JP2006092475A (en) * 2004-09-27 2006-04-06 Hitachi Software Eng Co Ltd Source code inspection system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11134187A (en) * 1997-10-27 1999-05-21 Fujitsu Ltd Source program analysis device and its program storage medium
JP2006092475A (en) * 2004-09-27 2006-04-06 Hitachi Software Eng Co Ltd Source code inspection system

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011133966A (en) * 2009-12-22 2011-07-07 Fujitsu Ltd Device and method for analyzing program
WO2013186642A1 (en) * 2012-06-13 2013-12-19 International Business Machines Corporation Instantiating a coding competition to develop a program module in a networked computing environment
US8875093B2 (en) 2012-06-13 2014-10-28 International Business Machines Corporation Instantiating a coding competition to develop a program module in a networked computing environment
US9336114B2 (en) 2012-07-24 2016-05-10 Samsung Electronics Co., Ltd. Apparatus and method for detecting error
CN106681708A (en) * 2016-11-16 2017-05-17 中国科学院软件研究所 Automatic source code annotation generation method based on data mining
WO2022114486A1 (en) * 2020-11-24 2022-06-02 주식회사 비투엔 Automated annotation examination system

Also Published As

Publication number Publication date
JP4915362B2 (en) 2012-04-11

Similar Documents

Publication Publication Date Title
US8719791B1 (en) Display of aggregated stack traces in a source code viewer
US10019240B2 (en) Method and apparatus for detecting code change
US8694977B2 (en) Distributed compiling process with instruction signature support
JP4915362B2 (en) Annotation automatic insertion method of static verification tool
JP2010238228A (en) Method and device for dynamically analyzing program
JP2010097426A (en) Computer program, and device and method for receiving input of source program
EP2778629A1 (en) Method and device for code change detection
JP2008191963A (en) Source code verification system, source code verification method and source code verification program
JP2015011372A (en) Debug support system, method, program, and recording medium
US20110202906A1 (en) Compiling method and compiling program
JP5188421B2 (en) Source code analysis method and source code analysis support system
US10042612B2 (en) Software development support apparatus, software development support method, and computer readable medium
JP5170555B2 (en) Error trace simplification system, error trace simplification method, and program
US9417871B2 (en) Automatic generation of certificate of origin (COO) for software systems
JP2005339204A (en) Information processor, and program testing method
JP5811859B2 (en) Source code static analysis device, system, method, and program therefor
JP5024252B2 (en) Trace information acquisition device, trace information acquisition program, and trace information acquisition method
JP2017151594A (en) Supporting device, supporting method, and program
JP4983027B2 (en) Check program and check method
JP2007257397A (en) Contention state detection process additional program, contention state detection process adding apparatus and contention state detection process adding method
JP5365846B2 (en) Program verification apparatus, program verification method, and verification function execution program
CN116361748B (en) Software supply chain safety detection method and device
JP2014154039A (en) Sequence monitoring automatic programming device and automatic programming method
JP6724673B2 (en) Test support program, test support method, and test support device
JP2012018641A (en) Software development system

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20111018

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20111020

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20111207

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20111227

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

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20120109

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

Free format text: PAYMENT UNTIL: 20150203

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees