aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2017-09-04 19:13:08 +0200
committerSimon Marchi <simon.marchi@ericsson.com>2017-09-04 19:13:48 +0200
commit80a65e9b8fbc93d4a7548ac17b8094ced23f66a7 (patch)
tree9fee8bb1c13b929f564e73068c2ef4800e56989a /gdb/cli
parent6b66338c70422d670637623cea8dc3b62e05e7de (diff)
downloadgdb-80a65e9b8fbc93d4a7548ac17b8094ced23f66a7.zip
gdb-80a65e9b8fbc93d4a7548ac17b8094ced23f66a7.tar.gz
gdb-80a65e9b8fbc93d4a7548ac17b8094ced23f66a7.tar.bz2
Error out immediatly when using if command without args in command list
When using "if" (or while) without args directly on gdb's command line, you get this: (gdb) if if/while commands require arguments When doing the same when entering a command list, you only get an error when the command is executed, when parse_exp_in_context_1 fails to evaluate the expression. (gdb) define foo Type commands for definition of "foo". End with a line saying just "end". >if >end >end (gdb) foo Argument required (expression to compute). I think it would make more sense to error out when inputting the command list directly: (gdb) define foo Type commands for definition of "foo". End with a line saying just "end". >if if/while commands require arguments. The only required change is to check whether args is an empty string in build_command_line. gdb/ChangeLog: * cli/cli-script.c (build_command_line): For if/while commands, check whether args is empty. gdb/testsuite/ChangeLog: * gdb.base/commands.exp: Call new procedure. (define_if_without_arg_test): New procedure.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-script.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 64b4c2b..1757e4e 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -147,7 +147,8 @@ build_command_line (enum command_control_type type, const char *args)
{
struct command_line *cmd;
- if (args == NULL && (type == if_control || type == while_control))
+ if ((args == NULL || *args == '\0')
+ && (type == if_control || type == while_control))
error (_("if/while commands require arguments."));
gdb_assert (args != NULL);