/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
-/*
- * HISTORY
- *
- * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez
- * Import of Mac OS X kernel (~semeria)
- *
- * Revision 1.1.1.1 1998/03/07 02:26:09 wsanchez
- * Import of OSF Mach kernel (~mburg)
- *
- * Revision 1.2.18.5 1996/01/09 19:16:34 devrcs
- * Search the alternate register names if configured
- * Changed declarations of 'register foo' to 'register int foo'.
- * [1995/12/01 21:42:42 jfraser]
- *
- * Merged '64-bit safe' changes from DEC alpha port.
- * [1995/11/21 18:03:56 jfraser]
- *
- * Revision 1.2.18.4 1995/02/23 21:43:56 alanl
- * Merged with DIPC2_SHARED.
- * [1995/01/05 13:35:55 alanl]
- *
- * Revision 1.2.21.1 1994/11/04 09:53:26 dwm
- * mk6 CR668 - 1.3b26 merge
- * * Revision 1.2.4.6 1994/05/06 18:40:13 tmt
- * Merged osc1.3dec/shared with osc1.3b19
- * Merge Alpha changes into osc1.312b source code.
- * 64bit cleanup.
- * * End1.3merge
- * [1994/11/04 08:50:12 dwm]
- *
- * Revision 1.2.18.2 1994/09/23 01:22:35 ezf
- * change marker to not FREE
- * [1994/09/22 21:11:24 ezf]
- *
- * Revision 1.2.18.1 1994/06/11 21:12:37 bolinger
- * Merge up to NMK17.2.
- * [1994/06/11 20:03:04 bolinger]
- *
- * Revision 1.2.23.1 1994/12/06 19:43:18 alanl
- * Intel merge, Oct 94 code drop.
- * Added db_find_reg_name (came from db_print.c).
- * [94/11/28 mmp]
- *
- * Revision 1.2.16.1 1994/02/08 10:59:08 bernadat
- * Added completion variable.
- * [93/08/17 paire]
- *
- * Set up new fields (hidden_xxx) of db_vars[] array that are supposed
- * to be helpful to display variables depending on an internal value
- * like db_macro_level for macro arguments.
- * Added db_auto_wrap as new variable.
- * Added "set help" for listing all available variables.
- * Added db_show_variable() and db_show_one_variable()
- * to print variable values.
- * [93/08/12 paire]
- * [94/02/08 bernadat]
- *
- * Revision 1.2.4.4 1993/08/11 20:38:20 elliston
- * Add ANSI Prototypes. CR #9523.
- * [1993/08/11 03:34:13 elliston]
- *
- * Revision 1.2.4.3 1993/07/27 18:28:27 elliston
- * Add ANSI prototypes. CR #9523.
- * [1993/07/27 18:13:22 elliston]
- *
- * Revision 1.2.4.2 1993/06/09 02:21:02 gm
- * Added to OSF/1 R1.3 from NMK15.0.
- * [1993/06/02 20:57:43 jeffc]
- *
- * Revision 1.2 1993/04/19 16:03:25 devrcs
- * Changes from mk78:
- * Added void to db_read_write_variable().
- * Removed unused variable 'func' from db_set_cmd().
- * [92/05/16 jfriedl]
- * [93/02/02 bruel]
- *
- * Print old value when changing register values.
- * [barbou@gr.osf.org]
- * [92/12/03 bernadat]
- *
- * Revision 1.1 1992/09/30 02:01:31 robert
- * Initial revision
- *
- * $EndLog$
- */
-/* CMU_HIST */
-/*
- * Revision 2.5 91/10/09 16:03:59 af
- * Revision 2.4.3.1 91/10/05 13:08:27 jeffreyh
- * Added suffix handling and thread handling of variables.
- * Added new variables: lines, task, thread, work and arg.
- * Moved db_read_variable and db_write_variable to db_variables.h
- * as macros, and added db_read_write_variable instead.
- * Changed some error messages.
- * [91/08/29 tak]
- *
- * Revision 2.4.3.1 91/10/05 13:08:27 jeffreyh
- * Added suffix handling and thread handling of variables.
- * Added new variables: lines, task, thread, work and arg.
- * Moved db_read_variable and db_write_variable to db_variables.h
- * as macros, and added db_read_write_variable instead.
- * Changed some error messages.
- * [91/08/29 tak]
- *
- * Revision 2.4 91/05/14 15:36:57 mrt
- * Correcting copyright
- *
- * Revision 2.3 91/02/05 17:07:19 mrt
- * Changed to new Mach copyright
- * [91/01/31 16:19:46 mrt]
- *
- * Revision 2.2 90/08/27 21:53:24 dbg
- * New db_read/write_variable functions. Should be used instead
- * of dereferencing valuep directly, which might not be a true
- * pointer if there is an fcn() access function.
- * [90/08/20 af]
- *
- * Fix declarations.
- * Check for trailing garbage after last expression on command line.
- * [90/08/10 14:34:54 dbg]
- *
- * Created.
- * [90/07/25 dbg]
- *
- */
-/* CMU_ENDHIST */
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
#include <ddb/db_macro.h>
#include <ddb/db_output.h> /* For db_printf() */
-extern db_expr_t db_radix;
extern db_expr_t db_max_width;
extern db_expr_t db_tab_stop_width;
extern db_expr_t db_max_line;
db_expr_t db_work[DB_NWORK]; /* work variable */
struct db_variable db_vars[] = {
- { "maxoff", (db_expr_t*)&db_maxoff, FCN_NULL },
- { "autowrap", &db_auto_wrap, FCN_NULL },
- { "completion", &db_auto_completion, FCN_NULL },
- { "maxwidth", &db_max_width, FCN_NULL },
- { "radix", &db_radix, FCN_NULL },
- { "tabstops", &db_tab_stop_width, FCN_NULL },
- { "lines", &db_max_line, FCN_NULL },
- { "thr_act", 0, db_set_default_act },
- { "task", 0, db_get_task_act,
- 1, 2, -1, -1 },
- { "work", &db_work[0], FCN_NULL,
- 1, 1, 0, DB_NWORK-1 },
- { "arg", 0, db_arg_variable,
- 1, 1, 1, DB_MACRO_NARGS,
- 1, 0, DB_MACRO_LEVEL-1, (int *)&db_macro_level },
+ {
+ .name = "maxoff",
+ .valuep = (db_expr_t*)&db_maxoff,
+ },
+ {
+ .name = "autowrap",
+ .valuep = &db_auto_wrap,
+ },
+ {
+ .name = "completion",
+ .valuep = &db_auto_completion,
+ },
+ {
+ .name = "maxwidth",
+ .valuep = &db_max_width,
+ },
+ {
+ .name = "radix",
+ .valuep = &db_radix,
+ },
+ {
+ .name = "tabstops",
+ .valuep = &db_tab_stop_width,
+ },
+ {
+ .name = "lines",
+ .valuep = &db_max_line,
+ },
+ {
+ .name = "thr_act",
+ .fcn = db_set_default_act,
+ },
+ {
+ .name = "task",
+ .fcn = db_get_task_act,
+ .min_level = 1,
+ .max_level = 2,
+ .low = -1,
+ .high = -1,
+ },
+ {
+ .name = "work",
+ .valuep = &db_work[0],
+ .min_level = 1,
+ .max_level = 1,
+ .high = DB_NWORK - 1,
+ },
+ {
+ .name = "arg",
+ .fcn = db_arg_variable,
+ .min_level = 1,
+ .max_level = 1,
+ .low = 1,
+ .high = DB_MACRO_NARGS,
+ .hidden_level = 1,
+ .hidden_low = 0,
+ .hidden_high = DB_MACRO_LEVEL - 1,
+ .hidden_levelp = (int *)&db_macro_level,
+ },
};
struct db_variable *db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]);
/* Prototypes for functions local to this file.
*/
-static char *db_get_suffix(
- register char *suffix,
- short *suffix_value);
+static const char *db_get_suffix(const char *, short *);
-static boolean_t db_cmp_variable_name(
- struct db_variable *vp,
- char *name,
- register db_var_aux_param_t ap);
+static boolean_t db_cmp_variable_name(struct db_variable *, const char *,
+ db_var_aux_param_t);
static int db_find_variable(
struct db_variable **varp,
db_var_aux_param_t ap);
-static int db_set_variable(db_expr_t value);
-
void db_list_variable(void);
-static char *
-db_get_suffix(
- register char *suffix,
- short *suffix_value)
+static const char *
+db_get_suffix(const char *suffix, short *suffix_value)
{
register int value;
}
static boolean_t
-db_cmp_variable_name(
- struct db_variable *vp,
- char *name,
- register db_var_aux_param_t ap)
+db_cmp_variable_name(struct db_variable *vp, const char *name,
+ db_var_aux_param_t ap)
{
- register char *var_np, *np;
- register int level;
+ const char *var_np, *np;
+ int level;
for (np = name, var_np = vp->name; *var_np; ) {
if (*np++ != *var_np++)
|| (vp->high >= 0 && ap->suffix[0] > vp->high))))
return(FALSE);
strcpy(ap->modif, (*np)? np+1: "");
- ap->thr_act = (db_option(ap->modif, 't')?db_default_act: THR_ACT_NULL);
+ ap->thr_act = (db_option(ap->modif, 't')?db_default_act: THREAD_NULL);
ap->level = level;
ap->hidden_level = -1;
return(TRUE);
return (1);
}
-static int
-db_set_variable(db_expr_t value)
-{
- struct db_variable *vp;
- struct db_var_aux_param aux_param;
- char modif[TOK_STRING_SIZE];
-
- aux_param.modif = modif;
- if (!db_find_variable(&vp, &aux_param))
- return (0);
-
- db_read_write_variable(vp, &value, DB_VAR_SET, &aux_param);
-
- return (1);
-}
-
void
db_read_write_variable(
struct db_variable *vp,
if (ap == 0) {
ap = &aux_param;
- ap->modif = "";
+ ap->modif = NULL;
ap->level = 0;
- ap->thr_act = THR_ACT_NULL;
+ ap->thr_act = THREAD_NULL;
}
if (rw_flag == DB_VAR_SET && vp->precious)
db_read_write_variable(vp, &old_value, DB_VAR_GET, ap);
} else
(*func)(vp, valuep, rw_flag, ap);
if (rw_flag == DB_VAR_SET && vp->precious)
- db_printf("\t$%s:%s<%#x>\t%#8n\t=\t%#8n\n", vp->name,
- ap->modif, ap->thr_act, old_value, *valuep);
+ db_printf("\t$%s:%s<%#x>\t%#8lln\t=\t%#8lln\n", vp->name,
+ ap->modif, ap->thr_act, (unsigned long long)old_value, (unsigned long long)*valuep);
}
void
struct db_variable *cur;
unsigned int len;
unsigned int sl;
- unsigned int slen;
- short h;
+ unsigned int slen = 0;
+ short h = 0;
short i;
- short j;
+ unsigned short j;
short k;
short low;
- int hidden_level;
+ int hidden_level = 0;
struct db_var_aux_param aux_param;
- char *p;
- char *q;
+ const char *p = NULL, *q;
char *name;
- db_addr_t offset;
+ db_addr_t offset = 0;
for (cur = db_vars; cur < db_evars; cur++)
if (db_cmp_variable_name(cur, db_tok_string, &aux_param))
strcpy(aux_param.modif, *p ? p + 1 : "");
aux_param.thr_act = (db_option(aux_param.modif, 't') ?
- db_default_act : THR_ACT_NULL);
+ db_default_act : THREAD_NULL);
}
if (cur->hidden_level)
aux_param.suffix[0] = i;
(*cur->fcn)(cur, (db_expr_t *)0, DB_VAR_SHOW, &aux_param);
} else {
- db_printf("%#n", *(cur->valuep + i));
+ db_printf("%#lln", (unsigned long long)*(cur->valuep + i));
db_find_xtrn_task_sym_and_offset(*(cur->valuep + i), &name,
&offset, TASK_NULL);
if (name != (char *)0 && offset <= db_maxoff &&
offset != *(cur->valuep + i)) {
db_printf("\t%s", name);
if (offset != 0)
- db_printf("+%#r", offset);
+ db_printf("+%#llr", (unsigned long long)offset);
}
}
db_putchar('\n');
}
void
-db_show_variable(void)
+db_show_variable(__unused db_expr_t addr, __unused boolean_t have_addr,
+ __unused db_expr_t count, __unused char *modif)
{
struct db_variable *cur;
unsigned int l;
unsigned int len;
unsigned int sl;
unsigned int slen;
- short h;
+ short h = 0;
short i;
- short j;
+ unsigned short j;
short k;
int t;
int t1;
len = l + 1;
}
- aux_param.modif = "";
+ aux_param.modif = NULL;
aux_param.level = 1;
- aux_param.thr_act = THR_ACT_NULL;
+ aux_param.thr_act = THREAD_NULL;
for (cur = db_vars; cur < db_evars; cur++) {
i = cur->low;
aux_param.suffix[0] = i;
(*cur->fcn)(cur, (db_expr_t *)0, DB_VAR_SHOW, &aux_param);
} else {
- db_printf("%#n", *(cur->valuep + i));
+ db_printf("%#lln", (unsigned long long)*(cur->valuep + i));
db_find_xtrn_task_sym_and_offset(*(cur->valuep + i), &name,
&offset, TASK_NULL);
if (name != (char *)0 && offset <= db_maxoff &&
offset != *(cur->valuep + i)) {
db_printf("\t%s", name);
if (offset != 0)
- db_printf("+%#r", offset);
+ db_printf("+%#llr", (unsigned long long)offset);
}
}
db_putchar('\n');