* elf32-ppc.c (allocate_dynrelocs): Ignore dyn_relocs when
[deliverable/binutils-gdb.git] / gdb / top.c
index 7d1448c9afb3e4f8379d97830b590e0edf56467c..7f46cafb0cc2c2e2a8f856b13bf87ca037dc3973 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1,8 +1,8 @@
 /* Top level stuff for GDB, the GNU debugger.
 
    Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
-   Free Software Foundation, Inc.
+   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+   2008 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -46,6 +46,7 @@
 #include "gdb_assert.h"
 #include "main.h"
 #include "event-loop.h"
+#include "gdbthread.h"
 
 /* readline include files */
 #include "readline/readline.h"
@@ -181,12 +182,6 @@ int remote_timeout = 2;
 
 int remote_debug = 0;
 
-/* Non-zero means the target is running. Note: this is different from
-   saying that there is an active target and we are stopped at a
-   breakpoint, for instance. This is a real indicator whether the
-   target is off and running, which gdb is doing something else. */
-int target_executing = 0;
-
 /* Sbrk location on entry to main.  Used for statistics only.  */
 #ifdef HAVE_SBRK
 char *lim_at_start;
@@ -251,13 +246,6 @@ void (*deprecated_readline_begin_hook) (char *, ...);
 char *(*deprecated_readline_hook) (char *);
 void (*deprecated_readline_end_hook) (void);
 
-/* Called as appropriate to notify the interface of the specified breakpoint
-   conditions.  */
-
-void (*deprecated_create_breakpoint_hook) (struct breakpoint * bpt);
-void (*deprecated_delete_breakpoint_hook) (struct breakpoint * bpt);
-void (*deprecated_modify_breakpoint_hook) (struct breakpoint * bpt);
-
 /* Called as appropriate to notify the interface that we have attached
    to or detached from an already running process. */
 
@@ -367,6 +355,8 @@ do_chdir_cleanup (void *old_dir)
 /* Execute the line P as a command.
    Pass FROM_TTY as second argument to the defining function.  */
 
+/* Execute command P, in the current user context.  */
+
 void
 execute_command (char *p, int from_tty)
 {
@@ -374,6 +364,25 @@ execute_command (char *p, int from_tty)
   enum language flang;
   static int warned = 0;
   char *line;
+  long time_at_cmd_start = 0;
+#ifdef HAVE_SBRK
+  long space_at_cmd_start = 0;
+#endif
+  extern int display_time;
+  extern int display_space;
+
+  if (target_can_async_p ())
+    {
+      time_at_cmd_start = get_run_time ();
+
+      if (display_space)
+       {
+#ifdef HAVE_SBRK
+         char *lim = (char *) sbrk (0);
+         space_at_cmd_start = lim - lim_at_start;
+#endif
+       }
+    }
   
   free_all_values ();
 
@@ -385,7 +394,7 @@ execute_command (char *p, int from_tty)
   if (p == NULL)
     return;
 
-  serial_log_command (p);
+  target_log_command (p);
 
   while (*p == ' ' || *p == '\t')
     p++;
@@ -399,14 +408,13 @@ execute_command (char *p, int from_tty)
 
       c = lookup_cmd (&p, cmdlist, "", 0, 1);
 
-      /* If the target is running, we allow only a limited set of
-         commands. */
-      if (target_can_async_p () && target_executing)
-       if (strcmp (c->name, "help") != 0
-           && strcmp (c->name, "pwd") != 0
-           && strcmp (c->name, "show") != 0
-           && strcmp (c->name, "stop") != 0)
-         error (_("Cannot execute this command while the target is running."));
+      /* If the selected thread has terminated, we allow only a
+        limited set of commands.  */
+      if (target_can_async_p ()
+         && is_exited (inferior_ptid)
+         && !get_cmd_no_selected_thread_ok (c))
+       error (_("\
+Cannot execute this command without a live selected thread.  See `help thread'."));
 
       /* Pass null arg rather than an empty one.  */
       arg = *p ? p : 0;
@@ -469,7 +477,7 @@ execute_command (char *p, int from_tty)
   /* FIXME:  This should be cacheing the frame and only running when
      the frame changes.  */
 
-  if (target_has_stack)
+  if (target_has_stack && !is_running (inferior_ptid))
     {
       flang = get_frame_language ();
       if (!warned
@@ -545,49 +553,14 @@ command_loop (void)
          long space_now = lim - lim_at_start;
          long space_diff = space_now - space_at_cmd_start;
 
-         printf_unfiltered (_("Space used: %ld (%c%ld for this command)\n"),
+         printf_unfiltered (_("Space used: %ld (%s%ld for this command)\n"),
                             space_now,
-                            (space_diff >= 0 ? '+' : '-'),
+                            (space_diff >= 0 ? "+" : ""),
                             space_diff);
 #endif
        }
     }
 }
-
-/* Read commands from `instream' and execute them until end of file or
-   error reading instream. This command loop doesnt care about any
-   such things as displaying time and space usage. If the user asks
-   for those, they won't work. */
-void
-simplified_command_loop (char *(*read_input_func) (char *),
-                        void (*execute_command_func) (char *, int))
-{
-  struct cleanup *old_chain;
-  char *command;
-  int stdin_is_tty = ISATTY (stdin);
-
-  while (instream && !feof (instream))
-    {
-      quit_flag = 0;
-      if (instream == stdin && stdin_is_tty)
-       reinitialize_more_filter ();
-      old_chain = make_cleanup (null_cleanup, 0);
-
-      /* Get a command-line. */
-      command = (*read_input_func) (instream == stdin ?
-                                   get_prompt () : (char *) NULL);
-
-      if (command == 0)
-       return;
-
-      (*execute_command_func) (command, instream == stdin);
-
-      /* Do any commands attached to breakpoint we stopped at.  */
-      bpstat_do_actions (&stop_bpstat);
-
-      do_cleanups (old_chain);
-    }
-}
 \f
 /* Commands call this if they do not want to be repeated by null lines.  */
 
@@ -1143,11 +1116,11 @@ print_gdb_version (struct ui_file *stream)
      program to parse, and is just canonical program name and version
      number, which starts after last space. */
 
-  fprintf_filtered (stream, "GNU gdb %s\n", version);
+  fprintf_filtered (stream, "GNU gdb %s%s\n", PKGVERSION, version);
 
   /* Second line is a copyright notice. */
 
-  fprintf_filtered (stream, "Copyright (C) 2007 Free Software Foundation, Inc.\n");
+  fprintf_filtered (stream, "Copyright (C) 2008 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
@@ -1155,10 +1128,10 @@ print_gdb_version (struct ui_file *stream)
      there is no warranty. */
 
   fprintf_filtered (stream, "\
-GDB is free software, covered by the GNU General Public License, and you are\n\
-welcome to change it and/or distribute copies of it under certain conditions.\n\
-Type \"show copying\" to see the conditions.\n\
-There is absolutely no warranty for GDB.  Type \"show warranty\" for details.\n");
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
+This is free software: you are free to change and redistribute it.\n\
+There is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\n\
+and \"show warranty\" for details.\n");
 
   /* After the required info we print the configuration information. */
 
@@ -1172,6 +1145,13 @@ There is absolutely no warranty for GDB.  Type \"show warranty\" for details.\n"
       fprintf_filtered (stream, "%s", host_name);
     }
   fprintf_filtered (stream, "\".");
+
+  if (REPORT_BUGS_TO[0])
+    {
+      fprintf_filtered (stream, 
+                       _("\nFor bug reporting instructions, please see:\n"));
+      fprintf_filtered (stream, "%s.", REPORT_BUGS_TO);
+    }
 }
 \f
 /* get_prompt: access method for the GDB prompt string.  */
@@ -1212,7 +1192,7 @@ quit_confirm (void)
       else if (attach_flag)
        s = "The program is running.  Quit anyway (and detach it)? ";
       else
-       s = "The program is running.  Exit anyway? ";
+       s = "The program is running.  Quit anyway (and kill it)? ";
 
       if (!query ("%s", s))
        return 0;
This page took 0.026281 seconds and 4 git commands to generate.