9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * CDDL HEADER START
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * The contents of this file are subject to the terms of the
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Common Development and Distribution License (the "License").
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * You may not use this file except in compliance with the License.
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * See the License for the specific language governing permissions
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * and limitations under the License.
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * When distributing Covered Code, include this CDDL HEADER in each
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * If applicable, add the following below this CDDL HEADER, with the
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * fields enclosed by brackets "[]" replaced with your own identifying
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * information: Portions Copyright [yyyy] [name of copyright owner]
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * CDDL HEADER END
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Use is subject to license terms.
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi#pragma ident "%Z%%M% %I% %E% SMI"
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * We use this to keep track of which bucket we're in while walking
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * the modhash and we also cache the length of the hash
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * This structure is used by the topo_nodehash walker instances to
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * keep track of where they're at in the node hash
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindistatic char *stab_lvls[] = {"Internal", "", "Private", "Obsolete", "External",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi/*ARGSUSED*/
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecinditopo_handle(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi char uuid[36], root[36], plat[36], isa[36], machine[36], product[36];
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Read in the structure and then read in all of the string fields from
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * the target's addr space
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&th, sizeof (th), addr) != sizeof (th)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(uuid, sizeof (uuid), (uintptr_t)th.th_uuid) < 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_snprintf(uuid, sizeof (uuid), "<%p>", th.th_uuid);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(root, sizeof (root), (uintptr_t)th.th_rootdir) < 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_snprintf(root, sizeof (root), "<%p>", th.th_rootdir);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(plat, sizeof (plat), (uintptr_t)th.th_platform) < 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(isa, sizeof (isa), (uintptr_t)th.th_isa) < 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_snprintf(isa, sizeof (isa), "<%p>", th.th_isa);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(machine, sizeof (machine), (uintptr_t)th.th_machine)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_snprintf(machine, sizeof (machine), "<%p>",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(product, sizeof (product), (uintptr_t)th.th_product)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_snprintf(product, sizeof (product), "<%p>",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Dump it all out in a nice pretty format and keep it to 80 chars wide
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%<u>%-12s %-36s %-30s%</u>\n", "FIELD", "VALUE",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "Mutex lock protecting handle");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "UUID of the topology snapshot");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "Root directory of plugin paths");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36s %-30s\n", "th_platform", plat, "Platform name");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36s %-30s\n", "th_isa", isa, "ISA name");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36s %-30s\n", "th_machine", machine,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "Machine name");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36s %-30s\n", "th_product", product,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "Product name");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "th_di", th.th_di,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "Handle to the root of the devinfo tree");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "th_pi", th.th_pi,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "Handle to the root of the PROM tree");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "th_modhash", th.th_modhash,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "Module hash");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "Scheme-specific topo tree list");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf(" %-12s 0x%-34p %-30s\n", "l_prev", th.th_trees.l_prev,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf(" %-12s 0x%-34p %-30s\n", "l_next", th.th_trees.l_next,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "th_alloc", th.th_alloc,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "Allocators");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36d %-30s\n", "tm_ernno", th.th_errno, "errno");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36d %-30s\n", "tm_debug", th.th_debug,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "Debug mask");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36d %-30s\n", "tm_dbout", th.th_dbout,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi "Debug channel");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi/*ARGSUSED*/
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecinditopo_module(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Read in the structure and then read in all of the string fields from
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * the target's addr space
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&tm, sizeof (tm), addr) != sizeof (tm)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(name, sizeof (name), (uintptr_t)tm.tm_name) < 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_snprintf(name, sizeof (name), "<%p>", tm.tm_name);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(path, sizeof (path), (uintptr_t)tm.tm_path) < 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_snprintf(path, sizeof (path), "<%p>", tm.tm_path);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(root, sizeof (root), (uintptr_t)tm.tm_rootdir) < 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_snprintf(root, sizeof (root), "<%p>", tm.tm_rootdir);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Dump it all out in a nice pretty format and keep it to 80 chars wide
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Module condition variable");
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj "Busy indicator");
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj "Busy indicator");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tm_next", tm.tm_next,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Next module in hash chain");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tm_hdl", tm.tm_hdl,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Topo handle for this module");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tm_alloc", tm.tm_alloc,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Allocators");
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Basename of module");
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Full pathname of module");
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Relative root directory of module");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36u %-30s\n", "tm_refs", tm.tm_refs,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Module reference count");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36u %-30s\n", "tm_flags", tm.tm_flags,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Module flags");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36s %-30s\n", "", "TOPO_MOD_INIT",
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Module init completed");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36s %-30s\n", "", "TOPO_MOD_FINI",
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Module fini completed");
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Module registered");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36s %-30s\n", "", "TOPO_MOD_UNREG",
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Module unregistered");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36u %-30s\n", "tm_debug", tm.tm_debug,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Debug printf mask");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tm_data", tm.tm_data,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Private rtld/builtin data");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tm_mops", tm.tm_mops,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Module class ops vector");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tm_info", tm.tm_info,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Module info registered with handle");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36d %-30s\n", "tm_ernno", tm.tm_errno,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Module errno");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi/*ARGSUSED*/
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecinditopo_node(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Read in the structure and then read in all of the string fields from
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * the target's addr space
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&tn, sizeof (tn), addr) != sizeof (tn)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(name, sizeof (name), (uintptr_t)tn.tn_name) < 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_snprintf(name, sizeof (name), "<%p>", tn.tn_name);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Dump it all out in a nice pretty format and keep it to 80 chars wide
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Lock protecting node members");
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Node name");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36d %-30s\n", "tn_instance", tn.tn_instance,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Node instance");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36d %-30s\n", "tn_state", tn.tn_state,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Node state");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36s %-30s\n", "", "TOPO_NODE_INIT", "");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36s %-30s\n", "", "TOPO_NODE_ROOT", "");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36s %-30s\n", "", "TOPO_NODE_BOUND", "");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36s %-30s\n", "", "TOPO_NODE_LINKED", "");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36d %-30s\n", "tn_fflags", tn.tn_fflags,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "FMRI flags");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tn_parent", tn.tn_parent,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Node parent");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tn_phash", tn.tn_phash,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Parent hash bucket");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tn_hdl", tn.tn_hdl,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Topo handle");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tn_enum", tn.tn_enum,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Enumerator module");
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Hash table of child nodes");
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock mdb_printf(" %-12s 0x%-34p\n", "l_prev", tn.tn_children.l_prev);
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock mdb_printf(" %-12s 0x%-34p\n", "l_next", tn.tn_children.l_next);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tn_pgroups", &(tn.tn_pgroups),
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Property group list");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tn_methods", &(tn.tn_methods),
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Registered method list");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s 0x%-34p %-30s\n", "tn_priv", tn.tn_priv,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Private enumerator data");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf("%-12s %-36d %-30s\n", "tn_refs", tn.tn_refs,
24db46411fd54f70c35b94bb952eb7ba040e43b4eschrock "Node reference count");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi/*ARGSUSED*/
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindifind_tree_root(uintptr_t addr, const void *data, void *arg)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(scheme, sizeof (scheme), (uintptr_t)tree->tt_scheme)
c40d7343efa60b18ad1ceb316eb337caeea79046cindi if (mdb_vread(&pm, sizeof (pm), addr) != sizeof (pm)) {
c40d7343efa60b18ad1ceb316eb337caeea79046cindi mdb_warn("failed to read topo_propmethod at %p", addr);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj if (mdb_readstr(mname, sizeof (mname), (uintptr_t)pm.tpm_name) < 0) {
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj (void) mdb_snprintf(mname, sizeof (mname), "<%p>", pm.tpm_name);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Dump the given property value. For the actual property values
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * we dump a pointer to the nvlist which can be decoded using the ::nvlist
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * dcmd from the libnvpair MDB module
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi/*ARGSUSED*/
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindidump_propval(uintptr_t addr, const void *data, void *arg)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&pval, sizeof (pval), (uintptr_t)plistp->tp_pval)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi != sizeof (pval)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(name, sizeof (name), (uintptr_t)pval.tp_name) < 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_snprintf(name, sizeof (name), "<%p>", pval.tp_name);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi case TOPO_TYPE_UINT32_ARRAY: type = "uint32[]"; break;
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi case TOPO_TYPE_UINT64_ARRAY: type = "uint64[]"; break;
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi case TOPO_TYPE_STRING_ARRAY: type = "string[]"; break;
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf(" %-32s %-16s value: %p\n", name, type, pval.tp_val);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Dumps the contents of the property group.
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi/*ARGSUSED*/
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindidump_pgroup(uintptr_t addr, const void *data, void *arg)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&ipg, sizeof (ipg), (uintptr_t)pgp->tpg_info)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi != sizeof (ipg)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(buf, sizeof (buf), (uintptr_t)ipg.tpi_name) < 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read string at %p", ipg.tpi_name);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * If this property group is the one we're interested in or if the user
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * specified the "all" property group, we'll dump it
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_printf(" group: %-32s version: %d, stability: %s/%s\n",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_pwalk("topo_proplist", dump_propval, NULL, curr_pg);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Recursive function to dump the specified node and all of it's children
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi/*ARGSUSED*/
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindidump_tnode(uintptr_t addr, const void *data, void *arg)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&node, sizeof (node), addr) != sizeof (node)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(buf, sizeof (buf), (uintptr_t)node.tn_name) < 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_snprintf(old_pname, sizeof (old_pname), "%s", parent);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_pwalk("topo_pgroup", dump_pgroup, NULL, addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_pwalk("topo_nodehash", dump_tnode, NULL, addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_snprintf(parent, sizeof (parent), "%s", old_pname);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Given a topo_hdl_t *, the topo dcmd dumps the topo tree. The format of the
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * output is modeled after fmtopo. Like fmtopo, by default, we'll dump the
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * "hc" scheme tree. The user can optionally specify a different tree via the
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * "-s <scheme>" option.
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Specifying the "-v" option provides more verbose output. Currently it
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * outputs the tnode_t * addr for each node, which is useful if you want to
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * dump it with the topo_node dcmd.
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * The functionality of the "-P" option is similar to fmtopo.
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi/*ARGSUSED*/
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindifmtopo(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &opt_v,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi 's', MDB_OPT_STR, &opt_s, 'P', MDB_OPT_STR, &opt_P, NULL)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Read in the topo_handle and some of its string fields from
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * the target's addr space
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&th, sizeof (th), addr) != sizeof (th)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_readstr(product, sizeof (product), (uintptr_t)th.th_product)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (void) mdb_snprintf(product, sizeof (product), "<%p>",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * Walk the list of topo trees, looking for the one that is for the
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * scheme we're interested in.
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_pwalk("topo_tree", find_tree_root, &tree_root, addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to find a topo tree for scheme %s\n",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi return (dump_tnode((uintptr_t)tree_root, NULL, NULL));
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&th, sizeof (th), wsp->walk_addr) != sizeof (th)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read topo_hdl_t at %p", wsp->walk_addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi wsp->walk_data = mdb_alloc(sizeof (ttree_t), UM_SLEEP);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(wsp->walk_data, sizeof (ttree_t), wsp->walk_addr)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi != sizeof (ttree_t)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read ttree_t at %p", wsp->walk_addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi rv = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&th, sizeof (th), wsp->walk_addr) != sizeof (th)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read topo_hdl_t at %p", wsp->walk_addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&tmh, sizeof (topo_modhash_t), (uintptr_t)th.th_modhash)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read topo_modhash_t at %p", wsp->walk_addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&(wsp->walk_addr), sizeof (uintptr_t *),
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read %u bytes at %p", sizeof (tnode_t *),
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi wsp->walk_data = mdb_alloc(sizeof (topo_mod_t), UM_SLEEP);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(wsp->walk_data, sizeof (topo_mod_t), wsp->walk_addr)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read topo_mod_t at %p", wsp->walk_addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi rv = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&(wsp->walk_addr), sizeof (uintptr_t *),
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (uintptr_t)(tmh.mh_hash+hash_idx)) != sizeof (tnode_t *)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&node, sizeof (node), wsp->walk_addr) != sizeof (node)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read tnode_t at %p", wsp->walk_addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi wsp->walk_data = mdb_alloc(sizeof (topo_pgroup_t), UM_SLEEP);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(wsp->walk_data, sizeof (topo_pgroup_t), wsp->walk_addr)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read topo_pgroup_t at %p", wsp->walk_addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi rv = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&pg, sizeof (pg), wsp->walk_addr) != sizeof (pg)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read topo_pgroup_t at %p", wsp->walk_addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi wsp->walk_data = mdb_alloc(sizeof (topo_proplist_t), UM_SLEEP);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(wsp->walk_data, sizeof (topo_proplist_t), wsp->walk_addr)
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi rv = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&node, sizeof (node), wsp->walk_addr) != sizeof (node)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read tnode_t at %p", wsp->walk_addr);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi state = mdb_zalloc(sizeof (tnwalk_state_t), UM_SLEEP);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi state->curr_hash = (topo_nodehash_t *)node.tn_children.l_next;
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if (mdb_vread(&(state->hash), sizeof (topo_nodehash_t),
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (uintptr_t)state->curr_hash) != sizeof (topo_nodehash_t)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi (uintptr_t)(state->hash.th_nodearr+i)) != sizeof (tnode_t *)) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi mdb_warn("failed to read %u bytes at %p", sizeof (tnode_t *),
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi rv = wsp->walk_callback(wsp->walk_addr, state, wsp->walk_cbdata);
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * move on to the next child hash bucket
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi { "topo_handle", "", "print contents of a topo handle", topo_handle,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi { "topo_module", "", "print contents of a topo module handle",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi { "topo_node", "", "print contents of a topo node", topo_node, NULL },
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi { "topo_tree", "walk the tree list for a given topo handle",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi ttree_walk_init, ttree_walk_step, ttree_walk_fini, NULL },
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi { "topo_module", "walk the module hash for a given topo handle",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi tmod_walk_init, tmod_walk_step, tmod_walk_fini, NULL },
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi { "topo_pgroup", "walk the property groups for a given topo node",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi { "topo_proplist", "walk the property list for a given property group",
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi { "topo_nodehash", "walk the child nodehash for a given topo node",