aboutsummaryrefslogtreecommitdiff
path: root/gdb/guile
diff options
context:
space:
mode:
authorDoug Evans <xdje42@gmail.com>2014-07-28 19:20:30 -0700
committerDoug Evans <xdje42@gmail.com>2014-07-28 19:20:30 -0700
commit7ebdbe9292e4b696740b021938369adb1484da27 (patch)
tree8b33e7c48f91cd111ccbd50ac27f7168e123dda7 /gdb/guile
parent385f635ae0be0077dad606c12118bbe0f886f28f (diff)
downloadgdb-7ebdbe9292e4b696740b021938369adb1484da27.zip
gdb-7ebdbe9292e4b696740b021938369adb1484da27.tar.gz
gdb-7ebdbe9292e4b696740b021938369adb1484da27.tar.bz2
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. testsuite/ * gdb.guile/scm-parameter.exp: Add tests for trying to create previously existing parameter, and previously ambiguously spelled parameter.
Diffstat (limited to 'gdb/guile')
-rw-r--r--gdb/guile/scm-param.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/gdb/guile/scm-param.c b/gdb/guile/scm-param.c
index 683ec7d..f0f83cd 100644
--- a/gdb/guile/scm-param.c
+++ b/gdb/guile/scm-param.c
@@ -966,9 +966,23 @@ gdbscm_make_parameter (SCM name_scm, SCM rest)
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)
@@ -990,6 +1004,17 @@ 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,