X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/8f6c56a50524aa785f7e596d52dddfb331e18961..7ee9d059c4eecf68ae4f8b0fb99ae2471eda79af:/osfmk/ddb/db_variables.c diff --git a/osfmk/ddb/db_variables.c b/osfmk/ddb/db_variables.c index e1241672d..f30e5cad4 100644 --- a/osfmk/ddb/db_variables.c +++ b/osfmk/ddb/db_variables.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -72,7 +72,6 @@ #include #include /* 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; @@ -85,21 +84,65 @@ extern db_expr_t db_auto_completion; 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]); @@ -108,27 +151,19 @@ 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; @@ -144,13 +179,11 @@ db_get_suffix( } 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++) @@ -164,7 +197,7 @@ db_cmp_variable_name( || (level > 0 && (ap->suffix[0] < vp->low || (vp->high >= 0 && ap->suffix[0] > vp->high)))) return(FALSE); - strcpy(ap->modif, (*np)? np+1: ""); + strlcpy(ap->modif, (*np)? np+1: "", TOK_STRING_SIZE); ap->thr_act = (db_option(ap->modif, 't')?db_default_act: THREAD_NULL); ap->level = level; ap->hidden_level = -1; @@ -223,22 +256,6 @@ db_get_variable(db_expr_t *valuep) 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, @@ -253,7 +270,7 @@ db_read_write_variable( if (ap == 0) { ap = &aux_param; - ap->modif = ""; + ap->modif = NULL; ap->level = 0; ap->thr_act = THREAD_NULL; } @@ -395,18 +412,17 @@ db_show_one_variable(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)) @@ -435,7 +451,7 @@ db_show_one_variable(void) return; } - strcpy(aux_param.modif, *p ? p + 1 : ""); + strlcpy(aux_param.modif, *p ? p + 1 : "", TOK_STRING_SIZE); aux_param.thr_act = (db_option(aux_param.modif, 't') ? db_default_act : THREAD_NULL); } @@ -535,16 +551,17 @@ db_show_one_variable(void) } 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; @@ -598,7 +615,7 @@ db_show_variable(void) len = l + 1; } - aux_param.modif = ""; + aux_param.modif = NULL; aux_param.level = 1; aux_param.thr_act = THREAD_NULL;