/*
* 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"
/*
* MDB Regression Test Module
*
* This module contains dcmds and walkers that exercise various aspects of
* MDB and the MDB Module API. It can be manually loaded and executed to
* verify that MDB is still working properly.
*/
#include <mdb/mdb_modapi.h>
#define _MDB
#include <mdb/mdb_io_impl.h>
static int
{
return (WALK_NEXT);
}
static int
{
return (WALK_DONE);
return (status);
}
/*ARGSUSED*/
static int
{
return (DCMD_ERR);
}
if (argc != 0) {
return (DCMD_ERR);
}
return (DCMD_OK);
}
static int
{
}
/*ARGSUSED*/
static int
{
mdb_pipe_t p;
size_t i;
return (DCMD_ERR);
}
if (argc != 0) {
return (DCMD_ERR);
}
mdb_get_pipe(&p);
mdb_warn("ERROR: qsort got bad results from mdb_get_pipe\n");
return (DCMD_ERR);
}
mdb_warn("ERROR: qsort pipe_data[0] != addr\n");
return (DCMD_ERR);
}
mdb_set_pipe(&p);
for (i = 0; i < 16; i++) {
if (p.pipe_data[i] != i) {
mdb_warn("ERROR: qsort got bad data in slot %lu\n", i);
return (DCMD_ERR);
}
}
return (DCMD_OK);
}
/*ARGSUSED*/
static int
{
int state, i;
mdb_printf("- adding countdown walker\n");
if (mdb_add_walker(&w) != 0) {
mdb_warn("ERROR: failed to add walker");
return (DCMD_ERR);
}
mdb_printf("- executing countdown pipeline\n");
if (mdb_eval("::walk mdb_test`count |::mdb_test`qsort |::praddr")) {
mdb_warn("ERROR: failed to eval command");
return (DCMD_ERR);
}
mdb_printf("- removing countdown walker\n");
if (mdb_remove_walker("count") != 0) {
mdb_warn("ERROR: failed to remove walker");
return (DCMD_ERR);
}
state = mdb_get_state();
state == MDB_STATE_RUNNING)) {
mdb_printf("- exercising pipelines\n");
for (i = 0; i < 100; i++) {
if (mdb_eval("::walk proc p | ::map *. | ::grep .==0 "
"| ::map <p | ::ps") != 0) {
mdb_warn("ERROR: failed to eval pipeline");
return (DCMD_ERR);
}
}
}
return (DCMD_OK);
}
static int
{
void *buf;
return (DCMD_USAGE);
else
if (rbytes >= 0) {
mdb_printf("mdb_vread of %lu bytes returned %ld\n",
} else
return (DCMD_OK);
}
/*ARGSUSED*/
static int
{
void *buf;
return (DCMD_USAGE);
else
if (rbytes >= 0) {
mdb_printf("mdb_pread of %lu bytes returned %ld\n",
} else
return (DCMD_OK);
}
/*ARGSUSED*/
static int
{
void *buf;
return (DCMD_USAGE);
else
if (rbytes >= 0) {
mdb_printf("mdb_readsym of %lu bytes returned %ld\n",
} else
return (DCMD_OK);
}
static int
{
const char *dcmd;
return (DCMD_USAGE);
argv++;
argc--;
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*ARGSUSED*/
static int
{
if (argc != 0)
return (DCMD_USAGE);
mdb_set_dot(0x12345678feedbeefULL);
if (mdb_get_dot() != 0x12345678feedbeefULL) {
mdb_warn("mdb_get_dot() returned wrong value!\n");
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*
* kmdb doesn't export some of the symbols used by these tests - namely mdb and
* mdb_iob_.*. We therefore can't use these tests with kmdb.
*/
#ifndef _KMDB
static void
{
int i;
for (i = 0; i < 8; i++)
mdb_printf("0123456789");
mdb_printf("\n");
for (i = 0; i < 50; i++)
mdb_printf(" xx");
mdb_printf("\n");
}
/*ARGSUSED*/
static int
{
if (argc != 0)
return (DCMD_USAGE);
if (!(flags & DCMD_ADDRSPEC))
do_nputs_tests("tests with (~WRAP, ~INDENT)",
do_nputs_tests("tests with (WRAP, ~INDENT)",
do_nputs_tests("tests with (~WRAP, INDENT)",
do_nputs_tests("tests with (WRAP, INDENT)",
return (DCMD_OK);
}
#endif
/*ARGSUSED*/
static int
{
return (DCMD_USAGE);
else
return (DCMD_OK);
}
/*ARGSUSED*/
static int
{
return (*((volatile int *)NULL));
}
#ifndef _KMDB
#endif
{ NULL }
};
{ NULL }
};
const mdb_modinfo_t *
_mdb_init(void)
{
return (&modinfo);
}