* config/monitor.exp: Detect the "Couldn't establish connection"
[deliverable/binutils-gdb.git] / gdb / top.c
index bfab3f7306b0d92cb52e8ac72e2bdad25283b440..3afa8c9ad6627bb04f3e4b64dc49174963772e4e 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -48,19 +48,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #endif
 
 #include "gdb_string.h"
-#ifndef        NO_SYS_FILE
-#include <sys/file.h>
-#endif
-#include <sys/param.h>
 #include "gdb_stat.h"
 #include <ctype.h>
 
-extern void initialize_targets PARAMS ((void));
-
 extern void initialize_utils PARAMS ((void));
 
 /* Prototypes for local functions */
 
+static void dont_repeat_command PARAMS ((char *, int));
+
+static void source_cleanup_lines PARAMS ((PTR));
+
+static void user_defined_command PARAMS ((char *, int));
+
+static void init_signals PARAMS ((void));
+
+#ifdef STOP_SIGNAL
+static void stop_sig PARAMS ((int));
+#endif
+
+static void disconnect PARAMS ((int));
+
 static char * line_completion_function PARAMS ((char *, int, char *, int));
 
 static char * readline_line_completion_function PARAMS ((char *, int));
@@ -319,6 +327,10 @@ int server_command;
 
 int baud_rate = -1;
 
+/* Timeout limit for response from target. */
+
+int remote_timeout = 20;       /* Set default to 20 */
+
 /* Non-zero tells remote* modules to output debugging info.  */
 
 int remote_debug = 0;
@@ -389,7 +401,7 @@ void (*print_frame_info_listing_hook) PARAMS ((struct symtab *s, int line,
                                               int stopline, int noerror));
 /* Replaces most of query.  */
 
-int (*query_hook) PARAMS (());
+int (*query_hook) PARAMS ((const char *, va_list));
 
 /* Called from gdb_flush to flush output.  */
 
@@ -442,7 +454,7 @@ void (*call_command_hook) PARAMS ((struct cmd_list_element *c, char *cmd,
 /* Takes control from error ().  Typically used to prevent longjmps out of the
    middle of the GUI.  Usually used in conjunction with a catch routine.  */
 
-NORETURN void (*error_hook) PARAMS (()) ATTR_NORETURN;
+NORETURN void (*error_hook) PARAMS ((void)) ATTR_NORETURN;
 
 \f
 /* Where to go for return_to_top_level (RETURN_ERROR).  */
@@ -620,7 +632,7 @@ read_command_file (stream)
   do_cleanups (cleanups);
 }
 \f
-extern void init_proc ();
+extern void init_proc PARAMS ((void));
 
 void (*pre_init_ui_hook) PARAMS ((void));
 
@@ -799,6 +811,7 @@ execute_control_command (cmd)
   struct command_line *current;
   struct cleanup *old_chain = 0;
   value_ptr val;
+  value_ptr val_mark;
   int loop;
   enum command_control_type ret;
   char *new_line;
@@ -838,13 +851,18 @@ execute_control_command (cmd)
        /* Keep iterating so long as the expression is true.  */
        while (loop == 1)
          {
+           int cond_result;
+
            QUIT;
 
            /* Evaluate the expression.  */
+           val_mark = value_mark ();
            val = evaluate_expression (expr);
+           cond_result = value_true (val);
+           value_free_to_mark (val_mark);
 
            /* If the value is false, then break out of the loop.  */
-           if (!value_true (val))
+           if (!cond_result)
              break;
 
            /* Execute the body of the while statement.  */
@@ -892,6 +910,7 @@ execute_control_command (cmd)
        ret = simple_control;
 
        /* Evaluate the conditional.  */
+       val_mark = value_mark ();
        val = evaluate_expression (expr);
 
        /* Choose which arm to take commands from based on the value of the
@@ -900,6 +919,7 @@ execute_control_command (cmd)
          current = *cmd->body_list;
        else if (cmd->body_count == 2)
          current = *(cmd->body_list + 1);
+       value_free_to_mark (val_mark);
 
        /* Execute commands in the given arm.  */
        while (current)
@@ -1156,7 +1176,8 @@ execute_command (p, from_tty)
   register struct cmd_list_element *c;
   register enum language flang;
   static int warned = 0;
-  extern FILE *serial_logfp;
+  /* FIXME: These should really be in an appropriate header file */
+  extern void serial_log_command PARAMS ((const char *));
 
   free_all_values ();
 
@@ -1164,8 +1185,7 @@ execute_command (p, from_tty)
   if (p == NULL)
       return;
 
-  if (serial_logfp != NULL)
-    serial_log_command (p);
+  serial_log_command (p);
 
   while (*p == ' ' || *p == '\t') p++;
   if (*p)
@@ -1445,7 +1465,7 @@ filename_completer (text, word)
      char *word;
 {
   /* From readline.  */
-  extern char *filename_completion_function ();
+  extern char *filename_completion_function PARAMS ((char *, int));
   int subsequent_name;
   char **return_val;
   int return_val_used;
@@ -2731,29 +2751,43 @@ document_command (comname, from_tty)
   free_command_lines (&doclines);
 }
 \f
-void
-print_gnu_advertisement ()
-{
-    printf_unfiltered ("\
-GDB is free software and you are welcome to distribute copies of it\n\
- under certain conditions; type \"show copying\" to see the conditions.\n\
-There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
-");
-}
-
 void
 print_gdb_version (stream)
   GDB_FILE *stream;
 {
+  /* From GNU coding standards, first line is meant to be easy for a
+     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);
+
+  /* Second line is a copyright notice. */
+
+  fprintf_filtered (stream, "Copyright 1996 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
+     certain conditions, that it is covered by the GNU GPL, and that
+     there is no warranty. */
+
   fprintf_filtered (stream, "\
-GDB %s (%s", version, host_name);
+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");
 
-  if (!STREQ (host_name, target_name))
-    fprintf_filtered (stream, " --target %s", target_name);
+  /* After the required info we print the configuration information. */
 
-  fprintf_filtered (stream, "), ");
-  wrap_here("");
-  fprintf_filtered (stream, "Copyright 1996 Free Software Foundation, Inc.");
+  fprintf_filtered (stream, "This GDB was configured as \"");
+  if (!STREQ (host_name, target_name))
+    {
+      fprintf_filtered (stream, "--host=%s --target=%s", host_name, target_name);
+    }
+  else
+    {
+      fprintf_filtered (stream, "%s", host_name);
+    }
+  fprintf_filtered (stream, "\".");
 }
 
 /* ARGSUSED */
@@ -2763,7 +2797,6 @@ show_version (args, from_tty)
      int from_tty;
 {
   immediate_quit++;
-  print_gnu_advertisement ();
   print_gdb_version (gdb_stdout);
   printf_filtered ("\n");
   immediate_quit--;
@@ -2819,6 +2852,8 @@ quit_command (args, from_tty)
   if (write_history_p && history_filename)
     write_history (history_filename);
 
+  do_final_cleanups(ALL_CLEANUPS);     /* Do any final cleanups before exiting */
+
   exit (exit_code);
 }
 
@@ -2969,8 +3004,11 @@ source_command (args, from_tty)
   old_cleanups = make_cleanup (free, file);
 
   stream = fopen (file, FOPEN_RT);
-  if (stream == 0)
-    perror_with_name (file);
+  if (!stream)
+    if (from_tty)
+      perror_with_name (file);
+    else
+      return;
 
   make_cleanup (fclose, stream);
 
@@ -3589,4 +3627,18 @@ using remote targets.", &setlist),
 When enabled, each packet sent or received with the remote target\n\
 is displayed.", &setlist),
                     &showlist);
+
+  add_show_from_set (
+    add_set_cmd ("remotetimeout", no_class, var_integer, (char *)&remote_timeout,
+                  "Set timeout limit to wait for target to respond.\n\
+This value is used to set the time limit for gdb to wait for a response\n\
+from he target.", &setlist),
+                    &showlist);
+
+  c = add_set_cmd ("annotate", class_obscure, var_zinteger, 
+                  (char *)&annotation_level, "Set annotation_level.\n\
+0 == normal;     1 == fullname (for use when running under emacs)\n\
+2 == output annotated suitably for use by programs that control GDB.",
+                &setlist);
+  c = add_show_from_set (c, &showlist);
 }
This page took 0.028086 seconds and 4 git commands to generate.