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"));
506 enum_values =
xmalloc ((size + 1) *
sizeof (
char *));
507 memset (enum_values, 0, (size + 1) *
sizeof (
char *));
510 while (!scm_is_eq (enum_values_scm, SCM_EOL))
512 SCM
value = scm_car (enum_values_scm);
515 if (!scm_is_string (value))
517 freeargv (enum_values);
518 SCM_ASSERT_TYPE (0, value, arg_pos, func_name,
_(
"string"));
521 if (enum_values[i] == NULL)
523 freeargv (enum_values);
527 enum_values_scm = scm_cdr (enum_values_scm);
532 freeargv (enum_values);
562 for (i = 0; parameter_types[i].
name != NULL; ++i)
564 if (parameter_types[i].
value == param_type)
578 for (i = 0; parameter_types[i].
name != NULL; ++i)
580 if (parameter_types[i].
value == param_type)
581 return parameter_types[i].
name;
592 int arg_pos,
const char *func_name)
606 char *str = * (
char **) var;
634 if (* (
int *) var == -1)
639 return scm_from_int (* (
int *) var);
642 if (* (
unsigned int *) var ==
UINT_MAX)
646 return scm_from_uint (* (
unsigned int *) var);
654 _(
"program error: unhandled type"));
663 const char *
const *enumeration,
664 SCM
value,
int arg_pos,
const char *func_name)
672 SCM_ASSERT_TYPE (scm_is_string (value)
675 value, arg_pos, func_name,
676 _(
"string or #f for non-PARAM_FILENAME parameters"));
704 SCM_ASSERT_TYPE (scm_is_string (value), value, arg_pos, func_name,
709 for (i = 0; enumeration[i]; ++i)
711 if (strcmp (enumeration[i], str) == 0)
715 if (enumeration[i] == NULL)
718 _(
"not member of enumeration"));
725 SCM_ASSERT_TYPE (
gdbscm_is_bool (value), value, arg_pos, func_name,
733 value, arg_pos, func_name,
734 _(
"boolean or #:auto"));
752 value, arg_pos, func_name,
753 _(
"integer or #:unlimited"));
765 SCM_ASSERT_TYPE (scm_is_integer (value), value, arg_pos, func_name,
772 unsigned int u = scm_to_uint (value);
780 int i = scm_to_int (value);
838 const SCM keywords[] = {
844 int cmd_class_arg_pos = -1, param_type_arg_pos = -1;
845 int enum_list_arg_pos = -1, set_func_arg_pos = -1, show_func_arg_pos = -1;
846 int doc_arg_pos = -1, set_doc_arg_pos = -1, show_doc_arg_pos = -1;
847 int initial_value_arg_pos = -1;
852 SCM enum_list_scm = SCM_BOOL_F;
853 SCM set_func = SCM_BOOL_F, show_func = SCM_BOOL_F;
854 char *
doc = NULL, *set_doc = NULL, *show_doc = NULL;
855 SCM initial_value_scm = SCM_BOOL_F;
856 const char *
const *enum_list = NULL;
861 name_scm, &name, rest,
862 &cmd_class_arg_pos, &cmd_class,
863 ¶m_type_arg_pos, ¶m_type,
864 &enum_list_arg_pos, &enum_list_scm,
865 &set_func_arg_pos, &set_func,
866 &show_func_arg_pos, &show_func,
868 &set_doc_arg_pos, &set_doc,
869 &show_doc_arg_pos, &show_doc,
870 &initial_value_arg_pos, &initial_value_scm);
875 if (show_doc == NULL)
897 scm_from_int (cmd_class),
898 _(
"invalid command class argument"));
903 scm_from_int (param_type),
904 _(
"invalid parameter type argument"));
906 if (enum_list_arg_pos > 0 && param_type !=
var_enum)
909 _(
"#:enum-values can only be provided with PARAM_ENUM"));
911 if (enum_list_arg_pos < 0 && param_type ==
var_enum)
914 _(
"PARAM_ENUM requires an enum-values argument"));
916 if (set_func_arg_pos > 0)
921 if (show_func_arg_pos > 0)
924 show_func_arg_pos,
FUNC_NAME,
_(
"procedure"));
938 p_smob = (
param_smob *) SCM_SMOB_DATA (p_scm);
951 if (initial_value_arg_pos > 0)
995 scm_misc_error (
FUNC_NAME,
_(
"parameter is already registered"), SCM_EOL);
1008 _(
"parameter exists, \"set\" command is already defined"));
1013 _(
"parameter exists, \"show\" command is already defined"));
1025 set_list, show_list,
1041 return SCM_UNSPECIFIED;
1051 self, SCM_ARG1,
FUNC_NAME,
_(
"<gdb:parameter> or string"));
1074 newarg = concat (
"show ", name, (
char *) NULL);
1091 _(
"parameter not found"));
1093 if (cmd->
var == NULL)
1096 _(
"not a parameter"));
1114 return SCM_UNSPECIFIED;
1123 Make a GDB parameter object.\n\
1126 [#:command-class <cmd-class>] [#:parameter-type <parameter-type>]\n\
1127 [#:enum-list <enum-list>]\n\
1128 [#:set-func function] [#:show-func function]\n\
1129 [#:doc string] [#:set-doc string] [#:show-doc string]\n\
1130 [#:initial-value initial-value]\n\
1131 name: The name of the command. It may consist of multiple words,\n\
1132 in which case the final word is the name of the new parameter, and\n\
1133 earlier words must be prefix commands.\n\
1134 cmd-class: The class of the command, one of COMMAND_*.\n\
1135 The default is COMMAND_NONE.\n\
1136 parameter-type: The kind of parameter, one of PARAM_*\n\
1137 The default is PARAM_BOOLEAN.\n\
1138 enum-list: If parameter-type is PARAM_ENUM, then this specifies the set\n\
1139 of values of the enum.\n\
1140 set-func: A function of one parameter: the <gdb:parameter> object.\n\
1141 Called *after* the parameter has been set. Returns either \"\" or a\n\
1142 non-empty string to be displayed to the user.\n\
1143 If non-empty, GDB will add a trailing newline.\n\
1144 show-func: A function of two parameters: the <gdb:parameter> object\n\
1145 and the string representation of the current value.\n\
1146 The result is a string to be displayed to the user.\n\
1147 GDB will add a trailing newline.\n\
1148 doc: The \"doc string\" of the parameter.\n\
1149 set-doc: The \"doc string\" when setting the parameter.\n\
1150 show-doc: The \"doc string\" when showing the parameter.\n\
1151 initial-value: The initial value of the parameter." },
1155 Register a <gdb:parameter> object with GDB." },
1159 Return #t if the object is a <gdb:parameter> object." },
1163 Return the value of a <gdb:parameter> object\n\
1164 or any gdb parameter if param is a string naming the parameter." },
1168 Set the value of a <gdb:parameter> object.\n\
1170 Arguments: <gdb:parameter> value" },
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 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 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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void gdbscm_define_functions(const scheme_function *, int is_public)
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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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)
struct ui_file * gdb_stdout
enum command_class cmd_class
const struct gdb_exception exception_none
struct cmd_list_element * set_command
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 * lookup_cmd(const char **line, struct cmd_list_element *list, char *cmdtype, int allow_unknown, int ignore_help_classes)
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)
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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static SCM unlimited_keyword
struct cmd_list_element * setlist
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_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)
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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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)
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
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_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)
excp_matcher_func gdbscm_user_error_p
#define gdb_assert_not_reached(message)
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)
void cmd_sfunc_ftype(char *args, int from_tty, struct cmd_list_element *c)
SCM gdbscm_safe_call_2(SCM proc, SCM arg0, SCM arg1, excp_matcher_func *ok_excps)
void gdbscm_throw(SCM exception) ATTRIBUTE_NORETURN
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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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( show_value_ftype)(struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value)
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 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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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)
static void pascm_set_func(char *args, int from_tty, struct cmd_list_element *c)
void gdbscm_out_of_range_error(const char *subr, int arg_pos, SCM bad_value, const char *error) ATTRIBUTE_NORETURN
static void pascm_signal_setshow_error(SCM exception, const char *msg)
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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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)
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 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 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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void do_cleanups(struct cleanup *old_chain)
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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
char * gdbscm_gc_xstrdup(const char *)
static SCM show_func_keyword
#define END_INTEGER_CONSTANTS