kgrep.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Generic memory walker, used by both the genunix and libumem dmods.
*/
#include <mdb/mdb_modapi.h>
#include <sys/sysmacros.h>
#include "kgrep.h"
#define KGREP_FULL_MASK (~(uintmax_t)0)
typedef struct kgrep_data {
void *kg_page;
char kg_cbtype;
char kg_seen;
} kgrep_data_t;
#define KG_BASE 0
#define KG_VERBOSE 1
#define KG_PIPE 2
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; \
\
\
continue; \
\
} \
} \
if (seen) \
\
return (WALK_NEXT); \
}
/*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);
}