Upload
others
View
7
Download
0
Embed Size (px)
Citation preview
1© 2014 The MathWorks, Inc.
Polyspace®によるソフト不具合修正のフロントローディング
MathWorks Japan
Application Engineering ・ アプリケーションエンジニアリング部Application Engineer ・ アプリケーションエンジニアFred Noto ・ 能戸 フレッド
2
Polyspaceの静的解析ソリューション
コーディングルールバグ検出
形式手法
コンパイラー警告 コードメトリックス
(No False negative)
(False negative)
Polyspace Bug FinderTM
Polyspace Code ProverTM
Polyspace Code Prover
エラー予防
Polyspace Bug Finder
エラー検出
コード証明
Polyspaceはコードの信頼性を確保するための機能を提供
自動生成コード、ハンドコード検証可能
ファイル単位、プロジェクト単位検証可能
3
このようなことでお困りでしょうか?
Code
Review
source1.c
source2.c
source3.cUnit
Test
Integration
Test
Hardware
Testing
C
C
C
動的テスト完了後・製品リリース後にエラーが判明した!
CCC
全てのエラーを検出できた?
!
4
このようなことでお困りでしょうか?
Code
Review
Unit
Test
Integration
Test
Hardware
Testing
ソフトウェアバグが残されて検証を進めている可能性
後段階で検出したバグは修正コストが高い!
製品リリース後のバグはより危険!=バグ
5
コード検証の目的
要求仕様通りの設計かを確認 要求仕様に問題ないことを確認
不具合(ゼロ割等)がないことを確認 コーディングルール準拠の確認
C
適切な検証手法を使用してプロセスを効率化
動的検証
C!
CCC
C静的検証
6
モデルベースデザインでも
S-Function
(ハンドコード)
制御アルゴリズム、故障診断自動生成コード(モデル)
インターフェイス、RTOS、等
自動生成コードとハンドコードと統合していませんか?
コード検証が必要になります
7
モデル検証とコード検証の役割分担
シミュレーション• 設計エラー検出
• 機能的エラー検出
• 数学エラー検出
• カバレッジエラー検出
コード検証• スタンダード準拠確認
• エラー不在の証明
• ハンドコードの検証
• 実装エラー検出
モデル検証• モデル標準確認
• 設計エラー検出
• 設計の簡素化
• カバレッジ確認
• 非到達状態・遷移検出
• テストケース生成
手戻りを最低限にするには早期の検証が求められます
Polyspace Bug Finder
Polyspace Code Prover
8
Polyspace Bug Finderのスピーディー解析
バグ検出– コード作成後、すぐに欠陥を
検出・修正
コーディングルールチェック– エラー予防と再利用性向上
– MISRA準拠を確認
コードメトリックス解析– コードの複雑度を測定
時間を掛けずに大部分のバグを識別
コード作成
Bug Finder解析
レポート自動生成
修正
開発プロセスの上流で不具合を発見!コードを統合前に多くの欠陥を修正!
コード開発の効率に繋がる!
素早い欠陥検出・修正を可能とするPolyspace Bug Finder
9
MISRA C® チェッカー
MISRA AC AGC– 自動生成コード用
MISRA C++ チェッカー
JSF++ チェッカー
カスタマイズ– ルールのオン・オフ設定
カスタムルール
コーディングルールの確認
Polyspaceコードルールチェックによりエラーの予防可能
10
Polyspace Bug Finder:検出項目リストNumerical
Integer division by zero
Float division by zero
Integer conversion overflow
Unsigned integer conversion overflow
Sign change integer conversion overflow
Float conversion overflow
Integer overflow
Unsigned integer overflow
Float overflow
Invalid use of std. library integer routine
Invalid use of std. library float routine
Shift of a negative value
Shift operation overflow
Static memory
Array access out of bounds
Null pointer
Pointer access out of bounds
Unreliable cast of function pointer
Unreliable cast of pointer
Invalid use of std. library memory routine
Invalid use of standard library string routine
Arithmetic operation with NULL pointer
Other
Race condition
Invalid use of other standard library routine
Large pass-by-value argument
Assertion
Format string specifiers and arguments
mismatch
Dynamic memory
Use of previously freed pointer
Unprotected dynamic memory allocation
Release of previously deallocated pointer
Invalid free of pointer
Memory leak
Programming
Invalid use of = operator
Invalid use of == operator
Declaration mismatch
Invalid use of floating point operation
Wrap-around on unsigned integer
Missing null in string array
Qualifier removed in conversion
Wrong type used in sizeof
Dataflow
Write without further read
Non-initialized variable
Non-initialized pointer
Variable shadowing
Missing or invalid return statement
Unreachable code
Dead code
Partially accessed array
Uncalled function
Pointer to non initialized value converted to
const pointer
Code deactivated by constant false condition
Polyspace Bug Finder GUI
*) bold: checks that are part of Bug Finder analysis only
11
Polyspace Code Proveでコードの正しさを証明
Quality(品質)
– ランタイムエラーの証明
– 測定、向上、管理
Usage(使用方法)
– コンパイル、プログラム実行、
テストケースは不要
– 対応言語:C/C++/Ada
Process(プロセス)
– ランタイムエラーの早期検出
– 自動生成コード、ハンドコード
の解析可能
– コードの信頼性を測定
Polyspaceは全ての実行パスの結果を証明する!
static void pointer_arithmetic (void) {
int array[100];
int *p = array;
int i;
for (i = 0; i < 100; i++) {
*p = 0;
p++;
}
if (get_bus_status() > 0) {
if (get_oil_pressure() > 0) {
*p = 5;
} else {
i++;
}
}
i = get_bus_status();
if (i >= 0) {
*(p - i) = 10;
}
}
variable ‘I’ (int32): [0 .. 99]
assignment of ‘I’ (int32): [1 .. 100]
グリーン:正常ランタイムエラーが存在しない
レッド:エラー実行される度にランタイムエラー
グレー:デッドコード無実行
オレンジ:Unproven条件によってランタイムエラー
パープル:ViolationMISRA-C/C++, JSF++
変数値範囲ツールチップ
実機実験前にコード信頼性を確保して手戻りを削減
12
Polyspace Code Proverによるランタイムエラー有無の証明
C run-time checks
Unreachable Code
Out of Bounds Array Index
Division by Zero
Non-Initialized Variable
Scalar and Float Overflow (left shift on signed variables,
float underflow versus values near zero)
Initialized Return Value
Shift Operations (shift amount in 0..31/0..63, left operand
of left shift is negative)
Illegal Dereferenced Pointer (illegal pointer access to
variable of structure field, pointer within bounds)
Correctness Condition (array conversion must not extend
range, function pointer does not point to a valid function)
Non-Initialized Pointer
User Assertion
Non-Termination of Call (non-termination of calls and
loops, arithmetic expressions)
Known Non-Termination of Call
Non-Termination of Loop
Standard Library Function Call
Absolute Address
Inspection Points
C++ run-time checks
Unreachable Code
Out of Bounds Array Index
Division by Zero
Non-Initialized Variable
Scalar and Float Overflow
Shift Operations
Pointer of function Not Null
Function Returns a Value
Illegal Dereferenced Pointer
Correctness Condition
Non-Initialized Pointer
Exception Handling (calls to throws, destructor or delete
throws, main/tasks/C_lib_func throws, exception raised is
not specified in the throw list, throw during catch
parameter construction, continue execution in__except)
User Assertion
Object Oriented Programming (invalid pointer to member,
call of pure virtual function, incorrect type for this-pointer)
Non-Termination of Call
Non Termination of Loop
Absolute Address
Potential Call
C++ Specific Checks (positive array size, incorrect typeid
argument, incorrect dynamic_cast on reference)
static void pointer_arithmetic (void) {
int array[100];
int *p = array;
int i;
for (i = 0; i < 100; i++) {
*p = 0;
p++;
}
if (get_bus_status() > 0) {
if (get_oil_pressure() > 0) {
*p = 5;
} else {
i++;
}
}
i = get_bus_status();
if (i >= 0) {
*(p - i) = 10;
}
}
Green: reliablesafe pointer access
Red: faultyout of bounds error
Gray: deadunreachable code
Orange: unprovenmay be unsafe for some
conditions
13
Polyspaceのワークフロー
BF
Software
engineers
Quality Assurance
Engineers
CP Code Prover
BF Bug Finder
Software engineers
and/or
Quality engineers
Software engineers
and/or
Quality engineers
CP実装
ソフトウェア統合テスト
ソフトウェアリリース
ソフトウェア単体テスト
設計
要求仕様
モデル検証
Design
engineers
BF
CP
BF
14
MathWorksツールチェーンへの統合
Simulink®環境からPolyspace解析を実行
Polyspaceで発見した不具合をSimulinkモデルで強調表示
モデルの入力・パラメータ情報を利用
PolyspaceのSimulink連携機能でモデル修正が容易
15
Polyspaceのメリット
Code
Review
source1.c
source2.c
source3.cUnit
Test
Integration
Test
Hardware
Testing
C
C
C
早期段階でのコード検証によりスムーズな流れを実現
CCC
Polyspace Bug Finder
Polyspace Code Prover
16
Polyspace ソースコード静的検証 ~まとめ~
Polyspace Bug Finderで素早くコードの欠陥を検出!早期段階で不具合の修正が可能!
Polyspace Code Proverでクリティカルシステムにランタイムエラーの有無を証明!
両ツールを使用して効率的にソフトウェアの品質を管理・向上!
時間を掛けずに大部分のバグを識別
形式手法の解析によるコード信頼性
安全なコードを確保して実機実験へ
Simulink環境から実行可能
ファイル・プロジェクト単位で使用可能
17
トレーニング・コンサルティング サービス
投資 効果
トレーニング サービス 定期 トレーニング;
東京、名古屋、大阪にて定期開催
基礎コース(11)、応用コース(11)、
専門コース(4)を ご提供
オンサイト トレーニング; お客様サイトにて開催
ご要望に応じて3つのレベルでカリキュラム
のカスタマイズが可能
コンサルティング サービス カスタム“Jumpstart”;
顧客モデルをベースにした短期集中型ツール導入サポート
Advisory Service; 顧客Project に合わせた中長期アドバイザリサービス
投資対効果の最大化
18
制御設計関連トレーニングコース
MATLAB 関連
基礎 期間
MATLAB 基礎 3日
応用 期間
MATLAB によるデータ処理と可視化 1日
MATLAB のプログラミング手法 2日
MATLAB の最適化手法 1日
MATLAB と Simulink による制御設計 2日
Simulink 関連
コース名 期間
MATLAB/Simulink によるモデルベース開発 2日
基礎 期間
Simulink 基礎 2日
応用 期間
SimPowerSystems による電力系統の物理モデリング 1日
Simulink への外部コードの取り込み 1日
Simscape によるマルチドメインシステムの物理モデリング 1日
SimMechanics による力学系の物理モデリング 1日
専門 期間
Simulink モデルの検証と妥当性確認 1日
Simulink モデルの管理 2日
Stateflow 関連
基礎 期間
Stateflow 基礎 2日
コード生成関連
基礎 期間
リアルタイム コードの生成およびテストの基礎 1日
専門 期間
Embedded Coder による量産向けコード生成 3日
Polyspace 関連
専門 期間
Polyspace によるコード検証 2日
https://www.mathworks.co.jp/services/training/courses/MLBE_1_ja.htmlhttps://www.mathworks.co.jp/services/training/courses/MLVI_1.htmlhttps://www.mathworks.co.jp/services/training/courses/MLPR_1.htmlhttps://www.mathworks.co.jp/services/training/courses/MLOP_1.htmlhttps://www.mathworks.co.jp/services/training/courses/SLCT_1.htmlhttps://www.mathworks.co.jp/services/training/courses/MBD01_1.htmlhttps://www.mathworks.co.jp/services/training/courses/SLBE_1.htmlhttps://www.mathworks.co.jp/services/training/courses/SLPM-P_1.htmlhttps://www.mathworks.co.jp/services/training/courses/SLEX_1.htmlhttps://www.mathworks.co.jp/services/training/courses/SLPM-S_1.htmlhttps://www.mathworks.co.jp/services/training/courses/SLPM-M_1.htmlhttps://www.mathworks.co.jp/services/training/courses/SLVV_1.htmlhttps://www.mathworks.co.jp/services/training/courses/SLMB_1.htmlhttps://www.mathworks.co.jp/services/training/courses/SLSF_1.htmlhttps://www.mathworks.co.jp/services/training/courses/SLRT_1.htmlhttps://www.mathworks.co.jp/services/training/courses/SLEC_1.htmlhttps://www.mathworks.co.jp/services/training/courses/PSCC_1.html
19
Thank You For Your Attention
ご清聴ありがとうございました
© 2014 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The
MathWorks, Inc. See www.mathworks.com/trademarks for a list of additional
trademarks. Other product or brand names may be trademarks or registered
trademarks of their respective holders.
http://www.mathworks.com/trademarks