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.  使用运行时检查

运行时检查功能

何时使用运行时检查

运行时检查要求

使用运行时检查

启用内存使用和内存泄漏检查

启用内存访问检查

启用所有运行时检查

关闭运行时检查

运行程序

使用访问检查

理解内存访问错误报告

内存访问错误

使用内存泄漏检查

检测内存泄漏错误

可能的泄漏

检查泄漏

理解内存泄漏报告

生成泄漏报告

合并泄漏

修复内存泄漏

利用内存使用检查

抑制错误

抑制的类型

按作用域和类型抑制

抑制上一错误

限制报告的错误数

抑制错误示例

缺省抑制

使用抑制来管理错误

对子进程使用运行时检查

对连接的进程使用运行时检查

在运行 Solaris 的系统中

在运行 Linux 的系统中

结合使用修复并继续功能与运行时检查

运行时检查应用编程接口

在批处理模式下使用运行时检查

bcheck 语法

bcheck 示例

直接在 dbx 中启用批处理模式

疑难解答提示

运行时检查限制

具有更多符号和调试信息时工作效果会更好

SIGSEGVSIGALTSTACK 信号在 x86 平台上受限制

当 8 MB 的所有现有代码中具有足够的补丁区域时工作效果会更好(仅限 SPARC 平台)。

运行时检查错误

访问错误

错误释放 (baf) 错误

重复释放 (duf) 错误

未对齐释放 (maf) 错误

未对齐读 (mar) 错误

未对齐写 (maw) 错误

内存不足 (oom) 错误

从数组越界中读 (rob) 错误

从未分配的内存中读 (rua) 错误

从未初始化的内存中读 (rui) 错误

写入到数组越界内存 (wob) 错误

写入到只读内存 (wro) 错误

写入到未分配内存 (wua) 错误

内存泄漏错误

地址位于块内 (aib) 错误

地址位于寄存器内 (air) 错误

内存泄漏 (mel) 错误

10.  修复并继续

11.  调试多线程应用程序

12.  调试子进程

13.  调试 OpenMP 程序

14.  处理信号

15.  使用 dbx 调试 C++

16.  使用 dbx 调试 Fortran

17.  使用 dbx 调试 Java 应用程序

18.  在机器指令级调试

19.  将 dbx 与 Korn Shell 配合使用

20.  调试共享库

A.  修改程序状态

B.  事件管理

C.  宏

D.  命令参考

索引

结合使用修复并继续功能与运行时检查

可以将运行时检查与修复并继续功能一起使用,以便快速查出并修复编程错误。修复并继续功能提供了强大的组合功能,可以为您节省大量调试时间。以下是一个示例 。

% cat -n bug.c
     1 #include stdio.h
     2 char *s = NULL;
     3
     4 void
     5 problem()
     6 {
     7      *s = ’c’;
     8 }
     9
    10 main()
    11 {
    12      problem();
    13      return 0;
    14 }
% cat -n bug-fixed.c
     1 #include stdio.h
     2 char *s = NULL;
     3
     4 void
     5 problem()
     6 {
     7
     8      s = (char *)malloc(1);
     9      *s = ’c’;
    10 }
    11
    12 main()
    13 {
    14      problem();
    15      return 0;
    16 }
yourmachine46: cc -g bug.c
yourmachine47: dbx -C a.out
Reading symbolic information for a.out
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 libintl.so.1
Reading symbolic information for libdl.so.1
Reading symbolic information for libw.so.1
(dbx) check -access
access checking - ON
(dbx) run
Running: a.out
(process id 15052)
Enabling Error Checking... done
Write to unallocated (wua):
Attempting to write 1 byte through NULL pointer
Current function is problem
    7       *s = ’c’;
(dbx) pop
stopped in main at line 12 in file "bug.c"
   12       problem();
(dbx) #at this time we would edit the file; in this example just copy  
the correct version
(dbx) cp bug-fixed.c bug.c
(dbx) fix
fixing "bug.c" ......
pc moved to "bug.c":14
stopped in main at line 14 in file "bug.c"
   14       problem();
(dbx) cont

execution completed, exit code is 0
(dbx) quit
The following modules in \Qa.out’ have been changed (fixed):
bug.c
Remember to remake program.

有关使用修复和继续功能的更多信息,请参见内存泄漏 (mel) 错误