2003-11-07 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / top.c
index 3bffaf4efd4d3915d42e1a712a79ac13fdb97760..c52c1765d68aa8cee05908fabe4bf3570ffe71fe 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1,6 +1,8 @@
 /* Top level stuff for GDB, the GNU debugger.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -25,6 +27,7 @@
 #include "cli/cli-cmds.h"
 #include "cli/cli-script.h"
 #include "cli/cli-setshow.h"
+#include "cli/cli-decode.h"
 #include "symtab.h"
 #include "inferior.h"
 #include <signal.h>
 #include "gdb_string.h"
 #include "gdb_stat.h"
 #include <ctype.h>
-#ifdef UI_OUT
 #include "ui-out.h"
 #include "cli-out.h"
-#endif
 
 /* Default command line prompt.  This is overriden in some configs. */
 
@@ -81,7 +82,7 @@ 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 = 1;
+int use_windows = 0;
 
 extern char lang_frame_mismatch_warn[];                /* language.c */
 
@@ -146,7 +147,7 @@ int baud_rate = -1;
    In mid-1996, remote_timeout was moved from remote.c to top.c and 
    it began being used in other remote-* targets.  It appears that the
    default was changed to 20 seconds at that time, perhaps because the
-   Hitachi E7000 ICE didn't always respond in a timely manner.
+   Renesas E7000 ICE didn't always respond in a timely manner.
 
    But if 5 seconds is a long time to sit and wait for retransmissions,
    20 seconds is far worse.  This demonstrates the difficulty of using 
@@ -170,6 +171,11 @@ int target_executing = 0;
 /* Level of control structure.  */
 static int control_level;
 
+/* Sbrk location on entry to main.  Used for statistics only.  */
+#ifdef HAVE_SBRK
+char *lim_at_start;
+#endif
+
 /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT.  */
 
 #ifndef STOP_SIGNAL
@@ -196,7 +202,7 @@ void (*init_ui_hook) (char *argv0);
 int (*ui_loop_hook) (int);
 
 /* Called instead of command_loop at top level.  Can be invoked via
-   return_to_top_level.  */
+   throw_exception().  */
 
 void (*command_loop_hook) (void);
 
@@ -298,13 +304,13 @@ NORETURN void (*error_hook) (void) ATTR_NORETURN;
 #define SIGLONGJMP(buf,val)    longjmp((buf), (val))
 #endif
 
-/* Where to go for return_to_top_level.  */
+/* Where to go for throw_exception().  */
 static SIGJMP_BUF *catch_return;
 
 /* Return for reason REASON to the nearest containing catch_errors().  */
 
 NORETURN void
-return_to_top_level (enum return_reason reason)
+throw_exception (enum return_reason reason)
 {
   quit_flag = 0;
   immediate_quit = 0;
@@ -340,7 +346,7 @@ return_to_top_level (enum return_reason reason)
 
 /* Call FUNC() with args FUNC_UIOUT and FUNC_ARGS, catching any
    errors.  Set FUNC_CAUGHT to an ``enum return_reason'' if the
-   function is aborted (using return_to_top_level() or zero if the
+   function is aborted (using throw_exception() or zero if the
    function returns normally.  Set FUNC_VAL to the value returned by
    the function or 0 if the function was aborted.
 
@@ -458,7 +464,7 @@ catcher (catch_exceptions_ftype *func,
   /* The caller didn't request that the event be caught, relay the
      event to the next containing catch_errors(). */
 
-  return_to_top_level (caught);
+  throw_exception (caught);
 }
 
 int
@@ -484,7 +490,7 @@ struct catch_errors_args
   void *func_args;
 };
 
-int
+static int
 do_catch_errors (struct ui_out *uiout, void *data)
 {
   struct catch_errors_args *args = data;
@@ -634,8 +640,8 @@ do_chdir_cleanup (void *old_dir)
 void
 execute_command (char *p, int from_tty)
 {
-  register struct cmd_list_element *c;
-  register enum language flang;
+  struct cmd_list_element *c;
+  enum language flang;
   static int warned = 0;
   char *line;
   
@@ -663,19 +669,28 @@ execute_command (char *p, int from_tty)
       /* If the target is running, we allow only a limited set of
          commands. */
       if (event_loop_p && target_can_async_p () && target_executing)
-       if (!strcmp (c->name, "help")
-           && !strcmp (c->name, "pwd")
-           && !strcmp (c->name, "show")
-           && !strcmp (c->name, "stop"))
+       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.");
 
       /* Pass null arg rather than an empty one.  */
       arg = *p ? p : 0;
 
-      /* Clear off trailing whitespace, except for set and complete command.  */
+      /* FIXME: cagney/2002-02-02: The c->type test is pretty dodgy
+         while the is_complete_command(cfunc) test is just plain
+         bogus.  They should both be replaced by a test of the form
+         c->strip_trailing_white_space_p.  */
+      /* NOTE: cagney/2002-02-02: The function.cfunc in the below
+         can't be replaced with func.  This is because it is the
+         cfunc, and not the func, that has the value that the
+         is_complete_command hack is testing for.  */
+      /* Clear off trailing whitespace, except for set and complete
+         command.  */
       if (arg
          && c->type != set_cmd
-         && !is_complete_command (c->function.cfunc))
+         && !is_complete_command (c))
        {
          p = arg + strlen (arg) - 1;
          while (p >= arg && (*p == ' ' || *p == '\t'))
@@ -684,12 +699,7 @@ execute_command (char *p, int from_tty)
        }
 
       /* If this command has been pre-hooked, run the hook first. */
-      if ((c->hook_pre) && (!c->hook_in))
-      {
-        c->hook_in = 1; /* Prevent recursive hooking */
-        execute_user_command (c->hook_pre, (char *) 0);
-        c->hook_in = 0; /* Allow hook to work again once it is complete */
-      }
+      execute_cmd_pre_hook (c);
 
       if (c->flags & DEPRECATED_WARN_USER)
        deprecated_cmd_warning (&line);
@@ -698,20 +708,15 @@ execute_command (char *p, int from_tty)
        execute_user_command (c, arg);
       else if (c->type == set_cmd || c->type == show_cmd)
        do_setshow_command (arg, from_tty & caution, c);
-      else if (c->function.cfunc == NO_FUNCTION)
+      else if (!cmd_func_p (c))
        error ("That is not a command, just a help topic.");
       else if (call_command_hook)
        call_command_hook (c, arg, from_tty & caution);
       else
-       (*c->function.cfunc) (arg, from_tty & caution);
+       cmd_func (c, arg, from_tty & caution);
        
       /* If this command has been post-hooked, run the hook last. */
-      if ((c->hook_post) && (!c->hook_in))
-      {
-        c->hook_in = 1; /* Prevent recursive hooking */
-        execute_user_command (c->hook_post, (char *) 0);
-        c->hook_in = 0; /* allow hook to work again once it is complete */
-      }
+      execute_cmd_post_hook (c);
 
     }
 
@@ -782,10 +787,8 @@ command_loop (void)
       if (display_space)
        {
 #ifdef HAVE_SBRK
-         extern char **environ;
          char *lim = (char *) sbrk (0);
-
-         space_at_cmd_start = (long) (lim - (char *) &environ);
+         space_at_cmd_start = lim - lim_at_start;
 #endif
        }
 
@@ -805,9 +808,8 @@ command_loop (void)
       if (display_space)
        {
 #ifdef HAVE_SBRK
-         extern char **environ;
          char *lim = (char *) sbrk (0);
-         long space_now = lim - (char *) &environ;
+         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",
@@ -890,11 +892,6 @@ gdb_readline (char *prompt_arg)
          character position to be off, since the newline we read from
          the user is not accounted for.  */
       fputs_unfiltered (prompt_arg, gdb_stdout);
-      /* OBSOLETE #ifdef MPW */
-      /* OBSOLETE          Move to a new line so the entered line doesn't have a prompt */
-      /* OBSOLETE          on the front of it. */
-      /* OBSOLETE       fputs_unfiltered ("\n", gdb_stdout); */
-      /* OBSOLETE #endif  *//* MPW */
       gdb_flush (gdb_stdout);
     }
 
@@ -952,6 +949,29 @@ static int write_history_p;
 static int history_size;
 static char *history_filename;
 
+/* This is like readline(), but it has some gdb-specific behavior.
+   gdb can use readline in both the synchronous and async modes during
+   a single gdb invocation.  At the ordinary top-level prompt we might
+   be using the async readline.  That means we can't use
+   rl_pre_input_hook, since it doesn't work properly in async mode.
+   However, for a secondary prompt (" >", such as occurs during a
+   `define'), gdb just calls readline() directly, running it in
+   synchronous mode.  So for operate-and-get-next to work in this
+   situation, we have to switch the hooks around.  That is what
+   gdb_readline_wrapper is for.  */
+char *
+gdb_readline_wrapper (char *prompt)
+{
+  /* Set the hook that works in this case.  */
+  if (event_loop_p && after_char_processing_hook)
+    {
+      rl_pre_input_hook = (Function *) after_char_processing_hook;
+      after_char_processing_hook = NULL;
+    }
+
+  return readline (prompt);
+}
+
 \f
 #ifdef STOP_SIGNAL
 static void
@@ -1041,8 +1061,8 @@ static int operate_saved_history = -1;
 
 /* This is put on the appropriate hook and helps operate-and-get-next
    do its work.  */
-void
-gdb_rl_operate_and_get_next_completion ()
+static void
+gdb_rl_operate_and_get_next_completion (void)
 {
   int delta = where_history () - operate_saved_history;
   /* The `key' argument to rl_get_previous_history is ignored.  */
@@ -1064,6 +1084,8 @@ gdb_rl_operate_and_get_next_completion ()
 static int
 gdb_rl_operate_and_get_next (int count, int key)
 {
+  int where;
+
   if (event_loop_p)
     {
       /* Use the async hook.  */
@@ -1076,8 +1098,20 @@ gdb_rl_operate_and_get_next (int count, int key)
       rl_pre_input_hook = (Function *) gdb_rl_operate_and_get_next_completion;
     }
 
-  /* Add 1 because we eventually want the next line.  */
-  operate_saved_history = where_history () + 1;
+  /* Find the current line, and find the next line to use.  */
+  where = where_history();
+
+  /* FIXME: kettenis/20020817: max_input_history is renamed into
+     history_max_entries in readline-4.2.  When we do a new readline
+     import, we should probably change it here too, even though
+     readline maintains backwards compatibility for now by still
+     defining max_input_history.  */
+  if ((history_is_stifled () && (history_length >= max_input_history)) ||
+      (where >= history_length - 1))
+    operate_saved_history = where;
+  else
+    operate_saved_history = where + 1;
+
   return rl_newline (1, key);
 }
 \f
@@ -1101,7 +1135,7 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
 {
   static char *linebuffer = 0;
   static unsigned linelength = 0;
-  register char *p;
+  char *p;
   char *p1;
   char *rl;
   char *local_prompt = prompt_arg;
@@ -1167,9 +1201,9 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
 
       if (annotation_level > 1 && instream == stdin)
        {
-         printf_unfiltered ("\n\032\032pre-");
-         printf_unfiltered (annotation_suffix);
-         printf_unfiltered ("\n");
+         puts_unfiltered ("\n\032\032pre-");
+         puts_unfiltered (annotation_suffix);
+         puts_unfiltered ("\n");
        }
 
       /* Don't use fancy stuff if not talking to stdin.  */
@@ -1179,7 +1213,7 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
        }
       else if (command_editing_p && instream == stdin && ISATTY (instream))
        {
-         rl = readline (local_prompt);
+         rl = gdb_readline_wrapper (local_prompt);
        }
       else
        {
@@ -1188,9 +1222,9 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
 
       if (annotation_level > 1 && instream == stdin)
        {
-         printf_unfiltered ("\n\032\032post-");
-         printf_unfiltered (annotation_suffix);
-         printf_unfiltered ("\n");
+         puts_unfiltered ("\n\032\032post-");
+         puts_unfiltered (annotation_suffix);
+         puts_unfiltered ("\n");
        }
 
       if (!rl || rl == (char *) EOF)
@@ -1232,7 +1266,7 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
 #define SERVER_COMMAND_LENGTH 7
   server_command =
     (p - linebuffer > SERVER_COMMAND_LENGTH)
-    && STREQN (linebuffer, "server ", SERVER_COMMAND_LENGTH);
+    && strncmp (linebuffer, "server ", SERVER_COMMAND_LENGTH) == 0;
   if (server_command)
     {
       /* Note that we don't set `line'.  Between this and the check in
@@ -1325,7 +1359,7 @@ print_gdb_version (struct ui_file *stream)
 
   /* Second line is a copyright notice. */
 
-  fprintf_filtered (stream, "Copyright 2001 Free Software Foundation, Inc.\n");
+  fprintf_filtered (stream, "Copyright 2003 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
@@ -1341,7 +1375,7 @@ There is absolutely no warranty for GDB.  Type \"show warranty\" for details.\n"
   /* After the required info we print the configuration information. */
 
   fprintf_filtered (stream, "This GDB was configured as \"");
-  if (!STREQ (host_name, target_name))
+  if (strcmp (host_name, target_name) != 0)
     {
       fprintf_filtered (stream, "--host=%s --target=%s", host_name, target_name);
     }
@@ -1354,267 +1388,13 @@ There is absolutely no warranty for GDB.  Type \"show warranty\" for details.\n"
 \f
 /* get_prompt: access method for the GDB prompt string.  */
 
-#define MAX_PROMPT_SIZE 256
-
-/*
- * int get_prompt_1 (char * buf);
- *
- * Work-horse for get_prompt (called via catch_errors).
- * Argument is buffer to hold the formatted prompt.
- *
- * Returns: 1 for success (use formatted prompt)
- *          0 for failure (use gdb_prompt_string).
- */
-
-static int gdb_prompt_escape;
-
-static int
-get_prompt_1 (void *data)
-{
-  char *formatted_prompt = data;
-  char *local_prompt;
-
-  if (event_loop_p)
-    local_prompt = PROMPT (0);
-  else
-    local_prompt = gdb_prompt_string;
-
-
-  if (gdb_prompt_escape == 0)
-    {
-      return 0;                        /* do no formatting */
-    }
-  else
-    /* formatted prompt */
-    {
-      char fmt[40], *promptp, *outp, *tmp;
-      struct value *arg_val;
-      DOUBLEST doubleval;
-      LONGEST longval;
-      CORE_ADDR addrval;
-
-      int i, len;
-      struct type *arg_type, *elt_type;
-
-      promptp = local_prompt;
-      outp = formatted_prompt;
-
-      while (*promptp != '\0')
-       {
-         int available = MAX_PROMPT_SIZE - (outp - formatted_prompt) - 1;
-
-         if (*promptp != gdb_prompt_escape)
-           {
-             if (available >= 1)       /* overflow protect */
-               *outp++ = *promptp++;
-           }
-         else
-           {
-             /* GDB prompt string contains escape char.  Parse for arg.
-                Two consecutive escape chars followed by arg followed by
-                a comma means to insert the arg using a default format.
-                Otherwise a printf format string may be included between
-                the two escape chars.  eg:
-                %%foo, insert foo using default format
-                %2.2f%foo,     insert foo using "%2.2f" format
-                A mismatch between the format string and the data type
-                of "foo" is an error (which we don't know how to protect
-                against).  */
-
-             fmt[0] = '\0';    /* assume null format string */
-             if (promptp[1] == gdb_prompt_escape)      /* double esc char */
-               {
-                 promptp += 2; /* skip past two escape chars. */
-               }
-             else
-               {
-                 /* extract format string from between two esc chars */
-                 i = 0;
-                 do
-                   {
-                     fmt[i++] = *promptp++;    /* copy format string */
-                   }
-                 while (i < sizeof (fmt) - 1 &&
-                        *promptp != gdb_prompt_escape &&
-                        *promptp != '\0');
-
-                 if (*promptp != gdb_prompt_escape)
-                   error ("Syntax error at prompt position %d",
-                          promptp - local_prompt);
-                 else
-                   {
-                     promptp++;        /* skip second escape char */
-                     fmt[i++] = '\0';  /* terminate the format string */
-                   }
-               }
-
-             arg_val = parse_to_comma_and_eval (&promptp);
-             if (*promptp == ',')
-               promptp++;      /* skip past the comma */
-             arg_type = check_typedef (VALUE_TYPE (arg_val));
-             switch (TYPE_CODE (arg_type))
-               {
-               case TYPE_CODE_ARRAY:
-                 elt_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
-                 if (TYPE_LENGTH (arg_type) > 0 &&
-                     TYPE_LENGTH (elt_type) == 1 &&
-                     TYPE_CODE (elt_type) == TYPE_CODE_INT)
-                   {
-                     int len = TYPE_LENGTH (arg_type);
-
-                     if (VALUE_LAZY (arg_val))
-                       value_fetch_lazy (arg_val);
-                     tmp = VALUE_CONTENTS (arg_val);
-
-                     if (len > available)
-                       len = available;        /* overflow protect */
-
-                     /* FIXME: how to protect GDB from crashing
-                        from bad user-supplied format string? */
-                     if (fmt[0] != 0)
-                       sprintf (outp, fmt, tmp);
-                     else
-                       strncpy (outp, tmp, len);
-                     outp[len] = '\0';
-                   }
-                 break;
-               case TYPE_CODE_PTR:
-                 elt_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
-                 addrval = value_as_address (arg_val);
-
-                 if (TYPE_LENGTH (elt_type) == 1 &&
-                     TYPE_CODE (elt_type) == TYPE_CODE_INT &&
-                     addrval != 0)
-                   {
-                     /* display it as a string */
-                     char *default_fmt = "%s";
-                     char *tmp;
-                     int err = 0;
-
-                     /* Limiting the number of bytes that the following call
-                        will read protects us from sprintf overflow later. */
-                     i = target_read_string (addrval,  /* src */
-                                             &tmp,     /* dest */
-                                             available,        /* len */
-                                             &err);
-                     if (err)  /* read failed */
-                       error ("%s on target_read", safe_strerror (err));
-
-                     tmp[i] = '\0';    /* force-terminate string */
-                     /* FIXME: how to protect GDB from crashing
-                        from bad user-supplied format string? */
-                     sprintf (outp, fmt[0] == 0 ? default_fmt : fmt,
-                              tmp);
-                     xfree (tmp);
-                   }
-                 else
-                   {
-                     /* display it as a pointer */
-                     char *default_fmt = "0x%x";
-
-                     /* FIXME: how to protect GDB from crashing
-                        from bad user-supplied format string? */
-                     if (available >= 16 /*? */ )      /* overflow protect */
-                       sprintf (outp, fmt[0] == 0 ? default_fmt : fmt,
-                                (long) addrval);
-                   }
-                 break;
-               case TYPE_CODE_FLT:
-                 {
-                   char *default_fmt = "%g";
-
-                   doubleval = value_as_double (arg_val);
-                   /* FIXME: how to protect GDB from crashing
-                      from bad user-supplied format string? */
-                   if (available >= 16 /*? */ )        /* overflow protect */
-                     sprintf (outp, fmt[0] == 0 ? default_fmt : fmt,
-                              (double) doubleval);
-                   break;
-                 }
-               case TYPE_CODE_INT:
-                 {
-                   char *default_fmt = "%d";
-
-                   longval = value_as_long (arg_val);
-                   /* FIXME: how to protect GDB from crashing
-                      from bad user-supplied format string? */
-                   if (available >= 16 /*? */ )        /* overflow protect */
-                     sprintf (outp, fmt[0] == 0 ? default_fmt : fmt,
-                              (long) longval);
-                   break;
-                 }
-               case TYPE_CODE_BOOL:
-                 {
-                   /* no default format for bool */
-                   longval = value_as_long (arg_val);
-                   if (available >= 8 /*? */ )         /* overflow protect */
-                     {
-                       if (longval)
-                         strcpy (outp, "<true>");
-                       else
-                         strcpy (outp, "<false>");
-                     }
-                   break;
-                 }
-               case TYPE_CODE_ENUM:
-                 {
-                   /* no default format for enum */
-                   longval = value_as_long (arg_val);
-                   len = TYPE_NFIELDS (arg_type);
-                   /* find enum name if possible */
-                   for (i = 0; i < len; i++)
-                     if (TYPE_FIELD_BITPOS (arg_type, i) == longval)
-                       break;  /* match -- end loop */
-
-                   if (i < len)        /* enum name found */
-                     {
-                       char *name = TYPE_FIELD_NAME (arg_type, i);
-
-                       strncpy (outp, name, available);
-                       /* in casel available < strlen (name), */
-                       outp[available] = '\0';
-                     }
-                   else
-                     {
-                       if (available >= 16 /*? */ )    /* overflow protect */
-                         sprintf (outp, "%ld", (long) longval);
-                     }
-                   break;
-                 }
-               case TYPE_CODE_VOID:
-                 *outp = '\0';
-                 break;        /* void type -- no output */
-               default:
-                 error ("bad data type at prompt position %d",
-                        promptp - local_prompt);
-                 break;
-               }
-             outp += strlen (outp);
-           }
-       }
-      *outp++ = '\0';          /* terminate prompt string */
-      return 1;
-    }
-}
-
 char *
 get_prompt (void)
 {
-  static char buf[MAX_PROMPT_SIZE];
-
-  if (catch_errors (get_prompt_1, buf, "bad formatted prompt: ",
-                   RETURN_MASK_ALL))
-    {
-      return &buf[0];          /* successful formatted prompt */
-    }
+  if (event_loop_p)
+    return PROMPT (0);
   else
-    {
-      /* Prompt could not be formatted.  */
-      if (event_loop_p)
-       return PROMPT (0);
-      else
-       return gdb_prompt_string;
-    }
+    return gdb_prompt_string;
 }
 
 void
@@ -1652,39 +1432,36 @@ quit_confirm (void)
       else
        s = "The program is running.  Exit anyway? ";
 
-      if (!query (s))
+      if (!query ("%s", s))
        return 0;
     }
 
   return 1;
 }
 
-/* Quit without asking for confirmation.  */
+/* Helper routine for quit_force that requires error handling.  */
 
-void
-quit_force (char *args, int from_tty)
+struct qt_args
 {
-  int exit_code = 0;
-
-  /* An optional expression may be used to cause gdb to terminate with the 
-     value of that expression. */
-  if (args)
-    {
-      struct value *val = parse_and_eval (args);
+  char *args;
+  int from_tty;
+};
 
-      exit_code = (int) value_as_long (val);
-    }
+static int
+quit_target (void *arg)
+{
+  struct qt_args *qt = (struct qt_args *)arg;
 
   if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
     {
       if (attach_flag)
-       target_detach (args, from_tty);
+        target_detach (qt->args, qt->from_tty);
       else
-       target_kill ();
+        target_kill ();
     }
 
   /* UDI wants this, to kill the TIP.  */
-  target_close (1);
+  target_close (&current_target, 1);
 
   /* Save the history information if it is appropriate to do so.  */
   if (write_history_p && history_filename)
@@ -1692,6 +1469,33 @@ quit_force (char *args, int from_tty)
 
   do_final_cleanups (ALL_CLEANUPS);    /* Do any final cleanups before exiting */
 
+  return 0;
+}
+
+/* Quit without asking for confirmation.  */
+
+void
+quit_force (char *args, int from_tty)
+{
+  int exit_code = 0;
+  struct qt_args qt;
+
+  /* An optional expression may be used to cause gdb to terminate with the 
+     value of that expression. */
+  if (args)
+    {
+      struct value *val = parse_and_eval (args);
+
+      exit_code = (int) value_as_long (val);
+    }
+
+  qt.args = args;
+  qt.from_tty = from_tty;
+
+  /* We want to handle any quit errors and exit regardless.  */
+  catch_errors (quit_target, &qt,
+               "Quitting: ", RETURN_MASK_ALL);
+
   exit (exit_code);
 }
 
@@ -1704,7 +1508,6 @@ input_from_terminal_p (void)
   return gdb_has_a_terminal () && (instream == stdin) & caution;
 }
 \f
-/* ARGSUSED */
 static void
 dont_repeat_command (char *ignored, int from_tty)
 {
@@ -1790,7 +1593,6 @@ show_commands (char *args, int from_tty)
 }
 
 /* Called by do_setshow_command.  */
-/* ARGSUSED */
 static void
 set_history_size_command (char *args, int from_tty, struct cmd_list_element *c)
 {
@@ -1805,7 +1607,6 @@ set_history_size_command (char *args, int from_tty, struct cmd_list_element *c)
     }
 }
 
-/* ARGSUSED */
 void
 set_history (char *args, int from_tty)
 {
@@ -1813,7 +1614,6 @@ set_history (char *args, int from_tty)
   help_list (sethistlist, "set history ", -1, gdb_stdout);
 }
 
-/* ARGSUSED */
 void
 show_history (char *args, int from_tty)
 {
@@ -1823,7 +1623,6 @@ show_history (char *args, int from_tty)
 int info_verbose = 0;          /* Default verbose msgs off */
 
 /* Called by do_setshow_command.  An elaborate joke.  */
-/* ARGSUSED */
 void
 set_verbose (char *args, int from_tty, struct cmd_list_element *c)
 {
@@ -1912,7 +1711,6 @@ init_main (void)
       if (annotation_level > 1)
         set_async_annotation_level (NULL, 0, NULL);
     }
-  gdb_prompt_escape = 0;       /* default to none.  */
 
   /* Set the important stuff up for command editing.  */
   command_editing_p = 1;
@@ -1920,11 +1718,11 @@ init_main (void)
   write_history_p = 0;
 
   /* Setup important stuff for command line editing.  */
-  rl_completion_entry_function = (int (*)()) readline_line_completion_function;
-  rl_completer_word_break_characters =
-                                get_gdb_completer_word_break_characters ();
+  rl_completion_entry_function = readline_line_completion_function;
+  rl_completer_word_break_characters = default_word_break_characters ();
   rl_completer_quote_characters = get_gdb_completer_quote_characters ();
   rl_readline_name = "gdb";
+  rl_terminal_name = getenv ("TERM");
 
   /* The name for this defun comes from Bash, where it originated.
      15 is Control-o, the same binding this function has in Bash.  */
@@ -1948,16 +1746,9 @@ init_main (void)
                       (char *) &new_async_prompt, "Set gdb's prompt",
                       &setlist);
       add_show_from_set (c, &showlist);
-      c->function.sfunc = set_async_prompt;
+      set_cmd_sfunc (c, set_async_prompt);
     }
 
-  add_show_from_set
-    (add_set_cmd ("prompt-escape-char", class_support, var_zinteger,
-                 (char *) &gdb_prompt_escape,
-                 "Set escape character for formatting of gdb's prompt",
-                 &setlist),
-     &showlist);
-
   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.");
@@ -1984,7 +1775,7 @@ Without an argument, command line editing is enabled.  To edit, use\n\
 EMACS-like or VI-like commands like control-P or ESC.", &setlist);
 
       add_show_from_set (c, &showlist);
-      c->function.sfunc = set_async_editing_command;
+      set_cmd_sfunc (c, set_async_editing_command);
     }
 
   add_show_from_set
@@ -1995,16 +1786,16 @@ Without an argument, saving is enabled.", &sethistlist),
      &showhistlist);
 
   c = add_set_cmd ("size", no_class, var_integer, (char *) &history_size,
-                  "Set the size of the command history, \n\
+                  "Set the size of the command history,\n\
 ie. the number of previous commands to keep a record of.", &sethistlist);
   add_show_from_set (c, &showhistlist);
-  c->function.sfunc = set_history_size_command;
+  set_cmd_sfunc (c, set_history_size_command);
 
   c = add_set_cmd ("filename", no_class, var_filename,
                   (char *) &history_filename,
                   "Set the filename in which to record the command history\n\
- (the list of previous commands of which a record is kept).", &sethistlist);
-  c->completer = filename_completer;
+(the list of previous commands of which a record is kept).", &sethistlist);
+  set_cmd_completer (c, filename_completer);
   add_show_from_set (c, &showhistlist);
 
   add_show_from_set
@@ -2035,7 +1826,7 @@ ie. the number of previous commands to keep a record of.", &sethistlist);
 2 == output annotated suitably for use by programs that control GDB.",
                       &setlist);
       add_show_from_set (c, &showlist);
-      c->function.sfunc = set_async_annotation_level;
+      set_cmd_sfunc (c, set_async_annotation_level);
     }
   if (event_loop_p)
     {
@@ -2091,21 +1882,4 @@ gdb_init (char *argv0)
      it wants GDB to revert to the CLI, it should clear init_ui_hook. */
   if (init_ui_hook)
     init_ui_hook (argv0);
-
-#ifdef UI_OUT
-  /* Install the default UI */
-  if (!init_ui_hook)
-    {
-      uiout = cli_out_new (gdb_stdout);
-
-      /* All the interpreters should have had a look at things by now.
-        Initialize the selected interpreter. */
-      if (interpreter_p)
-       {
-         fprintf_unfiltered (gdb_stderr, "Interpreter `%s' unrecognized.\n",
-                             interpreter_p);
-         exit (1);
-       }
-    }
-#endif
 }
This page took 0.035736 seconds and 4 git commands to generate.