JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Modular Debugger Guide     Oracle Solaris 11.1 Information Library
search filter icon
search icon

Document Information

Preface

1.  Modular Debugger Overview

2.  Debugger Concepts

3.  MDB Language Syntax

4.  Using MDB Commands Interactively

5.  Built-In Commands

6.  Execution Control

7.  Kernel Execution Control

8.  Kernel Debugging Modules

9.  Debugging With the Kernel Memory Allocator

10.  Module Programming API

Debugger Module Linkage

_mdb_init()

_mdb_fini()

Dcmd Definitions

Walker Definitions

API Functions

mdb_pwalk()

mdb_walk()

mdb_pwalk_dcmd()

mdb_walk_dcmd()

mdb_call_dcmd()

mdb_layered_walk()

mdb_add_walker()

mdb_remove_walker()

mdb_vread() and mdb_vwrite()

mdb_fread() and mdb_fwrite()

mdb_pread() and mdb_pwrite()

mdb_readstr()

mdb_writestr()

mdb_readsym()

mdb_writesym()

mdb_readvar() and mdb_writevar()

mdb_lookup_by_name() and mdb_lookup_by_obj()

mdb_lookup_by_addr()

mdb_getopts()

mdb_strtoull()

mdb_alloc(), mdb_zalloc() and mdb_free()

mdb_printf()

Flag Specifiers

Field Width Specifiers

Integer Specifiers

Terminal Attribute Specifiers

Format Specifiers

mdb_snprintf()

mdb_warn()

mdb_flush()

mdb_nhconvert()

mdb_dumpptr() and mdb_dump64()

mdb_one_bit()

mdb_inval_bits()

mdb_inc_indent() and mdb_dec_indent()

mdb_eval()

mdb_set_dot() and mdb_get_dot()

mdb_get_pipe()

mdb_set_pipe()

mdb_get_xdata()

Additional Functions

A.  MDB Options

B.  Notes

C.  Transition From adb and kadb

D.  Transition From crash

Index

Debugger Module Linkage

_mdb_init()

const mdb_modinfo_t *_mdb_init(void);

Each debugger module is required to provide, for linkage and identification purposes, a function named _mdb_init(). This function returns a pointer to a persistent (that is, not declared as an automatic variable) mdb_modinfo_t structure, as defined in <sys/mdb_modapi.h>:

typedef struct mdb_modinfo {
        ushort_t mi_dvers;               /* Debugger API version number */
        const mdb_dcmd_t *mi_dcmds;      /* NULL-terminated list of dcmds */
        const mdb_walker_t *mi_walkers;  /* NULL-terminated list of walks */
} mdb_modinfo_t;

The mi_dvers member is used to identify the API version number, and should always be set to MDB_API_VERSION. The current version number is therefore compiled into each debugger module, allowing the debugger to identify and verify the application binary interface used by the module. The debugger does not load modules that are compiled for an API version that is more recent than the debugger itself.

The mi_dcmds and mi_walkers members, if not NULL, point to arrays of dcmd and walker definition structures, respectively. Each array must be terminated by a NULL element. These dcmds and walkers are installed and registered with the debugger as part of the module loading process. The debugger will refuse to load the module if one or more dcmds or walkers are defined improperly or if they have conflicting or invalid names. Dcmd and walker names are prohibited from containing characters that have special meaning to the debugger, such as quotation marks and parentheses.

The module can also execute code in _mdb_init() using the module API to determine if it is appropriate to load. For example, a module can only be appropriate for a particular target if certain symbols are present. If these symbols are not found, the module can return NULL from the _mdb_init() function. In this case, the debugger will refuse to load the module and an appropriate error message is printed.

_mdb_fini()

void _mdb_fini(void);

If the module performs certain tasks prior to unloading, such as freeing persistent memory previously allocated with mdb_alloc(), it can declare a function named _mdb_fini() for this purpose. This function is not required by the debugger. If declared, it is called once prior to unloading the module. Modules are unloaded when the user requests that the debugger terminate or when the user explicitly unloads a module using the ::unload built-in dcmd.