WO2014112317A1 - 変数アクセス一貫性検査装置、変数アクセス一貫性検査方法、変数アクセス一貫性検査プログラム - Google Patents

変数アクセス一貫性検査装置、変数アクセス一貫性検査方法、変数アクセス一貫性検査プログラム Download PDF

Info

Publication number
WO2014112317A1
WO2014112317A1 PCT/JP2013/084883 JP2013084883W WO2014112317A1 WO 2014112317 A1 WO2014112317 A1 WO 2014112317A1 JP 2013084883 W JP2013084883 W JP 2013084883W WO 2014112317 A1 WO2014112317 A1 WO 2014112317A1
Authority
WO
WIPO (PCT)
Prior art keywords
branch
variable
processes
write
block
Prior art date
Application number
PCT/JP2013/084883
Other languages
English (en)
French (fr)
Inventor
智 市川
Original Assignee
日産自動車株式会社
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 日産自動車株式会社 filed Critical 日産自動車株式会社
Priority to JP2014557382A priority Critical patent/JP6015778B2/ja
Priority to CN201380071044.7A priority patent/CN104937558B/zh
Publication of WO2014112317A1 publication Critical patent/WO2014112317A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/28Error detection; Error correction; Monitoring by checking the correct order of processing

Definitions

  • the present invention relates to a variable access consistency check device, a variable access consistency check method, and a variable access consistency check program.
  • Patent Document 1 a static analysis method for analyzing a control flow and a data flow in a source program described in a programming language without executing the source program is known (see Patent Document 1).
  • Patent Document 1 According to the static analysis method of Patent Document 1, it is possible to clarify the relationship between input and output and visualize the structure of the program. However, it is impossible for the user to notice a portion of the visualized program structure where there is a possibility of malfunction.
  • the present invention has been made in view of the above problems, and its purpose is to provide a variable access consistency checking device and a variable access that can make a user aware of a possible defect in a program structure. It is to provide a consistency check method and a variable access consistency check program.
  • the variable access consistency checking device detects the number of branch processes that can be switched within a branch block, detects the number of branch processes that write to a variable, and switches within the branch block. It is determined whether or not the number of branch processes that can be executed matches the number of branch processes that write to a variable. If it is determined that the number of branch processes that can be switched in the branch block does not match the number of branch processes that write to the variable, at least one of the variable and the branch block is output.
  • FIG. 1 is a block diagram showing a hardware configuration of a variable access consistency checking apparatus according to the first embodiment of the present invention.
  • FIG. 2 is a block diagram showing a functional configuration of the CPU 11.
  • FIG. 3 is a data flow diagram showing a flow of information processing executed by the variable access consistency checking apparatus according to the first embodiment of the present invention and intermediate data generated during the information processing.
  • FIGS. 4A, 4B, and 4C are diagrams showing an example of a program described in the C language as the read source code D01.
  • FIGS. 5A, 5 ⁇ / b> B, and 5 ⁇ / b> C are diagrams illustrating branch block ID ⁇ b> 1 and ID ⁇ b> 2 specified by the branch block specifying unit 21.
  • FIG. 5A, 5 ⁇ / b> B, and 5 ⁇ / b> C are diagrams illustrating branch block ID ⁇ b> 1 and ID ⁇ b> 2 specified by the branch block specifying unit 21.
  • FIG. 6 is a table showing a “branch block variable access list” that summarizes the results of processing performed by the variable detection unit 22.
  • 7A and 7B are tables showing a “statement number assignment list (D03)” that summarizes the results of the statement number assignment processing.
  • FIG. 8 is a table showing a “variable access order list (D04)” that summarizes the results of the variable access order specifying process.
  • FIGS. 9A, 9B, and 9C are diagrams for explaining the contents of the path number specifying process (S04).
  • FIG. 10 is a table showing the “number of paths and variable access order list (D05)” that summarizes the results of the path number identification process (S04).
  • FIG. 11 is a table showing an “access ratio list (D06)” that summarizes the results of the access ratio determination (S05).
  • FIG. 12 is a table showing an “access consistency determination result (D07)” that summarizes the results of the access consistency determination process (S06).
  • FIGS. 13A, 13B, and 13C are diagrams showing examples of program corrections in FIGS. 4A, 4B, and 4C.
  • FIGS. 14A and 14B are flowcharts showing an example of a case where the value is changed depending on the condition in the specification.
  • FIG. 15 is a flowchart illustrating an example in which the variable writing process is missing in a specific branch process.
  • FIG. 16 is a block diagram illustrating a functional configuration of the CPU 11 ′ according to the second embodiment.
  • FIG. 17 is a data flow diagram showing a flow of information processing executed by the variable access consistency checking device according to the second embodiment of the present invention and intermediate data generated during the information processing.
  • FIG. 18 is a table showing a “threshold determination result (D09)” that summarizes the results of the threshold determination process (S07).
  • FIGS. 19A and 19B are flowcharts showing cases where the ratios calculated by the ratio calculator 25 are different.
  • variable access consistency inspection apparatus [Hardware configuration of variable access consistency checker]
  • the variable access consistency inspection apparatus can be applied to variable access consistency inspection processing of a computer program executed by, for example, an electronic control unit (ECU) mounted on a vehicle. In particular, it examines the possibility of malfunctions due to omissions in computer program specifications or omissions in coding.
  • ECU electronice control unit
  • variable access consistency checking apparatus stores an input / output device 12 that reads a computer program (source code D01) to be checked from a storage medium, and stores a source code D01 read by the input / output device 12 and analysis intermediate data.
  • a device 14 a CPU (central processing unit) 11 that executes various calculations and analyzes the source code D01, an input device 13 for a user to input information necessary for analysis, and a test result output from the CPU 11 And a display device 15 for displaying.
  • the inspection result can also be written to a storage medium using the input / output device 12.
  • variable access consistency check device can be realized as a client server model.
  • a general-purpose personal computer (client) is connected to the server via a computer network.
  • a server including the CPU 11 shown in FIG. 1 can be connected to the input / output device 12, the input device 13, the storage device 14, or the display device 15 via a computer network.
  • the variable access consistency checking device is mainly configured by the CPU 11 (server), and the input / output device 12, the input device 13, the storage device 14, or the display device 15 is not included in the variable access consistency checking device.
  • intermediate data generated during the analysis may be temporarily stored in the internal hard disk of the server 11 instead of the storage device 14.
  • variable access consistency inspection program for causing a computer including the CPU 11 to function as a variable access consistency inspection apparatus is installed and executed on the computer including the CPU 11.
  • CPU11 comprises each information processing part shown below.
  • the variable access consistency check device is implemented by software.
  • a dedicated hardware for executing the following information processing is prepared, and the variable access consistency check device is installed. It is also possible to configure.
  • the CPU 11 includes a branch block specifying unit 21, a variable detection unit 22, a total branch number detection unit 23, a write branch number detection unit 24, a branch number determination unit 26, and a test result output unit 28.
  • the branch block specifying unit 21 reads the source code D01 from the storage device 14, and specifies a branch block from the computer program to be inspected.
  • the branch block is composed of a group of statements for switching and executing a plurality of branch processes based on a predetermined condition.
  • a “statement” is a processing unit for each line on the source code. Specifically, for example, in the case of C language, a branch block is determined by a condition such as an if statement or a switch statement and brackets “ ⁇ ” and “ ⁇ ” in a statement executed by switching a plurality of processes (branch processes). Refers to the enclosed processing unit. For example, “if” and “switch” are determined in advance as locations that can be determined as conditional branches.
  • the branch block specifying unit 21 specifies a part that can be determined as a conditional branch from the source code D01 to be analyzed, and specifies a part surrounded by “ ⁇ ” and “ ⁇ ” that follows as a branch block. For example, in the case of an if statement, the branch block specifying unit 21 determines that “ ⁇ ” after the conditional statement “()” of the if statement is ended is the start of the branch block. Next, when “ ⁇ ” is detected and no else statement follows, this “ ⁇ ” is determined as the end of the branch block. On the other hand, when the else statement follows, the next “ ⁇ ” is detected again, and this “ ⁇ ” is determined as the end of the branch block.
  • the total branch number detection unit 23 reads the branch block from the storage unit 14 and detects the number of branch processes (referred to as “total path number”) that can be switched in the branch block. For example, in the case of a branch block specified by “if”, a portion surrounded by “ ⁇ ” and “ ⁇ ” following “if” indicates a branch process. The total branch number detecting unit 23 detects the number of locations surrounded by “ ⁇ ” and “ ⁇ ” included in the branch block as the total number of paths. In the case of the branch block specified by “switch”, the total branch number detection unit 23 detects the number of “cases” following “switch” as the total number of paths. When a plurality of branch blocks are specified, the total branch number detection unit 23 detects the total number of paths for each branch block. The total number of paths detected by the total branch number detection unit 23 is temporarily stored in the storage unit 14.
  • the write branch number detection unit 24 reads the branch block from the storage unit 14 and detects the number of branch processes (referred to as “write path number”) for writing to the variable. Specifically, the write branch number detection unit 24 detects the number of branch processes that are writing to a variable among the branch processes included in the branch block as the number of write paths. When a plurality of branch blocks are specified, the write branch number detection unit 24 detects the number of write paths for each branch block. Further, when a plurality of variables are detected in one branch block, the write branch number detection unit 24 detects the number of write passes for each variable. The number of write paths detected by the write branch number detection unit 24 is temporarily stored in the storage unit 14.
  • the branch number determination unit 26 reads the total number of paths and the number of write paths from the storage unit 14. Then, the branch number determination unit 26 determines whether or not the number of branch processes (total number of paths) that can be switched in the branch block matches the number of branch processes (write path number) that writes to a variable. to decide. When a plurality of branch blocks or a plurality of variables are specified or detected, the write branch number detection unit 24 makes a determination for each branch block and for each variable. For example, the branch number determination unit 26 may determine whether the ratio calculated by the ratio calculation unit 25 illustrated in FIG. 2 is 100%. The determination result by the branch number determination unit 26 is temporarily stored in the storage unit 14.
  • the inspection result output unit 28 reads the determination result by the branch number determination unit 26 from the storage unit 14. When the branch number determination unit 26 determines that the number of branch processes that can be switched within the branch block does not match the number of branch processes that write to the variable, the inspection result output unit 28 At least one of the variable detected by 22 and the branch block specified by the branch block specifying unit 21 is output.
  • FIGS. 4A, 4B, and 4C show an example of a computer program described in C language as the read source code D01.
  • the computer program to be inspected is described across the three files shown in FIGS. 4 (a), (b), and (c).
  • the file name in FIG. 4A is “Task1.c”
  • the file name in FIG. 4B is “Task2.c”
  • the file name in FIG. 4C is “foo.c”.
  • a serial number starting from 1 written at the left end of each file indicates a “line number” of each file.
  • the branch block specifying unit 21 executes a “variable access analysis” process (S01) shown in FIG.
  • the branch block specifying unit 21 specifies a branch block from the computer programs shown in FIGS. 4 (a), 4 (b), and 4 (c). Specifically, “if” and “switch” are specified as the start position of the branch block. Then, a portion surrounded by “ ⁇ ” and “ ⁇ ” following the specified “if” and “switch” is specified as a branch block, and an identification number is sequentially assigned to the specified branch block.
  • FIGS. 5A, 5 ⁇ / b> B, and 5 ⁇ / b> C show branch blocks ID ⁇ b> 1 and ID ⁇ b> 2 specified by the branch block specifying unit 21.
  • Branch block ID1 is specified in “Task1.c”
  • branch block ID2 is specified in “Task2.c”.
  • the identified branch blocks ID1 and ID2 are temporarily stored in the storage unit 14.
  • the variable detector 22 detects a variable for each of the branch blocks ID1 and ID2. In a branch block where no variable is written, branch statements such as “if”, “else”, and “case” are detected.
  • the table in FIG. 6 shows a “variable access list (DO2)” that summarizes the results of the above-described variable access analysis process (S01).
  • DO2 variable access list
  • the variable name, file name, line number, statement, branch block ID, and R / W that are being written in the branch block are output.
  • R / Ws “W” indicates that the variable is being written
  • “R” indicates that the variable is being read.
  • accessing a variable includes writing to the variable and reading the variable.
  • the variable “SW1” is specified from the branch block ID1 shown in FIG. 5A
  • the variable “V1_Out” is specified from the branch block ID2 shown in FIG. It shows that.
  • the “variable access list (DO2)” is temporarily stored in the storage unit 14.
  • variable access consistency checking device executes “statement number assignment” processing (S02) shown in FIG.
  • the statement number assignment process (S02) the source code D01 is read from the storage unit 14, the execution order of statements is analyzed for each task (Task1.c, Task2.c), and an execution order number is assigned to each statement.
  • FIGS. 7A and 7B show a “statement number assignment list (D03)” that summarizes the results of the statement number assignment processing. 7A and 7B, “statement number” indicates the execution order of statements.
  • the statements are analyzed from the upstream of each task, and the order in which the programs are executed is specified.
  • variable access consistency checking device executes a “variable access order specification” process (S03) shown in FIG.
  • the variable access order specifying process (S03) first, the “branch block variable access list (D02)” and the “statement number assignment list (D03)” are read from the storage unit 14.
  • the “branch block variable access list (D02)” shown in FIG. 6 is compared with the “statement number assignment list (D03)” shown in FIGS. 7 (a) and 7 (b).
  • the execution order (statement number) of the variable accessed in the branch block is specified.
  • FIG. 8 shows a “variable access order list (D04)” that summarizes the results of the variable access order specifying process (S03).
  • the variable access order list (D04) shows in what execution order the variables accessed in each branch block are accessed.
  • the “variable access order list (D04)” is temporarily stored in the storage unit 14.
  • variable access consistency checking device executes “pass number specifying process” (S04) shown in FIG.
  • the total branch number specifying process (S04) the total number of passes and the number of write passes are detected for each of the branch blocks ID1 and ID2.
  • the total branch number detection unit 23 reads the “variable access order list (D04)” from the storage unit 14, and determines the number of branch processes surrounded by “ ⁇ ” and “ ⁇ ” following “if”. Detect as the total number of paths.
  • the total branch number detection unit 23 detects the number of “cases” following “switch” as the total number of paths.
  • the write branch number detection unit 24 detects the number of branch processes that are writing to the variable among the branch processes included in the branch block as the number of write paths. When a plurality of variables are detected in one branch block, the write branch number detection unit 24 detects the number of write passes for each variable.
  • the contents of the pass number specifying process (S04) will be described with reference to FIGS. 9 (a), 9 (b), and 9 (c).
  • the total number of paths of the branch block ID1 is 5, and the number of write paths of the variable “SW1” is 5.
  • the total number of paths of the branch block ID2 is 6, and the number of write paths of the variable “V1_Out” is 5.
  • the table in FIG. 10 shows a “path number and variable access order list (D05)” that summarizes the results of the path number specifying process (S04) shown in FIG.
  • the table of FIG. 10 is obtained by adding the total number of passes and the number of write passes for each variable to the table of FIG.
  • the “pass number and variable access order list (D05)” is temporarily stored in the storage unit 14.
  • variable access consistency checking device executes an “access ratio determination” process (S05) shown in FIG.
  • the access ratio determination process (S05) the access ratio for each branch block is calculated.
  • the ratio calculation unit 25 reads the “number of paths and variable access order list (D05)” from the storage unit 14, and the ratio (access ratio) of the number of write paths to the total number of paths, that is, the number of write paths.
  • (B) / Total number of paths (A) is calculated. This ratio is a numerical value indicating how much of the branch processing in which writing is performed with respect to all branch processing included in the branch block.
  • the table in FIG. 11 shows an “access ratio list (D06)” that summarizes the results of the access ratio determination process (S05).
  • the table of FIG. 11 is obtained by adding an access ratio (ratio) to the table of FIG.
  • the “access ratio list (D06)” is temporarily stored in the storage unit 14.
  • variable access consistency checking device executes “access consistency determination (S06)” processing shown in FIG.
  • the branch number determination unit 26 reads the “access ratio list (D06)” from the storage unit 14 and determines whether or not the ratio calculated in the access ratio determination process (S05) is 100%. To do.
  • the inspection result output unit 28 specifies the variables detected by the variable detection unit 22 and the branch block specification unit 21. Output at least one of the branched blocks.
  • the table of FIG. 12 shows “access consistency determination result (D07)” that summarizes the results of the access consistency determination process (S06).
  • the table of FIG. 12 is obtained by extracting the variable “V1_Out” in which the total number of passes and the number of write passes do not match from the table of FIG.
  • the inspection result output unit 28 includes a variable name, file name, line number, statement number, statement, branch block ID, total number of paths, and writing whose total path number and write path number do not match. The number of paths, access ratio, and R / W are output.
  • the user By the access consistency determination process (S06), the user (designer) can specify a variable in which the total number of paths and the number of write paths do not match. Also, after the statement “case 4:” on the 18th line of the file “Task2.c”, the variable “V1_Out” is read on the 5th line of the file “Task2.c” without writing to the variable “V1_Out”. ing. Therefore, the user can review whether there is no omission of specifications and coding. This review allows the designer to notice missing specifications and coding and add processing. Modification examples of the programs shown in FIGS. 4A, 4B, and 4C are shown in FIGS. 13A, 13B, and 13C.
  • FIGS. 14A and 14B are flowcharts showing an example of a case where different values are written in accordance with the specification conditions.
  • FIG. 14A shows an example in which the value written to “V1_Out” is changed according to the value of the variable “SW1”.
  • FIG. 14B shows an example in which the value written to “V2_Out” is changed according to the value of the variable “SW2”.
  • variable write processing only for a certain path (branch processing) in the branch block. This is because there are cases where the specifications are not properly considered for all branch processes, or there are too many branch processes to test all branch processes. Therefore, when there is a variable writing process in the branch block, it is necessary to check that the variable writing process is not lost in a specific branch process.
  • FIG. 15 is a flowchart showing an example in which a variable writing process is missing in a specific branch process.
  • the setting of the air conditioner is switched according to the state of the variable “SW1” indicating the state of the temperature switch of the air conditioner.
  • the variable “SW1” can take a value from 0 to 4.
  • the variable “SW1” is 0 to 3
  • the process of writing 18, 20, 22, and 24 to “V1_Out” is performed, and then the branches converge.
  • the variable “SW1” is 4, the process of writing 26 to “V1_Out” is necessary, but the branch has converged without performing the write process.
  • the detailed specification defines the specifications of the path (branch processing) when the variable “SW1” is 4, and the unit test is performed for all paths when the variable “SW1” is 0 to 4. If the (branch process) is performed, the leakage of the writing process when the variable “SW1” is 4 is noticed. However, if the specification of the path (branch process) when the variable “SW1” is 4 is not considered at the stage of creating the detailed specification, it cannot be detected even if the unit test is performed. This is because the specification of the path (branch process) when the variable “SW1” is 4 is not considered.
  • the inspection result output unit 28 when the branch number determination unit 26 determines that the total number of passes and the number of write passes do not match, the inspection result output unit 28, as shown in FIG. Output at least one. If the total number of passes and the number of write passes do not match, there is a possibility of specification omission or coding omission. Therefore, by outputting at least one of a variable or a branch block, the user can be made aware of a possible defect in the program structure. It is possible to suggest the possibility of a defect in the structure of a program that requires writing to a variable in all branch processes.
  • the non-write branch specifying unit 27 specifies a branch process that does not write to a variable when the total number of passes and the number of write passes do not match, and the test result output unit 28, as shown in FIG.
  • Information specifying branch processing that does not write to the variable is output in association with at least one of the variable and the branch block. Since the location to be verified is specified in the program structure, the efficiency of verification work by the user can be improved.
  • the “information for specifying the branch process” includes a file name, a line number, a statement number, and a statement.
  • the ratio calculation unit 25 calculates the ratio of the number of write paths to the total number of paths, and the inspection result output unit 28 outputs the calculated ratio in association with at least one of a variable and a branch block.
  • the ratio is output in association with at least one of the variable and the branch block. Thereby, the possibility of a malfunction can be quantified.
  • the priority as a verification target can be communicated to the user, so that the efficiency of verification work by the user can be improved.
  • a ratio (access ratio) is calculated for each branch block and notified to the user. This makes it possible to realize that there is no specification leak or coding leak and prevent problems.
  • variable access consistency checking device that further includes a function of determining a ratio calculated by the ratio calculation unit 25 using a predetermined threshold
  • a functional configuration of the CPU 11 ′ according to the second embodiment will be described with reference to FIG.
  • the hardware configuration of the variable access consistency checking apparatus according to the second embodiment is the same as that shown in FIG. As shown in FIG. 16, in addition to the functional configuration (21 to 28) shown in FIG. 2, the CPU 11 ′ determines whether or not the ratio calculated by the ratio calculator 25 is higher than a predetermined threshold value.
  • a ratio determining unit 29 is further provided.
  • Information processing (S01 to S06) up to the access consistency determination process (S06), source code D01 and intermediate data (D02 to D07) up to the access consistency determination result D07 are the same as in FIG.
  • the variable access consistency inspection apparatus executes a “threshold determination” process (S07) shown in FIG.
  • the ratio determination unit 29 determines whether the ratio calculated by the ratio calculation unit 25 is higher than a predetermined threshold value.
  • the ratio determination unit 29 reads the access consistency determination result (D07) and the threshold value (D08) preset by the user shown in FIG. 12 from the storage unit 14, and the access consistency determination result (D07) and the threshold value. Judge using (D08). Then, as shown in the table of FIG. 18, the inspection result output unit 28 outputs the determination result by the ratio determination unit 29 in association with at least one of the variable and the branch block.
  • FIGS. 19A and 19B show cases where the ratios calculated by the ratio calculation unit 25 are different.
  • the access ratio (ratio) is 83%.
  • the access ratio (ratio) is 83%.
  • the access ratio (ratio) ) Is 66%.
  • the access ratio (ratio) of the variable “V2_Out” is low, the possibility of specification leakage or coding leakage is low. Therefore, the user sets a threshold value in advance.
  • the ratio determining unit 29 determines whether or not the ratio calculated by the ratio calculating unit 25 is higher than a predetermined threshold value. A warning can be output for a ratio greater than the threshold. Therefore, when the verification time of the user is short, such as immediately before shipment, the user can perform verification by narrowing down a highly dangerous part.
  • the table of FIG. 18 shows the “threshold determination result (D09)” that summarizes the results of the threshold determination process (S07).
  • the table of FIG. 18 is obtained by further adding an access ratio (ratio) determination result and a threshold (80%) for variables “V1_Out” and “V2_Out” in which the total number of paths and the number of write paths do not match.
  • the access ratio (67%) of the variable “V2_Out” is lower than the threshold (0.8).
  • the access ratio (83%) of the variable “V1_Out” is higher than the threshold (0.8).
  • the ratio determination unit 29 determines whether the ratio is higher than a predetermined threshold value, and the inspection result output unit 28 associates the determination result by the ratio determination unit 29 with at least one of a variable and a branch block. Output. As a result, a determination result based on the threshold value for the priority as the verification target can be obtained, so that the verification target can be clarified to further increase the efficiency of the verification work.
  • the variable detection unit 22 does not need to detect a variable that has been written in the branch process (pass) if the variable has not been read after the branch has converged. This is because if the variable is not read after the branch has converged, the possibility of specification leakage and coding leakage is low even if the number of write passes does not match the total number of passes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Debugging And Monitoring (AREA)

Abstract

 アクセス一貫性検査装置は、所定の条件に基づいて複数の分岐処理を切り替えて実行する一群のステートメントからなる分岐ブロックを特定し、分岐ブロック内で書き込みが行われる変数を検出する(S01)。分岐ブロック内で切り替わることが可能な分岐処理の数を検出し、変数に書き込みを行う分岐処理の数を検出し(S04)、分岐ブロック内で切り替わることが可能な分岐処理の数と変数に書き込みを行う分岐処理の数が一致するか否かを判断する(S06)。そして、分岐ブロック内で切り替わることが可能な分岐処理の数と変数に書き込みを行う分岐処理の数とが一致しないと判断した場合、変数及び分岐ブロックの少なくとも一方を出力する(D07)。

Description

変数アクセス一貫性検査装置、変数アクセス一貫性検査方法、変数アクセス一貫性検査プログラム
 本発明は、変数アクセス一貫性検査装置、変数アクセス一貫性検査方法、変数アクセス一貫性検査プログラムに関するものである。
 従来から、プログラミング言語で記述されたソースプログラムにおける制御の流れやデータの流れを、そのソースプログラムを実行すること無しに解析する、静的解析方法が知られている(特許文献1参照)。
特開平09-282173号公報
 特許文献1の静的解析方法によれば、入力と出力の関係を明確にしてプログラムの構造を可視化することはできる。しかし、可視化されたプログラムの構造のうち、不具合の可能性がある箇所をユーザに気づかせることはできない。
 本発明は、上記課題に鑑みて成されたものであり、その目的は、プログラムの構造のうち、不具合の可能性がある箇所をユーザに気づかせることができる変数アクセス一貫性検査装置、変数アクセス一貫性検査方法、変数アクセス一貫性検査プログラムを提供することである。
 本発明の一態様に係わる変数アクセス一貫性検査装置は、分岐ブロック内で切り替わることが可能な分岐処理の数を検出し、変数に書き込みを行う分岐処理の数を検出し、分岐ブロック内で切り替わることが可能な分岐処理の数と変数に書き込みを行う分岐処理の数が一致するか否かを判断する。そして、分岐ブロック内で切り替わることが可能な分岐処理の数と前記変数に書き込みを行う分岐処理の数とが一致しないと判断した場合、変数及び分岐ブロックの少なくとも一方を出力する。
図1は、本発明の第1実施形態に係わる変数アクセス一貫性検査装置のハードウェア構成を示すブロック図である。 図2は、CPU11の機能的構成を示すブロック図である。 図3は、本発明の第1実施形態に係わる変数アクセス一貫性検査装置によって実行される情報処理の流れ及び情報処理の途中で生成される中間データを示すデータフロー図である。 図4(a)、(b)、(c)は、読み込まれたソースコードD01としてC言語で記述されたプログラムの一例を示す図である。 図5(a)、(b)、(c)は、分岐ブロック特定部21により特定された分岐ブロックID1、ID2を示す図である。 図6は、変数検出部22が行った処理結果をまとめた「分岐ブロック変数アクセス一覧」を示す表である。 図7(a)、(b)は、ステートメント番号割付処理の結果をまとめた「ステートメント番号割付一覧(D03)」を示す表である。 図8は、変数アクセス順序特定処理の結果をまとめた「変数アクセス順序一覧(D04)」を示す表である。 図9(a)、(b)、(c)は、パス数特定処理(S04)の内容を説明するための図である。 図10は、パス数特定処理(S04)の結果をまとめた「パス数と変数アクセス順序一覧(D05)」を示す表である。 図11は、アクセス割合判定(S05)の結果をまとめた「アクセス割合一覧(D06)」を示す表である。 図12は、アクセス一貫性判定処理(S06)の結果をまとめた「アクセス一貫性判定結果(D07)」を示す表である。 図13(a)、(b)、(c)は、図4(a)、(b)、(c)のプログラム修正例を示す図である。 図14(a)、(b)は、仕様上の条件によって値を変えて書き込むケースの例を示すフローチャートである。 図15は、特定の分岐処理において変数の書込処理が抜けている例を示すフローチャートである。 図16は、第2実施形態に係わるCPU11’の機能的構成を示すブロック図である。 図17は、本発明の第2実施形態に係わる変数アクセス一貫性検査装置によって実行される情報処理の流れ及び情報処理の途中で生成される中間データを示すデータフロー図である。 図18は、スレッシュホールド判定処理(S07)の結果をまとめた「スレッシュホールド判定結果(D09)」を示す表である。 図19(a)、(b)は比率算出部25により算出された比率が異なるケースを示すフローチャートである。
 図面を参照して、本発明の実施形態を説明する。図面の記載において同一部分には同一符号を付し説明を省略する。
(第1実施形態)
[変数アクセス一貫性検査装置のハードウェア構成]
 本発明の第1実施形態に係わる変数アクセス一貫性検査装置は、例えば車両に搭載されるる電子制御装置(ECU)により実行されるコンピュータプログラムの変数アクセス一貫性検査処理に適用することができる。特に、コンピュータプログラムの仕様漏れ或いはコーディング漏れに起因する不具合の可能性を検査するものである。
 図1を参照して、本発明の第1実施形態に係わる変数アクセス一貫性検査装置のハードウェア構成を説明する。変数アクセス一貫性検査装置のハードウェア構成として、汎用のコンピュータを用いることができる。例えば、変数アクセス一貫性検査装置は、記憶媒体から検査対象のコンピュータプログラム(ソースコードD01)を読み込む入出力装置12と、入出力装置12で読み込んだソースコードD01や解析の中間データを記憶する記憶装置14と、各種演算を実行してソースコードD01を解析するCPU(中央処理装置)11と、ユーザが解析に必要な情報を入力するための入力装置13と、CPU11から出力される検査結果を表示する表示装置15とを備える。検査結果は、入出力装置12を用いて記憶媒体に書き込むことも可能である。
 また、変数アクセス一貫性検査装置は、クライアントサーバモデルとしても実現可能である。例えば、汎用のパーソナルコンピュータ(クライアント)をコンピュータネットワークを介してサーバに接続する。これにより、図1に示すCPU11を備えるサーバを、コンピュータネットワークを介して、入出力装置12、入力装置13、記憶装置14、或いは表示装置15に接続することができる。この場合、変数アクセス一貫性検査装置は、主にCPU11(サーバ)により構成され、入出力装置12、入力装置13、記憶装置14、或いは表示装置15は変数アクセス一貫性検査装置に含まれない。この場合、解析の途中で生成される中間データは、記憶装置14の代わりに、サーバ11が備える内部ハードディスクに一時的に格納すればよい。
 図2を参照して、CPU11の機能的構成を説明する。CPU11を備えるコンピュータを変数アクセス一貫性検査装置として機能させるためのコンピュータプログラム(変数アクセス一貫性検査プログラム)を、CPU11を備えるコンピュータにインストールして実行する。これにより、CPU11は、以下に示す各情報処理部を構成する。なお、ここでは、ソフトウェアによって変数アクセス一貫性検査装置を実現する例を示すが、もちろん、以下に示す各情報処理を実行するための専用のハードウェアを用意して、変数アクセス一貫性検査装置を構成することも可能である。
 CPU11は、分岐ブロック特定部21、変数検出部22、総分岐数検出部23、書込分岐数検出部24、分岐数判断部26、及び検査結果出力部28を構成する。
 分岐ブロック特定部21は、記憶装置14からソースコードD01を読み込み、検査対象となるコンピュータプログラムの中から、分岐ブロックを特定する。分岐ブロックは、所定の条件に基づいて複数の分岐処理を切り替えて実行する一群のステートメントからなる。「ステートメント」とは、ソースコード上の1行ごとの処理単位のことである。具体的に、分岐ブロックは、例えばC言語の場合、if文或いはswitch文などの条件により判定して複数の処理(分岐処理)を切り替えて実行するステートメント内のブラケット“{”と“}”で囲まれた処理単位を指す。予め、条件分岐と判定できる箇所として例えば「if」及び「switch」を定めておく。分岐ブロック特定部21は、解析対象となるソースコードD01の中から、条件分岐と判定できる箇所を特定し、その後に続く“{”と“}”で囲まれた箇所を分岐ブロックとして特定する。例えば、if文の場合、分岐ブロック特定部21は、if文の条件文“()”が終了した後の“{”を分岐ブロックの開始と判断する。次に“}”を検出し、その後にelse文が続かない場合、この“}”を分岐ブロックの終端と判断する。一方、その後にelse文が続く場合、改めて次の“}”を検出し、この“}”を分岐ブロックの終端と判断する。if文の場合でも次に続く処理が1行で済ませられる場合、“{”、 “}”を省略する場合があるが、この場合、この1行の行頭に“{”、行末に“}”があると判断し、同じ処理をする。また、switch文の場合、“{“と“}“とで囲まれた部分を分岐ブロックとして認識する。分岐ブロック特定部21により特定された分岐ブロックは、記憶部14に一時的に記憶される。
 変数検出部22は、分岐ブロックを記憶部14から読み込み、分岐ブロック内で書き込みが行われる変数を検出する。具体的に、変数検出部22は、分岐ブロック内の分岐処理ごとに書き込まれている変数を検出する。例えばC言語の場合、“=”で示された式の左辺の変数を総て検出する。複数の分岐ブロックが特定されている場合、変数検出部22は、分岐ブロック毎に変数を検出する。変数検出部22により検出された変数は、記憶部14に一時的に記憶される。
 総分岐数検出部23は、分岐ブロックを記憶部14から読み込み、分岐ブロック内で切り替わることが可能な分岐処理の数(「総パス数」という)を検出する。例えば、「if」により特定された分岐ブロックの場合、「if」の後に続く“{”と“}”で囲まれる箇所が分岐処理を示す。総分岐数検出部23は、分岐ブロック内に含まれる、“{”と“}”で囲まれる箇所の数を総パス数として検出する。「switch」により特定された分岐ブロックの場合、総分岐数検出部23は、「switch」の後に続く“case”の数を総パス数として検出する。複数の分岐ブロックが特定されている場合、総分岐数検出部23は、各分岐ブロックについて総パス数を検出する。総分岐数検出部23により検出された総パス数は、記憶部14に一時的に記憶される。
 書込分岐数検出部24は、分岐ブロックを記憶部14から読み込み、変数に書き込みを行う分岐処理の数(「書込パス数」という)を検出する。具体的に、書込分岐数検出部24は、分岐ブロック内に含まれる分岐処理のうち、変数に書き込みを行っている分岐処理の数を書込パス数として検出する。複数の分岐ブロックが特定されている場合、書込分岐数検出部24は、分岐ブロック毎に、書込パス数を検出する。更に、1つの分岐ブロックの中で複数の変数が検出されている場合、書込分岐数検出部24は、各変数について書込パス数を検出する。書込分岐数検出部24により検出された書込パス数は、記憶部14に一時的に記憶される。
 分岐数判断部26は、総パス数及び書込パス数を記憶部14から読み込む。そして、分岐数判断部26は、分岐ブロック内で切り替わることが可能な分岐処理の数(総パス数)と変数に書き込みを行う分岐処理の数(書込パス数)が一致するか否かを判断する。複数の分岐ブロック或いは複数の変数が特定或いは検出されている場合、書込分岐数検出部24は、分岐ブロック毎且つ変数毎に、判断する。例えば、分岐数判断部26は、図2に示す比率算出部25が算出した比率が100%であるか否かを判断してもよい。分岐数判断部26による判断結果は、記憶部14に一時的に記憶される。
 検査結果出力部28は、分岐数判断部26による判断結果を記憶部14から読み込む。そして、検査結果出力部28は、分岐ブロック内で切り替わることが可能な分岐処理の数と変数に書き込みを行う分岐処理の数とが一致しないと分岐数判断部26が判断した場合、変数検出部22により検出された変数、及び分岐ブロック特定部21により特定された分岐ブロックの少なくとも一方を出力する。
 CPU11は、非書込分岐特定部27を更に構成する。非書込分岐特定部27は、分岐数判断部26による判断結果を記憶部14から読み込む。そして、非書込分岐特定部27は、分岐ブロック内で切り替わることが可能な分岐処理の数と変数に書き込みを行う分岐処理の数とが一致しない場合において、変数に書き込みを行わない分岐処理を特定する。変数に書き込みを行わない分岐処理を特定する情報は、記憶部14に一時的に記憶される。検査結果出力部28は、変数に書き込みを行わない分岐処理を特定する情報を、変数及び分岐ブロックの少なくとも一方に関連づけて出力する。
 CPU11は、比率算出部25を更に構成する。比率算出部25は、分岐数判断部26による判断結果を記憶部14から読み込む。そして、比率算出部25は、分岐ブロック内で切り替わることが可能な分岐処理の数に対する、変数に書き込みを行う分岐処理の数の比率(アクセス割合)を算出する。比率算出部25により算出された比率は、記憶部14に一時的に記憶される。検査結果出力部28は、比率算出部25により算出された比率を、変数及び分岐ブロックの少なくとも一方に関連づけて出力する。
[変数アクセス一貫性検査装置により実行される情報処理の手順]
 次に、図3~図13を参照して、本発明の第1実施形態に係わる変数アクセス一貫性検査方法の一例として、図1及び図2に示す変数アクセス一貫性検査装置によって実行される情報処理の手順を説明する。
 先ず、CPU11は、検査対象となるソースコードD01を入出力装置12から読み込む。なお、ソースコードD01は、予め入出力装置12を用いてユーザにより変数アクセス一貫性検査装置内に読み込まれ、記憶装置14に格納されていてもよい。図4(a)、(b)、(c)は、読み込まれたソースコードD01として、C言語で記述されたコンピュータプログラムの一例を示す。検査対象となるコンピュータプログラムは、図4(a)、(b)、(c)に示す3つのファイルに跨って記述されている。図4(a)のファイル名は「Task1.c」であり、図4(b)のファイル名は「Task2.c」であり、図4(c)のファイル名は「foo.c」である。C言語で記述されたプログラムの一例において、各ファイルの左端部に記載された1から始まる連続番号は、各ファイルの「行番号」を示す。
 次に、分岐ブロック特定部21は、図3に示す「変数アクセス解析」処理(S01)を実行する。先ず、分岐ブロック特定部21は、図4(a)、(b)、(c)に示すコンピュータプログラムの中から、分岐ブロックを特定する。具体的には、分岐ブロックの開始位置として、「if」及び「switch」を特定する。そして、特定された「if」及び「switch」の後に続く“{”と“}”で囲まれた箇所を分岐ブロックとして特定し、特定された分岐ブロックに識別番号を順次付与する。図5(a)、(b)、(c)は、分岐ブロック特定部21により特定された分岐ブロックID1、ID2を示す。「Task1.c」の中に分岐ブロックID1が特定され、「Task2.c」の中に分岐ブロックID2が特定された。特定された分岐ブロックID1、ID2は、記憶部14に一時的に記憶される。
 次に、変数検出部22は、分岐ブロックID1、ID2を記憶部14から読み込み、分岐ブロックID1、ID2内で書き込みが行われる変数を検出する。具体的に、“=”で示された式の左辺の変数を総て検出する。変数検出部22は、分岐ブロックID1、ID2毎に変数を検出する。変数の書き込みが無い分岐ブロックでは、「if」,「else」,「case」などの分岐のステートメントを検出する。
 また、変数検出部22は、変数を書き込んだ後にその変数を読み込んでいる箇所を、分岐ブロック内であるか否かに関わらず検出する。その変数を読み込んでいる箇所に、分岐ブロックIDは付さなくてもよい。
 図6の表は、上記した変数アクセス解析処理(S01)の結果をまとめた「変数アクセス一覧(DO2)」を示す。図6の表の中では、分岐ブロック内で書き込みが行われている変数名、ファイル名、行番号、ステートメント、分岐ブロックID、及びR/Wを出力する。R/Wのうち、「W」は変数に書き込みを行っていることを示し、「R」は変数の読み出しを行っていることを示す。もし、「if」,「else」,「case」などの分岐のステートメントを検出したが、変数に書き込みが無い場合、「No W」と出力する。ここで、変数にアクセスすることには、変数に書き込みを行うことと、変数を読み込むことが含まれる。図6の表は、図5(a)に示す分岐ブロックID1の中から、変数「SW1」が特定され、図5(b)に示す分岐ブロックID2の中から、変数「V1_Out」が特定されたことを示す。「変数アクセス一覧(DO2)」は、記憶部14に一時的に記憶される。
 次に、変数アクセス一貫性検査装置は、図3に示す「ステートメント番号割付」処理(S02)を実行する。ステートメント番号割付処理(S02)では、ソースコードD01を記憶部14から読み込み、タスク(Task1.c、Task2.c)毎にステートメントの実行順序を解析し、各ステートメントに実行順序番号を付る。図7(a)、(b)は、ステートメント番号割付処理の結果をまとめた「ステートメント番号割付一覧(D03)」を示す。図7(a)、(b)において、「ステートメント番号」はステートメントの実行順序を示す。ステートメント番号割付処理(S02)では、各タスクの上流からステートメントを解析し、プログラムが実行される順序を特定する。分岐文がある場合は全分岐が上流から順序実行されたものとしてステートメント番号を付加する。繰り返り処理がある場合、その繰り返し処理が1回実行されたものとしてステートメント番号を付加する。また、子関数(サブルーチン処理)がある場合はそのサブルーチン処理が実行されたものとして、ステートメントの実行順序を特定する。「ステートメント番号割付一覧(D03)」は、記憶部14に一時的に記憶される。
 次に、変数アクセス一貫性検査装置は、図3に示す「変数アクセス順序特定」処理(S03)を実行する。変数アクセス順序特定処理(S03)では、まず、「分岐ブロック変数アクセス一覧(D02)」及び「ステートメント番号割付一覧(D03)」を記憶部14から読み込む。図6に示す「分岐ブロック変数アクセス一覧(D02)」と図7(a)、(b)に示す「ステートメント番号割付一覧(D03)」とを比較する。そして、分岐ブロック内でアクセスしている変数の実行順序(ステートメント番号)を特定する。図8は、変数アクセス順序特定処理(S03)の結果をまとめた「変数アクセス順序一覧(D04)」を示す。変数アクセス順序一覧(D04)によって、各分岐ブロックでアクセスされている変数がどのような実行順序でアクセスされているかが分かる。「変数アクセス順序一覧(D04)」は、記憶部14に一時的に記憶される。
 次に、変数アクセス一貫性検査装置は、図3に示す「パス数特定処理」(S04)を実行する。パス数特定処理(S04)では、分岐ブロックID1、ID2ごとに総パス数と書込パス数を検出する。具体的には、総分岐数検出部23は、「変数アクセス順序一覧(D04)」を記憶部14から読み込み、「if」の後に続く“{”と“}”で囲まれる分岐処理の数を総パス数として検出する。また、総分岐数検出部23は、「switch」の後に続く“case”の数を総パス数として検出する。
 また、書込分岐数検出部24は、分岐ブロック内に含まれる分岐処理のうち、変数に書き込みを行っている分岐処理の数を書込パス数として検出する。1つの分岐ブロックの中で複数の変数が検出されている場合、書込分岐数検出部24は、各変数について書込パス数を検出する。
 図9(a)、(b)、(c)を参照して、パス数特定処理(S04)の内容を説明する。図9(a)の「Task1.c」において、分岐ブロックID1の総パス数は5であり、変数「SW1」の書込パス数は5である。また、図9(b)の「Task2.c」において、分岐ブロックID2の総パス数は6であり、変数「V1_Out」の書込パス数は5である。図10の表は、図9に示したパス数特定処理(S04)の結果をまとめた「パス数と変数アクセス順序一覧(D05)」を示す。図10の表は、図6の表に対して、変数毎に総パス数と書込パス数を追加したものである。「パス数と変数アクセス順序一覧(D05)」は、記憶部14に一時的に記憶される。
 次に、変数アクセス一貫性検査装置は、図3に示す「アクセス割合判定」処理(S05)を実行する。アクセス割合判定処理(S05)では、分岐ブロック毎のアクセス割合を算出する。具体的に、比率算出部25は、「パス数と変数アクセス順序一覧(D05)」を記憶部14から読み込み、総パス数に対する書込パス数の比率(アクセス割合)、即ち、書込パス数(B)/全パス数(A)を算出する。この比率は、分岐ブロックに含まれる全ての分岐処理に対して、書き込みが行われる分岐処理がどのくらいの割合で占められているかを示す数値である。
 図11の表は、アクセス割合判定処理(S05)の結果をまとめた「アクセス割合一覧(D06)」を示す。図11の表は、図10の表に対して、アクセス割合(比率)を追加したものである。変数「SW1」の比率は、5/5=100%となる。つまり、分岐ブロックID1に含まれる全ての分岐処理において、抜け盛れなく変数「SW1」に書込処理を行っている。一方、変数「V1_Out」の比率は、5/6=83%となる。17%の割合で、変数「V1_Out」への書込処理が存在していない。「アクセス割合一覧(D06)」は、記憶部14に一時的に記憶される。
 次に、変数アクセス一貫性検査装置は、図3に示す「アクセス一貫性判定(S06)」処理を実行する。アクセス一貫性判定処理(S06)では、全パス数と書込パス数が一致していない箇所を検出して出力する。具体的に、先ず、分岐数判断部26は、「アクセス割合一覧(D06)」を記憶部14から読み込み、アクセス割合判定処理(S05)で算出された比率が100%であるか否かを判断する。そして、検査結果出力部28は、総パス数と書込パス数とが一致しないと分岐数判断部26が判断した場合、変数検出部22により検出された変数、及び分岐ブロック特定部21により特定された分岐ブロックの少なくとも一方を出力する。
 図12の表は、アクセス一貫性判定処理(S06)の結果をまとめた「アクセス一貫性判定結果(D07)」を示す。図12の表は、図11の表から、総パス数と書込パス数とが一致しない変数「V1_Out」を抽出したものである。図12に示すように、検査結果出力部28は、総パス数と書込パス数とが一致しない変数名、ファイル名、行番号、ステートメント番号、ステートメント、分岐ブロックID、総パス数、書込パス数、アクセス割合、及びR/Wを出力する。
 アクセス一貫性判定処理(S06)により、ユーザ(設計者)は、総パス数と書込パス数とが一致しない変数を特定することができる。また、ファイル「Task2.c」の18行目におけるステートメント「case 4:」の後、変数「V1_Out」に書き込みがないまま、ファイル「Task2.c」の5行目で変数「V1_Out」が読み込まれている。よって、ユーザは、仕様及びコーディングの漏れが無いか否かをレビューすることができる。設計者はこのレビューによって、仕様及びコーディングの抜けに気づき、処理を追加することができる。図4(a)、(b)、(c)に示したプログラムの修正例を図13(a)、(b)、(c)に示す。図4(b)のファイル「Task2.c」の18行目におけるステートメント「case 4:」の後、図13(b)の符号AM1に示すように、変数「V1_Out」に26を書き込むステートメントを追加した。
[第1実施形態による効果]
 ソフトウェアの処理において変数にアクセスする時、仕様上の条件に応じて異なる値を書き込むケースが多々ある。例えば、自動車などで使用されるエアコンがある。手動で設定を行うエアコンは、風量、温度をそれぞれ数段階分けて、段階的に出力を調整することができる。この場合、ソフトウェアの処理としては、風量、温度の各スイッチの状態をポートから読み込み、エアコンの出力の変数を設定するロジックが組み込まれる。図14(a)、(b)は、仕様上の条件に応じて異なる値を書き込むケースの例を示すフローチャートである。図14(a)では、変数「SW1」の値に応じて「V1_Out」に書き込む値を変化させる例を示す。図14(b)では、変数「SW2」の値に応じて「V2_Out」に書き込む値を変化させる例を示す。このように、“条件”によって“変数の値を必ず書き換える”という仕様は、ソフトウェアでは頻繁に存在する。
 しかし、条件が多く存在するため処理が複雑になると、分岐ブロック内のあるパス(分岐処理)だけ、変数の書込処理を記述し忘れてしまう場合がある。なぜなら、全ての分岐処理に対して仕様をきちんと考えられていないケースや、分岐処理の数が多すぎて、全ての分岐処理についてテストしきれないケースがあるからである。したがって、分岐ブロック内で変数の書込処理がある場合は、特定の分岐処理において変数の書込処理が抜けないように検査する必要がある。
 図15は、特定の分岐処理において変数の書込処理が抜けている例を示すフローチャートである。エアコンの温度スイッチの状態を示す変数「SW1」の状態に応じて、エアコンの設定を切り替えている。変数「SW1」は0~4の値を取り得る。変数「SW1」が0~3である場合、それぞれ「V1_Out」に18、20、22、24を書き込む処理が行われ、その後に分岐が収束している。変数「SW1」が4である場合、「V1_Out」に26を書き込む処理が必要であるが、その書込処理が行われないまま分岐が収束している。この場合、詳細仕様書が、変数「SW1」が4である時のパス(分岐処理)の仕様を定義しており、且つ単体テストを、変数「SW1」が0~4である時の全てのパス(分岐処理)について実施していれば、変数「SW1」が4である場合の書込処理の漏れに気づく。しかし、詳細仕様を作成している段階で、変数「SW1」が4である時のパス(分岐処理)の仕様を考えられていない場合、単体テストを実施しても検出できない。なぜなら、変数「SW1」が4である時のパス(分岐処理)の仕様が考えられていないからである。また、変数「SW1」が4である時のパス(分岐処理)の仕様が考えられている場合でも、分岐処理の数が多く単体テストを全ての分岐処理で実施できない場合は、書込処理の漏れを検出できない可能性がある。このように、従来の仕様の作成、単体テストの実施では、書込処理の漏れによる不具合を抑制することが難しい。また、このような観点で検出するツールも存在しない。すなわち、分岐処理で値を書き込む場合、全てのパス(分岐処理)で変数の書き込み処理が行われている(アクセスの一貫性)ことを検証しなければならない。
 第1実施形態によれば、総パス数と書込パス数とが一致しないと分岐数判断部26が判断した場合、検査結果出力部28は、図12に示すように、変数及び分岐ブロックの少なくとも一方を出力する。総パス数と書込パス数とが一致しない場合、仕様漏れ或いはコーディング漏れの可能性がある。そこで、変数或いは分岐ブロックの少なくとも一方を出力することにより、プログラムの構造のうち不具合の可能性がある箇所をユーザに気づかせることができる。総ての分岐処理において変数への書き込みが必要なプログラムの構造について、不具合の可能性を示唆することができる。このように、設計の段階から仕様として処理が抜けている場合や、仕様に定義されていても、単体テストが実施できないようなプログラムの構造の場合、書込処理抜けの不具合を抑制することができる。また、膨大なソースコードから、人の目で判断できない変数アクセスの一貫性が保たれていないことをユーザに気づかせることができる。また、ソフトウェアプロセスで使用されているテスト(単体テスト、結合テスト、システムテスト)で見つけられないような変数アクセス一貫性が保たれていないプログラムのバグを未然に防ぐことができる。
 非書込分岐特定部27は、総パス数と書込パス数とが一致しない場合において、変数に書き込みを行わない分岐処理を特定し、検査結果出力部28は、図12に示すように、変数に書き込みを行わない分岐処理を特定する情報を、変数及び分岐ブロックの少なくとも一方に関連づけて出力する。プログラムの構造の中で検証すべき箇所が特定されるので、ユーザによる検証作業の効率を高めることができる。なお、「分岐処理を特定する情報」には、ファイル名、行番号、ステートメント番号、ステートメントが含まれる。
 比率算出部25は、総パス数に対する書込パス数の比率を算出し、検査結果出力部28は、算出された比率を、変数及び分岐ブロックの少なくとも一方に関連づけて出力する。総パス数と書込パス数とが一致しない場合において、比率(アクセス割合)が高い程、つまり、100%に近い程、仕様漏れ或いはコーディング漏れの可能性が高まる。そこで、比率を、変数及び分岐ブロックの少なくとも一方に関連づけて出力する。これにより、不具合の可能性を数値化することができる。不具合の可能性がある箇所として、複数の変数或いは複数の分岐ブロックが出力される場合、検証対象としての優先度をユーザに伝えることができるので、ユーザによる検証作業の効率を高めることができる。このように、ソースコード内に数多くの分岐処理がある中から、分岐ブロックごとに比率(アクセス割合)を算出し、ユーザに通知する。これにより、仕様の漏れ、コーディングの漏れがないことに気づき、不具合を未然に防止することができる。
(第2実施形態)
 第2実施形態では、予め定めた閾値を用いて比率算出部25により算出された比率を判定する機能を更に備える変数アクセス一貫性検査装置について説明する。図16を参照して、第2実施形態に係わるCPU11’の機能的構成を説明する。なお、第2実施形態に係わる変数アクセス一貫性検査装置のハードウェア構成は図1と同じであり説明を省略する。図16に示すように、CPU11’は、図2に示した機能的構成(21~28)の他に、比率算出部25により算出された比率が予め定めた閾値よりも高いか否かを判断する比率判断部29を更に備える。
 図17を参照して、本発明の第2実施形態に係わる変数アクセス一貫性検査装置によって実行される情報処理の流れ及び情報処理の途中で生成される中間データを説明する。アクセス一貫性判定処理(S06)までの情報処理(S01~S06)、ソースコードD01及びアクセス一貫性判定結果D07までの中間データ(D02~D07)は、図3と同じで有り説明を省略する。
 アクセス一貫性判定処理(S06)の後、変数アクセス一貫性検査装置は、図17に示す「スレッシュホールド判定」処理(S07)を実行する。スレッシュホールド判定処理(S07)では、比率判断部29が、比率算出部25により算出された比率が予め定めた閾値よりも高いか否かを判断する。比率判断部29は、図12に示すアクセス一貫性判定結果(D07)及びユーザにより予め設定されたスレッシュホールド値(D08)を記憶部14から読み込み、アクセス一貫性判定結果(D07)及びスレッシュホールド値(D08)を用いて判断する。そして、検査結果出力部28は、図18の表に示すように、比率判断部29による判断結果を、変数及び分岐ブロックの少なくとも一方に関連づけて出力する。
 図19(a)、(b)は比率算出部25により算出された比率が異なるケースを示す。図19(a)に示すように、変数「V1_Out」の書込処理では、総パス数が6であるのに対して書込パス数が5であるため、アクセス割合(比率)が83%となる。これに対して、図19(b)に示すように、変数「V2_Out」の書込処理では、総パス数が3であるのに対して書込パス数が2であるため、アクセス割合(比率)が66%となる。図19(b)に示すケースでは、変数「V2_Out」のアクセス割合(比率)が低いため、仕様の漏れ或いはコーディングの漏れの可能性は低い。そこで、ユーザは予め閾値を設定しておく。そして、比率判断部29が、比率算出部25により算出された比率が予め定めた閾値よりも高いか否かを判断する。そして、閾値より大きい比率に対して警告を出力することができる。そのため、出荷直前など、ユーザの検証時間が少ないときに、ユーザは危険性の高い箇所を絞って検証することができる。
 図18の表は、スレッシュホールド判定処理(S07)の結果をまとめた「スレッシュホールド判定結果(D09)」を示す。図18の表は、総パス数と書込パス数とが一致しない変数「V1_Out」及び「V2_Out」について、アクセス割合(比率)の判断結果及び閾値(80%)を更に追加したものである。変数「V2_Out」のアクセス割合(67%)は、閾値(0.8)よりも低い。一方、変数「V1_Out」のアクセス割合(83%)は、閾値(0.8)よりも高い。
 アクセス一貫性が保たれていないように一見できるプログラムの構造であっても、実際は意図通りに設計されているケースがある。このため、本当の不具合を突き止めるまでの検証効率が低下する場合がある。そこで、比率判断部29が、比率が予め定めた閾値よりも高いか否かを判断し、検査結果出力部28は、比率判断部29による判断結果を、変数及び分岐ブロックの少なくとも一方に関連づけて出力する。これにより、検証対象としての優先度について閾値に基づく判断結果が得られるので、検証対象を明確にして更に検証作業の効率を高めることができる。
 上記のように、本発明の実施形態を記載したが、この開示の一部をなす論述及び図面はこの発明を限定するものであると理解すべきではない。この開示から当業者には様々な代替実施の形態、実施例及び運用技術が明らかとなろう。
 変数検出部22は、分岐処理(パス)で書き込みが行われた変数であっても、分岐が収束した後に、変数の読み込みが行われていない場合、当該変数は検出しなくてもよい。分岐が収束した後に変数の読み込みが行われなければ、書込パス数が総パス数に一致していなくても、仕様の漏れ、コーディングの漏れの可能性が低いからである。
 21 分岐ブロック特定部
 22 変数検出部
 23 総分岐数検出部
 24 書込分岐数検出部
 25 比率算出部
 26 分岐数判断部
 27 非書込分岐特定部
 28 検査結果出力部
 29 比率判断部

Claims (6)

  1.  コンピュータプログラムを検査する変数アクセス一貫性検査装置であって、
     検査対象となる前記コンピュータプログラムの中から、所定の条件に基づいて複数の分岐処理を切り替えて実行する一群のステートメントからなる分岐ブロックを特定する分岐ブロック特定部と、
     前記分岐ブロック内で書き込みが行われる変数を検出する変数検出部と、
     前記分岐ブロック内で切り替わることが可能な分岐処理の数を検出する総分岐数検出部と、
     前記変数に書き込みを行う分岐処理の数を検出する書込分岐数検出部と、
     前記分岐ブロック内で切り替わることが可能な分岐処理の数と前記変数に書き込みを行う分岐処理の数が一致するか否かを判断する分岐数判断部と、
     前記分岐ブロック内で切り替わることが可能な分岐処理の数と前記変数に書き込みを行う分岐処理の数とが一致しないと前記分岐数判断部が判断した場合、前記変数及び前記分岐ブロックの少なくとも一方を出力する検査結果出力部と、
    を備えることを特徴とする変数アクセス一貫性検査装置。
  2.  請求項1に記載の変数アクセス一貫性検査装置であって、
     前記分岐ブロック内で切り替わることが可能な分岐処理の数と前記変数に書き込みを行う分岐処理の数とが一致しない場合において、前記変数に書き込みを行わない分岐処理を特定する非書込分岐特定部を更に備え、
     前記検査結果出力部は、前記変数に書き込みを行わない分岐処理を特定する情報を、前記変数及び前記分岐ブロックの少なくとも一方に関連づけて出力する
    ことを特徴とする変数アクセス一貫性検査装置。
  3.  請求項1又は2に記載の変数アクセス一貫性検査装置であって、
     前記分岐ブロック内で切り替わることが可能な分岐処理の数に対する、前記変数に書き込みを行う分岐処理の数の比率を算出する比率算出部を更に備え、
     前記検査結果出力部は、前記比率を、前記変数及び前記分岐ブロックの少なくとも一方に関連づけて出力する
    ことを特徴とする変数アクセス一貫性検査装置。
  4.  請求項3に記載の変数アクセス一貫性検査装置であって、
     前記比率が予め定めた閾値よりも高いか否かを判断する比率判断部とを更に備え、
     前記検査結果出力部は、前記比率判断部による判断結果を、前記変数及び前記分岐ブロックの少なくとも一方に関連づけて出力する
    ことを特徴とする変数アクセス一貫性検査装置。
  5.  コンピュータプログラムを検査する変数アクセス一貫性検査方法であって、
     検査対象となる前記コンピュータプログラムの中から、所定の条件に基づいて複数の分岐処理を切り替えて実行する一群のステートメントからなる分岐ブロックを特定し、
     前記分岐ブロック内で書き込みが行われる変数を検出し、
     前記分岐ブロック内で切り替わることが可能な分岐処理の数を検出し、
     前記変数に書き込みを行う分岐処理の数を検出し、
     前記分岐ブロック内で切り替わることが可能な分岐処理の数と前記変数に書き込みを行う分岐処理の数が一致するか否かを判断し、
     前記分岐ブロック内で切り替わることが可能な分岐処理の数と前記変数に書き込みを行う分岐処理の数とが一致しないと判断した場合、前記変数及び前記分岐ブロックの少なくとも一方を出力する
    ことを特徴とする変数アクセス一貫性検査方法。
  6.  コンピュータプログラムを検査するための変数アクセス一貫性検査プログラムであって、
     コンピュータに、
     検査対象となる前記コンピュータプログラムの中から、所定の条件に基づいて複数の分岐処理を切り替えて実行する一群のステートメントからなる分岐ブロックを特定する機能と、
     前記分岐ブロック内で書き込みが行われる変数を検出する機能と、
     前記分岐ブロック内で切り替わることが可能な分岐処理の数を検出する機能と、
     前記変数に書き込みを行う分岐処理の数を検出する機能と、
     前記分岐ブロック内で切り替わることが可能な分岐処理の数と前記変数に書き込みを行う分岐処理の数が一致するか否かを判断する機能と、
     前記分岐ブロック内で切り替わることが可能な分岐処理の数と前記変数に書き込みを行う分岐処理の数とが一致しないと判断した場合、前記変数及び前記分岐ブロックの少なくとも一方を出力する機能と
    を実現させることを特徴とする変数アクセス一貫性検査プログラム。
PCT/JP2013/084883 2013-01-21 2013-12-26 変数アクセス一貫性検査装置、変数アクセス一貫性検査方法、変数アクセス一貫性検査プログラム WO2014112317A1 (ja)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2014557382A JP6015778B2 (ja) 2013-01-21 2013-12-26 変数アクセス一貫性検査装置、変数アクセス一貫性検査方法、変数アクセス一貫性検査プログラム
CN201380071044.7A CN104937558B (zh) 2013-01-21 2013-12-26 变量访问一贯性检查装置、变量访问一贯性检查方法

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2013008352 2013-01-21
JP2013-008352 2013-01-21

Publications (1)

Publication Number Publication Date
WO2014112317A1 true WO2014112317A1 (ja) 2014-07-24

Family

ID=51209419

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2013/084883 WO2014112317A1 (ja) 2013-01-21 2013-12-26 変数アクセス一貫性検査装置、変数アクセス一貫性検査方法、変数アクセス一貫性検査プログラム

Country Status (3)

Country Link
JP (1) JP6015778B2 (ja)
CN (1) CN104937558B (ja)
WO (1) WO2014112317A1 (ja)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP7480082B2 (ja) 2021-03-08 2024-05-09 株式会社東芝 ソフトウェア開発支援装置、方法及びプログラム

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003316615A (ja) * 2002-04-26 2003-11-07 Nissan Motor Co Ltd 演算順序チェック装置およびその方法
JP2006331027A (ja) * 2005-05-25 2006-12-07 Nissan Motor Co Ltd 検査装置、検査方法、及び検査プログラム
JP2008090696A (ja) * 2006-10-04 2008-04-17 Nissan Motor Co Ltd プログラム解析装置及びプログラム解析方法

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS62118448A (ja) * 1985-11-18 1987-05-29 Nec Corp 不定値参照の検出方式
JP2661562B2 (ja) * 1994-10-11 1997-10-08 日本電気株式会社 プログラム評価装置
CN101937395B (zh) * 2010-09-20 2012-07-25 南京大学 一种用于漏洞检测的检测对象程序特征提取方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003316615A (ja) * 2002-04-26 2003-11-07 Nissan Motor Co Ltd 演算順序チェック装置およびその方法
JP2006331027A (ja) * 2005-05-25 2006-12-07 Nissan Motor Co Ltd 検査装置、検査方法、及び検査プログラム
JP2008090696A (ja) * 2006-10-04 2008-04-17 Nissan Motor Co Ltd プログラム解析装置及びプログラム解析方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP7480082B2 (ja) 2021-03-08 2024-05-09 株式会社東芝 ソフトウェア開発支援装置、方法及びプログラム

Also Published As

Publication number Publication date
JPWO2014112317A1 (ja) 2017-01-19
JP6015778B2 (ja) 2016-10-26
CN104937558B (zh) 2016-11-09
CN104937558A (zh) 2015-09-23

Similar Documents

Publication Publication Date Title
US20130191689A1 (en) Functional testing of a processor design
US9792402B1 (en) Method and system for debugging a system on chip under test
JP4427002B2 (ja) 半導体試験用プログラムデバッグ装置
US20150051890A1 (en) Automated augmented model extension for robust system design
JP6717059B2 (ja) 制御システム
US10162324B2 (en) Method for manipulating a control program of a control device
TW201907304A (zh) 用於一微控制器程式之程式碼涵蓋範圍追蹤
JP6015778B2 (ja) 変数アクセス一貫性検査装置、変数アクセス一貫性検査方法、変数アクセス一貫性検査プログラム
JPWO2019077738A1 (ja) データ検証装置、データ検証方法及びデータ検証プログラム
US20120124425A1 (en) Method and Apparatus Useful In Manufacturing Test Case Operations
US10229029B2 (en) Embedded instruction sets for use in testing and error simulation of computing programs
JP6053854B2 (ja) 制御プログラムに対するインタラクション方法
US10579761B1 (en) Method and system for reconstructing a graph presentation of a previously executed verification test
US10528691B1 (en) Method and system for automated selection of a subset of plurality of validation tests
US9165007B2 (en) Log message optimization to ignore or identify redundant log messages
JP2016128941A (ja) 出力判定装置、出力判定方法、出力判定プログラム、及び、静的解析装置
US20100077383A1 (en) Simulation method and storage medium for storing program
JP5962779B2 (ja) フラグアクセス不具合検査装置、フラグアクセス不具合検査方法、フラグアクセス不具合検査プログラム
JP6037034B2 (ja) ソフトウェア検査装置、ソフトウェア検査方法、ソフトウェア検査プログラム
US10503854B1 (en) Method and system for generating validation tests
WO2019142266A1 (ja) テストケース生成装置、テストケース生成方法およびテストケース生成プログラム
KR102638058B1 (ko) 펌웨어 에뮬레이션 방법 및 이를 위한 장치
US11397662B2 (en) Method for debugging computer program, device employing method, and storage medium
TWI761917B (zh) 程式調試方法、裝置及可讀存儲介質
JP5736588B2 (ja) ソースコード変換方法及びソースコード変換プログラム

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

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2014557382

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 13872260

Country of ref document: EP

Kind code of ref document: A1