configury changes to make ld plugin support controlled by --enable-plugins
[deliverable/binutils-gdb.git] / gdb / top.c
index f92043d523c6cf9653b133be33088823b1071018..fc2b84d70bb96301280639247c5dee61714a80d9 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -25,6 +25,7 @@
 #include "cli/cli-decode.h"
 #include "symtab.h"
 #include "inferior.h"
+#include "infrun.h"
 #include "exceptions.h"
 #include <signal.h>
 #include "target.h"
 #include "version.h"
 #include "serial.h"
 #include "doublest.h"
-#include "gdb_assert.h"
 #include "main.h"
 #include "event-loop.h"
 #include "gdbthread.h"
-#include "python/python.h"
+#include "extension.h"
 #include "interps.h"
 #include "observer.h"
 #include "maint.h"
 #include <sys/types.h>
 
 #include "event-top.h"
-#include <string.h>
 #include <sys/stat.h>
 #include <ctype.h>
 #include "ui-out.h"
 #include "cli-out.h"
 #include "tracepoint.h"
+#include "inf-loop.h"
 
 extern void initialize_all_files (void);
 
@@ -406,6 +406,8 @@ execute_command (char *p, int from_tty)
     {
       const char *cmd = p;
       char *arg;
+      int was_sync = sync_execution;
+
       line = p;
 
       /* If trace-commands is set then this will print this command.  */
@@ -440,7 +442,7 @@ execute_command (char *p, int from_tty)
       /* If this command has been pre-hooked, run the hook first.  */
       execute_cmd_pre_hook (c);
 
-      if (c->flags & DEPRECATED_WARN_USER)
+      if (c->deprecated_warn_user)
        deprecated_cmd_warning (line);
 
       /* c->user_commands would be NULL in the case of a python command.  */
@@ -461,7 +463,7 @@ execute_command (char *p, int from_tty)
         command's list, running command hooks or similars), and we
         just ran a synchronous command that started the target, wait
         for that command to end.  */
-      if (!interpreter_async && sync_execution)
+      if (!interpreter_async && !was_sync && sync_execution)
        {
          while (gdb_do_one_event () >= 0)
            if (!sync_execution)
@@ -558,11 +560,14 @@ command_loop (void)
 
       make_command_stats_cleanup (1);
 
-      execute_command (command, instream == stdin);
-
-      /* Do any commands attached to breakpoint we are stopped at.  */
-      bpstat_do_actions ();
+      /* Do not execute commented lines.  */
+      if (command[0] != '#')
+       {
+         execute_command (command, instream == stdin);
 
+         /* Do any commands attached to breakpoint we are stopped at.  */
+         bpstat_do_actions ();
+       }
       do_cleanups (old_chain);
     }
 }
@@ -750,7 +755,8 @@ gdb_readline_wrapper_line (char *line)
   after_char_processing_hook = NULL;
 
   /* Prevent parts of the prompt from being redisplayed if annotations
-     are enabled, and readline's state getting out of sync.  */
+     are enabled, and readline's state getting out of sync.  We'll
+     restore it in gdb_readline_wrapper_cleanup.  */
   if (async_command_editing_p)
     rl_callback_handler_remove ();
 }
@@ -759,6 +765,9 @@ struct gdb_readline_wrapper_cleanup
   {
     void (*handler_orig) (char *);
     int already_prompted_orig;
+
+    /* Whether the target was async.  */
+    int target_is_async_orig;
   };
 
 static void
@@ -770,12 +779,21 @@ gdb_readline_wrapper_cleanup (void *arg)
 
   gdb_assert (input_handler == gdb_readline_wrapper_line);
   input_handler = cleanup->handler_orig;
+
+  /* Reinstall INPUT_HANDLER in readline, without displaying a
+     prompt.  */
+  if (async_command_editing_p)
+    rl_callback_handler_install (NULL, input_handler);
+
   gdb_readline_wrapper_result = NULL;
   gdb_readline_wrapper_done = 0;
 
   after_char_processing_hook = saved_after_char_processing_hook;
   saved_after_char_processing_hook = NULL;
 
+  if (cleanup->target_is_async_orig)
+    target_async (inferior_event_handler, 0);
+
   xfree (cleanup);
 }
 
@@ -792,8 +810,13 @@ gdb_readline_wrapper (char *prompt)
 
   cleanup->already_prompted_orig = rl_already_prompted;
 
+  cleanup->target_is_async_orig = target_is_async_p ();
+
   back_to = make_cleanup (gdb_readline_wrapper_cleanup, cleanup);
 
+  if (cleanup->target_is_async_orig)
+    target_async (NULL, NULL);
+
   /* Display our prompt and prevent double prompt display.  */
   display_gdb_prompt (prompt);
   rl_already_prompted = 1;
@@ -1055,15 +1078,6 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
   if (*linebuffer && input_from_terminal_p ())
     add_history (linebuffer);
 
-  /* Note: lines consisting solely of comments are added to the command
-     history.  This is useful when you type a command, and then
-     realize you don't want to execute it quite yet.  You can comment
-     out the command and then later fetch it from the value history
-     and remove the '#'.  The kill ring is probably better, but some
-     people are in the habit of commenting things out.  */
-  if (*p1 == '#')
-    *p1 = '\0';                        /* Found a comment.  */
-
   /* Save into global buffer if appropriate.  */
   if (repeat)
     {
@@ -1191,6 +1205,15 @@ This GDB was configured as follows:\n\
              --with-python=%s%s\n\
 "), WITH_PYTHON_PATH, PYTHON_PATH_RELOCATABLE ? " (relocatable)" : "");
 #endif
+#if HAVE_GUILE
+  fprintf_filtered (stream, _("\
+             --with-guile\n\
+"));
+#else
+  fprintf_filtered (stream, _("\
+             --without-guile\n\
+"));
+#endif
 #ifdef RELOC_SRCDIR
   fprintf_filtered (stream, _("\
              --with-relocated-sources=%s\n\
@@ -1547,7 +1570,7 @@ set_history (char *args, int from_tty)
 {
   printf_unfiltered (_("\"set history\" must be followed "
                       "by the name of a history subcommand.\n"));
-  help_list (sethistlist, "set history ", -1, gdb_stdout);
+  help_list (sethistlist, "set history ", all_commands, gdb_stdout);
 }
 
 void
@@ -1666,14 +1689,28 @@ show_exec_done_display_p (struct ui_file *file, int from_tty,
                    value);
 }
 
+/* New values of the "data-directory" parameter are staged here.  */
+static char *staged_gdb_datadir;
+
 /* "set" command for the gdb_datadir configuration variable.  */
 
 static void
 set_gdb_datadir (char *args, int from_tty, struct cmd_list_element *c)
 {
+  set_gdb_data_directory (staged_gdb_datadir);
   observer_notify_gdb_datadir_changed ();
 }
 
+/* "show" command for the gdb_datadir configuration variable.  */
+
+static void
+show_gdb_datadir (struct ui_file *file, int from_tty,
+                 struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("GDB's data directory is \"%s\".\n"),
+                   gdb_datadir);
+}
+
 static void
 set_history_filename (char *args, int from_tty, struct cmd_list_element *c)
 {
@@ -1791,11 +1828,11 @@ Use \"on\" to enable the notification, and \"off\" to disable it."),
                           &setlist, &showlist);
 
   add_setshow_filename_cmd ("data-directory", class_maintenance,
-                           &gdb_datadir, _("Set GDB's data directory."),
+                           &staged_gdb_datadir, _("Set GDB's data directory."),
                            _("Show GDB's data directory."),
                            _("\
 When set, GDB uses the specified path to search for data files."),
-                           set_gdb_datadir, NULL,
+                           set_gdb_datadir, show_gdb_datadir,
                            &setlist,
                            &showlist);
 }
@@ -1850,11 +1887,9 @@ gdb_init (char *argv0)
   if (deprecated_init_ui_hook)
     deprecated_init_ui_hook (argv0);
 
-#ifdef HAVE_PYTHON
-  /* Python initialization can require various commands to be
+  /* Python initialization, for example, can require various commands to be
      installed.  For example "info pretty-printer" needs the "info"
      prefix to be installed.  Keep things simple and just do final
-     python initialization here.  */
-  finish_python_initialization ();
-#endif
+     script initialization here.  */
+  finish_ext_lang_initialization ();
 }
This page took 0.026451 seconds and 4 git commands to generate.