include/
[external/binutils.git] / gdb / macrocmd.c
index c9ab440..355efe0 100644 (file)
@@ -1,5 +1,5 @@
 /* C preprocessor macro expansion commands for GDB.
-   Copyright (C) 2002, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Red Hat, Inc.
 
    This file is part of GDB.
@@ -158,7 +158,10 @@ info_macro_command (char *name, int from_tty)
 
       fprintf_filtered (gdb_stdout, "Defined at ");
       show_pp_source_pos (gdb_stdout, file, line);
-      fprintf_filtered (gdb_stdout, "#define %s", name);
+      if (line != 0)
+       fprintf_filtered (gdb_stdout, "#define %s", name);
+      else
+       fprintf_filtered (gdb_stdout, "-D%s", name);
       if (d->kind == macro_function_like)
         {
           int i;
@@ -172,7 +175,10 @@ info_macro_command (char *name, int from_tty)
             }
           fputs_filtered (")", gdb_stdout);
         }
-      fprintf_filtered (gdb_stdout, " %s\n", d->replacement);
+      if (line != 0)
+       fprintf_filtered (gdb_stdout, " %s\n", d->replacement);
+      else
+       fprintf_filtered (gdb_stdout, "=%s\n", d->replacement);
     }
   else
     {
@@ -315,13 +321,17 @@ macro_define_command (char *exp, int from_tty)
        }
       /* Skip the closing paren.  */
       ++exp;
+      skip_ws (&exp);
 
       macro_define_function (macro_main (macro_user_macros), -1, name,
                             new_macro.argc, (const char **) new_macro.argv,
                             exp);
     }
   else
-    macro_define_object (macro_main (macro_user_macros), -1, name, exp);
+    {
+      skip_ws (&exp);
+      macro_define_object (macro_main (macro_user_macros), -1, name, exp);
+    }
 
   do_cleanups (cleanup_chain);
 }
@@ -345,7 +355,8 @@ macro_undef_command (char *exp, int from_tty)
 
 
 static void
-print_one_macro (const char *name, const struct macro_definition *macro)
+print_one_macro (const char *name, const struct macro_definition *macro,
+                void *ignore)
 {
   fprintf_filtered (gdb_stdout, "macro define %s", name);
   if (macro->kind == macro_function_like)
@@ -357,16 +368,14 @@ print_one_macro (const char *name, const struct macro_definition *macro)
                          macro->argv[i]);
       fprintf_filtered (gdb_stdout, ")");
     }
-  /* Note that we don't need a leading space here -- "macro define"
-     provided it.  */
-  fprintf_filtered (gdb_stdout, "%s\n", macro->replacement);
+  fprintf_filtered (gdb_stdout, " %s\n", macro->replacement);
 }
 
 
 static void
 macro_list_command (char *exp, int from_tty)
 {
-  macro_for_each (macro_user_macros, print_one_macro);
+  macro_for_each (macro_user_macros, print_one_macro, NULL);
 }