diff options
author | Doug Evans <xdje42@gmail.com> | 2014-07-28 19:20:30 -0700 |
---|---|---|
committer | Doug Evans <xdje42@gmail.com> | 2014-07-28 19:20:30 -0700 |
commit | 7ebdbe9292e4b696740b021938369adb1484da27 (patch) | |
tree | 8b33e7c48f91cd111ccbd50ac27f7168e123dda7 /gdb | |
parent | 385f635ae0be0077dad606c12118bbe0f886f28f (diff) | |
download | gdb-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')
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/guile/scm-param.c | 27 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.guile/scm-parameter.exp | 28 |
4 files changed, 68 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0b80869..0e47fbc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +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. 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, diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 2da2c66..e65e76a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +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. diff --git a/gdb/testsuite/gdb.guile/scm-parameter.exp b/gdb/testsuite/gdb.guile/scm-parameter.exp index 0dd8a47..c0df185 100644 --- a/gdb/testsuite/gdb.guile/scm-parameter.exp +++ b/gdb/testsuite/gdb.guile/scm-parameter.exp @@ -166,3 +166,31 @@ with_test_prefix "test-restricted-param" { 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" +} |