Writing Device Drivers

Getting Started With MDB

MDB provides sophisticated debugging support for analyzing kernel problems. This section provides an overview of MDB's features. For a more complete discussion of MDB's capabilities, refer to the Solaris Modular Debugger Guide.

MDB's command syntax is compatible with the kadb syntax and MDB can execute all of the kadb (and legacy adb) macros. These are stored in /usr/lib/adb and in /usr/platform/`uname -i`/lib/adb for 32-bit kernels; and in /usr/lib/adb/sparcv9 and /usr/platform/`uname -i`/lib/adb/sparcv9 for 64-bit kernels.

In addition to macro files, MDB supports 'debugger commands' or dcmds. These dcmds can be dynamically loaded at runtime from a set of debugger modules. MDB provides a first-class programming API for implementing debugger modules so that driver developers can implement their own custom debugging support. MDB also provides a host of usability features, such as command line editing, command history, an output pager, and online help.

MDB provides a rich set of modules and dcmds for debugging the Solaris kernel and associated modules and device drivers. These facilities allow you to formulate complex debugging queries: locate all the memory allocated by a particular thread; print a visual picture of a kernel STREAM; determine what type of structure a particular address refers to; locate leaked memory blocks in the kernel; analyze memory to locate stack traces; and more.


Note -

In earlier versions of the Solaris operating environment, adb(1) was the recommended tool for post-mortem analysis. In the Solaris 8 operating environment, mdb(1) is the new recommended tool for post-mortem analysis; it provides an upward-compatible syntax and feature set. In addition, mdb includes features that surpass the set of commands available from the legacy crash(1M) utility.


To get started, run mdb and supply it with a system crash dump:

% cd /var/crash/testsystem
% ls
bounds     unix.0     vmcore.0
% mdb unix.0 vmcore.0
Loading modules: [ unix krtld genunix ip logindmux ptm pts nfs lofs ]
> ::status
debugging crash dump vmcore.1 (32-bit) from testsystem
operating system: 5.8 generic (sun4u)

When mdb responds with the '>' prompt, it is ready for commands. To examine the running kernel on a live system, type:

# mdb -k
Loading modules: [ unix krtld genunix ip logindmux ptm nfs ipc ]
> ::status
debugging live kernel (32-bit) on testsystem
operating system: 5.8 Generic (sun4u)