Skip Navigation Links | |
Exit Print View | |
Oracle Solaris Modular Debugger Guide Oracle Solaris 11.1 Information Library |
4. Using MDB Commands Interactively
Generic Kernel Debugging Support (genunix)
Kernel Memory Allocator Walkers
CPU Structures and the Kernel Dispatcher
Device Drivers and DDI Framework
Files, Processes, and Threads Dcmds
Files, Processes, and Threads Walkers
Synchronization Primitives Dcmds
Interprocess Communication Debugging Support (ipc)
Interprocess Communication Dcmds
Interprocess Communication Walkers
Loopback File System Debugging Support (lofs)
Internet Protocol Module Debugging Support (ip)
Kernel Runtime Link Editor Debugging Support (krtld)
Kernel Runtime Link Editor Dcmds
Kernel Runtime Link Editor Walkers
USB Framework Debugging Support (uhci)
USB Framework Debugging Support (usba)
x86: x86 Platform Debugging Support (unix)
SPARC: sun4u Platform Debugging Support (unix)
9. Debugging With the Kernel Memory Allocator
This section discusses the dcmds and walkers used to debug problems identified by the Oracle Solaris kernel memory allocator and to examine memory and memory usage. The dcmds and walkers described here are discussed in more detail in Chapter 9, Debugging With the Kernel Memory Allocator.
Given the address of a kernel thread, print a list of memory allocations it has performed in reverse chronological order.
Print a summary of the bufctl information for the specified bufctl address. If one or more options are present, the bufctl information is printed only if it matches the criteria defined by the option arguments; in this way, the dcmd can be used as a filter for input from a pipeline. The -a option indicates that the bufctl's corresponding buffer address must equal the specified address. The -c option indicates that a program counter value from the specified caller must be present in the bufctl's saved stack trace. The -e option indicates that the bufctl's timestamp must be greater than or equal to the specified earliest timestamp. The -l option indicates that the bufctl's timestamp must be less than or equal to the specified latest timestamp. The -t option indicates that the bufctl's thread pointer must be equal to the specified thread address.
The ::findleaks dcmd provides powerful and efficient detection of memory leaks in kernel crash dumps where the full set of kmem debug features has been enabled. The first execution of ::findleaks processes the dump for memory leaks (this can take a few minutes), then coalesces the leaks by the allocation stack trace. The findleaks report shows a bufctl address and the topmost stack frame for each memory leak that was identified.
If the -v option is specified, the dcmd prints more verbose messages as it executes. If an explicit address is specified prior to the dcmd, the report is filtered and only leaks whose allocation stack traces contain the specified function address are displayed.
Given the address of a kernel thread, print a list of memory frees it has performed, in reverse chronological order.
Search the kernel address space for pointer-aligned addresses that contain the specified pointer-sized value. The list of addresses that contain matching values is then printed. Unlike MDB's built-in search operators, ::kgrep searches every segment of the kernel's address space and searches across discontiguous segment boundaries. On large kernels, ::kgrep can take a considerable amount of time to execute.
Display events in a kernel memory allocator transaction log. Events are displayed in time-reverse order, with the most recent event displayed first. For each event, ::kmalog displays the time relative to the most recent event in T-minus notation (for example, T-0.000151879), the bufctl, the buffer address, the kmem cache name, and the stack trace at the time of the event. Without arguments, ::kmalog displays the kmem transaction log, which is present only if KMF_AUDIT is set in kmem_flags. ::kmalog fail displays the allocation failure log, which is always present; this can be useful in debugging drivers that don't cope with allocation failure correctly. ::kmalog slab displays the slab create log, which is always present. ::kmalog slab can be useful when searching for memory leaks.
Display the list of kernel memory allocator caches and virtual memory arenas, along with corresponding statistics.
Print information about the medium and large users of the kernel memory allocator that have current memory allocations. The output consists of one entry for each unique stack trace specifying the total amount of memory and number of allocations that was made with that stack trace. This dcmd requires that the KMF_AUDIT flag is set in kmem_flags.
If one or more cache names (for example, kmem_alloc_256) are specified, the scan of memory usage is restricted to those caches. By default all caches are included. If the -e option is used, the small users of the allocator are included. The small users are allocations that total less than 1024 bytes of memory or for which there are less than 10 allocations with the same stack trace. If the -f option is used, the stack traces are printed for each individual allocation.
Format and display the kmem_cache structure stored at the specified address, or the complete set of active kmem_cache structures.
Display the complete set of kmem transaction logs, sorted in reverse chronological order. This dcmd uses a more concise tabular output format than ::kmalog.
Verify the integrity of the kmem_cache structure stored at the specified address, or the complete set of active kmem_cache structures. If an explicit cache address is specified, the dcmd displays more verbose information regarding errors; otherwise, a summary report is displayed. The ::kmem_verify dcmd is discussed in more detail in Kernel Memory Caches.
Format and display the vmem structure stored at the specified address, or the complete set of activevmem structures. This structure is defined in <sys/vmem_impl.h>.
Format and display the vmem_seg structure stored at the specified address. This structure is defined in <sys/vmem_impl.h>.
Report information about the specified address. In particular, ::whatis will attempt to determine if the address is a pointer to a kmem-managed buffer or another type of special memory region, such as a thread stack, and report its findings. If the -a option is present, the dcmd reports all matches instead of just the first match to its queries. If the -b option is present, the dcmd also attempts to determine if the address is referred to by a known kmem bufctl. If the -v option is present, the dcmd reports its progress as it searches various kernel data structures.
Given the address of a kthread_t structure as a starting point, iterate over the set of bufctl structures corresponding to memory allocations performed by this kernel thread.
Given the address of a kmem_cache_t structure as a starting point, iterate over the set of allocated bufctls associated with this cache.
Given the address of a kmem_cache_t structure as a starting point, iterate over the set of free bufctls associated with this cache.
Given the address of a kthread_t structure as a starting point, iterate over the set of bufctl structures corresponding to memory deallocations performed by this kernel thread.
Given the address of a kmem_cache_t structure as a starting point, iterate over the set of free buffers associated with this cache.
Given the address of a kmem_cache_t structure as a starting point, iterate over the set of allocated buffers associated with this cache.
Iterate over the active set of kmem_cache_t structures. This structure is defined in <sys/kmem_impl.h>.
Given the address of a kmem_cache_t structure as a starting point, iterate over the per-CPU kmem_cpu_cache_t structures associated with this cache. This structure is defined in <sys/kmem_impl.h>.
Given the address of a kmem_cache_t structure as a starting point, iterate over the set of associated kmem_slab_t structures. This structure is defined in <sys/kmem_impl.h>.
Iterate over the set of bufctls stored in the kmem allocator transaction log.
Given the address of a bufctl structure, iterate over the set of bufctl structures corresponding to leaked memory buffers with similar allocation stack traces. The ::findleaks dcmd must be applied to locate memory leaks before the leak walker can be used
Given the address of a bufctl structure, iterate over the set of buffer addresses corresponding to leaked memory buffers with similar allocation stack traces. The ::findleaks dcmd must be applied to locate memory leaks before the leakbuf walker can be used.
The MDB file systems debugging support includes a built-in facility to convert vnode pointers to the corresponding file system path name. This conversion is performed using the Directory Name Lookup Cache (DNLC); because the cache does not hold all active vnodes, some vnodes might not be able to be converted to path names and “??” is displayed instead of a name.
Display a table of mounted file systems, including the vfs_t address, ops vector, and mount point of each file system.
Display a table of vnodes with active network locks registered with the lock manager. The pathname corresponding to each vnode is shown.
Display the pathname corresponding to the given vnode address. If the -v option is specified, the dcmd prints a more verbose display, including the vnode pointer of each intermediate path component.
Iterate over the set of active block I/O transfer structures (buf_t structures). The buf structure is defined in <sys/buf.h> and is described in more detail in buf(9S).
This section describes the debugging support for the kernel virtual memory subsystem.
Print the smap structure address that corresponds to the given address in the kernel's segmap address space segment.
Display the proc_t address for the process corresponding to the as_t address as.
Display the specified memlist structure or one of the well-known memlist structures. If no memlist address and options are present or if the -i option is present, the memlist representing physically installed memory is displayed. If the -a option is present, the memlist representing available physical memory is displayed. If the -v option is present, the memlist representing available virtual memory is displayed.
Display a system-wide memory usage summary. The amount and percentage of system memory consumed by different classes of pages (kernel, anonymous memory, executables and libraries, page cache, and free lists) are displayed, along with the total amount of system memory.
Display the properties of the specified page_t. If no page_t address is specified, the dcmd displays the properties of all system pages.
Format and display the specified address space segment (seg_t address).
Display information on all active swapinfo structures or about the specified struct swapinfo. The vnode, filename, and statistics for each structure are displayed.
Print the smap structure address that corresponds to the given vnode_t address and offset.
Given the address of an anon_map structure as a starting point, iterate over the set of related anon structures. The anon map implementation is defined in <vm/anon.h>.
Iterate over the spans of the specified memlist structure. This walker can be used in conjunction with the ::memlist dcmd to display each span.
Iterate over all system page structures. If an explicit address is specified for the walk, this is taken to be the address of a vnode and the walker iterates over only those pages associated with the vnode.
Given the address of an as_t structure as a starting point, iterate over the set of address space segments (seg structures) associated with the specified address space. The seg structure is defined in <vm/seg.h>.
Iterate over the list of active swapinfo structures. This walker may be used in conjunction with the ::swapinfo dcmd.
This section describes the facilities for examining the state of the CPU structures and the kernel dispatcher.
Display the callout table. The function, argument, and expiration time for each callout is displayed.
Display the scheduling class table.
Display a table of the threads currently executing on each CPU. If an optional CPU ID number or CPU structure address is specified prior to the dcmd name, only the information for the specified CPU is displayed. If the -v option is present, ::cpuinfo also displays the runnable threads waiting to execute on each CPU as well as the active interrupt threads.
Iterate over the set of kernel CPU structures. The cpu_t structure is defined in <sys/cpuvar.h>.
This section describes dcmds and walkers that are useful for kernel developers as well as third-party device driver developers.
Given the address of a kernel name-to-major number binding hash table entry (struct bind), display the node binding name, major number, and pointer to the next element.
Display the list of all instances of the named driver. The output consists of an entry for each instance, beginning with the pointer to the struct dev_info (viewable with $<devinfo or ::devinfo), the driver name, the instance number, and the driver and system properties associated with that instance.
Print the system and driver properties associated with a devinfo node. If the -q option is specified, only a quick summary of the device node is shown.
Print the name of the driver (if any) associated with the devinfo node.
Display the kernel's devnames table along with the dn_head pointer, which points at the driver instance list. If the -v flag is specified, additional information stored at each entry in the devnames table is displayed.
Display the kernel device tree starting at the device node specified by devinfo. If devinfo is not provided, the root of the device tree is assumed by default. If the -c option is specified, only children of the given device node are displayed. If the -p option is specified, only ancestors of the given device node are displayed. If -v is specified, the properties associated with each node are displayed.
Display the driver name corresponding to the specified major number. The major number can be specified as an expression preceding the dcmd or as a command-line argument.
Print all of the device nodes that correspond to the specified modctl address.
Given a device driver name, display its major number.
Given a softstate state pointer (see ddi_soft_state_init(9F)) and a device instance number, display the soft state for that instance.
Given the address of an array of kernel binding hash table entries (struct bind **), walk all entries in the hash table and return the address of each struct bind.
First, iterate over the parents of the given devinfo and return them in order of seniority from most to least senior. Second, return the given devinfo itself. Third, iterate over the children of the given devinfo in order of seniority from most to least senior. The dev_info struct is defined in <sys/ddi_impldefs.h>.
First, return the given devinfo, then iterate over the children of the given devinfo in order of seniority from most to least senior. The dev_info struct is defined in <sys/ddi_impldefs.h>.
Iterate over the parents of the given devinfo in order of seniority from most to least senior, and then return the given devinfo. The dev_info struct is defined in <sys/ddi_impldefs.h>.
Iterate over the siblings of the given devinfo. The dev_info struct is defined in <sys/ddi_impldefs.h>.
Iterate over the entries in the devnames array. This structure is defined in <sys/autoconf.h>.
Given a softstate pointer (see ddi_soft_state_init(9F)) display all non-NULL pointers to driver state structures.
Given a softstate pointer (see ddi_soft_state_init(9F)) display all pointers to driver state structures. Note that the pointers for unused instances will be NULL.
This section describes dcmds and walkers that are useful for kernel developers as well as developers of third-party STREAMS modules and drivers.
Given the address of an mblk_t, print the address of the corresponding dblk_t.
Verify the integrity of one or more message blocks. If an explicit message block address is specified, the integrity of this message block is checked. If no address is specified, the integrity of all active message blocks are checked. This dcmd produces output for any invalid message block state that is detected.
Filter and display the specified queue_t data structure. With no options, various properties of the queue_t are shown. If the -v option is present, the queue flags are decoded in greater detail. If the -f, -F, or -m options are present, the queue is displayed only if it matches the criteria defined by the arguments to these options; in this way, the dcmd can be used as a filter for input from a pipeline. The -f option indicates that the specified flag (one of the Q flag names from <sys/stream.h>) must be present in the queue flags. The -F option indicates that the specified flag must be absent from the queue flags. The -m option indicates that the module name associated with the queue must match the specified modname. The -s option indicates that the syncq_t associated with the queue must match the specified syncq_t address.
Given the address of a queue_t, print the address of the corresponding syncq_t data structure.
Given the address of a queue_t, print the address of the peer read or write queue structure.
Given the address of a queue_t, print the address of the corresponding read queue.
Given the address of a queue_t, print the address of the corresponding write queue.
Display a visual picture of a kernel STREAM data structure, given the address of the stdata_t structure representing the STREAM head. The read and write queue pointers, byte count, and flags for each module are shown, and in some cases additional information for the specific queue is shown in the margin.
Filter and display the specified syncq_t data structure. With no options, various properties of the syncq_t are shown. If the -v option is present, the syncq flags are decoded in greater detail. If the -f, -F, -t, or -T options are present, the syncq is displayed only if it matches the criteria defined by the arguments to these options; in this way, the dcmd can be used as a filter for input from a pipeline. The -f option indicates that the specified flag (one of the SQ_ flag names from <sys/strsubr.h>) must be present in the syncq flags. The -F option indicates that the specified flag must be absent from the syncq flags. The -t option indicates that the specified type (one of the SQ_CI or SQ_CO type names from <sys/strsubr.h>) must be present in the syncq type bits. The -T option indicates that the specified type must be absent from the syncq type bits.
Given the address of a syncq_t, print the address of the corresponding queue_t data structure.
Given the address of an mblk_t, iterate over the set of associated message structures by following the b_cont pointer. The b_cont pointer is used to link a given message block to the next associated message block that is the continuation of the same message. The message block is described in more detail in msgb(9S)
Given the address of an mblk_t, iterate over the set of associated message structures by following the b_next pointer. The b_next pointer is used to link a given message block to the next associated message block on a given queue. The message block is described in more detail in msgb(9S).
Given the address of a queue_t structure, walk the list of related queues using the q_link pointer. This structure is defined in <sys/stream.h>.
Given the address of a queue_t structure, walk the list of related queues using the q_next pointer. This structure is defined in <sys/stream.h>.
Given the address of an stdata_t structure, walk the list of read-side queue structures.
Given the address of an stdata_t structure, walk the list of write-side queue structures.
The following dcmds and walkers are provided to help debug the core kernel networking stack protocols.
Given the address of a kernel MI_O, filter and display the MI_O or its payload. If the -p option is specified, then the address of the corresponding payload of the MI_O is displayed, otherwise the MI_O itself is displayed. Specifying filter -d or -m enables the dcmd to filter device or module MI_O objects respectively.
Show network statistics and active connections. If the -a option is present, the state of all sockets is displayed. If the -v option is present, more verbose output is displayed. If the -f option is present, only connections associated with the specified address family are displayed. If the -P option is present, only connections associated with the specified protocols are displayed.
Filters and displays sonode objects. If no address is given, then the list of AF_UNIX sockets is displayed, otherwise only the specified sonode is displayed. If the -f option is present, then only sockets of the given family will be output. If the -t option is present, then only sonodes of the given type will be output. If the -p option is present, then only sockets of the given protocol will be displayed.
Filters and displays tcpb objects. If no address is specified, all connections are walked, otherwise only the specified tcpb is filtered/displayed. Specifying -a filters for only active connections and -P can be used to filter for TCP IPv4 or IPv6 connections. The tcpb dcmd is intelligent about filtering TCP connections, and if a IPv6 TCP connection is in a state that would still facilitate a IPv4 connection, the -P filter considers the connection as both IPv4 and IPv6 in much the same way that ::netstat does. If the dcmd is not being used as a filter and the -v option is specified, then the output of the dcmd will be verbose.
Given the address of an ar, this walker walks all ar objects from the given ar to the final ar. If no address is specified, all ar objects are walked.
Given the address of an icmp, this walker walks all icmp objects from the given icmp to the final icmp. If no address is specified, all icmp objects are walked.
Given the address of an interface link layer structure (ill), this walker walks all ill objects from the given ill to the final. If no address is specified, all ill objects are walked.
Given the address of an ipc, this walker walks all ipc objects from the given ipc to the final ipc. If no address is specified, all ipc objects are walked.
Given the address of a MI_O, walk all the MI_O's in this MI.
Given the address of a AF_UNIX sonode, walk the associated list of AF_UNIX sonodes beginning with the given sonode. If no address is specified, this walker walks the list of all AF_UNIX sockets.
Given the address of a tcpb, this walker walks all TCP connections from the given tcpb to the final TCP connection. If no address is specified, all tcpb objects are walked.
Given the address of a udp, this walker walks all udp objects from the given udp to the final udp. If no address is specified, all udp objects are walked.
This section describes dcmds and walkers used to format and examine various fundamental file, process, and thread structures in the Oracle Solaris kernel.
Print the file_t address corresponding to the file descriptor fd-num associated with the specified process. The process is specified using the virtual address of its proc_t structure.
Print the stack trace associated with the given kernel thread, identified by the virtual address of its kthread_t structure. The dcmd employs several different algorithms to locate the appropriate stack backtrace. If an optional command string is specified, the dot variable is reset to the frame pointer address of the topmost stack frame, and the specified command is evaluated as if it had been typed at the command line. The default command string is “<.$C0”; that is, print a stack trace including frame pointers but no arguments.
Display process information for processes whose name matches the regexp regular expression pattern. The ::pgrep dcmd is similar to the pgrep(1) command. The ::pgrep dcmd is used to pattern match against all processes. When the -n option is used, display only the newest process that matches the pattern. When the -o option is used, display only the oldest process that matches the pattern. When the -x option is used, display only those processes whose names are exactly the same as the search pattern.
In kmdb(1), the regexp used with ::pgrep must be a plain alpha-numeric text string.
Print the proc_t address corresponding to the specified PID. Recall that MDB's default base is hexadecimal, so decimal PIDs obtained using pgrep(1) or ps(1) should be prefixed with 0t.
Print the memory map of the process indicated by the given process address. The dcmd displays output using a format similar to pmap(1). If the -q option is present, the dcmd displays an abbreviated form of its output that requires less processing time.
Print a summary of the information related to the specified process, or all active system processes, similar to ps(1). If the -f option is specified, the full command name and initial arguments are printed. If the -l option is specified, the LWPs associated with each process are printed. If the -t option is specified, the kernel threads associated with each process LWP are printed. If the -T option is specified, the task ID associated with each process is displayed. If the -P option is specified, the project ID associated with each process is displayed.
Print a process tree, with child processes indented from their respective parent processes. The dcmd displays output using a format similar to ptree(1).
Print a list of the active kernel task structures and their associated ID numbers and attributes. The process task ID is described in more detail in settaskid(2).
Display properties of the specified kernel kthread_t structure. If no kthread_t address is specified, the properties of all kernel threads are displayed. The dcmd options are used to control which output columns are shown. If no options are present, the -i option is enabled by default. If the -b option is present, information relating to the thread's turnstile and blocking synchronization object is shown. If the -d option is present, the thread's dispatcher priority, binding, and last dispatch time is shown. If the -f option is present, threads whose state is TS_FREE are elided from the output. If the -i option is present (the default), thread state, flags, priority, and interrupt information is shown. If the -m option is present, all of the other output options are merged together on to a single output line. If the -p option is present, the thread's process, LWP, and credential pointers are displayed. If the -s option is present, the thread's signal queue and masks of pending and held signals are shown.
Given a vnode_t address, print the proc_t addresses of all processes that have this vnode currently open in their file table.
Given the address of a proc_t structure as a starting point, iterate over the set of open files (file_t structures) associated with the specified process. The file_t structure is defined in <sys/file.h>.
Iterate over the active process (proc_t) structures. This structure is defined in <sys/proc.h>.
Given a task pointer, iterate over the list of proc_t structures for processes that are members of the given task.
Iterate over a set of kernel thread (kthread_t) structures. If the global walk is invoked, all kernel threads are returned by the walker. If a local walk is invoked using a proc_t address as the starting point, the set of threads associated with the specified process is returned. The kthread_t structure is defined in <sys/thread.h>.
This section describes dcmds and walkers used to examine particular kernel synchronization primitives. The semantics of each primitive are discussed in the corresponding (9f) section of the manual pages.
Given the address of a readers-writers lock (see rwlock(9F)), display the current state of the lock and the list of waiting threads.
Convert the address of a synchronization object to the address of the corresponding turnstile and print the turnstile address.
Display the properties of the specified turnstile_t. If no turnstile_t address is specified, the dcmd displays the properties of all turnstiles.
Given the address of a condition variable (see condvar(9F)) or semaphore (see semaphore(9F)), display the current number of waiters on this object. If no explicit address is specified, display all such objects that have waiting threads. If the -v option is specified, display the list of threads that are blocked on each object.
Given the address of a synchronization object (such as a mutex(9F) or rwlock(9F)), iterate over the list of blocked kernel threads.
Given the address of a condition variable (see condvar(9F)) or semaphore (see semaphore(9F)), iterate over the list of blocked kernel threads.
The cyclic subsystem is a low-level kernel subsystem that provides high resolution, per-CPU interval timer facilities to other kernel services and programming interfaces.
Display the cyclic subsystem per-CPU state for each CPU. If the -v option is present, a more verbose display is shown. If the -V option is present, an even more verbose display than -v is shown.
Format and display the cyclic_t at the specified address.
Display cyclic subsystem code coverage information. This information is available only in a DEBUG kernel.
Display cyclic subsystem trace information. This information is available only in a DEBUG kernel.
Iterate over the per-CPU cyc_cpu_t structures. This structure is defined in <sys/cyclic_impl.h>.
Iterate over the cyclic trace buffer structures. This information is only available in a DEBUG kernel.
The task queue subsystem provides general-purpose asynchronous task scheduling for a variety of clients in the kernel.
Given the addresss of a taskq structure, iterate over the list of taskq_entry structures.
The error queue subsystem provides general-purpose asynchronous error event processing for platform-specific error handling code.
Display a summary of information relating to the specified error queue. If no address is given, display information relating to all system error queues. The address, name, queue length, and data element size for each queue are displayed, along with various queue statistics.
Walk the list of system error queues and return the address of each individual error queue.
Given the address of an error queue, return the address of each pending error event data buffer.
This section describes dcmds that can be used to examine system configuration data.