JavaScript is required to for searching.
ナビゲーションリンクをスキップ
印刷ビューの終了
Oracle Solaris Studio 12.3: dbx コマンドによるデバッグ     Oracle Solaris Studio 12.3 Information Library (日本語)
search filter icon
search icon

ドキュメントの情報

はじめに

1.  dbx の概要

2.  dbx の起動

3.  dbx のカスタマイズ

4.  コードの表示とコードへの移動

5.  プログラムの実行制御

6.  ブレークポイントとトレースの設定

7.  呼び出しスタックの使用

8.  データの評価と表示

9.  実行時検査

概要

RTC を使用する場合

RTC の必要条件

実行時検査

メモリー使用状況とメモリーリーク検査を有効化

メモリーアクセス検査を有効化

すべての RTC を有効化

RTC を無効化

プログラムを実行

アクセス検査の使用

メモリーアクセスエラーの報告

メモリーアクセスエラー

メモリーリークの検査

メモリーリーク検査の使用

リークの可能性

リークの検査

メモリーリークの報告を理解する

リークレポートの生成

リークレポート

メモリーリークの修正

メモリー使用状況検査の使用

エラーの抑止

抑止のタイプ

スコープと種類による抑制

最新エラーの抑止

エラー報告回数の制限

エラー抑止の例

デフォルトの抑止

抑止によるエラーの制御

子プロセスにおける RTC の実行

接続されたプロセスへの RTC の使用

Solaris を実行しているシステムの場合

Linux を実行しているシステムの場合

RTC での修正継続機能の使用

実行時検査アプリケーションプログラミングインタフェース

バッチモードでの RTC の使用

bcheck 構文

bcheck の例

dbx からバッチモードを直接有効化

トラブルシューティングのヒント

実行時検査の制限

より高い効果を得るにはより多くのシンボルおよびデバッグ情報が必要になる

x86 プラットフォームでは SIGSEGV シグナルと SIGALTSTACK シグナルが制限される

より高い効果を得るには、十分なパッチ領域を設け、すべての既存コードを含めて 8M バイト以内にする (SPARC プラットフォームのみ)

RTC エラー

アクセスエラー

不正解放 (baf) エラー

重複解放 (duf) エラー

境界整列を誤った解放 (maf) エラー

境界整列を誤った読み取り (mar) エラー

境界整列を誤った書き込み (maw) エラー

メモリー不足 (oom) エラー

配列範囲外からの読み込み (rob) エラー

非割り当てメモリーからの読み取り (rua) エラー

非初期化メモリーからの読み取り (rui) エラー

配列範囲外メモリーへの書き込み (wob) エラー

読み取り専用メモリーへの書き込み (wro) エラー

非割り当てメモリーへの書き込み (wua) エラー

メモリーリークエラー

ブロック中のアドレス (aib)

レジスタ中のアドレス (air)

メモリーリーク (mel) エラー

10.  修正継続機能 (fix と cont)

11.  マルチスレッドアプリケーションのデバッグ

12.  子プロセスのデバッグ

13.  OpenMP プログラムのデバッグ

14.  シグナルの処理

15.  dbx を使用してプログラムをデバッグする

16.  dbx を使用した Fortran のデバッグ

17.  dbx による Java アプリケーションのデバッグ

18.  機械命令レベルでのデバッグ

19.  dbx の Korn シェル機能

20.  共有ライブラリのデバッグ

A.  プログラム状態の変更

B.  イベント管理

C.  マクロ

D.  コマンドリファレンス

索引

子プロセスにおける RTC の実行

子プロセスで RTC を実行するには、dbx 環境変数 rtc_inheriton に設定します。デフォルトでは off になります (dbx 環境変数の設定」を参照)。

dbx は、親で RTC が有効になっていて、dbx 環境変数 follow_fork_modechild に設定されている場合、子プロセスの RTC を実行できます (dbx 環境変数の設定」を参照)。

分岐が発生すると、dbx は子に RTC を自動的に実行します。プログラムが exec() を呼び出すと、exec() を呼び出すプログラムの RTC 設定がそのプログラムに渡ります。

特定の時間に RTC の制御下におくことができるプロセスは 1 つだけです。次に例を示します。

% cat -n program1.c
     1 #include <sys/types.h>
     2 #include <unistd.h>
     3 #include <stdio.h>
     4
     5 int
     6 main()
     7 {
     8      pid_t child_pid;
     9      int parent_i, parent_j;
    10
    11      parent_i = parent_j;
    12
    13      child_pid = fork();
    14
    15      if (child_pid == -1) {
    16          printf("parent: Fork failed\n");
    17          return 1;
    18      } else if (child_pid == 0) {
    19          int child_i, child_j;
    20
    21          printf("child: In child\n");
    22          child_i = child_j;
    23          if (execl("./program2", NULL) == -1) {
    24              printf("child: exec of program2 failed\n");
    25              exit(1);
    26          }
    27      } else {
    28          printf("parent: child’s pid = %d\n", child_pid);
    29      }
    30      return 0;
    31 }
 % cat -n program2.c
     1
     2 #include <stdio.h>
     3
     4 main()
     5 {
     6      int program2_i, program2_j;
     7
     8      printf ("program2: pid = %d\n", getpid());
     9      program2_i = program2_j;
    10
    11      malloc(8);
    12
    13      return 0;
    14 }
%
 % cc -g -o program1 program1.c
 % cc -g -o program2 program2.c
 % dbx -C program1
 Reading symbolic information for program1
 Reading symbolic information for rtld /usr/lib/ld.so.1
 Reading symbolic information for librtc.so
 Reading symbolic information for libc.so.1
 Reading symbolic information for libdl.so.1
 Reading symbolic information for libc_psr.so.1
 (dbx) check -all
 access checking - ON
 memuse checking - ON
 (dbx) dbxenv rtc_inherit on
 (dbx) dbxenv follow_fork_mode child
 (dbx) run
 Running: program1
 (process id 3885)
 Enabling Error Checking... done
RTC reports first error in the parent, program1
 Read from uninitialized (rui):
 Attempting to read 4 bytes at address 0xeffff110
     which is 104 bytes above the current stack pointer
 Variable is ’parent_j’
 Current function is main
   11       parent_i = parent_j;
(dbx) cont
 dbx: warning: Fork occurred; error checking disabled in parent
 detaching from process 3885
 Attached to process 3886
Because  follow_fork_mode is set to child, when the fork occurs error checking is switched from the parent
to the child process
 stopped in _fork at 0xef6b6040
 0xef6b6040: _fork+0x0008:    bgeu    _fork+0x30
 Current function is main
    13       child_pid = fork();
 parent: child’s pid = 3886
 (dbx) cont
 child: In child
 Read from uninitialized (rui):
 Attempting to read 4 bytes at address 0xeffff108
     which is 96 bytes above the current stack pointer
RTC reports an error in the child
 Variable is ’child_j’
 Current function is main
    22       child_i = child_j;
 (dbx) cont
 dbx: process 3886 about to exec("./program2")
 dbx: program "./program2" just exec’ed
 dbx: to go back to the original program use "debug $oprog"
 Reading symbolic information for program2
 Skipping ld.so.1, already read
 Skipping librtc.so, already read
 Skipping libc.so.1, already read
 Skipping libdl.so.1, already read
 Skipping libc_psr.so.1, already read
When the exec of program2 occurs, the RTC settings are inherited by program2 so access and memory use checking
are enabled for that process
 Enabling Error Checking... done
 stopped in main at line 8 in file "program2.c"
     8       printf ("program2: pid = %d\n", getpid());
(dbx) cont
 program2: pid = 3886
 Read from uninitialized (rui):
 Attempting to read 4 bytes at address 0xeffff13c
     which is 100 bytes above the current stack pointer
RTC reports an access error in the executed program, program2
 Variable is ’program2_j’
 Current function is main
     9       program2_i = program2_j;
 (dbx) cont
 Checking for memory leaks...
RTC prints a memory use and memory leak report for the process that exited while under RTC control, program2
Actual leaks report   (actual leaks:      1  total size:   8
 bytes)

 Total      Num of  Leaked     Allocation call stack
 Size       Blocks  Block
                    Address
==========  ====== ========== ====================================
         8       1    0x20c50  main
 Possible leaks report  (possible leaks:   0  total size:   0
 bytes)

 execution completed, exit code is 0