mdb_set.c revision 186f7fbf5e07d046b50e4e15c32b21f109b76c80
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Support for ::set dcmd. The +/-o option processing code is provided in a
* stand-alone function so it can be used by the command-line option processing
* code in mdb_main.c. This facility provides an easy way for us to add more
* configurable options without having to add a new dcmd each time.
*/
#include <mdb/mdb_target.h>
#include <mdb/mdb_modapi.h>
#include <mdb/mdb_string.h>
#include <mdb/mdb_debug.h>
/*ARGSUSED*/
static int
{
return (1);
}
/*ARGSUSED*/
static int
{
return (1);
}
static int
{
if (enable)
else
}
static int
{
if (enable)
(void) mdb_set_prompt("");
else if (mdb.m_promptlen == 0)
(void) mdb_set_prompt("> ");
}
/*ARGSUSED*/
static int
{
return (1);
}
return (1);
}
return (0);
}
/*ARGSUSED*/
static int
{
return (1);
}
return (1);
}
return (0);
}
/*ARGSUSED*/
static int
{
return (1);
return (1);
return (1);
}
return (0);
}
/*ARGSUSED*/
static int
{
return (1);
return (1);
return (1);
}
return (0);
}
/*ARGSUSED*/
static int
{
return (1);
}
int
mdb_set_options(const char *s, int enable)
{
static const struct opdesc {
const char *opt_name;
} opdtab[] = {
{ "array_mem_limit", opt_armemlim, 0 },
{ "array_str_limit", opt_arstrlim, 0 },
{ "follow_exec_mode", opt_exec_mode, 0 },
{ "follow_fork_mode", opt_fork_mode, 0 },
{ "term", opt_set_term, 0 },
};
int status = 1;
*arg++ = '\0';
mdb_warn("option does not accept an "
"argument -- %s\n", opt);
status = 0;
mdb_warn("option requires an argument "
"-- %s\n", opt);
status = 0;
mdb_warn("invalid argument for option "
status = 0;
}
break;
}
}
status = 0;
}
}
return (status);
}
static void
{
}
mdb_printf("\n");
}
#define LABEL_INDENT 26
static void
print_properties(void)
{
mdb_printf("\n macro path: ");
mdb_printf(" module path: ");
else
mdb_printf("none\n");
mdb_printf(" array string print limit: ");
else
mdb_printf("none\n");
mdb_printf("follow_exec_mode=");
switch (mdb.m_execmode) {
case MDB_EM_ASK:
mdb_printf("ask");
break;
case MDB_EM_STOP:
mdb_printf("stop");
break;
case MDB_EM_FOLLOW:
mdb_printf("follow");
break;
}
COMMAFLAG("follow_fork_mode");
switch (mdb.m_forkmode) {
case MDB_FM_ASK:
mdb_printf("ask");
break;
case MDB_FM_PARENT:
mdb_printf("parent");
break;
case MDB_FM_CHILD:
mdb_printf("child");
break;
}
COMMAFLAG("adb");
COMMAFLAG("ignoreeof");
COMMAFLAG("lmraw");
COMMAFLAG("pager");
COMMAFLAG("repeatlast");
COMMAFLAG("showlmid");
COMMAFLAG("stop_on_bpt_nosym");
COMMAFLAG("write_readback");
mdb_printf("\n");
if (tflags & MDB_TGT_F_RDWR)
mdb_printf("read-write");
else
mdb_printf("read-only");
if (tflags & MDB_TGT_F_ALLOWIO)
COMMAFLAG("allow-io-access");
if (tflags & MDB_TGT_F_FORCE)
COMMAFLAG("force-attach");
if (tflags & MDB_TGT_F_PRELOAD)
COMMAFLAG("preload-syms");
if (tflags & MDB_TGT_F_NOLOAD)
COMMAFLAG("no-load-objs");
if (tflags & MDB_TGT_F_NOSTOP)
COMMAFLAG("no-stop");
mdb_printf("\n");
}
/*ARGSUSED*/
int
{
int tflags = 0;
int i;
if (flags & DCMD_ADDRSPEC)
return (DCMD_USAGE);
/*
* If no options are specified, print out the current set of target
* and debugger properties that can be modified with ::set.
*/
if (argc == 0) {
return (DCMD_OK);
}
uint_t n = 1;
argv += i; /* skip past args we processed */
argc -= i; /* adjust argc */
return (DCMD_USAGE);
opt_plus_W = TRUE;
opt_plus_w = TRUE;
n = 2;
} else
return (DCMD_USAGE);
/* remove the flag and possible argument */
argv += n;
argc -= n;
}
return (DCMD_USAGE);
/*
* Handle -w, -/+W and -F first: as these options modify the target,
* they are the only ::set changes that can potentially fail. We'll
* use these flags to modify a copy of the target's t_flags, which we'll
* then pass to the target's setflags op. This allows the target to
* detect newly-set and newly-cleared flags by comparing the passed
* value to the current t_flags.
*/
if (opt_w)
tflags |= MDB_TGT_F_RDWR;
if (opt_plus_w)
tflags &= ~MDB_TGT_F_RDWR;
if (opt_W)
if (opt_plus_W)
tflags &= ~MDB_TGT_F_ALLOWIO;
if (opt_F)
return (DCMD_ERR);
/*
* Now handle everything that either can't fail or we don't care if
* it does. Note that we handle +/-o first in case another option
* overrides a change made implicity by a +/-o argument (e.g. -P).
*/
if (opt_plus_o != NULL)
#ifdef _KMDB
mdb_warn("macro path cannot be set under kmdb\n");
#else
#endif
}
(void) mdb_set_prompt(opt_P);
return (DCMD_OK);
}