/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <string.h>
#include <sys/modhash_impl.h>
#include <mdb/mdb_modapi.h>
#include "modhash.h"
/* This is passed to the modent callback; allows caller to get context */
typedef struct modent_step_data_s {
int msd_hash_index;
/* Context for a walk over a modhash (variable length) */
typedef struct hash_walk_s {
} hash_walk_t;
/* Computes number of bytes to allocate for hash_walk_t structure. */
/* Used for decoding hash keys for display */
typedef struct hash_type_entry_s {
};
/* The information used during a walk */
typedef struct mod_walk_data_s {
/*
* Initialize a walk over all the modhashes in the system.
*/
int
{
mdb_warn("failed to read mh_head");
return (WALK_ERR);
}
return (WALK_NEXT);
}
/*
* Step to the next modhash in the system.
*/
int
{
int status;
return (WALK_DONE);
return (WALK_ERR);
}
return (status);
}
/*
* Initialize a walk over the entries in a given modhash.
*/
int
{
int retv;
mdb_warn("mod_hash_t address required\n");
return (WALK_ERR);
}
return (WALK_ERR);
}
mdb_warn("impossible number of chains in mod_hash_t at %p",
return (WALK_ERR);
}
/*
* If the user presents us with a garbage pointer, and thus the number
* of chains is just absurd, we don't want to bail out of mdb. Fail to
* walk instead.
*/
mdb_warn("unable to allocate %#x bytes for mod_hash_t at %p",
return (WALK_ERR);
}
if (retv == -1) {
mdb_warn("failed to read %#x mod_hash_entry pointers at %p",
return (WALK_ERR);
}
return (WALK_NEXT);
}
/*
* Step to the next entry in the modhash.
*/
int
{
int status;
return (WALK_DONE);
}
mdb_warn("failed to read mod_hash_entry at %p",
return (WALK_ERR);
}
wsp->walk_cbdata);
return (status);
}
/*
* Clean up after walking the entries in a modhash.
*/
void
{
}
/*
* Step to next entry on a hash chain.
*/
int
{
int status;
return (WALK_DONE);
mdb_warn("failed to read mod_hash_entry at %p",
return (WALK_ERR);
}
return (status);
}
/*
* This is called by ::modhash (via a callback) when gathering data about the
* entries in a given modhash. It keeps track of the longest chain, finds a
* specific entry (if the user requested one) and prints out a summary of the
* entry or entries.
*/
static int
{
/* If this chain is longest seen, then save start of chain */
}
/* If the user specified a particular chain, then ignore others */
/* Save address of *first* entry */
else
return (retv);
}
/* If the user specified a particular key, ignore others. */
if (mwd->mwd_opt_k_set &&
return (retv);
/* If the user specified a particular value, ignore others. */
if (mwd->mwd_opt_v_set &&
return (retv);
/* If the user just wants the chain heads, skip intermediate nodes. */
return (retv);
/* If the user asked to have the entries printed, then do that. */
/* If the output is to a pipeline, just print addresses */
else
}
return (retv);
}
void
modhash_help(void)
{
mdb_printf("Prints information about one or all mod_hash_t databases "
"in the system.\n"
"This command has three basic forms, summarized below.\n\n"
" ::modhash [-t]\n <addr>::modhash\n"
" <addr>::modhash -e [-ch] [-k key] [-v val] [-i index]\n\n"
"In the first form, no address is provided, and a summary of all "
"registered\n"
"hashes in the system is printed; adding the '-t' option shows"
" the hash\n"
"type instead of the limits. In the second form, the address of a"
" mod_hash_t\n"
"is provided, and the output is in a verbose format. The final "
"form prints\n"
"the elements of the hash, optionally selecting just those with a "
"particular\n"
"The -h option\n"
"shows hash indices instead of addresses.\n");
}
int
{
int len;
NULL);
mdb_warn("unexpected argument: %s\n",
else
mdb_warn("unexpected argument(s)\n");
return (DCMD_USAGE);
}
/* true if any element-related flags are set */
if (!(flags & DCMD_ADDRSPEC)) {
if (elem_flags) {
/*
* This isn't allowed so that the output doesn't become
* a confusing mix of hash table descriptions and
* element entries.
*/
mdb_warn("printing elements from all hashes is not "
"permitted\n");
return (DCMD_USAGE);
}
/* we force short mode here, no matter what he says */
mdb_warn("can't walk mod_hash structures");
return (DCMD_ERR);
}
return (DCMD_OK);
}
mdb_warn("hash summary options not permitted when "
"displaying elements\n");
return (DCMD_USAGE);
}
} else {
if (elem_flags) {
/*
* This isn't allowed so that the output doesn't become
* a confusing mix of hash table description and
* element entries.
*/
mdb_warn("printing elements requires -e\n");
return (DCMD_USAGE);
}
}
return (DCMD_ERR);
}
mdb_warn("mod_hash chain index %x out of range 0..%x\n",
return (DCMD_ERR);
}
if (opt_t != 0) {
mdb_printf("%<u>%?s %6s %5s %?s %s%</u>\n",
"ADDR", "CHAINS", "ELEMS", "TYPE", "NAME");
} else {
mdb_printf("%<u>%?s %6s %5s %6s %6s %s%</u>\n",
"ADDR", "CHAINS", "ELEMS", "MAXLEN", "MAXIDX",
"NAME");
}
}
if (len < 0)
kfunc[0] = '\0';
break;
mdb_printf("\tKey comparator: %?p %s\n",
mdb_printf("\tType: %s\n",
mdb_printf("\tSleep flag = %s, alloc failed = %#x\n",
mdb_printf("\tNumber of chains = %#x, elements = %#x\n",
mdb_printf("\tHits = %#x, misses = %#x, dups = %#x\n",
}
mdb_warn("can't walk mod_hash entries");
return (DCMD_ERR);
}
if (opt_s) {
const char *tname;
} else {
}
if (opt_t != 0) {
} else {
}
mdb_printf("\tMaximum chain length = %x (at index %x, first "
}
return (DCMD_OK);
}
static void
{
int len;
}
static void
{
int len;
}
static void
{
}
static void
{
}
void
modent_help(void)
{
mdb_printf("Options are mutually exclusive:\n"
" -t <type> print key in symbolic form; <type> is one of str, "
"ptr, or id\n"
" -v print value pointer alone\n"
" -k print key pointer alone\n");
}
static int
{
mdb_printf("%<u>%?s %?s %?s%</u>\n",
}
return (DCMD_ERR);
}
if (opt_k) {
} else if (opt_v) {
} else {
if (prtidx)
else
}
return (DCMD_OK);
}
/*
* This prints out a single mod_hash element, showing its value and its key.
* The key is decoded based on the type of hash keys in use.
*/
int
{
int len;
if (!(flags & DCMD_ADDRSPEC)) {
mdb_warn("address of mod_hash_entry must be specified\n");
return (DCMD_ERR);
}
NULL);
/* options are mutually exclusive */
return (DCMD_USAGE);
}
break;
return (DCMD_ERR);
}
}