* dbxread.c (set_namestring): Remove cast to unsigned. Check N_STRX
[deliverable/binutils-gdb.git] / gdb / top.c
index cb51e08d69e8550ea20d0cb606a5137a55fe9761..b6701b6ab870f11cb9174a549acc88641c9676d6 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -345,10 +345,21 @@ do_chdir_cleanup (void *old_dir)
 }
 #endif
 
-/* Execute the line P as a command.
-   Pass FROM_TTY as second argument to the defining function.  */
+void
+prepare_execute_command (void)
+{
+  free_all_values ();
+
+  /* With multiple threads running while the one we're examining is stopped,
+     the dcache can get stale without us being able to detect it.
+     For the duration of the command, though, use the dcache to help
+     things like backtrace.  */
+  if (non_stop)
+    target_dcache_invalidate ();
+}
 
-/* Execute command P, in the current user context.  */
+/* Execute the line P as a command, in the current user context.
+   Pass FROM_TTY as second argument to the defining function.  */
 
 void
 execute_command (char *p, int from_tty)
@@ -376,8 +387,8 @@ execute_command (char *p, int from_tty)
 #endif
        }
     }
-  
-  free_all_values ();
+
+  prepare_execute_command ();
 
   /* Force cleanup of any alloca areas if using C alloca instead of
      a builtin alloca.  */
@@ -446,10 +457,13 @@ execute_command (char *p, int from_tty)
 
     }
 
-  /* Tell the user if the language has changed (except first time).  */
+  /* Tell the user if the language has changed (except first time).
+     First make sure that a new frame has been selected, in case this
+     command or the hooks changed the program state.  */
+  deprecated_safe_get_selected_frame ();
   if (current_language != expected_language)
     {
-      if (language_mode == language_mode_auto)
+      if (language_mode == language_mode_auto && info_verbose)
        {
          language_info (1);    /* Print what changed.  */
        }
@@ -1176,6 +1190,9 @@ kill_or_detach (struct inferior *inf, void *args)
   struct qt_args *qt = args;
   struct thread_info *thread;
 
+  if (inf->pid == 0)
+    return 0;
+
   thread = any_thread_of_process (inf->pid);
   if (thread != NULL)
     {
@@ -1203,6 +1220,9 @@ print_inferior_quit_action (struct inferior *inf, void *arg)
 {
   struct ui_file *stb = arg;
 
+  if (inf->pid == 0)
+    return 0;
+
   if (inf->attach_flag)
     fprintf_filtered (stb,
                      _("\tInferior %d [%s] will be detached.\n"), inf->num,
@@ -1307,12 +1327,38 @@ quit_force (char *args, int from_tty)
   exit (exit_code);
 }
 
+/* If OFF, the debugger will run in non-interactive mode, which means
+   that it will automatically select the default answer to all the
+   queries made to the user.  If ON, gdb will wait for the user to
+   answer all queries.  If AUTO, gdb will determine whether to run
+   in interactive mode or not depending on whether stdin is a terminal
+   or not.  */
+static enum auto_boolean interactive_mode = AUTO_BOOLEAN_AUTO;
+
+/* Implement the "show interactive-mode" option.  */
+
+static void
+show_interactive_mode (struct ui_file *file, int from_tty,
+                       struct cmd_list_element *c,
+                       const char *value)
+{
+  if (interactive_mode == AUTO_BOOLEAN_AUTO)
+    fprintf_filtered (file, "\
+Debugger's interactive mode is %s (currently %s).\n",
+                      value, input_from_terminal_p () ? "on" : "off");
+  else
+    fprintf_filtered (file, "Debugger's interactive mode is %s.\n", value);
+}
+
 /* Returns whether GDB is running on a terminal and input is
    currently coming from that terminal.  */
 
 int
 input_from_terminal_p (void)
 {
+  if (interactive_mode != AUTO_BOOLEAN_AUTO)
+    return interactive_mode == AUTO_BOOLEAN_TRUE;
+
   if (gdb_has_a_terminal () && instream == stdin)
     return 1;
 
@@ -1644,6 +1690,18 @@ Use \"on\" to enable the notification, and \"off\" to disable it."),
                           show_exec_done_display_p,
                           &setlist, &showlist);
 
+  add_setshow_auto_boolean_cmd ("interactive-mode", class_support,
+                                &interactive_mode, _("\
+Set whether GDB should run in interactive mode or not"), _("\
+Show whether GDB runs in interactive mode"), _("\
+If on, run in interactive mode and wait for the user to answer\n\
+all queries.  If off, run in non-interactive mode and automatically\n\
+assume the default answer to all queries.  If auto (the default),\n\
+determine which mode to use based on the standard input settings"),
+                        NULL,
+                        show_interactive_mode,
+                        &setlist, &showlist);
+
   add_setshow_filename_cmd ("data-directory", class_maintenance,
                            &gdb_datadir, _("Set GDB's data directory."),
                            _("Show GDB's data directory."),
@@ -1672,6 +1730,13 @@ gdb_init (char *argv0)
   initialize_targets ();       /* Setup target_terminal macros for utils.c */
   initialize_utils ();         /* Make errors and warnings possible */
   initialize_all_files ();
+  /* This creates the current_program_space.  Do this after all the
+     _initialize_foo routines have had a chance to install their
+     per-sspace data keys.  Also do this before
+     initialize_current_architecture is called, because it accesses
+     exec_bfd of the current program space.  */
+  initialize_progspace ();
+  initialize_inferiors ();
   initialize_current_architecture ();
   init_cli_cmds();
   init_main ();                        /* But that omits this file!  Do it now */
This page took 0.028064 seconds and 4 git commands to generate.