Section 12.1. Introduction to the Modular Debugger


12.1. Introduction to the Modular Debugger

If you were a detective investigating the scene of a crime, you might interview witnesses and ask them to describe what happened and who they saw. However, if there were no witnesses or these descriptions proved insufficient, you might consider collecting fingerprints and forensic evidence that could be examined for DNA to help solve the case. Often, software program failures divide into analogous categories: problems that can be solved with source-level debugging tools; and problems that require low-level debugging facilities, examination of core files, and knowledge of assembly language to diagnose and correct. The MDB environment facilitates analysis of this second class of problems.

It might not be necessary to use MDB in every case, just as a detective doesn't need a microscope and DNA evidence to solve every crime. However, when programming a complex low-level software system such as an operating system, you might frequently encounter these situations. That's why MDB is designed as a debugging framework that lets you construct your own custom analysis tools to aid in the diagnosis of these problems. MDB also provides a powerful set of built-in commands with which you can analyze the state of your program at the assembly language level.

12.1.1. MDB

MDB provides a completely customizable environment for debugging programs, including a dynamic module facility that programmers can use to implement their own debugging commands to perform program-specific analysis. Each MDB module can examine the program in several different contexts, including live and postmortem. The Solaris Operating System includes a set of MDB modules that assist 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.

12.1.2. MDB Features

MDB offers an extensive collection of features for analyzing the Solaris kernel and other target programs. Here's what you can do:

  • Perform postmortem 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 do the following:

    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 on which the debugger can run dlopen(3C)), 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 and crash.

    MDB is backward compatible 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:

    Command-line editing

    Command history

    Built-in output pager

    Syntax error checking and handling

    Online help

    Interactive session logging

The MDB infrastructure was first added in Solaris 8. Many new features have been added throughout Solaris releases, as shown in Table 12.1.

Table 12.1. MDB History

Solaris Revision

Annotation

Solaris 8

MDB introduced

Solaris 9

Kernel type information (e.g., ::print)

Solaris 10

User-level type information (Common Type Format) kmdb replaces kadb


12.1.3. Terms

Throughout this chapter, MDB is used to describe the common debugger corethe set of functionality common to both mdb and kmdb. mdb refers to the userland debugger. kmdb refers to the in-situ kernel debugger.




Solaris Performance and Tools(c) Dtrace and Mdb Techniques for Solaris 10 and Opensolaris
Solaris Performance and Tools: DTrace and MDB Techniques for Solaris 10 and OpenSolaris
ISBN: 0131568191
EAN: 2147483647
Year: 2007
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net