Oracle® Developer Studio 12.5: コードアナライザユーザーズガイド

印刷ビューの終了

更新: 2016 年 6 月
 
 

問題のラベル付け

次のセクションでは、ラベルを使用して問題をソートおよび表示する一般的なワークフローについて説明します。

問題にラベル付けする方法

  1. –-showhash オプションを使用して、問題に関連付けられたハッシュを表示します。
  2. ラベル付けする問題とそのハッシュ文字列を特定します。
  3. バイナリの labels サブディレクトリを作成します。

    たとえば、バイナリが a.out の場合は、a.out.analyze/labels を作成します。

  4. ラベル付けする問題の (ハッシュとラベルの) ペアを次の 3 つのファイルに入れます。
    • a.out.analyze/labels/static_report_labels

    • a.out.analyze/labels/dynamic_report_labels

    • a.out.analyze/labels/coverage_report_labels

    各ディレクトリにはそれぞれ、静的レポート、動的レポート、およびカバレージレポート内の問題が入ります。ラベルファイルの形式は hash-name:label-name:comment です。

    次に、ラベルファイルの例を示します。

    $ cat codean.analyze/labels/dynamic_report_labels 
        54f3a6f0160dceb58156be03d07090a2:false_positive:bug 12345678 has been filed
        3b7ee9d573847e2dbf80652b7a89026e:false_positive
        6c575302146d147f5f1d2d2e6e1710a5:false_positive

    codean を使用して a.out というレポートを処理しているときに、一致するラベルが問題に含まれている場合は、ラベル名がデフォルトでその問題のあとに追加情報として表示されます。

ラベルで問題を表示または非表示にする方法

  1. 問題を表示するには、–-showlabel オプションを使用します。

    たとえば、誤検出のみを表示する場合:

    % codean --showlabel false_positive a.out
  2. 問題を非表示にするには、–-hidelabel オプションを使用します。

    たとえば、wont_be_fixed ラベルの付いた問題を非表示にする場合:

    % codean --hidelabel wont_be_fixed a.out

特定のハッシュを検索する方法

  1. ラベルファイル内の特定のハッシュが期限切れかどうかを調べるには、–-findhash hash-string を使用して、そのハッシュと一致する問題のみを表示するよう codean に指示します。
  2. 複数のハッシュを検索するには、複数の hash-string をコロン (:) で区切って指定します。例:
    % codean --findhash 54f3a6f0160dceb58156be03d07090a2:3b7ee9d573847e2dbf80652b7a89026e a.out
使用例 2  さまざまなラベルの使用

次に、さまざまなラベルの使用例を示します。

 $ cat t.c
#include <stdlib.h>

int main()
{
int *p = (int *)malloc(sizeof(int));
int i = *p;
free(p);
return i;
}

$ cc -g t.c
$ discover -a -o a.out.disc a.out
$ ./a.out.disc

$ codean -d --showhash a.out
DYNAMIC report of a.out:
ERROR 1 (UMR): accessing uninitialized data in "*p" at address 0x1001208e0 (4 bytes) on the heap:
hash: 79b6e1b242a057deec8762328b6860e6
main() + 0xac <t.c : 6>
3: int main()
4: {
5: int *p = (int *)malloc(sizeof(int));
6:=> int i = *p;
7: free(p);
_start() + 0x108
was allocated at (4 bytes):
main() + 0x20 <t.c : 5>
1: #include <stdlib.h>
3: int main()
4: {
5:=> int *p = (int *)malloc(sizeof(int));
6: int i = *p;
_start() + 0x108
DISCOVER SUMMARY for a.out: 1 non-leak issues, 0 leak issues
unique errors : 1 (1 total)
unique warnings : 0 (0 total)
unique leaks : 0 (0 blocks, 0 bytes)
unique possible leaks : 0 (0 blocks, 0 bytes)

$ cat a.out.analyze/labels/dynamic_report_labels
79b6e1b242a057deec8762328b6860e6:verified:I have verified that this is a bug.

$ codean -d a.out
DYNAMIC report of a.out:
ERROR 1 (UMR): accessing uninitialized data in "*p" at address 0x1001208e0 (4 bytes) on the heap:
label: verified "I have verified that this is a bug."
main() + 0xac <t.c : 6>
3: int main()
4: {
5: int *p = (int *)malloc(sizeof(int));
6:=> int i = *p;
7: free(p);
_start() + 0x108
was allocated at (4 bytes):
main() + 0x20 <t.c : 5>
1: #include <stdlib.h>
3: int main()
4: {
5:=> int *p = (int *)malloc(sizeof(int));
6: int i = *p;
_start() + 0x108
DISCOVER SUMMARY for a.out: 1 non-leak issues, 0 leak issues
unique errors : 1 (1 total)
unique warnings : 0 (0 total)
unique leaks : 0 (0 blocks, 0 bytes)
unique possible leaks : 0 (0 blocks, 0 bytes)

$ codean -d --showlabel verified a.out
DYNAMIC report of a.out:
ERROR 1 (UMR): accessing uninitialized data in "*p" at address 0x1001208e0 (4 bytes) on the heap:
label: verified "I have verified that this is a bug."
main() + 0xac <t.c : 6>
3: int main()
4: {
5: int *p = (int *)malloc(sizeof(int));
6:=> int i = *p;
7: free(p);
_start() + 0x108
was allocated at (4 bytes):
main() + 0x20 <t.c : 5>
1: #include <stdlib.h>
3: int main()
4: {
5:=> int *p = (int *)malloc(sizeof(int));
6: int i = *p;
_start() + 0x108
DISCOVER SUMMARY for a.out: 1 non-leak issues, 0 leak issues
unique errors : 1 (1 total)
unique warnings : 0 (0 total)
unique leaks : 0 (0 blocks, 0 bytes)
unique possible leaks : 0 (0 blocks, 0 bytes)

$ codean -d --hidelabel verified a.out
DYNAMIC report of a.out:
DISCOVER SUMMARY for a.out: 0 issues found (1 issues suppressed)