diff options
author | Tom Tromey <tromey@redhat.com> | 2008-08-14 18:03:22 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2008-08-14 18:03:22 +0000 |
commit | 886a217cf4ad31024cf799bf2803c39c07ad1d15 (patch) | |
tree | 2b9e71f2c415f3ba8b8ea95c6acab8064bc6bd7c /gdb | |
parent | 4e96a12e094223793435f3b27e99649a3dc26f70 (diff) | |
download | gdb-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')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/macrocmd.c | 12 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/macscp.exp | 10 |
4 files changed, 30 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f246016..3973634 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2008-08-14 Tom Tromey <tromey@redhat.com> + + * macrocmd.c (macro_define_command): Check for NULL argument. + (macro_undef_command): Likewise. + 2008-08-14 Pedro Alves <pedro@codesourcery.com> * infcmd.c (continue_1): Add an ERROR_NO_INFERIOR call. 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) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index b00e52b..577d0eb 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-08-14 Tom Tromey <tromey@redhat.com> + + * gdb.base/macscp.exp: Add regression test for "macro define" or + "macro undef" with no arguments. + 2008-08-08 Paul Pluzhnikov <ppluzhnikov@google.com> * gdb.base/args.exp: Prevent ~/.gdbinit from affecting test. diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp index 2df0eef..3424714 100644 --- a/gdb/testsuite/gdb.base/macscp.exp +++ b/gdb/testsuite/gdb.base/macscp.exp @@ -470,6 +470,16 @@ gdb_test "print M" \ "No symbol \"M\" in current context\." \ "print expression with macro after user undef." +# Regression test; this used to crash. +gdb_test "macro define" \ + "usage: macro define.*" \ + "macro define with no arguments" + +# Regression test; this used to crash. +gdb_test "macro undef" \ + "usage: macro undef.*" \ + "macro undef with no arguments" + # Regression test; this used to emit the wrong error. gdb_test "macro expand SPLICE(x, y)" \ "Token splicing is not implemented yet." \ |