135 int arg_pos,
const char *func_name);
150 scm_puts (
" {invalid}", port);
156 scm_display (
value, port);
158 scm_puts (
">", port);
160 scm_remember_upto_here_1 (
self);
175 memset (p_smob, 0,
sizeof (*p_smob));
181 p_smob->containing_scm = p_scm;
241 return xstrdup (
_(
"This command is not documented."));
257 error (
"%s", excp_text);
275 SCM
self, result, exception;
288 _(
"Error occurred setting parameter."));
291 if (!scm_is_string (result))
292 error (
_(
"Result of %s set-func is not a string."), p_smob->
name);
298 error (
_(
"Error converting show text to host string."));
318 SCM value_scm,
self, result, exception;
327 error (
_(
"Error converting parameter value \"%s\" to Scheme string."),
338 _(
"Error occurred showing parameter."));
345 error (
_(
"Error converting show text to host string."));
359 char *set_doc,
char *show_doc,
char *help_doc,
368 const char *tmp_name = NULL;
375 set_doc, show_doc, help_doc,
377 set_list, show_list);
383 &self->value.autoboolval,
384 set_doc, show_doc, help_doc,
386 set_list, show_list);
391 &self->value.uintval,
392 set_doc, show_doc, help_doc,
394 set_list, show_list);
400 set_doc, show_doc, help_doc,
402 set_list, show_list);
407 &self->value.uintval,
408 set_doc, show_doc, help_doc,
410 set_list, show_list);
416 set_doc, show_doc, help_doc,
418 set_list, show_list);
423 &self->value.stringval,
424 set_doc, show_doc, help_doc,
426 set_list, show_list);
431 &self->value.stringval,
432 set_doc, show_doc, help_doc,
434 set_list, show_list);
440 &self->value.stringval,
441 set_doc, show_doc, help_doc,
443 set_list, show_list);
448 &self->value.stringval,
449 set_doc, show_doc, help_doc,
451 set_list, show_list);
457 &self->value.cstringval,
458 set_doc, show_doc, help_doc,
460 set_list, show_list);
462 self->value.cstringval =
self->enumeration[0];
472 param =
lookup_cmd (&tmp_name, *show_list,
"", 0, 1);
478 param =
lookup_cmd (&tmp_name, *set_list,
"", 0, 1);
489 static const char *
const *
494 const char *
const *result;
497 enum_values_scm, arg_pos, func_name,
_(
"list"));
499 size = scm_ilength (enum_values_scm);
503 _(
"enumeration list is empty"));
509 while (!scm_is_eq (enum_values_scm, SCM_EOL))
511 SCM
value = scm_car (enum_values_scm);
514 if (!scm_is_string (
value))
516 freeargv (enum_values);
517 SCM_ASSERT_TYPE (0,
value, arg_pos, func_name,
_(
"string"));
520 if (enum_values[i] == NULL)
522 freeargv (enum_values);
526 enum_values_scm = scm_cdr (enum_values_scm);
531 freeargv (enum_values);
591 int arg_pos,
const char *func_name)
605 const char *str = *(
char **)
var;
633 if (* (
int *)
var == -1)
638 return scm_from_int (* (
int *)
var);
645 return scm_from_uint (* (
unsigned int *)
var);
653 _(
"program error: unhandled type"));
662 const char *
const *enumeration,
663 SCM
value,
int arg_pos,
const char *func_name)
671 SCM_ASSERT_TYPE (scm_is_string (
value)
674 value, arg_pos, func_name,
675 _(
"string or #f for non-PARAM_FILENAME parameters"));
680 var->stringval = xstrdup (
"");
682 var->stringval = NULL;
703 SCM_ASSERT_TYPE (scm_is_string (
value),
value, arg_pos, func_name,
708 for (i = 0; enumeration[i]; ++i)
710 if (strcmp (enumeration[i], str) == 0)
714 if (enumeration[i] == NULL)
717 _(
"not member of enumeration"));
719 var->cstringval = enumeration[i];
732 value, arg_pos, func_name,
733 _(
"boolean or #:auto"));
751 value, arg_pos, func_name,
752 _(
"integer or #:unlimited"));
764 SCM_ASSERT_TYPE (scm_is_integer (
value),
value, arg_pos, func_name,
771 unsigned int u = scm_to_uint (
value);
779 int i = scm_to_int (
value);
837 const SCM keywords[] = {
843 int cmd_class_arg_pos = -1, param_type_arg_pos = -1;
844 int enum_list_arg_pos = -1, set_func_arg_pos = -1, show_func_arg_pos = -1;
845 int doc_arg_pos = -1, set_doc_arg_pos = -1, show_doc_arg_pos = -1;
846 int initial_value_arg_pos = -1;
851 SCM enum_list_scm = SCM_BOOL_F;
852 SCM set_func = SCM_BOOL_F, show_func = SCM_BOOL_F;
853 char *
doc = NULL, *set_doc = NULL, *show_doc = NULL;
854 SCM initial_value_scm = SCM_BOOL_F;
855 const char *
const *enum_list = NULL;
860 name_scm, &
name, rest,
861 &cmd_class_arg_pos, &cmd_class,
862 ¶m_type_arg_pos, ¶m_type,
863 &enum_list_arg_pos, &enum_list_scm,
864 &set_func_arg_pos, &set_func,
865 &show_func_arg_pos, &show_func,
867 &set_doc_arg_pos, &set_doc,
868 &show_doc_arg_pos, &show_doc,
869 &initial_value_arg_pos, &initial_value_scm);
874 if (show_doc == NULL)
896 scm_from_int (cmd_class),
897 _(
"invalid command class argument"));
902 scm_from_int (param_type),
903 _(
"invalid parameter type argument"));
905 if (enum_list_arg_pos > 0 && param_type !=
var_enum)
908 _(
"#:enum-values can only be provided with PARAM_ENUM"));
910 if (enum_list_arg_pos < 0 && param_type ==
var_enum)
913 _(
"PARAM_ENUM requires an enum-values argument"));
915 if (set_func_arg_pos > 0)
920 if (show_func_arg_pos > 0)
923 show_func_arg_pos,
FUNC_NAME,
_(
"procedure"));
937 p_smob = (
param_smob *) SCM_SMOB_DATA (p_scm);
950 if (initial_value_arg_pos > 0)
994 scm_misc_error (
FUNC_NAME,
_(
"parameter is already registered"), SCM_EOL);
1007 _(
"parameter exists, \"set\" command is already defined"));
1012 _(
"parameter exists, \"show\" command is already defined"));
1024 set_list, show_list,
1040 return SCM_UNSPECIFIED;
1050 self, SCM_ARG1,
FUNC_NAME,
_(
"<gdb:parameter> or string"));
1072 newarg = concat (
"show ",
name, (
char *) NULL);
1089 _(
"parameter not found"));
1091 if (cmd->
var == NULL)
1094 _(
"not a parameter"));
1112 return SCM_UNSPECIFIED;
1121 Make a GDB parameter object.\n\ 1124 [#:command-class <cmd-class>] [#:parameter-type <parameter-type>]\n\ 1125 [#:enum-list <enum-list>]\n\ 1126 [#:set-func function] [#:show-func function]\n\ 1127 [#:doc string] [#:set-doc string] [#:show-doc string]\n\ 1128 [#:initial-value initial-value]\n\ 1129 name: The name of the command. It may consist of multiple words,\n\ 1130 in which case the final word is the name of the new parameter, and\n\ 1131 earlier words must be prefix commands.\n\ 1132 cmd-class: The class of the command, one of COMMAND_*.\n\ 1133 The default is COMMAND_NONE.\n\ 1134 parameter-type: The kind of parameter, one of PARAM_*\n\ 1135 The default is PARAM_BOOLEAN.\n\ 1136 enum-list: If parameter-type is PARAM_ENUM, then this specifies the set\n\ 1137 of values of the enum.\n\ 1138 set-func: A function of one parameter: the <gdb:parameter> object.\n\ 1139 Called *after* the parameter has been set. Returns either \"\" or a\n\ 1140 non-empty string to be displayed to the user.\n\ 1141 If non-empty, GDB will add a trailing newline.\n\ 1142 show-func: A function of two parameters: the <gdb:parameter> object\n\ 1143 and the string representation of the current value.\n\ 1144 The result is a string to be displayed to the user.\n\ 1145 GDB will add a trailing newline.\n\ 1146 doc: The \"doc string\" of the parameter.\n\ 1147 set-doc: The \"doc string\" when setting the parameter.\n\ 1148 show-doc: The \"doc string\" when showing the parameter.\n\ 1149 initial-value: The initial value of the parameter." },
1151 {
"register-parameter!", 1, 0, 0,
1154 Register a <gdb:parameter> object with GDB." },
1158 Return #t if the object is a <gdb:parameter> object." },
1162 Return the value of a <gdb:parameter> object\n\ 1163 or any gdb parameter if param is a string naming the parameter." },
1165 {
"set-parameter-value!", 2, 0, 0,
1168 Set the value of a <gdb:parameter> object.\n\ 1170 Arguments: <gdb:parameter> value" },
void add_setshow_filename_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void set_cmd_context(struct cmd_list_element *cmd, void *context)
char * gdbscm_canonicalize_command_name(const char *name, int want_trailing_space)
static scm_t_subr as_a_scm_t_subr(SCM(*func)(void))
static const scheme_function parameter_functions[]
static SCM scm_new_smob(scm_t_bits tc, scm_t_bits data)
static int pascm_is_parameter(SCM scm)
struct _param_smob param_smob
void * get_cmd_context(struct cmd_list_element *cmd)
const char *const * gdbscm_gc_dup_argv(char **argv)
void gdbscm_define_functions(const scheme_function *, int is_public)
void add_setshow_auto_boolean_cmd(const char *name, enum command_class theclass, enum auto_boolean *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void cmd_const_sfunc_ftype(const char *args, int from_tty, struct cmd_list_element *c)
static SCM show_doc_keyword
char * gdbscm_scm_to_host_string(SCM string, size_t *lenp, SCM *except)
static SCM gdbscm_set_parameter_value_x(SCM self, SCM value)
void * memset(T *s, int c, size_t n)=delete
enum command_class cmd_class
struct cmd_list_element * lookup_cmd(const char **line, struct cmd_list_element *list, const char *cmdtype, int allow_unknown, int ignore_help_classes)
void add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
const struct gdb_exception exception_none
struct cmd_list_element * set_command
static void add_setshow_generic(enum var_types param_type, enum command_class cmd_class, char *cmd_name, param_smob *self, char *set_doc, char *show_doc, char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list, struct cmd_list_element **set_cmd, struct cmd_list_element **show_cmd)
struct cmd_list_element * lookup_cmd_1(const char **text, struct cmd_list_element *clist, struct cmd_list_element **result_list, int ignore_help_classes)
SCM gdbscm_make_out_of_range_error(const char *subr, int arg_pos, SCM bad_value, const char *error)
scm_t_bits gdbscm_make_smob_type(const char *name, size_t size)
#define gdbscm_is_bool(scm)
static scm_t_bits parameter_smob_tag
static SCM gdbscm_parameter_value(SCM self)
struct cmd_list_element * prefix
int lookup_cmd_composition(const char *text, struct cmd_list_element **alias, struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd)
int gdbscm_is_exception(SCM scm)
#define gdbscm_is_true(scm)
char * gdbscm_parse_command_name(const char *name, const char *func_name, int arg_pos, struct cmd_list_element ***base_list, struct cmd_list_element **start_list)
static const scheme_integer_constant parameter_types[]
static SCM unlimited_keyword
void add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * setlist
void add_setshow_uinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static SCM set_func_keyword
void gdbscm_init_gsmob(gdb_smob *base)
#define CATCH(EXCEPTION, MASK)
char * gdbscm_exception_message_to_string(SCM exception)
static struct parser_state * pstate
void fprintf_filtered(struct ui_file *stream, const char *format,...)
SCM gdbscm_exception_key(SCM excp)
static void pascm_show_func(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
#define gdbscm_is_false(scm)
void add_setshow_zinteger_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static int pascm_parameter_defined_p(const char *name, struct cmd_list_element *list)
SCM gdbscm_scm_from_host_string(const char *string, size_t len)
struct cmd_list_element * showlist
excp_matcher_func gdbscm_user_error_p
#define gdb_assert_not_reached(message)
struct cmd_list_element * add_setshow_string_noescape_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
enum auto_boolean autoboolval
static SCM command_class_keyword
__extension__ enum var_types var_type
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
SCM gdbscm_safe_call_2(SCM proc, SCM arg0, SCM arg1, excp_matcher_func *ok_excps)
void add_setshow_string_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void gdbscm_throw(SCM exception) ATTRIBUTE_NORETURN
static SCM initial_value_keyword
static SCM enum_list_keyword
const char *const * enumeration
#define CMD_LIST_AMBIGUOUS
static SCM gdbscm_register_parameter_x(SCM self)
static const char *const * compute_enum_list(SCM enum_values_scm, int arg_pos, const char *func_name)
static void pascm_set_param_value_x(enum var_types type, union pascm_variable *var, const char *const *enumeration, SCM value, int arg_pos, const char *func_name)
void gdbscm_printf(SCM port, const char *format,...) ATTRIBUTE_PRINTF(2
static const char param_smob_name[]
static SCM set_doc_keyword
static SCM pascm_make_param_smob(void)
union pascm_variable value
SCM gdbscm_safe_call_1(SCM proc, SCM arg0, excp_matcher_func *ok_excps)
void gdbscm_define_integer_constants(const scheme_integer_constant *, int is_public)
static SCM gdbscm_parameter_p(SCM scm)
void gdbscm_misc_error(const char *subr, int arg_pos, SCM bad_value, const char *error) ATTRIBUTE_NORETURN
void gdbscm_print_gdb_exception(SCM port, SCM exception)
static SCM pascm_param_value(enum var_types type, void *var, int arg_pos, const char *func_name)
static char * get_doc_string(void)
void gdbscm_out_of_range_error(const char *subr, int arg_pos, SCM bad_value, const char *error) ATTRIBUTE_NORETURN
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static void pascm_signal_setshow_error(SCM exception, const char *msg)
void gdbscm_parse_function_args(const char *function_name, int beginning_arg_pos, const SCM *keywords, const char *format,...)
static int pascm_is_valid(param_smob *)
static SCM gdbscm_make_parameter(SCM name_scm, SCM rest)
#define GDBSCM_HANDLE_GDB_EXCEPTION(exception)
void add_setshow_optional_filename_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static void pascm_set_func(const char *args, int from_tty, struct cmd_list_element *c)
static param_smob * pascm_get_param_smob_arg_unsafe(SCM self, int arg_pos, const char *func_name)
static const char * pascm_param_type_name(enum var_types type)
struct cmd_list_element * show_command
void gdbscm_initialize_parameters(void)
static int pascm_valid_parameter_type_p(int param_type)
static int pascm_print_param_smob(SCM self, SCM port, scm_print_state *pstate)
int gdbscm_is_procedure(SCM proc)
int gdbscm_valid_command_class_p(int command_class)
void add_setshow_zuinteger_unlimited_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void error(const char *fmt,...)
static SCM parameter_type_keyword
static SCM pascm_get_param_arg_unsafe(SCM self, int arg_pos, const char *func_name)
void do_cleanups(struct cleanup *old_chain)
char * gdbscm_gc_xstrdup(const char *)
static SCM show_func_keyword
#define END_INTEGER_CONSTANTS
void() show_value_ftype(struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value)