Specifications

Red Hat Enterprise Linux to Oracle Solaris Porting Guide
47
Debugging Applications
Many powerful tools are available on Oracle Solaris 11 for debugging software. These debugging tools
can be broadly categorized as follows:
Kernel-land debuggers, for running in kernel mode
Kernel mode maps to the privilege mode of the CPU. Examples of kernel modules include file
system kernel modules, device drivers, and so on.
User-land debuggers for running in user mode
User-land maps to the non-privilege mode of the CPU. User-land is where applications execute
and the applications interface to the OS kernel via system calls. Kernel-land code and user-land
code have different address spaces.
Tools for addressing specific issues
This includes tools for detecting memory-access errors or leaks, code coverage, data races and
deadlocks, hot locks, and so on.
Kernel Debuggers
The tools under this category are used for debugging code running in kernel mode (which maps to the
privilege mode of the CPU). The most popular tools among kernel developers are kdb and mdb:
kdb is the interactive kernel debugger.
mdb is the modular debugger generally used for debugging the live kernel, processes, core dumps,
memory leaks, and so on, but it can also be used for debugging application core dumps. mdb is a
very popular tool for debugging system crash dumps. It is an easy-to-extend utility for low-level
debugging and it is modularized. Oracle Solaris 11 includes a set of mdb modules that assist
programmers in debugging the Oracle Solaris kernel and related device drivers. Third-party
developers can develop their own debugging modules for supervisor or user software.
Source-Level Debugging with dbx
Similar to gdb (the GNU debugger on Linux), dbx is a proprietary source-level debugger shipped
with Oracle Solaris Studio. dbx can be used for source-level debugging and execution of programs
written in C++, ANSI C, Fortran 77, Fortran 95, and Java programming languages. It provides
symbolic debugging for programs written in C and C++. Useful features of dbx include stepping
through programs one source line or one machine instruction at a time. In addition to simply viewing
the operation of the program, variables can be manipulated and a wide range of expressions can be
evaluated and displayed. A program, a running process, or a core file can be debugged using dbx.
When dbx is used to debug a running process, the process is stopped.
To use dbx effectively, you need a debug binary, that is, you need to build your source code with the -
g compiler flag. Also note that the full debugging information is available only with no compiler
optimization. Only partial debugging support is available for optimized code. dbx allows you to modify