Exemplo n.º 1
0
/* ARGSUSED */
static int
xhci_mdb_print_device(uintptr_t addr, uint_t flags, int argc,
    const mdb_arg_t *argv)
{
	int count;
	xhci_device_t xd;
	usba_device_t ud;
	char product[256], mfg[256];

	if (!(flags & DCMD_ADDRSPEC)) {
		return (mdb_eval("::walk xhci`xhci | ::walk xhci`xhci_device | "
		    "::xhci_device"));
	}

	if (mdb_vread(&xd, sizeof (xd), addr) != sizeof (xd)) {
		mdb_warn("failed to read xhci_device_t at 0x%x", addr);
		return (DCMD_ERR);
	}

	if (mdb_vread(&ud, sizeof (ud), (uintptr_t)xd.xd_usbdev) !=
	    sizeof (ud)) {
		mdb_warn("failed to read usba_device_t at %p\n", xd.xd_usbdev);
		return (DCMD_ERR);
	}

	if (ud.usb_mfg_str == NULL || mdb_readstr(mfg, sizeof (mfg),
	    (uintptr_t)ud.usb_mfg_str) <= 0) {
		(void) strlcpy(mfg, "Unknown Manufacturer", sizeof (mfg));
	}

	if (ud.usb_product_str == NULL || mdb_readstr(product, sizeof (product),
	    (uintptr_t)ud.usb_product_str) <= 0) {
		(void) strlcpy(product, "Unknown Product", sizeof (product));
	}

	mdb_printf("%<b>%s - %s%</b>\n", mfg, product);

	count = 0;
	if (mdb_pwalk("xhci`xhci_endpoint", xhci_mdb_endpoint_count, &count,
	    addr) == -1) {
		mdb_warn("failed to walk xhci_endpoint rooted at 0x%x", addr);
		return (DCMD_ERR);
	}

	mdb_printf("Port %02d | Slot %02d | # Endpoints %02d\n", xd.xd_port,
	    xd.xd_slot, count);
	mdb_printf("%<u>%-4s %-10s %-10s %-6s %-6s%</u>\n", "EP", "Type",
	    "State", "Head", "Tail");

	if (mdb_pwalk("xhci`xhci_endpoint", xhci_mdb_print_endpoint_summary,
	    &xd, addr) == -1) {
		mdb_warn("failed to walk xhci_endpoint rooted at 0x%x", addr);
		return (DCMD_ERR);
	}


	mdb_printf("\n");

	return (DCMD_OK);
}
Exemplo n.º 2
0
int
mi_payload_walk_step(mdb_walk_state_t *wsp)
{
	const mi_payload_walk_arg_t *arg = wsp->walk_arg;
	uintptr_t kaddr;

	kaddr = wsp->walk_addr + arg->mi_pwa_head_off;

	if (mdb_vread(&kaddr, sizeof (kaddr), kaddr) == -1) {
		mdb_warn("can't read address of mi head at %p for %s",
		    kaddr, arg->mi_pwa_walker);
		return (WALK_ERR);
	}

	if (kaddr == 0) {
		/* Empty list */
		return (WALK_DONE);
	}

	if (mdb_pwalk("genunix`mi", wsp->walk_callback,
	    wsp->walk_cbdata, kaddr) == -1) {
		mdb_warn("failed to walk genunix`mi");
		return (WALK_ERR);
	}
	return (WALK_NEXT);
}
Exemplo n.º 3
0
int
hotplug(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
	devinfo_cb_data_t data;
	uintptr_t devinfo_root;		/* Address of root of devinfo tree */
	ddi_hp_cn_handle_t	hdl;
	char			cn_type[15];
	char			cn_name[15];
	int status;

	data.di_flags = 0;
	if (mdb_getopts(argc, argv,
	    'p', MDB_OPT_SETBITS, DEVINFO_HP_PHYSICAL, &data.di_flags, NULL)
	    != argc)
		return (DCMD_USAGE);

	if (DCMD_HDRSPEC(flags)) {
		mdb_printf("%<u>%?s %?s %-12s %-15s %-15s%</u>\n",
		    "PARENT_DEVINFO", "HANDLE", "STATE", "TYPE", "CN_NAME");
	}

	if ((flags & DCMD_ADDRSPEC) == 0) {
		data.di_flags |= DEVINFO_PARENT | DEVINFO_CHILD;

		if (mdb_readvar(&devinfo_root, "top_devinfo") == -1) {
			mdb_warn("failed to read 'top_devinfo'");
			return (NULL);
		}

		data.di_base = devinfo_root;
		status = mdb_pwalk("devinfo", (mdb_walk_cb_t)hotplug_print,
		    &data, devinfo_root);
		if (status == -1) {
			mdb_warn("couldn't walk devinfo tree");
			return (DCMD_ERR);
		}
		return (DCMD_OK);
	}

	if (mdb_vread(&hdl, sizeof (ddi_hp_cn_handle_t), (uintptr_t)addr)
	    == -1) {
		mdb_warn("Failed to read hdlp!\n");
		return (DCMD_ERR);
	}
	if (mdb_readstr(cn_type, sizeof (cn_type),
	    (uintptr_t)hdl.cn_info.cn_type_str) == -1) {
		mdb_warn("Failed to read cn_type!\n");
		return (DCMD_ERR);
	}
	if (mdb_readstr(cn_name, sizeof (cn_name),
	    (uintptr_t)hdl.cn_info.cn_name) == -1) {
		mdb_warn("Failed to read cn_name!\n");
		return (DCMD_ERR);
	}
	mdb_printf("%?p %?p %-12s %-15s %-15s\n", hdl.cn_dip, addr,
	    ddihp_get_cn_state(hdl.cn_info.cn_state), cn_type, cn_name);

	return (DCMD_OK);
}
Exemplo n.º 4
0
int
pfiles(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
	int opt_f = 0;

	struct pfiles_cbdata cb;

	bzero(&cb, sizeof (cb));

	if (!(flags & DCMD_ADDRSPEC))
		return (DCMD_USAGE);

	if (mdb_getopts(argc, argv,
	    'p', MDB_OPT_SETBITS, TRUE, &cb.opt_p,
	    'f', MDB_OPT_SETBITS, TRUE, &opt_f, NULL) != argc)
		return (DCMD_USAGE);

	if (opt_f) {
		mdb_printf("%<u>%?s %4s %8s %?s %10s %?s %4s%</u>\n", "FILE",
		    "FD", "FLAG", "VNODE", "OFFSET", "CRED", "CNT");
		if (mdb_pwalk("allfile", (mdb_walk_cb_t)file_t_callback, &cb,
		    addr) == -1) {
			mdb_warn("failed to walk 'allfile'");
			return (DCMD_ERR);
		}
	} else {
		mdb_printf("%<u>%-4s %4s %?s ", "FD", "TYPE", "VNODE");
		if (cb.opt_p)
			mdb_printf("PATH");
		else
			mdb_printf("INFO");
		mdb_printf("%</u>\n");

		if (mdb_pwalk("allfile", (mdb_walk_cb_t)pfile_callback, &cb,
		    addr) == -1) {
			mdb_warn("failed to walk 'allfile'");
			return (DCMD_ERR);
		}
	}


	return (DCMD_OK);
}
Exemplo n.º 5
0
int
rctl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
	rctl_t rctl;
	rctl_dict_entry_t dict;
	char name[256];
	rctl_hndl_t hndl;

	if (!(flags & DCMD_ADDRSPEC))
		return (DCMD_USAGE);

	if (mdb_vread(&rctl, sizeof (rctl_t), addr) == -1) {
		mdb_warn("failed to read rctl_t structure at %p", addr);
		return (DCMD_ERR);
	}

	if (argc != 0) {
		const mdb_arg_t *argp = &argv[0];

		if (argp->a_type == MDB_TYPE_IMMEDIATE)
			hndl = (rctl_hndl_t)argp->a_un.a_val;
		else
			hndl = (rctl_hndl_t)mdb_strtoull(argp->a_un.a_str);

		if (rctl.rc_id != hndl)
			return (DCMD_OK);
	}

	if (mdb_vread(&dict, sizeof (rctl_dict_entry_t),
	    (uintptr_t)rctl.rc_dict_entry) == -1) {
		mdb_warn("failed to read dict entry for rctl_t %p at %p",
		    addr, rctl.rc_dict_entry);
		return (DCMD_ERR);
	}

	if (mdb_readstr(name, 256, (uintptr_t)(dict.rcd_name)) == -1) {
		mdb_warn("failed to read name for rctl_t %p", addr);
		return (DCMD_ERR);
	}

	mdb_printf("%0?p\t%3d : %s\n", addr, rctl.rc_id, name);

	if (mdb_pwalk("rctl_val", (mdb_walk_cb_t)print_val, &(rctl.rc_cursor),
	    addr) == -1) {
		mdb_warn("failed to walk all values for rctl_t %p", addr);
		return (DCMD_ERR);
	}

	return (DCMD_OK);
}
Exemplo n.º 6
0
/*ARGSUSED*/
static int
python_thread(uintptr_t addr, const PyInterpreterState *is, uint_t *verbose)
{
	/*
	 * Pass the InterpreterState to the threadstate walker.
	 */
	if (mdb_pwalk("pythread", (mdb_walk_cb_t)python_stack, verbose,
	    addr) == -1) {
		mdb_warn("can't walk 'pythread'");
		return (WALK_ERR);
	}

	return (WALK_NEXT);
}
Exemplo n.º 7
0
/*ARGSUSED*/
int
cyctrace(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
	if (!(flags & DCMD_ADDRSPEC) || argc != 0)
		addr = NULL;

	if (mdb_pwalk("cyctrace", (mdb_walk_cb_t)cyctrace_walk,
	    (void *)addr, addr) == -1) {
		mdb_warn("couldn't walk cyctrace");
		return (DCMD_ERR);
	}

	return (DCMD_OK);
}
Exemplo n.º 8
0
/*ARGSUSED*/
int
cycid(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av)
{
	cyc_id_t id;

	if (!(flags & DCMD_ADDRSPEC)) {
		if (mdb_walk_dcmd("cyclic_id_cache", "cycid", ac, av) == -1) {
			mdb_warn("can't walk cyclic_id_cache");
			return (DCMD_ERR);
		}

		return (DCMD_OK);
	}

	if (DCMD_HDRSPEC(flags)) {
		mdb_printf("%?s %4s %3s %?s %s\n", "ADDR", "CPU", "NDX",
		    "CYCLIC", "HANDLER");
	}

	if (mdb_vread(&id, sizeof (id), addr) == -1) {
		mdb_warn("couldn't read cyc_id_t at %p", addr);
		return (DCMD_ERR);
	}

	if (id.cyi_cpu == NULL) {
		/*
		 * This is an omnipresent cyclic.
		 */
		mdb_printf("%?p %4s %3s %?s %a\n", addr, "omni", "-", "-",
		    id.cyi_omni_hdlr.cyo_online);
		mdb_printf("%?s    |\n", "");
		mdb_printf("%?s    +-->%4s %3s %?s %s\n", "",
		    "CPU", "NDX", "CYCLIC", "HANDLER");

		if (mdb_pwalk("cycomni",
		    (mdb_walk_cb_t)cycid_walk_omni, NULL, addr) == -1) {
			mdb_warn("couldn't walk cycomni for %p", addr);
			return (DCMD_ERR);
		}

		mdb_printf("\n");

		return (DCMD_OK);
	}

	mdb_printf("%?p ", addr);

	return (cycid_cpu(id.cyi_cpu, id.cyi_ndx));
}
Exemplo n.º 9
0
static int
xhci_mdb_find(uintptr_t addr, uint_t flags, int argc,
    const mdb_arg_t *argv)
{
	uintptr_t ep, slot;
	boolean_t ep_set, slot_set;
	xhci_mdb_find_t xmf;

	if ((flags & DCMD_ADDRSPEC) == 0)
		return (DCMD_USAGE);

	ep_set = slot_set = B_FALSE;
	if (mdb_getopts(argc, argv, 'e', MDB_OPT_UINTPTR_SET, &ep_set, &ep,
	    's', MDB_OPT_UINTPTR_SET, &slot_set, &slot) != argc)
		return (DCMD_USAGE);

	if (!slot_set) {
		mdb_warn("-s is required\n");
		return (DCMD_USAGE);
	}

	xmf.xmf_slot = (int)slot;
	if (ep_set)
		xmf.xmf_ep = (int)ep;
	else
		xmf.xmf_ep = -1;
	xmf.xmf_addr = 0;

	if (mdb_pwalk("xhci`xhci_device", xhci_mdb_find_device_cb,
	    &xmf, addr) == -1) {
		mdb_warn("failed to walk xhci_device at %p", addr);
		return (DCMD_ERR);
	}

	if (xmf.xmf_addr == 0) {
		if (ep_set) {
			mdb_warn("failed to find xhci_endpoint_t for slot %d "
			    "and endpoint %d\n", slot, ep);
		} else {
			mdb_warn("failed to find xhci_device_t for slot %d\n",
			    slot);
		}
		return (DCMD_ERR);
	}

	mdb_printf("%p\n", xmf.xmf_addr);
	return (DCMD_OK);
}
Exemplo n.º 10
0
/*ARGSUSED3*/
int
dev2snode(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
	snode_cbdata_t sd;

	if (!(flags & DCMD_ADDRSPEC) || argc != 0)
		return (DCMD_USAGE);

	sd.sd_major = getmajor(addr);
	sd.sd_minor = getminor(addr);
	sd.sd_verbose = 0;

	if (mdb_pwalk("snode", (mdb_walk_cb_t)snode_cb, &sd, 0) != 0)
		return (DCMD_ERR);

	return (DCMD_OK);
}
Exemplo n.º 11
0
/*
 * Figure out which instance of uhci owns a td/qh.
 *
 * - td_qh: a pointer to a uhci td or qh
 * - td_or_qh: a flag indicating which it is (td/qh),
 * - uhci_statep, pointer to a uhci_state_t, to be filled in with data from
 * the found instance of uhci_state_t.
 *
 * Only works for Cntl/Interrupt tds/qhs; others are dynamically allocated
 * and so cannot be found with this method.
 *
 * Returns 0 on success (no match found), 1 on success (match found),
 * -1 on errors.
 */
static int
find_uhci_statep(void *td_qh, boolean_t td_or_qh, uhci_state_t *uhci_statep)
{
	find_instance_cb_t	cb_data;
	uintptr_t		uhci_ss;


	if (uhci_statep == NULL) {
		mdb_warn("failed to find uhci statep: "
		    "NULL uhci_statep param\n");
		return (-1);
	}

	cb_data.fic_td_qh = td_qh;
	cb_data.fic_td_or_qh = td_or_qh;
	cb_data.fic_found = FALSE;
	cb_data.fic_uhci_statep = uhci_statep;


	if (mdb_readsym(&uhci_ss, sizeof (uhci_statep),
	    "uhci_statep") == -1) {
		mdb_warn("failed to read uhci_statep");
		return (-1);
	}


	/*
	 * Walk all instances of uhci.
	 * The callback func checks if td_qh belongs to a given instance
	 * of uhci.
	 */
	if (mdb_pwalk("softstate", find_uhci_instance, &cb_data,
	    uhci_ss) != 0) {
		mdb_warn("failed to walk softstate");
		return (-1);
	}

	if (cb_data.fic_found == TRUE) {
		return (1);
	}

	return (0);
}
Exemplo n.º 12
0
/*
 * Given a usba_device pointer, figure out which dip is associated with it.
 * Relies on usba_device.usb_root_hub_dip being accurate.
 *
 * - usb_dev_addr is a pointer to a usba_device_t in core.
 * - dip_addr is the address of a uintptr_t to receive the address in core
 * of the found dip (if any).
 *
 * Returns:
 *  0 on success (no match found)
 *  1 on success (match found)
 * -1 on errors.
 */
static int
usba_device2dip(uintptr_t usb_dev_addr, uintptr_t *dip_addr)
{
	usba_device_t			usb_dev;
	usba_device2devinfo_cbdata_t	cb_data;

	/*
	 * Walk all USB children of the root hub devinfo.
	 * The callback func looks for a match on the usba_device address.
	 */
	cb_data.u2d_target_usb_dev_p = usb_dev_addr;
	cb_data.u2d_dip_addr = dip_addr;
	cb_data.u2d_found = FALSE;

	if (mdb_vread(&usb_dev, sizeof (usba_device_t),
	    usb_dev_addr) == -1) {
		mdb_warn("failed to read usba_device struct");

		return (-1);
	}

	/*
	 * Walk devinfo children starting with the root hub node,
	 * looking for a match on the usba_device pointer (which is what
	 * find_dip does).
	 * Result is placed in cb_data.dip_addr.
	 */
	if (mdb_pwalk("devinfo_children", find_dip, &cb_data,
	    (uintptr_t)usb_dev.usb_root_hub_dip) != 0) {
		mdb_warn("failed to walk devinfo_children");

		return (-1);
	}

	if (cb_data.u2d_found == TRUE) {

		return (1);
	}

	return (0);
}
Exemplo n.º 13
0
/*ARGSUSED*/
static int
umastat_lwp_cache(uintptr_t addr, const umem_cache_t *cp, ulwp_t *ulwp)
{
	char walk[60];
	int nbufs = 0;

	if (!(cp->cache_flags & UMF_PTC))
		return (WALK_NEXT);

	(void) snprintf(walk, sizeof (walk), "umem_ptc_%d", cp->cache_bufsize);

	if (mdb_pwalk(walk, (mdb_walk_cb_t)umastat_lwp_ptc,
	    &nbufs, (uintptr_t)ulwp->ul_self) == -1) {
		mdb_warn("unable to walk '%s'", walk);
		return (WALK_ERR);
	}

	mdb_printf("%3d ", ulwp->ul_tmem.tm_size ?
	    (nbufs * cp->cache_bufsize * 100) / ulwp->ul_tmem.tm_size : 0);

	return (WALK_NEXT);
}
Exemplo n.º 14
0
static int
stmf_sbd_it(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
    uint_t		verbose = FALSE;
    sbd_lu_t	slu;
    stmf_sbd_cb_t	cb_st = {0};

    if (!(flags & DCMD_ADDRSPEC))
        return (DCMD_USAGE);

    if (mdb_getopts(argc, argv,
                    'v', MDB_OPT_SETBITS, TRUE, &verbose, NULL) != argc)
        return (DCMD_USAGE);

    if (verbose) {
        cb_st.flag |= STMF_SBD_VERBOSE;
        mdb_printf("\nLU:- %p\n", addr);
    }

    /* If address of pgr_key is given, just print that key and return */
    if (mdb_vread(&slu, sizeof (sbd_lu_t), addr) == -1) {
        mdb_warn("failed to read sbd_lu at %p\n", addr);
        return (DCMD_ERR);
    }

    /* Just a sanity check, not necessarily needed */
    if (slu.sl_it_list == NULL) {
        if (verbose)
            mdb_printf("sbd_it_list is empty\n", addr);
        return (DCMD_OK);
    }

    if (mdb_pwalk("stmf_sbd_it", (mdb_walk_cb_t)stmf_sbd_it_cb, &cb_st,
                  (uintptr_t)slu.sl_it_list) == -1) {
        mdb_warn("failed to walk sbd_lu_it_list\n");
        return (DCMD_ERR);
    }
    return (DCMD_OK);
}
Exemplo n.º 15
0
/*ARGSUSED*/
static int
mod(
	uintptr_t	addr,
	uint_t		flags,
	int		argc,
	const mdb_arg_t	*argv)
{
	int		status;
	int		rc = DCMD_OK;
	mfdata_t	*mfp;

	mfp = mdb_zalloc(sizeof (mfdata_t), UM_SLEEP);

	if (mdb_getopts(argc, argv,
	    'v', MDB_OPT_SETBITS, MF_VERBOSE, &mfp->mf_flags,
	    NULL) != argc)
		return (DCMD_USAGE);

	if ((flags & DCMD_LOOPFIRST) || !(flags & DCMD_LOOP))
		mfp->mf_banner = B_TRUE;

	if (flags & DCMD_ADDRSPEC) {
		status = mod_format(addr, NULL, mfp);
		rc = (status == WALK_NEXT) ? DCMD_OK : DCMD_ERR;
		goto cleanup;
	}

	if (mdb_pwalk("ipp_byid", mod_format, mfp,
	    ipp_mod_byid) == -1) {
		mdb_warn("failed to execute ipp_byid walk");
		rc = DCMD_ERR;
	}

cleanup:
	mdb_free(mfp, sizeof (mfdata_t));

	return (rc);
}
Exemplo n.º 16
0
static int
xhci_mdb_find_device_cb(uintptr_t addr, const void *data, void *arg)
{
	const xhci_device_t *xd = data;
	xhci_mdb_find_t *xmf = arg;

	if (xd->xd_slot == xmf->xmf_slot) {
		if (xmf->xmf_ep == -1) {
			xmf->xmf_addr = addr;
			return (WALK_DONE);
		}

		if (mdb_pwalk("xhci`xhci_endpoint", xhci_mdb_find_endpoint_cb,
		    xmf, addr) == -1) {
			mdb_warn("failed to walk xhci_endpoint at %p", addr);
			return (WALK_ERR);
		}

		return (WALK_DONE);
	}

	return (WALK_NEXT);
}
Exemplo n.º 17
0
/* ARGSUSED */
int
pattbl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
    mmd_data_t data;
    uint_t pattbl_sz;
    int i, j;

    bzero(&data, sizeof (data));
    if (!(flags & DCMD_ADDRSPEC) || argc != 0)
        return (DCMD_USAGE);

    /* Figure out the size of hash table */
    mdb_readvar(&pattbl_sz, "pattbl_sz");

    mdb_printf("\n");
    mdb_printf("%<b>%<u>%-3s %-16s %-16s %-12s %-3s %-16s %-5s%</u>%</b>\n",
               "BKT", "PATBKT ADDR", "PATTR ADDR", "TYPE", "LEN", "BUF ADDR",
               "FLAGS");

    /* Walk each bucket and print its contents */
    for (i = 0, j = 0; i < (pattbl_sz * sizeof (patbkt_t));
            i += sizeof (patbkt_t)) {

        mdb_printf("%-3d %016p ", j++, addr + i);

        if (mdb_pwalk("pattr", (mdb_walk_cb_t)pattr_print, &data,
                      addr + i + offsetof(patbkt_t, pbkt_pattr_q)) == -1) {
            mdb_warn("couldn't walk pattr_t list");
            return (DCMD_ERR);
        }
        mdb_printf("\n");
    }
    mdb_printf("\n");

    return (DCMD_OK);
}
Exemplo n.º 18
0
static int
fmd_xprt(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
	uint_t opt_s = FALSE, opt_l = FALSE, opt_r = FALSE, opt_u = FALSE;
	fmd_xprt_impl_t xi;

	if (mdb_getopts(argc, argv,
	    'l', MDB_OPT_SETBITS, TRUE, &opt_l,
	    'r', MDB_OPT_SETBITS, TRUE, &opt_r,
	    's', MDB_OPT_SETBITS, TRUE, &opt_s,
	    'u', MDB_OPT_SETBITS, TRUE, &opt_u, NULL) != argc)
		return (DCMD_USAGE);

	if (!(flags & DCMD_ADDRSPEC)) {
		if (mdb_walk_dcmd("fmd_xprt", "fmd_xprt", argc, argv) != 0) {
			mdb_warn("failed to walk fmd_xprt");
			return (DCMD_ERR);
		}
		return (DCMD_OK);
	}

	if (mdb_vread(&xi, sizeof (xi), addr) != sizeof (xi)) {
		mdb_warn("failed to read fmd_xprt at %p", addr);
		return (DCMD_ERR);
	}

	if (DCMD_HDRSPEC(flags)) {
		mdb_printf("%<u>%-8s %-4s %-4s %-5s %s%</u>\n",
		    "ADDR", "ID", "VERS", "FLAGS", "STATE");
	}

	mdb_printf("%-8p %-4d %-4u %-5x %a\n",
	    addr, xi.xi_id, xi.xi_version, xi.xi_flags, xi.xi_state);

	if (opt_l | opt_s) {
		(void) mdb_inc_indent(4);
		mdb_printf("Local subscriptions requested by peer:\n");
		mdb_printf("%<u>%-8s %-4s %s%</u>\n", "ADDR", "REFS", "CLASS");
		(void) mdb_pwalk("fmd_xprt_class", fmd_xprt_class, &xi,
		    addr + OFFSETOF(fmd_xprt_impl_t, xi_lsub));
		(void) mdb_dec_indent(4);
	}

	if (opt_r | opt_s) {
		(void) mdb_inc_indent(4);
		mdb_printf("Remote subscriptions requested of peer:\n");
		mdb_printf("%<u>%-8s %-4s %s%</u>\n", "ADDR", "REFS", "CLASS");
		(void) mdb_pwalk("fmd_xprt_class", fmd_xprt_class, &xi,
		    addr + OFFSETOF(fmd_xprt_impl_t, xi_rsub));
		(void) mdb_dec_indent(4);
	}

	if (opt_u | opt_s) {
		(void) mdb_inc_indent(4);
		mdb_printf("Pending unsubscription acknowledgements:\n");
		mdb_printf("%<u>%-8s %-4s %s%</u>\n", "ADDR", "REFS", "CLASS");
		(void) mdb_pwalk("fmd_xprt_class", fmd_xprt_class, &xi,
		    addr + OFFSETOF(fmd_xprt_impl_t, xi_usub));
		(void) mdb_dec_indent(4);
	}

	return (DCMD_OK);
}
Exemplo n.º 19
0
static int
stmf_sbd_pgr_key(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
    uint_t		verbose = FALSE, keyonly = FALSE, pgrkeyaddr = FALSE;
    sbd_lu_t	slu;
    sbd_pgr_t	pgr;
    sbd_pgr_key_t	key;
    stmf_sbd_cb_t	cb_st = {0};

    if (!(flags & DCMD_ADDRSPEC))
        return (DCMD_USAGE);

    if (mdb_getopts(argc, argv,
                    'a', MDB_OPT_SETBITS, TRUE, &pgrkeyaddr,
                    'k', MDB_OPT_SETBITS, TRUE, &keyonly,
                    'v', MDB_OPT_SETBITS, TRUE, &verbose, NULL) != argc)
        return (DCMD_USAGE);

    if (pgrkeyaddr || verbose)
        cb_st.flag |= STMF_SBD_VERBOSE;

    /* If address of pgr_key is given, just print that key and return */
    if (pgrkeyaddr) {
        if (mdb_vread(&key, sizeof (sbd_pgr_key_t), addr) == -1) {
            mdb_warn("failed to read sbd_pgr_key at %p\n", addr);
            return (DCMD_ERR);
        }
        if (stmf_sbd_pgr_key_cb(addr, &key, &cb_st) == WALK_ERR) {
            return (DCMD_ERR);
        }
        return (DCMD_OK);
    } else {
        if (mdb_vread(&slu, sizeof (sbd_lu_t), addr) == -1) {
            mdb_warn("failed to read sbd_lu at %p\n", addr);
            return (DCMD_ERR);
        }
    }

    if (verbose) {
        mdb_printf("\nLU:- %p\n", addr);
    }
    /* Just a sanity check, not necessarily needed */
    if (slu.sl_pgr == NULL) {
        if (verbose)
            mdb_warn("pgr structure not found for lun %p\n", addr);
        return (DCMD_OK);
    }

    if (mdb_vread(&pgr, sizeof (sbd_pgr_t), (uintptr_t)slu.sl_pgr) == -1) {
        mdb_warn("failed to read sbd_lu at %p\n", slu.sl_pgr);
        return (DCMD_ERR);
    }

    if (!keyonly)
        stmf_sbd_print_pgr_info(&pgr);

    if (pgr.pgr_keylist == NULL) {
        if (verbose)
            mdb_printf("No registered pgr keys found\n");
        return (DCMD_OK);
    } else {
        if (!keyonly)
            mdb_printf("\nKeys\n");
    }

    if (mdb_pwalk("stmf_sbd_pgr_key", (mdb_walk_cb_t)stmf_sbd_pgr_key_cb,
                  &cb_st, (uintptr_t)pgr.pgr_keylist) == -1) {
        mdb_warn("failed to walk pgr_keylist\n");
        return (DCMD_ERR);
    }
    return (DCMD_OK);
}
Exemplo n.º 20
0
/*
 * Print additional Multidata statistics
 */
static int
multidata_stats(uintptr_t addr, multidata_t *mmd)
{
    mblk_t mp;
    uint_t i = 0, j = 0, k = 0, sz = 0;
    mmd_data_t data;
    uintptr_t patbkt;

    bzero(&data, sizeof (data));

    if (mmd->mmd_hbuf != 0) {
        if (mdb_vread(&mp, sizeof (mp),
                      (uintptr_t)mmd->mmd_hbuf) == -1) {
            mdb_warn("couldn't read mblk_t at %p", mmd->mmd_hbuf);
            return (DCMD_ERR);
        }

        i++;
        sz = MBLKL(&mp);
    }

    k += sz;	/* total bytes */
    j += i;		/* total buffers */

    mdb_printf("%<b>%<u>BUFFER STATS%</b>%</u>\n");
    mdb_printf("Header:\t\t\t%-4d% buffer,\t%-12d bytes\n", i, sz);

    for (i = 0, sz = 0; i < mmd->mmd_pbuf_cnt; i++) {
        if (mdb_vread(&mp, sizeof (mp),
                      (uintptr_t)mmd->mmd_pbuf[i]) == -1) {
            mdb_warn("couldn't read mblk_t at %p",
                     mmd->mmd_pbuf[i]);
            return (DCMD_ERR);
        }
        sz += MBLKL(&mp);
    }

    k += sz;	/* total bytes */
    j += i;		/* total buffers */

    mdb_printf("%<u>Payload:\t\t%-4d buffers,\t%-12d bytes%</u>\n", i, sz);
    mdb_printf("Total:\t\t\t%-4d buffers,\t%-12d bytes\n\n", j, k);

    mdb_printf("%<b>%<u>PACKET DESCRIPTOR STATS%</u>%</b>\n");

    /*
     * Total claimed packet descriptors
     */
    data.flags = 0;
    data.counter = 0;
    if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data,
                  (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) {
        mdb_warn("couldn't walk pdesc_t list");
        return (DCMD_ERR);
    }
    i = data.counter;	/* claimed */
    mdb_printf("Total claimed:\t\t%-4d", i);

    /*
     * Total active header references
     */
    data.flags = (PD_HDR | PD_REM_NOCNT);
    data.counter = 0;
    if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data,
                  (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) {
        mdb_warn("couldn't walk pdesc_t list");
        return (DCMD_ERR);
    }
    mdb_printf("\tActive header refs:\t%-12d bytes\n", data.counter);

    /*
     * Total active packet descriptors
     */
    data.flags = PD_REM_NOCNT;
    data.counter = 0;
    if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data,
                  (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) {
        mdb_warn("couldn't walk pdesc_t list");
        return (DCMD_ERR);
    }
    k = data.counter;	/* active */
    mdb_printf("Active:\t\t\t%-4d", data.counter);

    /*
     * Total active payload references
     */
    data.flags = (PD_PLD | PD_REM_NOCNT);
    data.counter = 0;
    if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data,
                  (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) {
        mdb_warn("couldn't walk pdesc_t list");
        return (DCMD_ERR);
    }
    mdb_printf("\t%<u>Active payload refs:\t%-12d bytes%</u>\n",
               data.counter);

    /*
     * Number of removed packet descriptors (claimed - active)
     */
    mdb_printf("Removed:\t\t%-4d", i - k);

    /*
     * Total active header and payload references
     */
    data.flags = (PD_PLD | PD_HDR | PD_REM_NOCNT);
    data.counter = 0;
    if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data,
                  (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) {
        mdb_warn("couldn't walk pdesc_t list");
        return (DCMD_ERR);
    }
    mdb_printf("\tTotal:\t\t\t%-12d bytes\n\n", data.counter);

    mdb_printf("%<b>%<u>ACTIVE ATTRIBUTE STATS%</u>%</b>\n");

    /*
     * Count local attributes
     */
    data.flags = (PD_ATTR | PD_REM_NOCNT);
    data.counter = 0;
    if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_count, &data,
                  (uintptr_t)VA_OFF(addr, offsetof(multidata_t, mmd_pd_q))) == -1) {
        mdb_warn("couldn't walk pdesc_t list");
        return (DCMD_ERR);
    }
    mdb_printf("Local:\t\t\t%-4d", data.counter);

    /*
     * Count global attributes
     */
    data.counter = 0;
    patbkt = (uintptr_t)mmd->mmd_pattbl;
    if (patbkt != 0) {
        uint_t pattbl_sz;

        /* Figure out the size of hash table */
        mdb_readvar(&pattbl_sz, "pattbl_sz");

        /* Walk each bucket and count its contents */
        for (i = 0; i < (pattbl_sz * sizeof (patbkt_t));
                i += sizeof (patbkt_t)) {
            if (mdb_pwalk("pattr",
                          (mdb_walk_cb_t)pattr_count, &data,
                          patbkt + i + offsetof(patbkt_t,
                                                pbkt_pattr_q)) == -1) {
                mdb_warn("couldn't walk pattr_t list");
                return (DCMD_ERR);
            }
        }
    }
    mdb_printf("\tGlobal:\t\t\t%-4d\n", data.counter);
    mdb_printf("\n");

    return (DCMD_OK);
}
Exemplo n.º 21
0
static int
dladm_show_bridge(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
	show_bridge_args_t *args;
	GElf_Sym sym;
	int i;

	args = mdb_zalloc(sizeof (*args), UM_SLEEP);

	i = mdb_getopts(argc, argv,
	    'l', MDB_OPT_SETBITS, 1, &args->opt_l,
	    'f', MDB_OPT_SETBITS, 1, &args->opt_f,
	    't', MDB_OPT_SETBITS, 1, &args->opt_t,
	    NULL);

	argc -= i;
	argv += i;

	if (argc > 1 || (argc == 1 && argv[0].a_type != MDB_TYPE_STRING)) {
		mdb_free(args, sizeof (*args));
		return (DCMD_USAGE);
	}
	if (argc == 1)
		args->name = argv[0].a_un.a_str;

	if ((args->lbolt = mdb_get_lbolt()) == -1) {
		mdb_warn("failed to read lbolt");
		goto err;
	}

	if (flags & DCMD_ADDRSPEC) {
		if (args->name != NULL) {
			mdb_printf("bridge name and address are mutually "
			    "exclusive\n");
			goto err;
		}
		if (!args->opt_l && !args->opt_f && !args->opt_t)
			mdb_printf("%-?s %-7s %-16s %-7s %-7s\n", "ADDR",
			    "PROTECT", "NAME", "NLINKS", "NFWD");
		if (do_show_bridge(addr, NULL, args) != WALK_NEXT)
			goto err;
		mdb_free(args, sizeof (*args));
		return (DCMD_OK);
	} else {
		if ((args->opt_l || args->opt_f || args->opt_t) &&
		    args->name == NULL) {
			mdb_printf("need bridge name or address with -[lft]\n");
			goto err;
		}
		if (mdb_lookup_by_obj("bridge", "inst_list", &sym) == -1) {
			mdb_warn("failed to find 'bridge`inst_list'");
			goto err;
		}
		if (!args->opt_l && !args->opt_f && !args->opt_t)
			mdb_printf("%-?s %-7s %-16s %-7s %-7s %-7s %s\n",
			    "ADDR", "PROTECT", "NAME", "NLINKS", "NFWD",
			    "NNICKS", "NICK");
		if (mdb_pwalk("list", do_show_bridge, args,
		    (uintptr_t)sym.st_value) != DCMD_OK)
			goto err;
		if (!args->found && args->name != NULL) {
			mdb_printf("bridge instance %s not found\n",
			    args->name);
			goto err;
		}
		mdb_free(args, sizeof (*args));
		return (DCMD_OK);
	}

err:
	mdb_free(args, sizeof (*args));
	return (DCMD_ERR);
}
Exemplo n.º 22
0
static int
do_show_bridge(uintptr_t addr, const void *data, void *ptr)
{
	show_bridge_args_t *args = ptr;
	bridge_inst_t bi;
	const bridge_inst_t *bip;
	trill_node_t tn;
	trill_sock_t tsp;
	trill_nickinfo_t tni;
	char bname[MAXLINKNAMELEN];
	char macaddr[ETHERADDRL * 3];
	char *cp;
	uint_t nnicks;
	int i;

	if (data != NULL) {
		bip = data;
	} else {
		if (mdb_vread(&bi, sizeof (bi), addr) == -1) {
			mdb_warn("cannot read bridge instance at %p", addr);
			return (WALK_ERR);
		}
		bip = &bi;
	}

	(void) strncpy(bname, bip->bi_name, sizeof (bname) - 1);
	bname[MAXLINKNAMELEN - 1] = '\0';
	cp = bname + strlen(bname);
	if (cp > bname && cp[-1] == '0')
		cp[-1] = '\0';

	if (args->name != NULL && strcmp(args->name, bname) != 0)
		return (WALK_NEXT);

	args->found = B_TRUE;
	args->nlinks = args->nfwd = 0;

	if (args->opt_l) {
		mdb_printf("%-?s %-16s %-17s %3s %-4s ", "ADDR", "LINK",
		    "MAC-ADDR", "FLG", "PVID");
		if (bip->bi_trilldata == NULL)
			mdb_printf("%-5s %s\n", "STATE", "VLANS");
		else
			mdb_printf("%s\n", "FWD-VLANS");
	}

	if (!args->opt_f && !args->opt_t &&
	    mdb_pwalk("list", do_bridge_links, args,
	    addr + offsetof(bridge_inst_t, bi_links)) != DCMD_OK)
		return (WALK_ERR);

	if (args->opt_f)
		mdb_printf("%-?s %-17s %-7s %-7s %s\n", "ADDR", "DEST", "TIME",
		    "REFS", "OUTPUT");

	if (!args->opt_l && !args->opt_t &&
	    mdb_pwalk("avl", do_bridge_fwd, args,
	    addr + offsetof(bridge_inst_t, bi_fwd)) != DCMD_OK)
		return (WALK_ERR);

	nnicks = 0;
	if (bip->bi_trilldata != NULL && !args->opt_l && !args->opt_f) {
		if (mdb_vread(&args->ti, sizeof (args->ti),
		    (uintptr_t)bip->bi_trilldata) == -1) {
			mdb_warn("cannot read trill instance at %p",
			    bip->bi_trilldata);
			return (WALK_ERR);
		}
		if (args->opt_t)
			mdb_printf("%-?s %-5s %-17s %s\n", "ADDR",
			    "NICK", "NEXT-HOP", "LINK");
		for (i = 0; i < RBRIDGE_NICKNAME_MAX; i++) {
			if (args->ti.ti_nodes[i] == NULL)
				continue;
			if (args->opt_t) {
				if (mdb_vread(&tn, sizeof (tn),
				    (uintptr_t)args->ti.ti_nodes[i]) == -1) {
					mdb_warn("cannot read trill node %d at "
					    "%p", i, args->ti.ti_nodes[i]);
					return (WALK_ERR);
				}
				if (mdb_vread(&tni, sizeof (tni),
				    (uintptr_t)tn.tn_ni) == -1) {
					mdb_warn("cannot read trill node info "
					    "%d at %p", i, tn.tn_ni);
					return (WALK_ERR);
				}
				mdb_mac_addr(tni.tni_adjsnpa, ETHERADDRL,
				    macaddr, sizeof (macaddr));
				if (tni.tni_nick == args->ti.ti_nick) {
					(void) strcpy(macaddr, "[self]");
				}
				mdb_printf("%-?p %-5u %-17s ",
				    args->ti.ti_nodes[i], tni.tni_nick,
				    macaddr);
				if (tn.tn_tsp != NULL) {
					if (mdb_vread(&tsp, sizeof (tsp),
					    (uintptr_t)tn.tn_tsp) == -1) {
						mdb_warn("cannot read trill "
						    "socket info at %p",
						    tn.tn_tsp);
						return (WALK_ERR);
					}
					if (tsp.ts_link != NULL) {
						print_link_name(args,
						    (uintptr_t)tsp.ts_link,
						    '\n');
						continue;
					}
				}
				mdb_printf("--\n");
			} else {
				nnicks++;
			}
		}
	} else {
		if (args->opt_t)
			mdb_printf("bridge is not running TRILL\n");
	}

	if (!args->opt_l && !args->opt_f && !args->opt_t) {
		mdb_printf("%-?p %-7s %-16s %-7u %-7u", addr,
		    bip->bi_trilldata == NULL ? "stp" : "trill", bname,
		    args->nlinks, args->nfwd);
		if (bip->bi_trilldata != NULL)
			mdb_printf(" %-7u %u\n", nnicks, args->ti.ti_nick);
		else
			mdb_printf(" %-7s %s\n", "--", "--");
	}
	return (WALK_NEXT);
}
Exemplo n.º 23
0
/* ARGSUSED */
static int
pdesc_count(uintptr_t addr, q_walk_t *qwp, mmd_data_t *data)
{
    pdesc_t pd;
    int i;
    uint_t f = data->flags;

    if (mdb_vread(&pd, sizeof (pd), addr) == -1) {
        mdb_warn("failed to read pdesc_t at %p", addr);
        return (WALK_ERR);
    }

    if (pd.pd_magic != PDESC_MAGIC)
        mdb_printf("Incorrect pdesc magic number at %p\n",
                   VA_OFF(addr, offsetof(pdesc_t, pd_magic)));

    if (f == 0) {
        /* No flags set, count all pdescs */
        data->counter++;
    } else if (f == PD_REM_NOCNT && !(pd.pd_pdi.flags & PDESC_REM_DEFER)) {
        /* Count only active (skip removed) pdescs */
        data->counter++;
    } else if (f & PD_ATTR) {
        uint_t pattbl_sz;
        uintptr_t patbkt = (uintptr_t)pd.pd_pattbl;
        mmd_data_t attr_data;

        /* Count local attributes */
        if ((!(f & PD_REM_NOCNT) || ((f & PD_REM_NOCNT) &&
                                     !(pd.pd_pdi.flags & PDESC_REM_DEFER))) && patbkt != 0) {

            /* Figure out the size of hash table */
            mdb_readvar(&pattbl_sz, "pattbl_sz");

            attr_data.counter = 0;
            /* Walk each bucket and count its contents */
            for (i = 0; i < (pattbl_sz * sizeof (patbkt_t));
                    i += sizeof (patbkt_t)) {
                if (mdb_pwalk("pattr",
                              (mdb_walk_cb_t)pattr_count, &attr_data,
                              patbkt + i + offsetof(patbkt_t,
                                                    pbkt_pattr_q)) == -1) {
                    mdb_warn("couldn't walk pattr_t list");
                    return (WALK_ERR);
                }
            }
            data->counter += attr_data.counter;
        }
    } else {
        if (f & PD_HDR) {
            /* Count header span referenced by pdesc */
            if (!(f & PD_REM_NOCNT) || ((f & PD_REM_NOCNT) &&
                                        !(pd.pd_pdi.flags & PDESC_REM_DEFER)))
                data->counter += PDESC_HDRL(&pd.pd_pdi);
        }

        if (f & PD_PLD) {
            /* Count payload span referenced by pdesc */
            if (!(f & PD_REM_NOCNT) || ((f & PD_REM_NOCNT) &&
                                        !(pd.pd_pdi.flags & PDESC_REM_DEFER))) {
                for (i = 0; i < pd.pd_pdi.pld_cnt; i++)
                    data->counter += PDESC_PLD_SPAN_SIZE(
                                         &pd.pd_pdi, i);
            }
        }
    }

    return (WALK_NEXT);
}
Exemplo n.º 24
0
int
zsd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
	zone_t zone;
	const mdb_arg_t *argp;
	int argcindex;
	struct zsd_cb_data cbd;
	char name[ZONE_NAMELEN];
	int len;

	/*
	 * Walk all zones if necessary.
	 */
	if (argc > 2)
		return (DCMD_USAGE);
	if ((flags & DCMD_ADDRSPEC) == 0) {
		if (mdb_walk_dcmd("zone", "zsd", argc, argv) == -1) {
			mdb_warn("failed to walk zone\n");
			return (DCMD_ERR);
		}
		return (DCMD_OK);
	}

	/*
	 * Make sure a zone_t can be read from the specified address.
	 */
	if (mdb_vread(&zone, sizeof (zone), addr) == -1) {
		mdb_warn("couldn't read zone_t at %p", (void *)addr);
		return (DCMD_ERR);
	}

	/*
	 * Get the optional arguments (key or -v or both).  Note that
	 * mdb_getopts() will not parse a key argument because it is not
	 * preceded by an option letter.  We'll get around this by requiring
	 * that all options precede the optional key argument.
	 */
	cbd.keygiven = FALSE;
	cbd.voptgiven = FALSE;
	if (argc > 0 && (argcindex = mdb_getopts(argc, argv, 'v',
	    MDB_OPT_SETBITS, TRUE, &cbd.voptgiven, NULL)) != argc) {
		/*
		 * No options may appear after the key.
		 */
		if (argcindex != argc - 1)
			return (DCMD_USAGE);

		/*
		 * The missed argument should be a key.
		 */
		argp = &argv[argcindex];
		if (argp->a_type == MDB_TYPE_IMMEDIATE)
			cbd.key = argp->a_un.a_val;
		else
			cbd.key = mdb_strtoull(argp->a_un.a_str);
		cbd.keygiven = TRUE;
		cbd.found = FALSE;
	}

	/*
	 * Prepare to output the specified zone's ZSD information.
	 */
	if (DCMD_HDRSPEC(flags))
		mdb_printf("%<u>%-20s %?s %?s %8s%</u>\n", "ZONE", "KEY",
		    "VALUE", "FLAGS");
	len = mdb_readstr(name, ZONE_NAMELEN, (uintptr_t)zone.zone_name);
	if (len > 0) {
		if (len == ZONE_NAMELEN)
			(void) strcpy(&name[len - 4], "...");
	} else {
		(void) strcpy(name, "??");
	}
	mdb_printf("%-20s ", name);

	/*
	 * Display the requested ZSD entries.
	 */
	mdb_inc_indent(21);
	if (mdb_pwalk("zsd", zsd_print, &cbd, addr) != 0) {
		mdb_warn("failed to walk zsd\n");
		mdb_dec_indent(21);
		return (DCMD_ERR);
	}
	if (cbd.keygiven == TRUE && cbd.found == FALSE) {
		mdb_printf("no corresponding ZSD entry found\n");
		mdb_dec_indent(21);
		return (DCMD_ERR);
	}
	mdb_dec_indent(21);
	return (DCMD_OK);
}
Exemplo n.º 25
0
/* ARGSUSED */
int
multidata(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
    mmd_data_t data;
    multidata_t mmd;
    char str[32] = "-";
    int i = 0;

    bzero(&data, sizeof (data));
    if (!(flags & DCMD_ADDRSPEC) || mdb_getopts(argc, argv,
            'v', MDB_OPT_SETBITS, MMD_VERBOSE, &data.flags,
            's', MDB_OPT_SETBITS, MMD_STATS, &data.flags, NULL) != argc)
        return (DCMD_USAGE);

    if (mdb_vread(&mmd, sizeof (mmd), addr) == -1) {
        mdb_warn("failed to read multidata_t structure at %p", addr);
        return (DCMD_ERR);
    }

    if (mmd.mmd_magic != MULTIDATA_MAGIC)
        mdb_printf("Incorrect Multidata magic number at %p\n",
                   VA_OFF(addr, offsetof(multidata_t, mmd_magic)));

    mdb_printf("\n");
    if (data.flags & MMD_STATS) {
        if ((i = multidata_stats(addr, &mmd)) != DCMD_OK)
            return (i);
    }

    mdb_printf("%<b>%-5s %-?s %-4s %-?s %-4s %-4s %-4s %-?s%</b>",
               "PDESC", "PATTBL", "HBUF", "HBUF", "PBUF", "PBUF", "PBUF", "PBUF");
    mdb_printf("\n");
    mdb_printf("%<b>%<u>%-5s %-?s %-4s %-?s %-4s %-4s %-4s %-?s%</u>%</b>",
               "CNT", "ADDRESS", "REF", "ADDRESS", "REF", "CNT", "IDX",
               "ADDRESS(ES)");
    mdb_printf("\n");

    if (mmd.mmd_pattbl != 0)
        mdb_snprintf(str, sizeof (str), "%016p", mmd.mmd_pattbl);

    i = 0;
    mdb_printf("%-5d %-16s %-4d %016p %-4d %-4d %-4d %016p\n",
               mmd.mmd_pd_cnt, str, mmd.mmd_hbuf_ref, mmd.mmd_hbuf,
               mmd.mmd_pbuf_ref, mmd.mmd_pbuf_cnt, i, mmd.mmd_pbuf[i]);

    for (++i; i < mmd.mmd_pbuf_cnt; i++)
        mdb_printf("%-54s %-4d %016p\n", "", i, mmd.mmd_pbuf[i]);

    if (!(data.flags & MMD_VERBOSE))
        return (DCMD_OK);

    /* Walk packet descriptor slab list */
    if (mdb_pwalk("pdesc_slab", (mdb_walk_cb_t)pdesc_slab_print,
                  &data, (uintptr_t)VA_OFF(addr, offsetof(multidata_t,
                                           mmd_pd_slab_q))) == -1) {
        mdb_warn("couldn't walk pdesc_slab_t list");
        return (DCMD_ERR);
    }

    /* Walk packet descriptor list */
    data.counter = 0;
    if (mdb_pwalk("pdesc", (mdb_walk_cb_t)pdesc_print,
                  &data, (uintptr_t)VA_OFF(addr, offsetof(multidata_t,
                                           mmd_pd_q))) == -1) {
        mdb_warn("couldn't walk pdesc_t list");
        return (DCMD_ERR);
    }

    return (DCMD_OK);
}
Exemplo n.º 26
0
static int
umastat_cache(uintptr_t addr, const umem_cache_t *cp, umastat_vmem_t **kvp)
{
	umastat_vmem_t *kv;
	datafmt_t *dfp = umemfmt;
	char buf[10];
	int magsize;

	int avail, alloc, total, nptc = 0;
	size_t meminuse = (cp->cache_slab_create - cp->cache_slab_destroy) *
	    cp->cache_slabsize;

	mdb_walk_cb_t cpu_avail = (mdb_walk_cb_t)umastat_cpu_avail;
	mdb_walk_cb_t cpu_alloc = (mdb_walk_cb_t)umastat_cpu_alloc;
	mdb_walk_cb_t slab_avail = (mdb_walk_cb_t)umastat_slab_avail;

	magsize = umem_get_magsize(cp);

	alloc = cp->cache_slab_alloc + cp->cache_full.ml_alloc;
	avail = cp->cache_full.ml_total * magsize;
	total = cp->cache_buftotal;

	(void) mdb_pwalk("umem_cpu_cache", cpu_alloc, &alloc, addr);
	(void) mdb_pwalk("umem_cpu_cache", cpu_avail, &avail, addr);
	(void) mdb_pwalk("umem_slab_partial", slab_avail, &avail, addr);

	if (cp->cache_flags & UMF_PTC) {
		char walk[60];

		(void) snprintf(walk, sizeof (walk),
		    "umem_ptc_%d", cp->cache_bufsize);

		if (mdb_walk(walk,
		    (mdb_walk_cb_t)umastat_cache_ptc, &nptc) == -1) {
			mdb_warn("unable to walk '%s'", walk);
			return (WALK_ERR);
		}

		(void) snprintf(buf, sizeof (buf), "%d", nptc);
	}

	for (kv = *kvp; kv != NULL; kv = kv->kv_next) {
		if (kv->kv_addr == (uintptr_t)cp->cache_arena)
			goto out;
	}

	kv = mdb_zalloc(sizeof (umastat_vmem_t), UM_SLEEP | UM_GC);
	kv->kv_next = *kvp;
	kv->kv_addr = (uintptr_t)cp->cache_arena;
	*kvp = kv;
out:
	kv->kv_meminuse += meminuse;
	kv->kv_alloc += alloc;
	kv->kv_fail += cp->cache_alloc_fail;

	mdb_printf((dfp++)->fmt, cp->cache_name);
	mdb_printf((dfp++)->fmt, cp->cache_bufsize);
	mdb_printf((dfp++)->fmt, total - avail);
	mdb_printf((dfp++)->fmt, cp->cache_flags & UMF_PTC ? buf : "-");
	mdb_printf((dfp++)->fmt, total);
	mdb_printf((dfp++)->fmt, meminuse);
	mdb_printf((dfp++)->fmt, alloc);
	mdb_printf((dfp++)->fmt, cp->cache_alloc_fail);
	mdb_printf("\n");

	return (WALK_NEXT);
}
Exemplo n.º 27
0
/*
 * Validate a rctl pointer by checking:
 *   - rctl_val_t's for that rctl form an ordered, non-circular list
 *   - the cursor points to a rctl_val_t within that list
 *   - there are no more than UINT64_MAX (or # specified by -n)
 *     rctl_val_t's in the list
 */
int
rctl_validate(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
	rctl_validate_data_t data;

	rctl_t r;

	uint64_t long_threshold = UINT64_MAX;

	/* Initialize validate data structure */
	data.v_rctl_addr = addr;
	data.v_flags = 0;
	data.v_bad_rctl = 0;
	data.v_seen_cnt = 0;
	data.v_cursor_valid = 0;
	data.v_circularity_detected = 0;
	data.v_seen_size = 1;
	data.v_seen = mdb_zalloc(data.v_seen_size * sizeof (rctl_val_seen_t),
	    UM_SLEEP | UM_GC);

	if (!(flags & DCMD_ADDRSPEC))
		return (DCMD_USAGE);

	if (mdb_getopts(argc, argv,
	    'v', MDB_OPT_SETBITS, RCV_VERBOSE, &data.v_flags,
	    'n', MDB_OPT_UINT64, &long_threshold,
	    NULL) != argc)
		return (DCMD_USAGE);

	if (mdb_vread(&r, sizeof (rctl_t), addr) != sizeof (rctl_t)) {
		mdb_warn("failed to read rctl structure at %p", addr);
		return (DCMD_ERR);
	}

	data.v_cursor = r.rc_cursor;

	if (data.v_cursor == NULL) {
		if (data.v_bad_rctl++ == 0)
			mdb_printf("%p ", addr);
		if (data.v_flags & RCV_VERBOSE)
			mdb_printf("/ NULL cursor seen ");
	} else if (data.v_cursor == (rctl_val_t *)0xbaddcafe) {
		if (data.v_bad_rctl++ == 0)
			mdb_printf("%p ", addr);
		if (data.v_flags & RCV_VERBOSE)
			mdb_printf("/ uninitialized cursor seen ");
	}

	/* Walk through each val in this rctl for individual validation. */
	if (mdb_pwalk("rctl_val", (mdb_walk_cb_t)rctl_val_validate, &data,
	    addr) == -1) {
		mdb_warn("failed to walk all values for rctl_t %p", addr);
		return (DCMD_ERR);
	}

	if (data.v_seen_cnt >= long_threshold) {
		if (data.v_bad_rctl++ == 0)
			mdb_printf("%p ", addr);
		if (data.v_flags & RCV_VERBOSE)
			mdb_printf("/ sequence length = %d ",
			    data.v_seen_cnt);
	}

	if (!data.v_cursor_valid) {
		if (data.v_bad_rctl++ == 0)
			mdb_printf("%p ", addr);
		if (data.v_flags & RCV_VERBOSE)
			mdb_printf("/ cursor outside sequence");
	}

	if (data.v_bad_rctl)
		mdb_printf("\n");

	if (data.v_circularity_detected)
		mdb_warn("circular list implies possible memory leak; "
		    "recommend invoking ::findleaks");

	return (DCMD_OK);
}