Writing Device Drivers for Oracle® Solaris 11.2

Exit Print View

Updated: September 2014
 
 

Using the mdb Modular Debugger

    The mdb(1) modular debugger can be applied to the following types of files:

  • Live operating system components

  • Operating system crash dumps

  • User processes

  • User process core dumps

  • Object files

The mdb debugger provides sophisticated debugging support for analyzing kernel problems. This section provides an overview of mdb features. For a complete discussion of mdb, refer to the Oracle Solaris Modular Debugger Guide .

Although mdb can be used to alter live kernel state, mdb lacks the kernel execution control that is provided by kmdb. As a result kmdb is preferred for runtime debugging. The mdb debugger is used more for static situations.


Note - The prompt for mdb is >.

Getting Started With the Modular Debugger

The mdb debugger provides an extensive programming API for implementing debugger modules so that driver developers can implement custom debugging support. The mdb debugger also provides many usability features, such as command-line editing, command history, an output pager, and online help.


Note -  The AFB macros should no longer be used. That functionality has largely been superseded by the dcmds in mdb.

The mdb debugger provides a rich set of modules and dcmds. With these tools, you can debug the Oracle Solaris kernel, any associated modules, and device drivers. These facilities enable you to perform tasks such as:

  • 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

  • Assemble dcmds into modules called mods for creating customized operations

To get started, switch to the crash directory and type mdb, specifying a system crash dump, as illustrated in the following example.

Example 23-7  Invoking mdb on a Crash Dump
% cd /var/crash/testsystem
% ls
bounds     unix.0    vmcore.0
% mdb unix.0 vmcore.0
Loading modules: [ unix kited genunix ufs_log ip SBA s1394 cc nfs ]
> ::status
debugging crash dump vmcore.0 (64-bit) from test system
operating system: 5.10 Generic (sun4u)
panic message: zero
dump content: kernel pages only

When mdb responds with the > prompt, you can run commands.

To examine the running kernel on a live system, run mdb from the system prompt as follows.

Example 23-8  Invoking mdb on a Running Kernel
# mdb -k
Loading modules: [ unix kited genunix ufs_log ip SBA s1394 Pym cc IPX nfs ]
> ::status
debugging live kernel (64-bit) on test system
operating system: 5.10 Generic (sun4u)