Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
  Previous   Contents   Next 
   
 
Chapter 1

Modular Debugger Overview

The Modular Debugger (MDB) is a general purpose debugging tool for Solaris whose primary feature is its extensibility. This book describes how to use MDB to debug complex software systems, with a particular emphasis on the facilities available for debugging the Solaris kernel and associated device drivers and modules. The book also includes a complete reference for and discussion of the MDB language syntax, debugger features, and MDB Module Programming API.

Introduction

Debugging is the process of analyzing the execution and state of a software program in order to remove defects. Traditional debugging tools provide facilities for execution control so that programmers can re-execute programs in a controlled environment and display the current state of program data or evaluate expressions in the source language used to develop the program. Unfortunately, these techniques are often inappropriate for debugging complex software systems such as:

  • An operating system, where bugs might not be reproducible and program state is massive and distributed

  • Programs that are highly optimized or have had their debug information removed

  • Programs that are themselves low-level debugging tools

  • Customer situations where the developer can only access post-mortem information

MDB is a tool that provides a completely customizable environment for debugging these programs and scenarios, including a dynamic module facility that programmers can use to implement their own debugging commands to perform program-specific analysis. Each MDB module can be used to examine the program in several different contexts, including live and post-mortem. The Solaris Operating Environment includes a set of MDB modules designed to aid programmers in debugging the Solaris kernel and related device drivers and kernel modules. Third-party developers might find it useful to develop and deliver their own debugging modules for supervisor or user software.

MDB Features

MDB provides an extensive collection of features for analyzing the Solaris kernel and other target programs. You can:

  • Perform post-mortem analysis of Solaris kernel crash dumps and user process core dumps: MDB includes a collection of debugger modules that facilitate sophisticated analysis of kernel and process state, in addition to standard data display and formatting capabilities. The debugger modules allow you to formulate complex queries to:

    • 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

  • Use a first-class programming API to implement your own debugger commands and analysis tools without having to recompile or modify the debugger itself: In MDB, debugging support is implemented as a set of loadable modules (shared libraries that the debugger can dlopen(3DL)), each of which provides a set of commands that extends the capabilities of the debugger itself. The debugger in turn provides an API of core services, such as the ability to read and write memory and access symbol table information. MDB provides a framework for developers to implement debugging support for their own drivers and modules; these modules can then be made available for everyone to use.

  • Learn to use MDB if you are already familiar with the legacy debugging tools adb(1) and crash(1M): MDB provides backward compatibility with these existing debugging solutions. The MDB language itself is designed as a superset of the adb language; all existing adb macros and commands work within MDB so developers who use adb can immediately use MDB without knowing any MDB-specific commands. MDB also provides commands that surpass the functionality available from the crash utility.

  • Benefit from enhanced usability features. MDB provides a host of usability features, including:

    • Command-line editing

    • Command history

    • Built-in output pager

    • Syntax error checking and handling

    • Online help

    • Interactive session logging

Future Enhancements

MDB provides a stable foundation for developing advanced post-mortem analysis tools. In the future, the Solaris operating environment will include additional MDB modules that provide even more sophisticated functionality for debugging the kernel and other software programs. You can use MDB to debug existing software programs, and develop your own modules to improve your ability to debug your own Solaris drivers and applications.

 
 
 
  Previous   Contents   Next