aboutsummaryrefslogtreecommitdiff
path: root/gdb/macrocmd.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2008-08-14 18:03:22 +0000
committerTom Tromey <tromey@redhat.com>2008-08-14 18:03:22 +0000
commit886a217cf4ad31024cf799bf2803c39c07ad1d15 (patch)
tree2b9e71f2c415f3ba8b8ea95c6acab8064bc6bd7c /gdb/macrocmd.c
parent4e96a12e094223793435f3b27e99649a3dc26f70 (diff)
downloadgdb-886a217cf4ad31024cf799bf2803c39c07ad1d15.zip
gdb-886a217cf4ad31024cf799bf2803c39c07ad1d15.tar.gz
gdb-886a217cf4ad31024cf799bf2803c39c07ad1d15.tar.bz2
gdb:
* macrocmd.c (macro_define_command): Check for NULL argument. (macro_undef_command): Likewise. gdb/testsuite: * gdb.base/macscp.exp: Add regression test for "macro define" or "macro undef" with no arguments.
Diffstat (limited to 'gdb/macrocmd.c')
-rw-r--r--gdb/macrocmd.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
index 4a70d4f..8213c0d 100644
--- a/gdb/macrocmd.c
+++ b/gdb/macrocmd.c
@@ -235,8 +235,12 @@ macro_define_command (char *exp, int from_tty)
{
struct macro_definition new_macro;
char *name = NULL;
- struct cleanup *cleanup_chain = make_cleanup (free_macro_definition_ptr,
- &new_macro);
+ struct cleanup *cleanup_chain;
+
+ if (!exp)
+ error (_("usage: macro define NAME[(ARGUMENT-LIST)] [REPLACEMENT-LIST]"));
+
+ cleanup_chain = make_cleanup (free_macro_definition_ptr, &new_macro);
make_cleanup (free_current_contents, &name);
memset (&new_macro, 0, sizeof (struct macro_definition));
@@ -308,6 +312,10 @@ static void
macro_undef_command (char *exp, int from_tty)
{
char *name;
+
+ if (!exp)
+ error (_("usage: macro undef NAME"));
+
skip_ws (&exp);
name = extract_identifier (&exp);
if (! name)