/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 2011 Joyent, Inc. All rights reserved.
*/
/*
* Generic memory walker, used by both the genunix and libumem dmods.
*/
#include <mdb/mdb_modapi.h>
#include <sys/sysmacros.h>
#include "kgrep.h"
typedef struct kgrep_data {
void *kg_page;
char kg_cbtype;
char kg_seen;
} kgrep_data_t;
#define KG_BASE 0
static void
{
switch (type) {
case KG_BASE:
default:
break;
case KG_VERBOSE:
break;
case KG_PIPE:
break;
}
}
static int
{
int seen = 0;
/*
* page-align everything, to simplify the loop
*/
continue;
seen = 1;
continue;
}
}
if (seen)
return (WALK_NEXT);
}
/*
* Full-service template -- instantiated for each supported size. We support
* the following options:
*
* addr in [minaddr, maxaddr), and
* value in [pattern, pattern + dist) OR
* mask matching: (value & mask) == (pattern & mask)
*/
static int \
{ \
\
uintbits_t *page_end; \
uintbits_t *pos; \
uintbits_t cur; \
\
int seen = 0; \
\
\
\
/* P2END(...) computes the next page boundry */ \
\
continue; \
\
seen = 1; \
\
\
/* \
* Due to C's (surprising) integral promotion \
* rules for unsigned types smaller than an \
* int, we need to explicitly cast the result \
* of cur minus pattern, below. \
*/ \
continue; \
\
} \
} \
if (seen) \
\
return (WALK_NEXT); \
}
void
kgrep_help(void)
{
"\n"
"Search the entire virtual address space for a particular pattern,\n"
"%<u>addr%</u>. By default, a pointer-sized search for an exact match is\n"
"done.\n\n");
mdb_dec_indent(2);
mdb_printf("%<b>OPTIONS%</b>\n");
mdb_inc_indent(2);
" -v Report the value matched at each address\n"
" -a minaddr\n"
" Restrict the search to addresses >= minaddr\n"
" -A maxaddr\n"
" Restrict the search to addresses < maxaddr\n"
" -d dist\n"
" Search for values in [addr, addr + dist)\n"
" -m mask\n"
" Search for values where (value & mask) == addr\n"
" -M invmask\n"
" Search for values where (value & ~invmask) == addr\n"
" -s size\n"
" Instead of pointer-sized values, search for size-byte values.\n"
" size must be 1, 2, 4, or 8.\n");
}
/*ARGSUSED*/
int
{
int verbose = 0;
int ret;
int args = 0;
return (DCMD_USAGE);
if (invmask != 0)
args++;
if (mask != KGREP_FULL_MASK)
args++;
if (dist != 0)
args++;
if (args > 1) {
mdb_warn("only one of -d, -m and -M may be specified\n");
return (DCMD_USAGE);
}
if (!(flags & DCMD_ADDRSPEC))
return (DCMD_USAGE);
if (invmask != 0)
mdb_warn("warning: pattern does not match mask\n");
mdb_warn("sizes greater than %d not supported\n",
sizeof (uintmax_t));
return (DCMD_ERR);
}
mdb_warn("size must be a power of 2\n");
return (DCMD_ERR);
}
else
mdb_warn("warning: pattern %llx overflows requested size "
"%d (max: %llx)\n",
if (dist > 0 &&
mdb_warn("pattern %llx + distance %llx overflows size\n"
return (DCMD_ERR);
}
/*
* All arguments have now been validated.
*/
if (flags & DCMD_PIPE_OUT) {
verbose = 0;
} else if (verbose) {
} else {
}
/*
* kgrep_range_basic handles the common case (no arguments)
* with dispatch.
*/
else {
switch (size) {
case 1:
break;
case 2:
break;
case 4:
break;
case 8:
break;
default:
mdb_warn("can't happen: non-recognized kgrep size\n");
return (DCMD_ERR);
}
}
/*
* Invoke the target, which should invoke func(start, end, &kg) for
* every range [start, end) of vaddrs which might have backing.
* Both start and end must be multiples of kgrep_subr_pagesize().
*/
mdb_warn("warning: nothing searched\n");
return (ret);
}