WO2023145165A1 - プログラム検査装置、及びプログラム検査方法 - Google Patents

プログラム検査装置、及びプログラム検査方法 Download PDF

Info

Publication number
WO2023145165A1
WO2023145165A1 PCT/JP2022/039564 JP2022039564W WO2023145165A1 WO 2023145165 A1 WO2023145165 A1 WO 2023145165A1 JP 2022039564 W JP2022039564 W JP 2022039564W WO 2023145165 A1 WO2023145165 A1 WO 2023145165A1
Authority
WO
WIPO (PCT)
Prior art keywords
program
change
code
source code
error
Prior art date
Application number
PCT/JP2022/039564
Other languages
English (en)
French (fr)
Inventor
亮輔 林
一 芹沢
Original Assignee
日立Astemo株式会社
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 日立Astemo株式会社 filed Critical 日立Astemo株式会社
Publication of WO2023145165A1 publication Critical patent/WO2023145165A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Definitions

  • the present invention relates to a program inspection device.
  • the incorrect source code description may not be output as an error, and the effect may propagate to other locations, causing the originally correct description to be output as an error. Since the user is not directly notified of the cause of the error, it may be difficult to correct the error.
  • Patent Document 1 Japanese Patent Laid-Open No. 2010-117808
  • a debug device executes instructions based on an object file, and if an error routine process in a misalignment check library is reached, a break occurs. Therefore, a language processing device that detects misalignment is described.
  • Patent document 2 Japanese Patent Application Laid-Open No. 2012-048445
  • An instruction execution unit that executes an object program, a cache memory that temporarily holds the object program, and a fetch request for the object program by the instruction execution unit.
  • a program reading unit that reads an object program and holds it in a cache memory, and a check code derivation formula that is sequentially calculated for the read object program, generates a check code for each block, and is inserted in the object program in advance.
  • a program execution device 120 is described that includes a check code determination unit that determines whether an object program is correct or not on a block-by-block basis by comparing with a check code.
  • the present invention was made to solve the above-mentioned problems, and aims to provide an inspection device that reveals the true cause of an error based on seemingly unknown behavioral changes.
  • the program checking apparatus is composed of a computer having an arithmetic unit for executing predetermined arithmetic processing and a storage device connected to the arithmetic unit, the storage device having at least a compiler for compiling source code. and the arithmetic unit identifies an error occurrence position in the source code by executing the compiler, generates a change position candidate for applying an equivalent change to the source code, and executes the compiler to identify the change position candidate.
  • the method is characterized by specifying an error occurrence location in a source code to which an equivalent change is applied to a candidate, and specifying a true error cause location in the source code based on a change in the error occurrence location.
  • the true causative code can be identified from the change in behavior of the compiler. Problems, configurations, and effects other than those described above will be clarified by the following description of the embodiments.
  • FIG. 1 is a block diagram showing an example configuration of an inspection apparatus according to a first embodiment
  • FIG. 1 is a configuration diagram of functional elements of an inspection apparatus according to Embodiment 1
  • FIG. 4 is a flow chart showing an example of processing executed by an analysis program according to the first embodiment
  • 4 is a flow chart showing an example of processing executed by a code modification program according to the first embodiment
  • 6 is a flow chart showing an example of processing executed by an inspection program according to the first embodiment
  • 4 is a flow chart showing an example of processing executed by an end determination program according to the first embodiment
  • It is a figure which shows an example of a change of the code
  • It is a figure which shows an example of a change of the code
  • It is a figure which shows an example of an end determination process.
  • It which shows an example of an end determination process.
  • FIG. 1 is a block diagram showing an example of the configuration of an inspection apparatus 1 according to Embodiment 1 of the present invention.
  • the inspection device 1 is a device for inspecting a code 9 to be inspected, which is a source code, and is composed of a computer including a processor (CPU) 20, a storage device (HDD) 21, a communication device 22, and a memory 23. be done. Processor 20 , storage device (HDD) 21 , communication device 22 and memory 23 are connected via interconnect 24 .
  • the inspection apparatus 1 may have an input interface and an output interface (not shown).
  • the processor 20 is an arithmetic device that executes programs stored in the memory 23 .
  • the program may be described as the subject of each process, but the processor 2 actually acts as the subject of each process. Note that part of the processing performed by the processor 20 by executing the program may be performed by another computing device (for example, hardware such as ASIC and FPGA).
  • the memory 23 includes ROM, which is a non-volatile storage element, and RAM, which is a volatile storage element.
  • the ROM stores immutable programs (eg, BIOS) and the like.
  • RAM is a high-speed and volatile storage device such as DRAM (Dynamic Random Access Memory), and temporarily stores programs executed by processor 20 and data used during program execution.
  • the memory 23 stores the analysis program 4, the code change program 5, the inspection program 6, the end determination program 7, the compiler 8, the code to be inspected 9, the initial error information 10, the changed code 11, the previous error A location 12 and a dummy code database 13 are stored.
  • the auxiliary storage device 21 is, for example, a large-capacity, non-volatile storage device such as a magnetic storage device (HDD) or flash memory (SSD).
  • the auxiliary storage device 21 stores data used by the processor 20 when executing the program (for example, the code to be checked 9, the initial error information 10, the modified code 11, the previous error location 12, the dummy code database 13, etc.), and the processor 20 Stores the program to run. That is, the program is read from the auxiliary storage device 21, loaded into the memory 23, and executed by the processor 20, thereby realizing each function of the inspection apparatus 1.
  • the communication device 22 is a network interface device that controls communication with other devices according to a predetermined protocol.
  • the input interface is an interface to which an input device such as a keyboard and mouse is connected and receives input from the operator.
  • the output interface is an interface to which an output device such as a display device or a printer is connected, and which outputs program execution results (for example, the identified true error cause position) in a form that can be visually recognized by the operator.
  • a user terminal connected to the inspection apparatus 1 via a network may provide the input device and the output device.
  • the inspection device 1 may have the function of a web server, and the user terminal may access the inspection device 1 using a predetermined protocol (for example, http).
  • the program executed by the processor 20 is provided to the inspection device 1 via removable media (CD-ROM, flash memory, etc.) or network, and stored in the non-volatile auxiliary storage device 21, which is a non-temporary storage medium. Therefore, the inspection apparatus 1 preferably has an interface for reading data from removable media.
  • the inspection apparatus 1 is a computer system configured on one physical computer or on a plurality of computers configured logically or physically, and is a virtual computer system configured on a plurality of physical computer resources. It may run on a computer.
  • the analysis program 4, the code modification program 5, the inspection program 6, the end determination program 7, and the compiler 8 may operate on separate physical or logical computers, or may be combined into one physical or logical computer. It may operate on a logical computer.
  • FIG. 2 is a configuration diagram of functional elements of the inspection apparatus 1 according to the first embodiment.
  • the analysis program 4 analyzes the code 9 to be inspected, the code change program 5 inserts dummy code into the code 9 to be inspected, and adds equivalent changes so that the code 9 to be inspected performs the same operation.
  • a compiler 8 compiles the modified code 11, a check program 6 checks the compiled result, and an end determination program 7 determines the end of processing. Details of each process will be described with reference to the flowcharts in FIG. 3 and subsequent figures.
  • the end determination program 7 determines to continue the processing, it instructs the code change program 5 to insert the dummy code in the next dummy code insertion position candidate, and the code change continues until the end determination program 7 determines the end of the processing. Inspection processing of the inspection target code 9 by the program 5, the compiler 8 and the inspection program 6 is repeated.
  • FIG. 3 is a flow chart showing an example of processing executed by the analysis program 4 according to the first embodiment.
  • the analysis program 4 analyzes the code 9 to be inspected, which is the source code, and outputs dummy code insertion position candidates.
  • the analysis program 4 acquires the inspection target code 9 to be analyzed.
  • the analysis program 4 analyzes the acquired inspection target code 9. For example, search for breaks in sentences.
  • the parsing program 4 may use parsing algorithms.
  • the analysis program 4 generates dummy code insertion position candidates.
  • the analysis program 4 may generate dummy code insertion position candidates in the entire range of the code 9 to be inspected.
  • dummy code insertion position candidates may be generated in the range from the beginning of the code 9 to be inspected to the error position of the initial error information 10.
  • a dummy code insertion position candidate may be generated in the range from the beginning of 9 to several lines below the error position of the initial error information 10 .
  • dummy code insertion position candidates may be generated in the range from the end of the code to be inspected 9 to the error position of the initial error information 10.
  • a dummy code insertion position candidate may be generated in the range from the end of 9 to several lines above the error position of the initial error information 10 .
  • the analysis program 4 outputs the generated dummy code insertion position candidate to the code modification program 5 .
  • FIG. 4 is a flow chart showing an example of processing executed by the code change program 5 according to the first embodiment.
  • the code change program 5 inserts the dummy code into one of the dummy code insertion position candidates to generate the changed code 11 .
  • the code modification program 5 acquires the dummy code insertion position generated by the analysis program 4.
  • the code modification program 5 acquires the dummy code description from the dummy code database 13.
  • the dummy code is a variable declaration statement or a function call statement that is not directly related to processing.
  • the inserted dummy code is desirably a statement that has the same grammatical properties as the error line.
  • the code change program 5 may determine the dummy code to be inserted according to the type of dummy code determined by the analysis program 4 with reference to the initial error information 10 .
  • the dummy code may be determined according to error information that occurs or can occur.
  • the initial error information 10 is the position information of the error line before dummy code insertion obtained by the first compilation of the program.
  • step 203 the code modification program 5 inserts dummy code into the dummy code insertion position candidate and modifies the source code. For example, inserting a dummy code in the 7th line in the code 9 to be tested shown in FIG. 7A before dummy code insertion yields a modified code 11 shown in FIG. 7B.
  • step 204 the code modification program 5 outputs the modified code 11 in which the dummy code is inserted and the information of the dummy code insertion position to the compiler 8, and outputs the information of the dummy code insertion position to the inspection program 6.
  • FIG. 5 is a flowchart showing an example of processing executed by the inspection program 6 according to the first embodiment.
  • the inspection program 6 compares the dummy code insertion location with the compile error occurrence location and outputs the inspection result.
  • step 301 the inspection program 6 acquires information on the object code generated by the compiler 8 from the modified code 11 in which the dummy code was inserted, the error occurrence position that occurred during compilation, and the dummy code insertion position.
  • the inspection program 6 compares and analyzes the dummy code insertion location and the compile error occurrence location, and acquires the inspection result.
  • step 303 the inspection program 6 outputs the inspection result (whether the insertion point is an error) to the end determination program 7.
  • FIG. 6 is a flow chart showing an example of processing executed by the termination determination program 7 according to the first embodiment.
  • the end determination program 7 estimates the true error cause location based on the presence or absence of change in the inspection result.
  • the end determination program 7 acquires the inspection result and the previous error position.
  • the end determination program 7 determines whether the acquired test results are "changed”. If the inspection result is "changed”, proceed to step 404; otherwise, proceed to step 403.
  • the error position will change. If there is no change in the error position from the previous error position, the true error position will be before the dummy code insertion position. Therefore, if the dummy code insertion position is shifted forward from the last part and the error position (the line number where the error occurs) does not change, it is assumed that there is a true error between the dummy code insertion position and the error position. can.
  • step 403 if the inspection result is "changed", the end determination program 7 specifies the true error cause position from the obtained result, and outputs the specified true error cause position from the output interface or the communication device 22. to end the process.
  • step 404 if the inspection result is "no change", the end determination program 7 records the current error position in the previous error position 12.
  • the previous error location 12 is used to compare if there is a change in the error location during the next compilation.
  • the end determination program 7 inserts a dummy code at the next dummy code insertion position and instructs the code change program 5 to continue the inspection processing of the code 9 to be inspected.
  • the program checking apparatus 1 identifies the error occurrence position of the code to be checked (source code) 9 by executing the compiler 8, and applies equivalent changes to the code to be checked 9. generated a change position candidate (dummy code insertion position candidate) that will Since the true error cause position of the code 9 to be inspected is specified by specifying the position and changing the error occurrence position, the description of the code that is the true cause can be estimated from the change in the operation of the compiler 8 .
  • the present invention is not limited to the above-described embodiments, and includes various modifications and equivalent configurations within the scope of the attached claims.
  • the above-described embodiments have been described in detail for easy understanding of the present invention, and the present invention is not necessarily limited to those having all the described configurations.
  • part of the configuration of one embodiment may be replaced with the configuration of another embodiment.
  • the configuration of another embodiment may be added to the configuration of one embodiment.
  • additions, deletions, and replacements of other configurations may be made for a part of the configuration of each embodiment.
  • each configuration, function, processing unit, processing means, etc. described above may be realized by hardware, for example, by designing a part or all of them with an integrated circuit, and the processor realizes each function. It may be realized by software by interpreting and executing a program to execute.
  • Information such as programs, tables, and files that implement each function can be stored in storage devices such as memories, hard disks, SSDs (Solid State Drives), or recording media such as IC cards, SD cards, and DVDs.
  • storage devices such as memories, hard disks, SSDs (Solid State Drives), or recording media such as IC cards, SD cards, and DVDs.
  • control lines and information lines indicate those that are considered necessary for explanation, and do not necessarily indicate all the control lines and information lines necessary for implementation. In practice, it can be considered that almost all configurations are interconnected.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

プログラム検査装置であって、所定の演算処理を実行する演算装置と、前記演算装置に接続された記憶デバイスとを有する計算機によって構成され、前記記憶デバイスは、少なくともソースコードをコンパイルするコンパイラを格納し、前記演算装置は、前記コンパイラの実行によって、前記ソースコードのエラー発生位置を特定し、前記ソースコードに等価変更を適用する変更位置候補を生成し、前記コンパイラの実行によって、前記変更位置候補に等価変更が適用されたソースコードのエラー発生位置を特定し、前記エラー発生位置の変化によって、前記ソースコードの真のエラー原因位置を特定する。

Description

プログラム検査装置、及びプログラム検査方法 参照による取り込み
 本出願は、令和4年(2022年)1月27日に出願された日本出願である特願2022-11199の優先権を主張し、その内容を参照することにより、本出願に取り込む。
 本発明は、プログラム検査装置に関する。
 コンパイラは、ソースコードをコンパイルする際に、誤ったソースコードの記述がエラーと出力されず、他の箇所に影響が伝播して、本来正常な記述がエラーと出力されることがある。ユーザは、エラーの原因が直接的に通知されないため、誤った箇所の修正が難しいことがある。
 本技術分野の背景技術として、以下の先行技術がある。特許文献1(特開2010-117808号公報)には、プログラムのソースファイルを参照した際に、プログラム中に、2byte以上のデータへのポインタ型の変数がある場合、ミスアラインを検出するためのミスアラインチェックライブラリを呼び出す処理を自動的に追加し、オブジェクト・ファイルを生成する。デバッグ装置は、オブジェクト・ファイルに基づいて命令実行し、ミスアラインチェックライブラリ内のエラールーチン処理に到達すれば、ブレークが発生するため、ミスアラインを検出する言語処理装置が記載されている。
 特許文献2(特開2012-048445号公報)には、オブジェクトプログラムを実行する命令実行部と、オブジェクトプログラムを一時的に保持するキャッシュメモリと、命令実行部によるオブジェクトプログラムのフェッチ要求を契機に、オブジェクトプログラムを読み込み、キャッシュメモリに保持させるプログラム読込部と、読み込まれたオブジェクトプログラムに対し、順次、チェックコード導出式を計算し、ブロック単位でチェックコードを生成し、オブジェクトプログラムに予め挿入されているチェックコードと比較してオブジェクトプログラムの正否をブロック単位で判定するチェックコード判定部とを備えるプログラム実行装置120が記載されている。
 ソースコードに処理的に等価な変更を加えると、コンパイラでの挙動(例えば、エラーの有無、エラー発生箇所)が変わることがある。しかし、処理的に等価な変更による挙動変化ではエラーの真の原因を明らかにすることが困難である。
 本発明は、前述の課題を解決するためになされたものであり、一見不明な挙動変化によってエラーの真の原因を明らかにする検査装置の提供を目的とする。
 本願において開示される発明の代表的な一例を示せば以下の通りである。すなわち、プログラム検査装置であって、所定の演算処理を実行する演算装置と、前記演算装置に接続された記憶デバイスとを有する計算機によって構成され、前記記憶デバイスは、少なくともソースコードをコンパイルするコンパイラを格納し、前記演算装置は、前記コンパイラの実行によって、前記ソースコードのエラー発生位置を特定し、前記ソースコードに等価変更を適用する変更位置候補を生成し、前記コンパイラの実行によって、前記変更位置候補に等価変更が適用されたソースコードのエラー発生位置を特定し、前記エラー発生位置の変化によって、前記ソースコードの真のエラー原因位置を特定することを特徴とする。
 本発明の一態様によれば、コンパイラの動作の変化から真の原因となるコードを特定できる。前述した以外の課題、構成及び効果は、以下の実施例の説明によって明らかにされる。
実施例1に係る検査装置の構成の一例を示すブロック図である。 実施例1に係る検査装置の機能要素の構成図である。 実施例1に係る解析プログラムで実行される処理の一例を示すフローチャートである。 実施例1に係るコード変更プログラムで実行される処理の一例を示すフローチャートである。 実施例1に係る検査プログラムで実行される処理の一例を示すフローチャートである。 実施例1に係る終了判定プログラムで実行される処理の一例を示すフローチャートである。 検査対象コードの変更の一例を示す図である。 検査対象コードの変更の一例を示す図である。 終了判定処理の一例を示す図である。 終了判定処理の一例を示す図である。
 以下、本発明の実施例について図面を参照して説明する。なお、本発明は以下の実施例に限定されるものではなく、本発明の趣旨を逸脱しない範囲で、各部の構成などを適宜追加、変更、削除などして実施できる。
 <実施例1>
 図1は、本発明の実施例1に係る検査装置1の構成の一例を示すブロック図である。
 検査装置1は、ソースコードである検査対象コード9を検査するための装置であり、プロセッサ(CPU)20と、記憶装置(HDD)21と、通信装置22と、メモリ23とを含む計算機で構成される。プロセッサ20と、記憶装置(HDD)21と、通信装置22と、メモリ23とは、インターコネクト24を介して接続される。検査装置1は、図示を省略する入力インターフェース及び出力インターフェースを有してもよい。
 プロセッサ20は、メモリ23に格納されたプログラムを実行する演算装置である。以下では、便宜上、プログラムを各処理の動作主体として説明することもあるが、各処理の実際の動作主体はプロセッサ2である。なお、プロセッサ20がプログラムを実行して行う処理の一部を、他の演算装置(例えば、ASIC、FPGA等のハードウェア)で実行してもよい。
 メモリ23は、不揮発性の記憶素子であるROM及び揮発性の記憶素子であるRAMを含む。ROMは、不変のプログラム(例えば、BIOS)などを格納する。RAMは、DRAM(Dynamic Random Access Memory)のような高速かつ揮発性の記憶素子であり、プロセッサ20が実行するプログラム及びプログラムの実行時に使用されるデータを一時的に格納する。メモリ23は、解析プログラム4と、コード変更プログラム5と、検査プログラム6と、終了判定プログラム7と、コンパイラ8と、検査対象コード9と、初期エラー情報10と、変更済みコード11と、前回エラー位置12と、ダミーコードデータベース13を格納する。
 補助記憶装置21は、例えば、磁気記憶装置(HDD)、フラッシュメモリ(SSD)等の大容量かつ不揮発性の記憶装置である。補助記憶装置21は、プロセッサ20がプログラムの実行時に使用するデータ(例えば、検査対象コード9、初期エラー情報10、変更済みコード11、前回エラー位置12、ダミーコードデータベース13など)、及びプロセッサ20が実行するプログラムを格納する。すなわち、プログラムは、補助記憶装置21から読み出されて、メモリ23にロードされて、プロセッサ20によって実行されることによって、検査装置1の各機能を実現する。
 通信装置22は、所定のプロトコルに従って、他の装置との通信を制御するネットワークインターフェース装置である。
 入力インターフェースは、キーボードやマウスなどの入力装置が接続され、オペレータからの入力を受けるインターフェースである。出力インターフェースは、ディスプレイ装置やプリンタなどの出力装置が接続され、プログラムの実行結果(例えば、特定された真のエラー原因位置)をオペレータが視認可能な形式で出力するインターフェースである。なお、検査装置1にネットワークを介して接続されたユーザ端末が入力装置及び出力装置を提供してもよい。この場合、検査装置1がウェブサーバの機能を有し、ユーザ端末が検査装置1に所定のプロトコル(例えばhttp)でアクセスしてもよい。
 プロセッサ20が実行するプログラムは、リムーバブルメディア(CD-ROM、フラッシュメモリなど)又はネットワークを介して検査装置1に提供され、非一時的記憶媒体である不揮発性の補助記憶装置21に格納される。このため、検査装置1は、リムーバブルメディアからデータを読み込むインターフェースを有するとよい。
 検査装置1は、物理的に一つの計算機上で、又は、論理的又は物理的に構成された複数の計算機上で構成される計算機システムであり、複数の物理的計算機資源上に構築された仮想計算機上で動作してもよい。例えば、解析プログラム4、コード変更プログラム5、検査プログラム6、終了判定プログラム7、コンパイラ8は、各々別個の物理的又は論理的計算機上で動作するものでも、複数が組み合わされて一つの物理的又は論理的計算機上で動作するものでもよい。
 図2は、実施例1に係る検査装置1の機能要素の構成図である。
 検査装置1では、解析プログラム4が検査対象コード9を解析し、コード変更プログラム5が検査対象コード9にダミーコードを挿入して、検査対象コード9が同じ動作をするような等価変更を加え変更済みコード11として出力し、コンパイラ8が変更済みコード11をコンパイルし、検査プログラム6がコンパイルした結果を検査し、終了判定プログラム7が処理の終了を判定する。各処理の詳細は図3以後のフローチャートを参照して説明する。終了判定プログラム7が処理を継続すると判定すると、コード変更プログラム5に次のダミーコード挿入位置候補にダミーコードを挿入する指示をして、終了判定プログラム7が処理の終了を判定するまで、コード変更プログラム5、コンパイラ8及び検査プログラム6による検査対象コード9の検査処理が繰り返される。
 図3は、実施例1に係る解析プログラム4で実行される処理の一例を示すフローチャートである。解析プログラム4は、ソースコードである検査対象コード9を解析して、ダミーコード挿入位置候補を出力する。
 ステップ101では、解析プログラム4は解析する検査対象コード9を取得する。
 ステップ102では、解析プログラム4は、取得した検査対象コード9を解析する。例えば、文の切れ目を探索する。解析プログラム4は、構文解析アルゴリズムを使ってもよい。
 ステップ103では、解析プログラム4はダミーコード挿入位置候補を生成する。解析プログラム4は、検査対象コード9の全範囲にダミーコード挿入位置候補を生成してもよい。また、ダミーコードを検査対象コード9の最初から挿入する場合、検査対象コード9の最初から初期エラー情報10のエラー位置までの範囲にダミーコード挿入位置候補を生成してもよいし、検査対象コード9の最初から初期エラー情報10のエラー位置の数行下までの範囲にダミーコード挿入位置候補を生成してもよい。また、ダミーコードを検査対象コード9の最後から挿入する場合、検査対象コード9の最後から初期エラー情報10のエラー位置までの範囲にダミーコード挿入位置候補を生成してもよいし、検査対象コード9の最後から初期エラー情報10のエラー位置の数行上までの範囲にダミーコード挿入位置候補を生成してもよい。
 ステップ104では、解析プログラム4は生成したダミーコード挿入位置候補をコード変更プログラム5に出力する。
 図4は、実施例1に係るコード変更プログラム5で実行される処理の一例を示すフローチャートである。コード変更プログラム5は、ダミーコード挿入位置候補の一つにダミーコードを挿入して変更済みコード11を生成する。
 ステップ201では、コード変更プログラム5は解析プログラム4が生成したダミーコード挿入位置を取得する。
 ステップ202では、コード変更プログラム5はダミーコードデータベース13からダミーコード記述を取得する。ダミーコードは、変数の宣言文や、処理に直接関係しない関数の呼出文であり、構文解析が可能なパターン毎にダミーコードをダミーコードデータベース13に準備しておくとよい。挿入されるダミーコードは、エラー行と文法的に同じ性質の文が望ましい。コード変更プログラム5は、解析プログラム4が初期エラー情報10を参照して判定したダミーコードの種類に従って、挿入するダミーコードを決定してもよい。発生する又は発生しうるエラー情報によってダミーコードを決定してもよい。例えば、特定のエラーしか発生しない検査対象コード9や、初期エラー情報10に特定の種類のエラーだけが記録されている場合、当該エラーに対応する1種のダミーコードを使用してもよい。初期エラー情報10は、プログラムの初回のコンパイルによって得られるダミーコード挿入前のエラー行の位置情報である。
 ステップ203では、コード変更プログラム5はダミーコード挿入位置候補にダミーコードを挿入し、ソースコードを変更する。例えば、図7Aに示すダミーコード挿入前の検査対象コード9において、7行目にダミーコードを挿入すると図7Bに示す変更済みコード11が得られる。
 ステップ204では、コード変更プログラム5は、ダミーコードが挿入された変更済みコード11とダミーコード挿入位置の情報をコンパイラ8に出力し、ダミーコード挿入位置の情報を検査プログラム6に出力する。
 図5は、実施例1に係る検査プログラム6で実行される処理の一例を示すフローチャートである。検査プログラム6は、ダミーコード挿入箇所とコンパイルエラー発生箇所とを対比し、検査結果を出力する。
 ステップ301では、検査プログラム6は、ダミーコードが挿入された変更済みコード11からコンパイラ8が生成したオブジェクトコードと、コンパイル時に発生したエラー発生位置と、ダミーコード挿入位置の情報を取得する。
 ステップ302では、検査プログラム6は、ダミーコード挿入箇所とコンパイルエラー発生箇所とを対比解析し、検査結果を取得する。
 ステップ303では、検査プログラム6は検査結果(挿入箇所がエラーになったか)を終了判定プログラム7に出力する。
 図6は、実施例1に係る終了判定プログラム7で実行される処理の一例を示すフローチャートである。終了判定プログラム7は、検査結果の変化有無によって、真のエラー原因箇所を推定する。
 ステップ401では、終了判定プログラム7は検査結果と前回エラー位置を取得する。
 ステップ402では、終了判定プログラム7は取得した検査結果が”変化あり”かを判定する。検査結果が”変化あり”の場合、ステップ404へ進み、それ以外の場合は、ステップ403へ進む。
 ダミーコード挿入位置が変わればエラー位置が変化する。前回エラー位置からエラー位置に変化がなければ、真のエラー箇所はダミーコード挿入位置より手前になる。このためダミーコード挿入位置を最後部から前方にずらして、エラー位置(エラーが発生する行番号)が変化しなくなれば、当該ダミーコード挿入位置とエラー位置の間に真のエラー箇所があると推定できる。
 例えば、図8Aに示す検査対象コード9では、行番号7にダミーコードが挿入されており、当該ダミーコード挿入位置にエラーが発生している。これは、1行目で定義されるref_tが5行目で再定義されており、二重に定義されたref_tを利用した関数プロンプト宣言(7行目)において、エラーが発生している。次に、図8Bに示す検査対象コード9では、行番号4に挿入されたダミーコード位置ではエラーが発生せず、初期エラー情報10のエラー文でエラーが発生している。これは、6行目のref_tの再定義の前に挿入された4行目のダミーコードではエラーが発生しない。このため、図8Bにおいて、今回のダミーコード挿入位置と前回のダミーコード挿入位置との間に真のエラー原因があると特定できる。
 ステップ403では、検査結果が”変化あり”の場合、終了判定プログラム7は得られた結果から真のエラー原因位置を特定し、特定された真のエラー原因位置を出力インターフェース又は通信装置22から出力して、処理を終了する。
 ステップ404では、検査結果が”変化なし”の場合、終了判定プログラム7は今回のエラー位置を前回エラー位置12に記録する。前回エラー位置12は、次のコンパイル時にエラー位置に変化があるかを比較するために使用される。
 ステップ405では、終了判定プログラム7は、次のダミーコード挿入位置にダミーコードを挿入して検査対象コード9の検査処理の継続をコード変更プログラム5に指示する。
 以上に説明したように、本発明の実施例のプログラム検査装置1は、コンパイラ8の実行によって、検査対象コード(ソースコード)9のエラー発生位置を特定し、検査対象コード9に等価変更を適用する変更位置候補(ダミーコード挿入位置候補)を生成し、コンパイラ8の実行によって、変更位置候補に等価変更が適用された(ダミーコード挿入位置候補にダミーコードが挿入された)ソースコードのエラー発生位置を特定し、エラー発生位置の変化によって、検査対象コード9の真のエラー原因位置を特定するので、コンパイラ8の動作の変化から真の原因となるコードの記述を推定できる。
 なお、本発明は前述した実施例に限定されるものではなく、添付した特許請求の範囲の趣旨内における様々な変形例及び同等の構成が含まれる。例えば、前述した実施例は本発明を分かりやすく説明するために詳細に説明したものであり、必ずしも説明した全ての構成を備えるものに本発明は限定されない。また、ある実施例の構成の一部を他の実施例の構成に置き換えてもよい。また、ある実施例の構成に他の実施例の構成を加えてもよい。また、各実施例の構成の一部について、他の構成の追加・削除・置換をしてもよい。
 また、前述した各構成、機能、処理部、処理手段等は、それらの一部又は全部を、例えば集積回路で設計する等により、ハードウェアで実現してもよく、プロセッサがそれぞれの機能を実現するプログラムを解釈し実行することにより、ソフトウェアで実現してもよい。
 各機能を実現するプログラム、テーブル、ファイル等の情報は、メモリ、ハードディスク、SSD(Solid State Drive)等の記憶装置、又は、ICカード、SDカード、DVD等の記録媒体に格納することができる。
 また、制御線や情報線は説明上必要と考えられるものを示しており、実装上必要な全ての制御線や情報線を示しているとは限らない。実際には、ほとんど全ての構成が相互に接続されていると考えてよい。

Claims (6)

  1.  プログラム検査装置であって、
     所定の演算処理を実行する演算装置と、前記演算装置に接続された記憶デバイスとを有する計算機によって構成され、
     前記記憶デバイスは、少なくともソースコードをコンパイルするコンパイラを格納し、
     前記演算装置は、
     前記コンパイラの実行によって、前記ソースコードのエラー発生位置を特定し、
     前記ソースコードに等価変更を適用する変更位置候補を生成し、
     前記コンパイラの実行によって、前記変更位置候補に等価変更が適用されたソースコードのエラー発生位置を特定し、
     前記エラー発生位置の変化によって、前記ソースコードの真のエラー原因位置を特定することを特徴とするプログラム検査装置。
  2.  請求項1に記載のプログラム検査装置であって、
     前記等価変更を適用する範囲は、前記等価変更の前のソースコードのエラー発生位置との関係で定められることを特徴とするプログラム検査装置。
  3.  請求項1に記載のプログラム検査装置であって、
     前記等価変更は、前記ソースコードが同じ動作をするダミーコードの挿入であることを特徴とするプログラム検査装置。
  4.  請求項3に記載のプログラム検査装置であって、
     前記等価変更は、前記等価変更の適用前のソースコードのエラー発生位置のコードと同じ性質のダミーコードの挿入であることを特徴とするプログラム検査装置。
  5.  請求項3に記載のプログラム検査装置であって、
     前記演算装置は、
     前記ダミーコードの挿入位置の変化によってエラー発生位置が変化した範囲が真のエラー原因位置であると推定することを特徴とするプログラム検査装置。
  6.  プログラム検査装置が実行するプログラム検査方法であって、
     前記プログラム検査装置は、所定の演算処理を実行する演算装置と、前記演算装置に接続された記憶デバイスとを有する計算機によって構成され、
     前記記憶デバイスは、少なくともソースコードをコンパイルするコンパイラを格納し、
     前記プログラム検査方法は、
     前記演算装置が、前記コンパイラの実行によって、前記ソースコードのエラー発生位置を特定し、
     前記演算装置が、前記ソースコードに等価変更を適用する変更位置候補を生成し、
     前記演算装置が、前記コンパイラの実行によって、前記変更位置候補に等価変更が適用されたソースコードのエラー発生位置を特定し、
     前記演算装置が、前記エラー発生位置の変化によって、前記ソースコードの真のエラー原因位置を特定することを特徴とするプログラム検査方法。
PCT/JP2022/039564 2022-01-27 2022-10-24 プログラム検査装置、及びプログラム検査方法 WO2023145165A1 (ja)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2022-011199 2022-01-27
JP2022011199 2022-01-27

Publications (1)

Publication Number Publication Date
WO2023145165A1 true WO2023145165A1 (ja) 2023-08-03

Family

ID=87471317

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2022/039564 WO2023145165A1 (ja) 2022-01-27 2022-10-24 プログラム検査装置、及びプログラム検査方法

Country Status (1)

Country Link
WO (1) WO2023145165A1 (ja)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0944347A (ja) * 1995-08-01 1997-02-14 Matsushita Electric Ind Co Ltd エラー知識ベース作成装置
CN113918444A (zh) * 2021-03-12 2022-01-11 京东科技控股股份有限公司 崩溃源代码定位方法、装置、介质及电子设备

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0944347A (ja) * 1995-08-01 1997-02-14 Matsushita Electric Ind Co Ltd エラー知識ベース作成装置
CN113918444A (zh) * 2021-03-12 2022-01-11 京东科技控股股份有限公司 崩溃源代码定位方法、装置、介质及电子设备

Similar Documents

Publication Publication Date Title
EP3788490B1 (en) Execution control with cross-level trace mapping
US9208057B2 (en) Efficient model checking technique for finding software defects
US9594553B2 (en) Identifying semantic differences between source code versions
US6430741B1 (en) System and method for data coverage analysis of a computer program
JP4204768B2 (ja) ユーザに固有のインスツルメンテーションを支援する方法とシステム
US8060869B1 (en) Method and system for detecting memory problems in user programs
US20020170034A1 (en) Method for debugging a dynamic program compiler, interpreter, or optimizer
US10942718B2 (en) Systems and/or methods for type inference from machine code
US20060277371A1 (en) System and method to instrument references to shared memory
CN112925524A (zh) 一种检测驱动程序中不安全直接存储器访问的方法及装置
JP2014219969A (ja) ソフトウェアプログラムを解析する方法及びシステム並びに非一時的なコンピュータ可読媒体
KR102117209B1 (ko) 바이너리 취약점 패치 방법 및 장치
Wang et al. Detecting and fixing precision-specific operations for measuring floating-point errors
US10380313B1 (en) Implementation and evaluation of designs for heterogeneous computing platforms with hardware acceleration
US7530060B1 (en) Methods and computer program product for optimizing binaries with coding style formalization
CN114116505A (zh) 代码测试方法及装置
KR102209151B1 (ko) 바이너리 취약점 패치 방법 및 장치
Valensi A generic approach to the definition of low-level components for multi-architecture binary analysis
WO2023145165A1 (ja) プログラム検査装置、及びプログラム検査方法
US8756580B2 (en) Instance-based field affinity optimization
US20020129336A1 (en) Automatic symbol table selection in a multi-cell environment
JP6878707B2 (ja) 試験装置、試験方法および試験プログラム
US7318221B2 (en) Windows™ F-language interpreter
Vitovská Instrumentation of LLVM IR
US20080163180A1 (en) Dynamic discovery of data segments within instrumented code

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22924020

Country of ref document: EP

Kind code of ref document: A1