kadbMacros
kadb(1M) supports macros that are used for displaying kernel data structures. kadb macros can be displayed with $M. Macros are used in the form:
[ address ] $<macroname |
Note - Neither the information displayed by these macros, nor the format in which the information is displayed constitute an interface. Therefore, the information and format can change at any time.
Device Macros
This section describes the kadb(1M) macros that can be used to retrieve information from the kernel about a device during a debugging session.
devinfo_brief | Prints a brief summary of a dev_info_t structure; the name and addr fields are shown in string form and are used in the /devices path to the node |
devinfo | Prints devinfo_brief information for a dev_info_t structure followed by an in-order dump of all fields |
devinfo.parent | Prints devinfo_brief information for the specified node and its parents all the way back to the root of the devinfo tree |
devinfo.sibling | Prints devinfo_brief information for all siblings of the specified node; you see all sibling nodes if you start at the parent's child |
devinfo.minor | Prints the ddi_minor_data structure for all minor name nodes associated with the specified device node |
devinfo.prop | Prints all the property lists associated with the specified device node |
devinfo_major | Prints devinfo_brief information for all device nodes associated with the specified driver major number |
devt | Breaks a dev_t into its major and minor parts and prints the values in hexadecimal and decimal |
devnames | Prints the contents of the specified devnames structure |
devnames_major | Prints the contents of the devnames structure for the specified major number |
bus_op | Prints the contents of a bus_ops structure |
The devinfo commands, such as devinfo and devinfo_brief, return a node_state value, which may be one of the following:
DS_LINKED | This device node has been linked into the kernel's device tree, but the system has not yet found a driver for it. |
DS_BOUND | The node is bound to a driver, but the driver's probe(9E) routine has not yet been called. |
DS_INITIALIZED | The parent nexus has assigned a bus address for the driver and completed implementation-specific initializations, but the driver's probe(9E) routine has not yet been called. |
DS_PROBED | The driver's probe(9E) routine returned successfully. |
DS_ATTACHED | The driver's attach(9E) routine returned successfully. |
DS_READY | The device is fully configured. |
Examples: Use of Device Macros
The examples in this section show how some of the device-related macros can be used to debug a driver.
The following ls -l command shows how the /devices path fits into the devinfo structure:
# ls -l /dev/ttya lrwxrwxrwx 1 root root 6 Aug 17 17:50 /dev/ttya -> term/a # ls -l /dev/term/a lrwxrwxrwx 1 root root 32 Aug 17 17:42 /dev/term/a -> ../../devices/obio/zs@0,100000:a |
Example 18-1 shows how to obtain information about the /dev/ttya device from the devinfo structure and other kernel structures, beginning with devinfo_major.
Example 18-1 The devinfo_major Macro
Example 18-2 shows the use of the devinfo_brief macro. It also shows the use of top_devinfo. top_devinfo is a pointer to the root of the devinfo tree (rootnexus)--all other devinfo nodes are descendants of this node. If you want to look at the device tree top-down in the debugger, this is where you start.
Example 18-2 The devinfo_brief Macro
Thread Macros
threadlist is a useful macro that displays the stacks of all the threads in the system.
Example 18-3 The threadlist Macro