* config/i386/nm-nbsd.h (FLOAT_INFO): Comment out.
[deliverable/binutils-gdb.git] / gdb / top.c
index 2d490a5bd072cb1506f19e4ad41ac3ed84552f2f..d7d85189515e2c4876a1780651a79d40602d742c 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1,5 +1,5 @@
 /* Top level stuff for GDB, the GNU debugger.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -649,6 +649,9 @@ build_command_line (type, args)
 {
   struct command_line *cmd;
 
+  if (args == NULL)
+    error ("if/while commands require arguments.\n");
+
   cmd = (struct command_line *)xmalloc (sizeof (struct command_line));
   cmd->next = NULL;
   cmd->control_type = type;
@@ -815,10 +818,10 @@ execute_control_command (cmd)
        make_cleanup (free_current_contents, &expr);
        
        ret = simple_control;
-       loop = true;
+       loop = 1;
 
        /* Keep iterating so long as the expression is true.  */
-       while (loop == true)
+       while (loop == 1)
          {
            /* Evaluate the expression.  */
            val = evaluate_expression (expr);
@@ -837,7 +840,7 @@ execute_control_command (cmd)
                   looping.  */
                if (ret == invalid_control || ret == break_control)
                  {
-                   loop = false;
+                   loop = 0;
                    break;
                  }
 
@@ -1136,6 +1139,7 @@ execute_command (p, from_tty)
   register struct cmd_list_element *c;
   register enum language flang;
   static int warned = 0;
+  extern FILE *serial_logfp;
 
   free_all_values ();
 
@@ -1143,6 +1147,9 @@ execute_command (p, from_tty)
   if (p == NULL)
       return;
 
+  if (serial_logfp != NULL)
+    serial_log_command (p);
+
   while (*p == ' ' || *p == '\t') p++;
   if (*p)
     {
@@ -1152,6 +1159,15 @@ execute_command (p, from_tty)
       /* Pass null arg rather than an empty one.  */
       arg = *p ? p : 0;
 
+      /* Clear off trailing whitespace, except for set and complete command.  */
+      if (arg && c->type != set_cmd && c->function.cfunc != complete_command)
+       {
+         p = arg + strlen (arg) - 1;
+         while (p >= arg && (*p == ' ' || *p == '\t'))
+           p--;
+         *(p + 1) = '\0';
+       }
+
       /* If this command has been hooked, run the hook first. */
       if (c->hook)
        execute_user_command (c->hook, (char *)0);
@@ -1824,6 +1840,12 @@ init_signals ()
 {
   signal (SIGINT, request_quit);
 
+  /* If SIGTRAP was set to SIG_IGN, then the SIG_IGN will get passed
+     to the inferior and breakpoints will be ignored.  */
+#ifdef SIGTRAP
+  signal (SIGTRAP, SIG_DFL);
+#endif
+
   /* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get
      passed to the inferior, which we don't want.  It would be
      possible to do a "signal (SIGQUIT, SIG_DFL)" after we fork, but
@@ -2029,16 +2051,11 @@ command_line_input (prrompt, repeat, annotation_suffix)
   /* If we just got an empty line, and that is supposed
      to repeat the previous command, return the value in the
      global buffer.  */
-  if (repeat)
-    {
-      if (p == linebuffer)
-       return line;
-      p1 = linebuffer;
-      while (*p1 == ' ' || *p1 == '\t')
-       p1++;
-      if (!*p1)
-       return line;
-    }
+  if (repeat && p == linebuffer)
+    return line;
+  for (p1 = linebuffer; *p1 == ' ' || *p1 == '\t'; p1++) ;
+  if (repeat && !*p1)
+    return line;
 
   *p = 0;
 
@@ -2053,36 +2070,8 @@ command_line_input (prrompt, repeat, annotation_suffix)
      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.  */
-  p1 = linebuffer;
-  while ((c = *p1++) != '\0')
-    {
-      if (c == '"')
-       while ((c = *p1++) != '"')
-         {
-           /* Make sure an escaped '"' doesn't make us think the string
-              is ended.  */
-           if (c == '\\')
-             parse_escape (&p1);
-           if (c == '\0')
-             break;
-         }
-      else if (c == '\'')
-       while ((c = *p1++) != '\'')
-         {
-           /* Make sure an escaped '\'' doesn't make us think the string
-              is ended.  */
-           if (c == '\\')
-             parse_escape (&p1);
-           if (c == '\0')
-             break;
-         }
-      else if (c == '#')
-       {
-         /* Found a comment.  */
-         p1[-1] = '\0';
-         break;
-       }
-    }
+  if (*p1 == '#')
+    *p1 = '\0';  /* Found a comment. */
 
   /* Save into global buffer if appropriate.  */
   if (repeat)
@@ -2237,9 +2226,7 @@ recurse_read_control_structure (current_cmd)
   enum misc_command_type val;
   enum command_control_type ret;
   struct command_line **body_ptr, *child_tail, *next;
-  struct cleanup *old_chains, *tmp_chains;
 
-  old_chains = NULL;
   child_tail = NULL;
   current_body = 1;
 
@@ -2308,19 +2295,12 @@ recurse_read_control_structure (current_cmd)
        }
       else
        {
-         /* We have just read the first line of the child's control
-            structure.  From now on, arrange to throw away the line
-            we have if we quit or get an error.  */
          body_ptr = current_cmd->body_list;
          for (i = 1; i < current_body; i++)
            body_ptr++;
 
          *body_ptr = next;
 
-         tmp_chains = make_cleanup (free_command_lines, body_ptr);
-
-         if (!old_chains)
-           old_chains = tmp_chains;
        }
 
       child_tail = next;
@@ -2340,10 +2320,6 @@ recurse_read_control_structure (current_cmd)
     }
 
   dont_repeat ();
-  if (ret == invalid_control && old_chains)
-    do_cleanups (old_chains);
-  else if (old_chains)
-    discard_cleanups (old_chains);
 
   return ret;
 }
@@ -2574,7 +2550,7 @@ validate_comname (comname)
   p = comname;
   while (*p)
     {
-      if (!isalnum(*p) && *p != '-')
+      if (!isalnum(*p) && *p != '-' && *p != '_')
        error ("Junk in argument list: \"%s\"", p);
       p++;
     }
@@ -2737,7 +2713,7 @@ GDB %s (%s", version, host_name);
 
   fprintf_filtered (stream, "), ");
   wrap_here("");
-  fprintf_filtered (stream, "Copyright 1995 Free Software Foundation, Inc.");
+  fprintf_filtered (stream, "Copyright 1996 Free Software Foundation, Inc.");
 }
 
 /* ARGSUSED */
@@ -3021,6 +2997,15 @@ echo_command (text, from_tty)
   gdb_flush (gdb_stdout);
 }
 
+/* ARGSUSED */
+static void
+dont_repeat_command (ignored, from_tty)
+     char *ignored;
+     int from_tty;
+{
+  *line = 0;           /* Can't call dont_repeat here because we're not
+                          necessarily reading from stdin.  */
+}
 \f
 #ifdef TARGET_BYTE_ORDER_SELECTABLE
 
@@ -3096,7 +3081,7 @@ set_endian_from_file (abfd)
 #ifdef TARGET_BYTE_ORDER_SELECTABLE
   int want;
 
-  if (abfd->xvec->byteorder_big_p)
+  if (bfd_big_endian (abfd))
     want = BIG_ENDIAN;
   else
     want = LITTLE_ENDIAN;
@@ -3109,11 +3094,11 @@ set_endian_from_file (abfd)
 
 #else /* ! defined (TARGET_BYTE_ORDER_SELECTABLE) */
 
-  if (abfd->xvec->byteorder_big_p
+  if (bfd_big_endian (abfd)
       ? TARGET_BYTE_ORDER != BIG_ENDIAN
       : TARGET_BYTE_ORDER == BIG_ENDIAN)
     warning ("%s endian file does not match %s endian target.",
-            abfd->xvec->byteorder_big_p ? "big" : "little",
+            bfd_big_endian (abfd) ? "big" : "little",
             TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little");
 
 #endif /* ! defined (TARGET_BYTE_ORDER_SELECTABLE) */
@@ -3455,6 +3440,9 @@ when gdb is started.", &cmdlist);
   add_com_alias ("q", "quit", class_support, 1);
   add_com_alias ("h", "help", class_support, 1);
 
+  add_com ("dont-repeat", class_support, dont_repeat_command, "Don't repeat this command.\n\
+Primarily used inside of user-defined commands that should not be repeated when\n\
+hitting return.");
 
   c = add_set_cmd ("verbose", class_support, var_boolean, (char *)&info_verbose,
                   "Set ",
This page took 0.0274 seconds and 4 git commands to generate.