* guile/scm-param.c (pascm_parameter_defined_p): New function.
(gdbscm_register_parameter_x): Call it. Raise error for pre-existing
parameters.
testsuite/
* gdb.guile/scm-parameter.exp: Add tests for trying to create
previously existing parameter, and previously ambiguously spelled
parameter.
+2014-07-28 Doug Evans <xdje42@gmail.com>
+
+ PR guile/17203
+ * guile/scm-param.c (pascm_parameter_defined_p): New function.
+ (gdbscm_register_parameter_x): Call it. Raise error for pre-existing
+ parameters.
+
2014-07-28 Will Newton <will.newton@linaro.org>
* arm-linux-tdep.c (THUMB2_SET_R7_SIGRETURN1): New define.
return p_scm;
}
+/* Subroutine of gdbscm_register_parameter_x to simplify it.
+ Return non-zero if parameter NAME is already defined in LIST. */
+
+static int
+pascm_parameter_defined_p (const char *name, struct cmd_list_element *list)
+{
+ struct cmd_list_element *c;
+
+ c = lookup_cmd_1 (&name, list, NULL, 1);
+
+ /* If the name is ambiguous that's ok, it's a new parameter still. */
+ return c != NULL && c != CMD_LIST_AMBIGUOUS;
+}
+
/* (register-parameter! <gdb:parameter>) -> unspecified
- It is an error to register a parameter more than once. */
+ It is an error to register a pre-existing parameter. */
static SCM
gdbscm_register_parameter_x (SCM self)
p_smob->cmd_name = gdbscm_gc_xstrdup (cmd_name);
xfree (cmd_name);
+ if (pascm_parameter_defined_p (p_smob->cmd_name, *set_list))
+ {
+ gdbscm_misc_error (FUNC_NAME, SCM_ARG1, self,
+ _("parameter exists, \"set\" command is already defined"));
+ }
+ if (pascm_parameter_defined_p (p_smob->cmd_name, *show_list))
+ {
+ gdbscm_misc_error (FUNC_NAME, SCM_ARG1, self,
+ _("parameter exists, \"show\" command is already defined"));
+ }
+
TRY_CATCH (except, RETURN_MASK_ALL)
{
add_setshow_generic (p_smob->type, p_smob->cmd_class,
+2014-07-28 Doug Evans <xdje42@gmail.com>
+
+ PR guile/17203
+ * gdb.guile/scm-parameter.exp: Add tests for trying to create
+ previously existing parameter, and previously ambiguously spelled
+ parameter.
+
2014-07-28 Will Newton <will.newton@linaro.org>
* gdb.base/varargs.exp: Remove KFAILs for ARM.
gdb_test "set test-restricted-param 42" "Error: Range of parameter is 0-10."
gdb_test "show test-restricted-param" "The value of the restricted parameter is 2."
}
+
+# Test registering a parameter that already exists.
+
+gdb_test "guile (register-parameter! (make-parameter \"height\"))" \
+ "ERROR.*is already defined.*" "error registering existing parameter"
+
+# Test registering a parameter named with what was an ambiguous spelling
+# of existing parameters.
+
+gdb_test_multiline "previously ambiguously named boolean parameter" \
+ "guile" "" \
+ "(define prev-ambig" "" \
+ " (make-parameter \"print s\"" "" \
+ " #:parameter-type PARAM_BOOLEAN))" "" \
+ "end"
+
+gdb_test_no_output "guile (register-parameter! prev-ambig)"
+
+with_test_prefix "previously-ambiguous" {
+ gdb_test "guile (print (parameter-value prev-ambig))" "= #f" "parameter value (false)"
+ gdb_test "show print s" "Command is not documented is off." "Show parameter off"
+ gdb_test_no_output "set print s on"
+ gdb_test "show print s" "Command is not documented is on." "Show parameter on"
+ gdb_test "guile (print (parameter-value prev-ambig))" "= #t" "parameter value (true)"
+ gdb_test "help show print s" "This command is not documented." "show help"
+ gdb_test "help set print s" "This command is not documented." "set help"
+ gdb_test "help set print" "set print s -- This command is not documented.*" "general help"
+}