175 else if (var_type_uses<auto_boolean> (
type))
184 gdb_assert_not_reached (
"unhandled var type");
207 const char *func_name);
222 scm_puts (
" {invalid}", port);
227 scm_display (
value, port);
229 scm_puts (
">", port);
231 scm_remember_upto_here_1 (self);
246 memset (p_smob, 0,
sizeof (*p_smob));
312 return xstrdup (_(
"This command is not documented."));
325 gdb::unique_xmalloc_ptr<char> excp_text
328 error (
"%s", excp_text.get ());
346 SCM self, result, exception;
357 _(
"Error occurred setting parameter."));
360 if (!scm_is_string (result))
361 error (_(
"Result of %s set-func is not a string."), p_smob->
name);
368 error (_(
"Error converting show text to host string."));
372 if (*msg.get () !=
'\0')
386 SCM value_scm, self, result, exception;
393 error (_(
"Error converting parameter value \"%s\" to Scheme string."),
404 _(
"Error occurred showing parameter."));
412 error (_(
"Error converting show text to host string."));
426 char *set_doc,
char *show_doc,
char *help_doc,
439 show_doc, help_doc, set_func,
440 show_func, set_list, show_list);
446 set_doc, show_doc, help_doc,
447 set_func, show_func, set_list,
455 show_doc, help_doc, set_func,
456 show_func, set_list, show_list);
463 show_doc, help_doc, set_func,
464 show_func, set_list, show_list);
471 show_doc, help_doc, set_func,
472 show_func, set_list, show_list);
478 show_doc, help_doc, set_func,
479 show_func, set_list, show_list);
485 set_doc, show_doc, help_doc,
486 set_func, show_func, set_list,
494 set_doc, show_doc, help_doc,
496 set_list, show_list);
502 show_doc, help_doc, set_func,
503 show_func, set_list, show_list);
511 show_doc, help_doc, set_func, show_func,
512 set_list, show_list);
516 gdb_assert_not_reached (
"bad param_type value");
532static const char *
const *
537 const char *
const *result;
540 enum_values_scm, arg_pos, func_name, _(
"list"));
542 size = scm_ilength (enum_values_scm);
546 _(
"enumeration list is empty"));
549 enum_values = XCNEWVEC (
char *,
size + 1);
552 while (!scm_is_eq (enum_values_scm, SCM_EOL))
554 SCM
value = scm_car (enum_values_scm);
557 if (!scm_is_string (
value))
559 freeargv (enum_values);
560 SCM_ASSERT_TYPE (0,
value, arg_pos, func_name, _(
"string"));
563 &exception).release ();
564 if (enum_values[i] == NULL)
566 freeargv (enum_values);
570 enum_values_scm = scm_cdr (enum_values_scm);
572 gdb_assert (i ==
size);
575 freeargv (enum_values);
625 gdb_assert_not_reached (
"bad parameter type");
642 const std::string &str = var.
get<std::string> ();
648 const char *str = var.
get<
const char *> ();
656 if (var.
get<
bool> ())
680 ?
static_cast<LONGEST
> (var.
get<
unsigned int> ())
681 :
static_cast<LONGEST
> (var.
get<
int> ()));
688 return scm_from_latin1_keyword (l->literal);
690 gdb_assert (
value >= 0);
693 return scm_from_uint (
static_cast<unsigned int> (
value));
695 return scm_from_int (
static_cast<int> (
value));
703 scm_from_int (var.
type ()),
704 _(
"program error: unhandled type"));
713 const char *
const *enumeration,
714 SCM
value,
int arg_pos,
const char *func_name)
724 SCM_ASSERT_TYPE (scm_is_string (
value)
727 value, arg_pos, func_name,
728 _(
"string or #f for non-PARAM_FILENAME parameters"));
730 var.
set<std::string> (
"");
735 gdb::unique_xmalloc_ptr<char>
string
737 if (
string ==
nullptr)
739 var.
set<std::string> (
string.release ());
748 SCM_ASSERT_TYPE (scm_is_string (
value),
value, arg_pos, func_name,
750 gdb::unique_xmalloc_ptr<char> str
754 for (i = 0; enumeration[i]; ++i)
756 if (strcmp (enumeration[i], str.get ()) == 0)
759 if (enumeration[i] ==
nullptr)
762 _(
"not member of enumeration"));
764 var.
set<
const char *> (enumeration[i]);
777 value, arg_pos, func_name,
778 _(
"boolean or #:auto"));
792 enum tribool allowed = TRIBOOL_UNKNOWN;
794 bool integer = scm_is_integer (
value);
796 std::string buffer =
"";
807 buffer = buffer +
"#:" + l->literal;
809 && allowed == TRIBOOL_UNKNOWN
811 scm_from_latin1_keyword (l->literal)))
814 allowed = TRIBOOL_TRUE;
818 if (allowed == TRIBOOL_UNKNOWN)
821 SCM_ASSERT_TYPE (integer,
value, arg_pos, func_name,
824 SCM_ASSERT_TYPE (integer,
value, arg_pos, func_name,
825 string_printf (_(
"integer or one of: %s"),
826 buffer.c_str ()).c_str ());
828 SCM_ASSERT_TYPE (integer,
value, arg_pos, func_name,
829 string_printf (_(
"integer or %s"),
830 buffer.c_str ()).c_str ());
833 ?
static_cast<LONGEST
> (scm_to_uint (
value))
834 :
static_cast<LONGEST
> (scm_to_int (
value)));
841 if (l->val.has_value () && val == *l->val)
843 allowed = TRIBOOL_TRUE;
847 else if (val == l->use)
848 allowed = TRIBOOL_FALSE;
852 if (allowed == TRIBOOL_UNKNOWN)
854 if (val > UINT_MAX || val < INT_MIN
859 allowed = TRIBOOL_FALSE;
861 if (allowed == TRIBOOL_FALSE)
863 _(
"integer out of range"));
866 var.
set<
unsigned int> (
static_cast<unsigned int> (val));
868 var.
set<
int> (
static_cast<int> (val));
874 gdb_assert_not_reached (
"bad parameter type");
935 const SCM keywords[] = {
941 int cmd_class_arg_pos = -1, param_type_arg_pos = -1;
942 int enum_list_arg_pos = -1, set_func_arg_pos = -1, show_func_arg_pos = -1;
943 int doc_arg_pos = -1, set_doc_arg_pos = -1, show_doc_arg_pos = -1;
944 int initial_value_arg_pos = -1;
949 SCM enum_list_scm = SCM_BOOL_F;
950 SCM set_func = SCM_BOOL_F, show_func = SCM_BOOL_F;
951 char *doc = NULL, *set_doc = NULL, *show_doc = NULL;
952 SCM initial_value_scm = SCM_BOOL_F;
953 const char *
const *enum_list = NULL;
958 name_scm, &
name, rest,
959 &cmd_class_arg_pos, &cmd_class,
960 ¶m_type_arg_pos, ¶m_type,
961 &enum_list_arg_pos, &enum_list_scm,
962 &set_func_arg_pos, &set_func,
963 &show_func_arg_pos, &show_func,
965 &set_doc_arg_pos, &set_doc,
966 &show_doc_arg_pos, &show_doc,
967 &initial_value_arg_pos, &initial_value_scm);
972 if (show_doc == NULL)
994 scm_from_int (cmd_class),
995 _(
"invalid command class argument"));
1000 scm_from_int (param_type),
1001 _(
"invalid parameter type argument"));
1003 if (enum_list_arg_pos > 0 && param_type !=
param_enum)
1006 _(
"#:enum-values can only be provided with PARAM_ENUM"));
1008 if (enum_list_arg_pos < 0 && param_type ==
param_enum)
1011 _(
"PARAM_ENUM requires an enum-values argument"));
1013 if (set_func_arg_pos > 0)
1016 set_func_arg_pos,
FUNC_NAME, _(
"procedure"));
1018 if (show_func_arg_pos > 0)
1021 show_func_arg_pos,
FUNC_NAME, _(
"procedure"));
1035 p_smob = (
param_smob *) SCM_SMOB_DATA (p_scm);
1055 if (initial_value_arg_pos > 0)
1099 scm_misc_error (
FUNC_NAME, _(
"parameter is already registered"), SCM_EOL);
1112 _(
"parameter exists, \"set\" command is already defined"));
1117 _(
"parameter exists, \"show\" command is already defined"));
1129 set_list, show_list);
1131 catch (
const gdb_exception &except)
1144 return SCM_UNSPECIFIED;
1154 self, SCM_ARG1,
FUNC_NAME, _(
"<gdb:parameter> or string"));
1171 gdb::unique_xmalloc_ptr<char>
name
1175 newarg = concat (
"show ",
name.get (), (
char *) NULL);
1180 catch (
const gdb_exception &ex)
1190 _(
"parameter not found"));
1193 if (!cmd->
var.has_value ())
1196 _(
"not a parameter"));
1214 return SCM_UNSPECIFIED;
1223Make a GDB parameter object.\n\
1226 [#:command-class <cmd-class>] [#:parameter-type <parameter-type>]\n\
1227 [#:enum-list <enum-list>]\n\
1228 [#:set-func function] [#:show-func function]\n\
1229 [#:doc string] [#:set-doc string] [#:show-doc string]\n\
1230 [#:initial-value initial-value]\n\
1231 name: The name of the command. It may consist of multiple words,\n\
1232 in which case the final word is the name of the new parameter, and\n\
1233 earlier words must be prefix commands.\n\
1234 cmd-class: The class of the command, one of COMMAND_*.\n\
1235 The default is COMMAND_NONE.\n\
1236 parameter-type: The kind of parameter, one of PARAM_*\n\
1237 The default is PARAM_BOOLEAN.\n\
1238 enum-list: If parameter-type is PARAM_ENUM, then this specifies the set\n\
1239 of values of the enum.\n\
1240 set-func: A function of one parameter: the <gdb:parameter> object.\n\
1241 Called *after* the parameter has been set. Returns either \"\" or a\n\
1242 non-empty string to be displayed to the user.\n\
1243 If non-empty, GDB will add a trailing newline.\n\
1244 show-func: A function of two parameters: the <gdb:parameter> object\n\
1245 and the string representation of the current value.\n\
1246 The result is a string to be displayed to the user.\n\
1247 GDB will add a trailing newline.\n\
1248 doc: The \"doc string\" of the parameter.\n\
1249 set-doc: The \"doc string\" when setting the parameter.\n\
1250 show-doc: The \"doc string\" when showing the parameter.\n\
1251 initial-value: The initial value of the parameter." },
1253 {
"register-parameter!", 1, 0, 0,
1256Register a <gdb:parameter> object with GDB." },
1260Return #t if the object is a <gdb:parameter> object." },
1264Return the value of a <gdb:parameter> object\n\
1265or any gdb parameter if param is a string naming the parameter." },
1267 {
"set-parameter-value!", 2, 0, 0,
1270Set the value of a <gdb:parameter> object.\n\
1272 Arguments: <gdb:parameter> value" },
static struct parser_state * pstate
struct cmd_list_element * showlist
struct cmd_list_element * setlist
const literal_def pinteger_unlimited_literals[]
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_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_uinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const literal_def *extra_literals, 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_integer_cmd(const char *name, enum command_class theclass, int *var, const literal_def *extra_literals, 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)
const literal_def uinteger_unlimited_literals[]
set_show_commands add_setshow_pinteger_cmd(const char *name, enum command_class theclass, int *var, const literal_def *extra_literals, 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)
#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)
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 set_show_commands add_setshow_generic(enum var_types param_type, const literal_def *extra_literals, 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)
static SCM show_func_keyword
static const scheme_integer_constant parameter_types[]
static const struct @77 param_to_var[]
static SCM enum_list_keyword
static int pascm_print_param_smob(SCM self, SCM port, scm_print_state *pstate)
void gdbscm_initialize_parameters(void)
static void pascm_set_func(const char *args, int from_tty, struct cmd_list_element *c)
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 SCM parameter_type_keyword
static SCM command_class_keyword
const literal_def * extra_literals
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)
@ param_optional_filename
@ param_zuinteger_unlimited
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 const char * pascm_param_type_name(enum scm_param_types type)
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 literal_def * extra_literals
const char *const * enumeration
const literal_def * extra_literals() const
setting_func_types< T >::type get() const
enum auto_boolean autoboolval
void gdb_printf(struct ui_file *stream, const char *format,...)