124 else if (var_type_uses<auto_boolean> (s->
type))
133 gdb_assert_not_reached (
"unhandled var type");
157 const char *func_name);
172 scm_puts (
" {invalid}", port);
177 scm_display (
value, port);
179 scm_puts (
">", port);
181 scm_remember_upto_here_1 (self);
196 memset (p_smob, 0,
sizeof (*p_smob));
262 return xstrdup (_(
"This command is not documented."));
275 gdb::unique_xmalloc_ptr<char> excp_text
278 error (
"%s", excp_text.get ());
296 SCM self, result, exception;
307 _(
"Error occurred setting parameter."));
310 if (!scm_is_string (result))
311 error (_(
"Result of %s set-func is not a string."), p_smob->
name);
318 error (_(
"Error converting show text to host string."));
322 if (*msg.get () !=
'\0')
336 SCM value_scm, self, result, exception;
343 error (_(
"Error converting parameter value \"%s\" to Scheme string."),
354 _(
"Error occurred showing parameter."));
362 error (_(
"Error converting show text to host string."));
374 char *set_doc,
char *show_doc,
char *help_doc,
387 show_doc, help_doc, set_func,
388 show_func, set_list, show_list);
394 set_doc, show_doc, help_doc,
395 set_func, show_func, set_list,
402 show_doc, help_doc, set_func,
403 show_func, set_list, show_list);
409 show_doc, help_doc, set_func,
410 show_func, set_list, show_list);
416 show_doc, help_doc, set_func,
417 show_func, set_list, show_list);
432 show_doc, help_doc, set_func,
433 show_func, set_list, show_list);
439 set_doc, show_doc, help_doc,
440 set_func, show_func, set_list,
448 set_doc, show_doc, help_doc,
450 set_list, show_list);
456 show_doc, help_doc, set_func,
457 show_func, set_list, show_list);
465 show_doc, help_doc, set_func, show_func,
466 set_list, show_list);
470 gdb_assert_not_reached (
"bad param_type value");
486static const char *
const *
491 const char *
const *result;
494 enum_values_scm, arg_pos, func_name, _(
"list"));
496 size = scm_ilength (enum_values_scm);
500 _(
"enumeration list is empty"));
503 enum_values = XCNEWVEC (
char *,
size + 1);
506 while (!scm_is_eq (enum_values_scm, SCM_EOL))
508 SCM
value = scm_car (enum_values_scm);
511 if (!scm_is_string (
value))
513 freeargv (enum_values);
514 SCM_ASSERT_TYPE (0,
value, arg_pos, func_name, _(
"string"));
517 &exception).release ();
518 if (enum_values[i] == NULL)
520 freeargv (enum_values);
524 enum_values_scm = scm_cdr (enum_values_scm);
526 gdb_assert (i ==
size);
529 freeargv (enum_values);
581 gdb_assert_not_reached (
"bad parameter type");
602 const std::string &str = var.
get<std::string> ();
608 const char *str = var.
get<
const char *> ();
616 if (var.
get<
bool> ())
635 if (var.
get<
int> () == -1)
637 gdb_assert (var.
get<
int> () >= 0);
640 return scm_from_int (var.
get<
int> ());
647 return scm_from_uint (var.
get<
unsigned int> ());
654 scm_from_int (var.
type ()),
655 _(
"program error: unhandled type"));
664 const char *
const *enumeration,
665 SCM
value,
int arg_pos,
const char *func_name)
675 SCM_ASSERT_TYPE (scm_is_string (
value)
678 value, arg_pos, func_name,
679 _(
"string or #f for non-PARAM_FILENAME parameters"));
681 var.
set<std::string> (
"");
686 gdb::unique_xmalloc_ptr<char>
string
688 if (
string ==
nullptr)
690 var.
set<std::string> (
string.release ());
699 SCM_ASSERT_TYPE (scm_is_string (
value),
value, arg_pos, func_name,
701 gdb::unique_xmalloc_ptr<char> str
705 for (i = 0; enumeration[i]; ++i)
707 if (strcmp (enumeration[i], str.get ()) == 0)
710 if (enumeration[i] ==
nullptr)
713 _(
"not member of enumeration"));
715 var.
set<
const char *> (enumeration[i]);
728 value, arg_pos, func_name,
729 _(
"boolean or #:auto"));
745 SCM_ASSERT_TYPE (scm_is_integer (
value)
747 value, arg_pos, func_name,
748 _(
"integer or #:unlimited"));
760 SCM_ASSERT_TYPE (scm_is_integer (
value),
value, arg_pos, func_name,
767 unsigned int u = scm_to_uint (
value);
771 var.
set<
unsigned int> (u);
775 int i = scm_to_int (
value);
787 gdb_assert_not_reached (
"bad parameter type");
848 const SCM keywords[] = {
854 int cmd_class_arg_pos = -1, param_type_arg_pos = -1;
855 int enum_list_arg_pos = -1, set_func_arg_pos = -1, show_func_arg_pos = -1;
856 int doc_arg_pos = -1, set_doc_arg_pos = -1, show_doc_arg_pos = -1;
857 int initial_value_arg_pos = -1;
862 SCM enum_list_scm = SCM_BOOL_F;
863 SCM set_func = SCM_BOOL_F, show_func = SCM_BOOL_F;
864 char *doc = NULL, *set_doc = NULL, *show_doc = NULL;
865 SCM initial_value_scm = SCM_BOOL_F;
866 const char *
const *enum_list = NULL;
871 name_scm, &
name, rest,
872 &cmd_class_arg_pos, &cmd_class,
873 ¶m_type_arg_pos, ¶m_type,
874 &enum_list_arg_pos, &enum_list_scm,
875 &set_func_arg_pos, &set_func,
876 &show_func_arg_pos, &show_func,
878 &set_doc_arg_pos, &set_doc,
879 &show_doc_arg_pos, &show_doc,
880 &initial_value_arg_pos, &initial_value_scm);
885 if (show_doc == NULL)
907 scm_from_int (cmd_class),
908 _(
"invalid command class argument"));
913 scm_from_int (param_type),
914 _(
"invalid parameter type argument"));
916 if (enum_list_arg_pos > 0 && param_type !=
var_enum)
919 _(
"#:enum-values can only be provided with PARAM_ENUM"));
921 if (enum_list_arg_pos < 0 && param_type ==
var_enum)
924 _(
"PARAM_ENUM requires an enum-values argument"));
926 if (set_func_arg_pos > 0)
929 set_func_arg_pos,
FUNC_NAME, _(
"procedure"));
931 if (show_func_arg_pos > 0)
934 show_func_arg_pos,
FUNC_NAME, _(
"procedure"));
948 p_smob = (
param_smob *) SCM_SMOB_DATA (p_scm);
965 if (initial_value_arg_pos > 0)
1009 scm_misc_error (
FUNC_NAME, _(
"parameter is already registered"), SCM_EOL);
1022 _(
"parameter exists, \"set\" command is already defined"));
1027 _(
"parameter exists, \"show\" command is already defined"));
1038 set_list, show_list);
1040 catch (
const gdb_exception &except)
1053 return SCM_UNSPECIFIED;
1063 self, SCM_ARG1,
FUNC_NAME, _(
"<gdb:parameter> or string"));
1080 gdb::unique_xmalloc_ptr<char>
name
1084 newarg = concat (
"show ",
name.get (), (
char *) NULL);
1089 catch (
const gdb_exception &ex)
1099 _(
"parameter not found"));
1102 if (!cmd->
var.has_value ())
1105 _(
"not a parameter"));
1123 return SCM_UNSPECIFIED;
1132Make a GDB parameter object.\n\
1135 [#:command-class <cmd-class>] [#:parameter-type <parameter-type>]\n\
1136 [#:enum-list <enum-list>]\n\
1137 [#:set-func function] [#:show-func function]\n\
1138 [#:doc string] [#:set-doc string] [#:show-doc string]\n\
1139 [#:initial-value initial-value]\n\
1140 name: The name of the command. It may consist of multiple words,\n\
1141 in which case the final word is the name of the new parameter, and\n\
1142 earlier words must be prefix commands.\n\
1143 cmd-class: The class of the command, one of COMMAND_*.\n\
1144 The default is COMMAND_NONE.\n\
1145 parameter-type: The kind of parameter, one of PARAM_*\n\
1146 The default is PARAM_BOOLEAN.\n\
1147 enum-list: If parameter-type is PARAM_ENUM, then this specifies the set\n\
1148 of values of the enum.\n\
1149 set-func: A function of one parameter: the <gdb:parameter> object.\n\
1150 Called *after* the parameter has been set. Returns either \"\" or a\n\
1151 non-empty string to be displayed to the user.\n\
1152 If non-empty, GDB will add a trailing newline.\n\
1153 show-func: A function of two parameters: the <gdb:parameter> object\n\
1154 and the string representation of the current value.\n\
1155 The result is a string to be displayed to the user.\n\
1156 GDB will add a trailing newline.\n\
1157 doc: The \"doc string\" of the parameter.\n\
1158 set-doc: The \"doc string\" when setting the parameter.\n\
1159 show-doc: The \"doc string\" when showing the parameter.\n\
1160 initial-value: The initial value of the parameter." },
1162 {
"register-parameter!", 1, 0, 0,
1165Register a <gdb:parameter> object with GDB." },
1169Return #t if the object is a <gdb:parameter> object." },
1173Return the value of a <gdb:parameter> object\n\
1174or any gdb parameter if param is a string naming the parameter." },
1176 {
"set-parameter-value!", 2, 0, 0,
1179Set the value of a <gdb:parameter> object.\n\
1181 Arguments: <gdb:parameter> value" },
static struct parser_state * pstate
struct cmd_list_element * showlist
struct cmd_list_element * setlist
set_show_commands add_setshow_filename_cmd(const char *name, enum command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands 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_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands 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_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands add_setshow_optional_filename_cmd(const char *name, enum command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * lookup_cmd_1(const char **text, struct cmd_list_element *clist, struct cmd_list_element **result_list, std::string *default_args, int ignore_help_classes, bool lookup_for_completion_p)
set_show_commands add_setshow_string_cmd(const char *name, enum command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands 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_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands 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_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands add_setshow_string_noescape_cmd(const char *name, enum command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands 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_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
int lookup_cmd_composition(const char *text, struct cmd_list_element **alias, struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd)
set_show_commands 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_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
#define CMD_LIST_AMBIGUOUS
bool var_type_uses< bool >(var_types t)
void() show_value_ftype(struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value)
@ var_zuinteger_unlimited
void cmd_func_ftype(const char *args, int from_tty, cmd_list_element *c)
bool var_type_uses< std::string >(var_types t)
bool var_type_uses< int >(var_types t)
bool var_type_uses< const char * >(var_types t)
bool var_type_uses< unsigned int >(var_types t)
SCM gdbscm_make_out_of_range_error(const char *subr, int arg_pos, SCM bad_value, const char *error)
#define gdbscm_is_true(scm)
void gdbscm_parse_function_args(const char *function_name, int beginning_arg_pos, const SCM *keywords, const char *format,...)
#define END_INTEGER_CONSTANTS
gdbscm_gdb_exception unpack(const gdb_exception &exc)
void gdbscm_misc_error(const char *subr, int arg_pos, SCM bad_value, const char *error) ATTRIBUTE_NORETURN
int gdbscm_is_procedure(SCM proc)
void gdbscm_init_gsmob(gdb_smob *base)
void gdbscm_print_gdb_exception(SCM port, SCM exception)
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)
char * gdbscm_gc_xstrdup(const char *)
gdb::unique_xmalloc_ptr< char > gdbscm_exception_message_to_string(SCM exception)
SCM gdbscm_exception_key(SCM excp)
void gdbscm_out_of_range_error(const char *subr, int arg_pos, SCM bad_value, const char *error) ATTRIBUTE_NORETURN
SCM gdbscm_safe_call_2(SCM proc, SCM arg0, SCM arg1, excp_matcher_func *ok_excps)
SCM gdbscm_safe_call_1(SCM proc, SCM arg0, excp_matcher_func *ok_excps)
char * gdbscm_canonicalize_command_name(const char *name, int want_trailing_space)
#define gdbscm_is_false(scm)
#define gdbscm_is_bool(scm)
void gdbscm_printf(SCM port, const char *format,...) ATTRIBUTE_PRINTF(2
void gdbscm_define_integer_constants(const scheme_integer_constant *, int is_public)
static SCM scm_new_smob(scm_t_bits tc, scm_t_bits data)
int gdbscm_is_exception(SCM scm)
void gdbscm_define_functions(const scheme_function *, int is_public)
#define GDBSCM_HANDLE_GDB_EXCEPTION(exception)
int gdbscm_valid_command_class_p(int command_class)
scm_t_bits gdbscm_make_smob_type(const char *name, size_t size)
const char *const * gdbscm_gc_dup_argv(char **argv)
void gdbscm_throw(SCM exception) ATTRIBUTE_NORETURN
gdb::unique_xmalloc_ptr< char > gdbscm_scm_to_host_string(SCM string, size_t *lenp, SCM *except)
SCM gdbscm_scm_from_host_string(const char *string, size_t len)
static scm_t_subr as_a_scm_t_subr(SCM(*func)(void))
excp_matcher_func gdbscm_user_error_p
#define prefix(a, b, R, do)
static SCM show_func_keyword
static const scheme_integer_constant parameter_types[]
static SCM enum_list_keyword
static int pascm_print_param_smob(SCM self, SCM port, scm_print_state *pstate)
static set_show_commands 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_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void gdbscm_initialize_parameters(void)
static void pascm_set_func(const char *args, int from_tty, struct cmd_list_element *c)
static SCM unlimited_keyword
static SCM pascm_param_value(const setting &var, int arg_pos, const char *func_name)
static SCM gdbscm_register_parameter_x(SCM self)
static scm_t_bits parameter_smob_tag
static const scheme_function parameter_functions[]
static size_t pascm_free_parameter_smob(SCM self)
static SCM pascm_make_param_smob(void)
static setting make_setting(param_smob *s)
static param_smob * pascm_get_param_smob_arg_unsafe(SCM self, int arg_pos, const char *func_name)
static int pascm_is_parameter(SCM scm)
static SCM show_doc_keyword
static SCM gdbscm_set_parameter_value_x(SCM self, SCM value)
static const char * pascm_param_type_name(enum var_types type)
static SCM parameter_type_keyword
static SCM command_class_keyword
static SCM initial_value_keyword
static void pascm_set_param_value_x(param_smob *p_smob, const char *const *enumeration, SCM value, int arg_pos, const char *func_name)
static const char param_smob_name[]
static SCM pascm_get_param_arg_unsafe(SCM self, int arg_pos, const char *func_name)
static SCM gdbscm_make_parameter(SCM name_scm, SCM rest)
static int pascm_valid_parameter_type_p(int param_type)
static void pascm_show_func(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static SCM set_doc_keyword
static void pascm_signal_setshow_error(SCM exception, const char *msg)
static int pascm_is_valid(param_smob *)
static SCM gdbscm_parameter_p(SCM scm)
static SCM gdbscm_parameter_value(SCM self)
static SCM set_func_keyword
static char * get_doc_string(void)
static int pascm_parameter_defined_p(const char *name, struct cmd_list_element *list)
static const char *const * compute_enum_list(SCM enum_values_scm, int arg_pos, const char *func_name)
gdb::optional< setting > var
void set_context(void *context)
union pascm_variable value
enum command_class cmd_class
set_show_commands commands
const char *const * enumeration
setting_func_types< T >::type get() const
enum auto_boolean autoboolval
void gdb_printf(struct ui_file *stream, const char *format,...)