configury changes to make ld plugin support controlled by --enable-plugins
[deliverable/binutils-gdb.git] / gdb / top.c
index 46faaa73b0eba8ece8db5331a97e8c991b99b6fb..fc2b84d70bb96301280639247c5dee61714a80d9 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1,6 +1,6 @@
 /* Top level stuff for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2013 Free Software Foundation, Inc.
+   Copyright (C) 1986-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "cli/cli-decode.h"
 #include "symtab.h"
 #include "inferior.h"
+#include "infrun.h"
 #include "exceptions.h"
 #include <signal.h>
 #include "target.h"
+#include "target-dcache.h"
 #include "breakpoint.h"
 #include "gdbtypes.h"
 #include "expression.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 "filenames.h"
 
 /* readline include files.  */
 #include "readline/readline.h"
 #include <sys/types.h>
 
 #include "event-top.h"
-#include "gdb_string.h"
-#include "gdb_stat.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);
 
@@ -84,11 +86,6 @@ const char gdbinit[] = GDBINIT;
 
 int inhibit_gdbinit = 0;
 
-/* If nonzero, and GDB has been configured to be able to use windows,
-   attempt to open them upon startup.  */
-
-int use_windows = 0;
-
 extern char lang_frame_mismatch_warn[];                /* language.c */
 
 /* Flag for whether we want to confirm potentially dangerous
@@ -143,13 +140,6 @@ int saved_command_line_size = 100;
    is issuing commands too.  */
 int server_command;
 
-/* Baud rate specified for talking to serial target systems.  Default
-   is left as -1, so targets can choose their own defaults.  */
-/* FIXME: This means that "show remotebaud" and gr_files_info can
-   print -1 or (unsigned int)-1.  This is a Bad User Interface.  */
-
-int baud_rate = -1;
-
 /* Timeout limit for response from target.  */
 
 /* The default value has been changed many times over the years.  It 
@@ -198,11 +188,6 @@ void (*deprecated_init_ui_hook) (char *argv0);
 
 int (*deprecated_ui_loop_hook) (int);
 
-/* Called instead of command_loop at top level.  Can be invoked via
-   throw_exception().  */
-
-void (*deprecated_command_loop_hook) (void);
-
 
 /* Called from print_frame_info to list the line we stopped in.  */
 
@@ -263,11 +248,6 @@ ptid_t (*deprecated_target_wait_hook) (ptid_t ptid,
 void (*deprecated_call_command_hook) (struct cmd_list_element * c, 
                                      char *cmd, int from_tty);
 
-/* Called after a `set' command has finished.  Is only run if the
-   `set' command succeeded.  */
-
-void (*deprecated_set_hook) (struct cmd_list_element * c);
-
 /* Called when the current thread changes.  Argument is thread id.  */
 
 void (*deprecated_context_hook) (int id);
@@ -426,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.  */
@@ -460,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.  */
@@ -481,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)
@@ -578,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);
     }
 }
@@ -770,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 ();
 }
@@ -779,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
@@ -790,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);
 }
 
@@ -812,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;
@@ -1072,19 +1075,9 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
   *p = 0;
 
   /* Add line to history if appropriate.  */
-  if (instream == stdin
-      && ISATTY (stdin) && *linebuffer)
+  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)
     {
@@ -1113,7 +1106,7 @@ print_gdb_version (struct ui_file *stream)
   /* Second line is a copyright notice.  */
 
   fprintf_filtered (stream,
-                   "Copyright (C) 2013 Free Software Foundation, Inc.\n");
+                   "Copyright (C) 2014 Free Software Foundation, Inc.\n");
 
   /* Following the copyright is a brief statement that the program is
      free software, that users are free to copy and change it on
@@ -1145,8 +1138,14 @@ Type \"show configuration\" for configuration details.");
     {
       fprintf_filtered (stream,
                        _("\nFor bug reporting instructions, please see:\n"));
-      fprintf_filtered (stream, "%s.", REPORT_BUGS_TO);
+      fprintf_filtered (stream, "%s.\n", REPORT_BUGS_TO);
     }
+  fprintf_filtered (stream,
+                   _("Find the GDB manual and other documentation \
+resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"));
+  fprintf_filtered (stream, _("For help, type \"help\".\n"));
+  fprintf_filtered (stream, _("Type \"apropos word\" to search for \
+commands related to \"word\"."));
 }
 
 /* Print the details of GDB build-time configuration.  */
@@ -1206,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\
@@ -1353,18 +1361,9 @@ quit_confirm (void)
   stb = mem_fileopen ();
   old_chain = make_cleanup_ui_file_delete (stb);
 
-  /* This is something of a hack.  But there's no reliable way to see
-     if a GUI is running.  The `use_windows' variable doesn't cut
-     it.  */
-  if (deprecated_init_ui_hook)
-    fprintf_filtered (stb, _("A debugging session is active.\n"
-                            "Do you still want to close the debugger?"));
-  else
-    {
-      fprintf_filtered (stb, _("A debugging session is active.\n\n"));
-      iterate_over_inferiors (print_inferior_quit_action, stb);
-      fprintf_filtered (stb, _("\nQuit anyway? "));
-    }
+  fprintf_filtered (stb, _("A debugging session is active.\n\n"));
+  iterate_over_inferiors (print_inferior_quit_action, stb);
+  fprintf_filtered (stb, _("\nQuit anyway? "));
 
   str = ui_file_xstrdup (stb, NULL);
   make_cleanup (xfree, str);
@@ -1426,7 +1425,8 @@ quit_force (char *args, int from_tty)
   /* Save the history information if it is appropriate to do so.  */
   DO_TRY
     {
-      if (write_history_p && history_filename)
+      if (write_history_p && history_filename
+         && input_from_terminal_p ())
        write_history (history_filename);
     }
   DO_PRINT_EX;
@@ -1570,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
@@ -1689,14 +1689,39 @@ 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)
+{
+  /* We include the current directory so that if the user changes
+     directories the file written will be the same as the one
+     that was read.  */
+  if (!IS_ABSOLUTE_PATH (history_filename))
+    history_filename = reconcat (history_filename, current_directory, "/", 
+                                history_filename, (char *) NULL);
+}
+
 static void
 init_main (void)
 {
@@ -1773,7 +1798,7 @@ variable \"HISTSIZE\", or to 256 if this variable is not set."),
 Set the filename in which to record the command history"), _("\
 Show the filename in which to record the command history"), _("\
 (the list of previous commands of which a record is kept)."),
-                           NULL,
+                           set_history_filename,
                            show_history_filename,
                            &sethistlist, &showhistlist);
 
@@ -1803,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);
 }
@@ -1862,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.029534 seconds and 4 git commands to generate.