import gdb-1999-07-07 post reformat
[deliverable/binutils-gdb.git] / gdb / top.c
index 9bf018e79efda936c1bdb035c2bc3a69b7ebf253..12b63754b8b3d90e1e0b23b7f60e77635fceb998 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1,5 +1,5 @@
 /* Top level stuff for GDB, the GNU debugger.
 /* Top level stuff for GDB, the GNU debugger.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995
+   Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
    Free Software Foundation, Inc.
 
 This file is part of GDB.
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -16,7 +16,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
 #include "gdbcmd.h"
 
 #include "defs.h"
 #include "gdbcmd.h"
@@ -32,41 +32,47 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "language.h"
 #include "terminal.h" /* For job_control.  */
 #include "annotate.h"
 #include "language.h"
 #include "terminal.h" /* For job_control.  */
 #include "annotate.h"
-#include <setjmp.h>
 #include "top.h"
 
 /* readline include files */
 #include "top.h"
 
 /* readline include files */
-#include "readline.h"
-#include "history.h"
+#include <readline/readline.h>
+#include <readline/history.h>
 
 /* readline defines this.  */
 #undef savestring
 
 #include <sys/types.h>
 
 /* readline defines this.  */
 #undef savestring
 
 #include <sys/types.h>
-#ifdef USG
-/* What is this for?  X_OK?  */
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 
 #include <unistd.h>
 #endif
 
-#include <string.h>
-#ifndef        NO_SYS_FILE
-#include <sys/file.h>
-#endif
-#include <sys/param.h>
-#include <sys/stat.h>
+#include "event-loop.h"
+#include "gdb_string.h"
+#include "gdb_stat.h"
 #include <ctype.h>
 
 #include <ctype.h>
 
-extern void initialize_targets PARAMS ((void));
+/* Prototypes for local functions */
 
 
-extern void initialize_utils PARAMS ((void));
+static void dont_repeat_command PARAMS ((char *, int));
 
 
-/* Prototypes for local functions */
+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 char * line_completion_function PARAMS ((char *, int, char *, int));
 
 static char * readline_line_completion_function PARAMS ((char *, int));
 
 
 static char * line_completion_function PARAMS ((char *, int, char *, int));
 
 static char * readline_line_completion_function PARAMS ((char *, int));
 
-static void command_loop_marker PARAMS ((int));
+/* NOTE 1999-04-29: this function will be static again, after we make the
+   event loop be the default command loop for gdb, and we merge
+   event-top.c into this file, top.c */
+/* static */ void command_loop_marker PARAMS ((int));
 
 static void while_command PARAMS ((char *, int));
 
 
 static void while_command PARAMS ((char *, int));
 
@@ -103,20 +109,6 @@ static void init_signals PARAMS ((void));
 
 static void set_verbose PARAMS ((char *, int, struct cmd_list_element *));
 
 
 static void set_verbose PARAMS ((char *, int, struct cmd_list_element *));
 
-#ifdef TARGET_BYTE_ORDER_SELECTABLE
-
-static void set_endian PARAMS ((char *, int));
-
-static void set_endian_big PARAMS ((char *, int));
-
-static void set_endian_little PARAMS ((char *, int));
-
-static void set_endian_auto PARAMS ((char *, int));
-
-static void show_endian PARAMS ((char *, int));
-
-#endif
-
 static void show_history PARAMS ((char *, int));
 
 static void set_history PARAMS ((char *, int));
 static void show_history PARAMS ((char *, int));
 
 static void set_history PARAMS ((char *, int));
@@ -148,9 +140,14 @@ static void complete_command PARAMS ((char *, int));
 
 static void do_nothing PARAMS ((int));
 
 
 static void do_nothing PARAMS ((int));
 
-static int quit_cover PARAMS ((char *));
+#ifdef SIGHUP
+/* NOTE 1999-04-29: This function will be static again, once we modify
+   gdb to use the event loop as the default command loop and we merge
+   event-top.c into this file, top.c */
+/* static */ int quit_cover PARAMS ((PTR));
 
 static void disconnect PARAMS ((int));
 
 static void disconnect PARAMS ((int));
+#endif
 
 static void source_cleanup PARAMS ((FILE *));
 
 
 static void source_cleanup PARAMS ((FILE *));
 
@@ -210,6 +207,14 @@ struct cmd_list_element *enablelist;
 
 struct cmd_list_element *disablelist;
 
 
 struct cmd_list_element *disablelist;
 
+/* Chain containing all defined toggle subcommands. */
+
+struct cmd_list_element *togglelist;
+
+/* Chain containing all defined stop subcommands. */
+
+struct cmd_list_element *stoplist;
+
 /* Chain containing all defined delete subcommands. */
 
 struct cmd_list_element *deletelist;
 /* Chain containing all defined delete subcommands. */
 
 struct cmd_list_element *deletelist;
@@ -230,12 +235,6 @@ struct cmd_list_element *unsetlist;
 
 struct cmd_list_element *showlist;
 
 
 struct cmd_list_element *showlist;
 
-#ifdef TARGET_BYTE_ORDER_SELECTABLE
-/* Chain containing the \"set endian\" commands.  */
-
-struct cmd_list_element *endianlist;
-#endif
-
 /* Chain containing all defined \"set history\".  */
 
 struct cmd_list_element *sethistlist;
 /* Chain containing all defined \"set history\".  */
 
 struct cmd_list_element *sethistlist;
@@ -250,21 +249,15 @@ struct cmd_list_element *unsethistlist;
 
 /* Chain containing all defined maintenance subcommands. */
 
 
 /* Chain containing all defined maintenance subcommands. */
 
-#if MAINTENANCE_CMDS
 struct cmd_list_element *maintenancelist;
 struct cmd_list_element *maintenancelist;
-#endif
 
 /* Chain containing all defined "maintenance info" subcommands. */
 
 
 /* Chain containing all defined "maintenance info" subcommands. */
 
-#if MAINTENANCE_CMDS
 struct cmd_list_element *maintenanceinfolist;
 struct cmd_list_element *maintenanceinfolist;
-#endif
 
 /* Chain containing all defined "maintenance print" subcommands. */
 
 
 /* Chain containing all defined "maintenance print" subcommands. */
 
-#if MAINTENANCE_CMDS
 struct cmd_list_element *maintenanceprintlist;
 struct cmd_list_element *maintenanceprintlist;
-#endif
 
 struct cmd_list_element *setprintlist;
 
 
 struct cmd_list_element *setprintlist;
 
@@ -276,7 +269,7 @@ struct cmd_list_element *showchecklist;
 
 /* stdio stream that command input is being read from.  Set to stdin normally.
    Set by source_command to the file we are sourcing.  Set to NULL if we are
 
 /* stdio stream that command input is being read from.  Set to stdin normally.
    Set by source_command to the file we are sourcing.  Set to NULL if we are
-   executing a user-defined command.  */
+   executing a user-defined command or interacting via a GUI.  */
 
 FILE *instream;
 
 
 FILE *instream;
 
@@ -297,7 +290,8 @@ int epoch_interface;
 int xgdb_verbose;
 
 /* gdb prints this when reading a command interactively */
 int xgdb_verbose;
 
 /* gdb prints this when reading a command interactively */
-static char *prompt;
+static char *gdb_prompt_string;                /* the global prompt string */
+extern char *get_prompt PARAMS((void));        /* access function for prompt string */
 
 /* Buffer used for reading command lines, and the size
    allocated for it so far.  */
 
 /* Buffer used for reading command lines, and the size
    allocated for it so far.  */
@@ -320,10 +314,20 @@ int server_command;
 
 int baud_rate = -1;
 
 
 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;
 
 /* Non-zero tells remote* modules to output debugging info.  */
 
 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;
+
 /* Level of control structure.  */
 static int control_level;
 
 /* Level of control structure.  */
 static int control_level;
 
@@ -367,16 +371,23 @@ static void stop_sig PARAMS ((int));
 /* Called after most modules have been initialized, but before taking users
    command file.  */
 
 /* Called after most modules have been initialized, but before taking users
    command file.  */
 
-void (*init_ui_hook) PARAMS ((void));
+void (*init_ui_hook) PARAMS ((char *argv0));
+
+/* This hook is called from within gdb's many mini-event loops which could
+   steal control from a real user interface's event loop. It returns
+   non-zero if the user is requesting a detach, zero otherwise. */
+
+int (*ui_loop_hook) PARAMS ((int));
 
 /* Called instead of command_loop at top level.  Can be invoked via
    return_to_top_level.  */
 
 void (*command_loop_hook) PARAMS ((void));
 
 
 /* Called instead of command_loop at top level.  Can be invoked via
    return_to_top_level.  */
 
 void (*command_loop_hook) PARAMS ((void));
 
+
 /* Called instead of fputs for all output.  */
 
 /* Called instead of fputs for all output.  */
 
-void (*fputs_unfiltered_hook) PARAMS ((const char *linebuffer, FILE *stream));
+void (*fputs_unfiltered_hook) PARAMS ((const char *linebuffer, GDB_FILE *stream));
 
 /* Called from print_frame_info to list the line we stopped in.  */
 
 
 /* Called from print_frame_info to list the line we stopped in.  */
 
@@ -384,11 +395,30 @@ void (*print_frame_info_listing_hook) PARAMS ((struct symtab *s, int line,
                                               int stopline, int noerror));
 /* Replaces most of query.  */
 
                                               int stopline, int noerror));
 /* Replaces most of query.  */
 
-int (*query_hook) PARAMS (());
+int (*query_hook) PARAMS ((const char *, va_list));
+
+/* Replaces most of warning.  */
+
+void (*warning_hook) PARAMS ((const char *, va_list));
 
 /* Called from gdb_flush to flush output.  */
 
 
 /* Called from gdb_flush to flush output.  */
 
-void (*flush_hook) PARAMS ((FILE *stream));
+void (*flush_hook) PARAMS ((GDB_FILE *stream));
+
+/* These three functions support getting lines of text from the user.  They
+   are used in sequence.  First readline_begin_hook is called with a text
+   string that might be (for example) a message for the user to type in a
+   sequence of commands to be executed at a breakpoint.  If this function
+   calls back to a GUI, it might take this opportunity to pop up a text
+   interaction window with this message.  Next, readline_hook is called
+   with a prompt that is emitted prior to collecting the user input.
+   It can be called multiple times.  Finally, readline_end_hook is called
+   to notify the GUI that we are done with the interaction window and it
+   can close it. */
+
+void (*readline_begin_hook) PARAMS ((char *, ...));
+char * (*readline_hook) PARAMS ((char *));
+void (*readline_end_hook) PARAMS ((void));
 
 /* Called as appropriate to notify the interface of the specified breakpoint
    conditions.  */
 
 /* Called as appropriate to notify the interface of the specified breakpoint
    conditions.  */
@@ -407,6 +437,14 @@ void (*interactive_hook) PARAMS ((void));
 
 void (*registers_changed_hook) PARAMS ((void));
 
 
 void (*registers_changed_hook) PARAMS ((void));
 
+/* Tell the GUI someone changed the register REGNO. -1 means
+   that the caller does not know which register changed or
+   that several registers have changed (see value_assign).*/
+void (*register_changed_hook) PARAMS ((int regno));
+
+/* Tell the GUI someone changed LEN bytes of memory at ADDR */
+void (*memory_changed_hook) PARAMS ((CORE_ADDR addr, int len));
+
 /* Called when going to wait for the target.  Usually allows the GUI to run
    while waiting for target events.  */
 
 /* Called when going to wait for the target.  Usually allows the GUI to run
    while waiting for target events.  */
 
@@ -418,16 +456,20 @@ int (*target_wait_hook) PARAMS ((int pid, struct target_waitstatus *status));
 void (*call_command_hook) PARAMS ((struct cmd_list_element *c, char *cmd,
                                   int from_tty));
 
 void (*call_command_hook) PARAMS ((struct cmd_list_element *c, char *cmd,
                                   int from_tty));
 
+/* Called when the current thread changes.  Argument is thread id.  */
+
+void (*context_hook) PARAMS ((int id));
+
 /* Takes control from error ().  Typically used to prevent longjmps out of the
    middle of the GUI.  Usually used in conjunction with a catch routine.  */
 
 /* 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 (());
+NORETURN void (*error_hook) PARAMS ((void)) ATTR_NORETURN;
 
 \f
 /* Where to go for return_to_top_level (RETURN_ERROR).  */
 
 \f
 /* Where to go for return_to_top_level (RETURN_ERROR).  */
-jmp_buf error_return;
+SIGJMP_BUF error_return;
 /* Where to go for return_to_top_level (RETURN_QUIT).  */
 /* Where to go for return_to_top_level (RETURN_QUIT).  */
-jmp_buf quit_return;
+SIGJMP_BUF quit_return;
 
 /* Return for reason REASON.  This generally gets back to the command
    loop, but can be caught via catch_errors.  */
 
 /* Return for reason REASON.  This generally gets back to the command
    loop, but can be caught via catch_errors.  */
@@ -445,6 +487,8 @@ return_to_top_level (reason)
 
   disable_current_display ();
   do_cleanups (ALL_CLEANUPS);
 
   disable_current_display ();
   do_cleanups (ALL_CLEANUPS);
+  if (async_p && target_has_async)
+    do_exec_cleanups (ALL_CLEANUPS);
 
   if (annotation_level > 1)
     switch (reason)
 
   if (annotation_level > 1)
     switch (reason)
@@ -457,7 +501,7 @@ return_to_top_level (reason)
        break;
       }
 
        break;
       }
 
-  (NORETURN void) longjmp
+  (NORETURN void) SIGLONGJMP
     (reason == RETURN_ERROR ? error_return : quit_return, 1);
 }
 
     (reason == RETURN_ERROR ? error_return : quit_return, 1);
 }
 
@@ -482,33 +526,40 @@ return_to_top_level (reason)
 
 int
 catch_errors (func, args, errstring, mask)
 
 int
 catch_errors (func, args, errstring, mask)
-     int (*func) PARAMS ((char *));
+     catch_errors_ftype *func;
      PTR args;
      char *errstring;
      return_mask mask;
 {
      PTR args;
      char *errstring;
      return_mask mask;
 {
-  jmp_buf saved_error;
-  jmp_buf saved_quit;
-  jmp_buf tmp_jmp;
+  SIGJMP_BUF saved_error;
+  SIGJMP_BUF saved_quit;
+  SIGJMP_BUF tmp_jmp;
   int val;
   struct cleanup *saved_cleanup_chain;
   char *saved_error_pre_print;
   int val;
   struct cleanup *saved_cleanup_chain;
   char *saved_error_pre_print;
+  char *saved_quit_pre_print;
 
   saved_cleanup_chain = save_cleanups ();
   saved_error_pre_print = error_pre_print;
 
   saved_cleanup_chain = save_cleanups ();
   saved_error_pre_print = error_pre_print;
+  saved_quit_pre_print = quit_pre_print;
 
   if (mask & RETURN_MASK_ERROR)
 
   if (mask & RETURN_MASK_ERROR)
-    memcpy ((char *)saved_error, (char *)error_return, sizeof (jmp_buf));
+    {
+      memcpy ((char *)saved_error, (char *)error_return, sizeof (SIGJMP_BUF));
+      error_pre_print = errstring;
+    }
   if (mask & RETURN_MASK_QUIT)
   if (mask & RETURN_MASK_QUIT)
-    memcpy (saved_quit, quit_return, sizeof (jmp_buf));
-  error_pre_print = errstring;
+    {
+      memcpy (saved_quit, quit_return, sizeof (SIGJMP_BUF));
+      quit_pre_print = errstring;
+    }
 
 
-  if (setjmp (tmp_jmp) == 0)
+  if (SIGSETJMP (tmp_jmp) == 0)
     {
       if (mask & RETURN_MASK_ERROR)
     {
       if (mask & RETURN_MASK_ERROR)
-       memcpy (error_return, tmp_jmp, sizeof (jmp_buf));
+       memcpy (error_return, tmp_jmp, sizeof (SIGJMP_BUF));
       if (mask & RETURN_MASK_QUIT)
       if (mask & RETURN_MASK_QUIT)
-       memcpy (quit_return, tmp_jmp, sizeof (jmp_buf));
+       memcpy (quit_return, tmp_jmp, sizeof (SIGJMP_BUF));
       val = (*func) (args);
     }
   else
       val = (*func) (args);
     }
   else
@@ -516,16 +567,22 @@ catch_errors (func, args, errstring, mask)
 
   restore_cleanups (saved_cleanup_chain);
 
 
   restore_cleanups (saved_cleanup_chain);
 
-  error_pre_print = saved_error_pre_print;
   if (mask & RETURN_MASK_ERROR)
   if (mask & RETURN_MASK_ERROR)
-    memcpy (error_return, saved_error, sizeof (jmp_buf));
+    {
+      memcpy (error_return, saved_error, sizeof (SIGJMP_BUF));
+      error_pre_print = saved_error_pre_print;
+    }
   if (mask & RETURN_MASK_QUIT)
   if (mask & RETURN_MASK_QUIT)
-    memcpy (quit_return, saved_quit, sizeof (jmp_buf));
+    {
+      memcpy (quit_return, saved_quit, sizeof (SIGJMP_BUF));
+      quit_pre_print = saved_quit_pre_print;
+    }
   return val;
 }
 
 /* Handler for SIGHUP.  */
 
   return val;
 }
 
 /* Handler for SIGHUP.  */
 
+#ifdef SIGHUP
 static void
 disconnect (signo)
 int signo;
 static void
 disconnect (signo)
 int signo;
@@ -538,30 +595,46 @@ int signo;
 
 /* Just a little helper function for disconnect().  */
 
 
 /* Just a little helper function for disconnect().  */
 
-static int
+/* NOTE 1999-04-29: This function will be static again, once we modify
+   gdb to use the event loop as the default command loop and we merge
+   event-top.c into this file, top.c */
+/* static */ int
 quit_cover (s)
 quit_cover (s)
-char *s;
+     PTR s;
 {
   caution = 0;         /* Throw caution to the wind -- we're exiting.
                           This prevents asking the user dumb questions.  */
   quit_command((char *)0, 0);
   return 0;
 }
 {
   caution = 0;         /* Throw caution to the wind -- we're exiting.
                           This prevents asking the user dumb questions.  */
   quit_command((char *)0, 0);
   return 0;
 }
+#endif /* defined SIGHUP */
 \f
 /* Line number we are currently in in a file which is being sourced.  */
 \f
 /* Line number we are currently in in a file which is being sourced.  */
-static int source_line_number;
+/* NOTE 1999-04-29: This variable will be static again, once we modify
+   gdb to use the event loop as the default command loop and we merge
+   event-top.c into this file, top.c */
+/* static */ int source_line_number;
 
 /* Name of the file we are sourcing.  */
 
 /* Name of the file we are sourcing.  */
-static char *source_file_name;
+/* NOTE 1999-04-29: This variable will be static again, once we modify
+   gdb to use the event loop as the default command loop and we merge
+   event-top.c into this file, top.c */
+/* static */ char *source_file_name;
 
 /* Buffer containing the error_pre_print used by the source stuff.
    Malloc'd.  */
 
 /* Buffer containing the error_pre_print used by the source stuff.
    Malloc'd.  */
-static char *source_error;
+/* NOTE 1999-04-29: This variable will be static again, once we modify
+   gdb to use the event loop as the default command loop and we merge
+   event-top.c into this file, top.c */
+/* static */ char *source_error;
 static int source_error_allocated;
 
 /* Something to glom on to the start of error_pre_print if source_file_name
    is set.  */
 static int source_error_allocated;
 
 /* Something to glom on to the start of error_pre_print if source_file_name
    is set.  */
-static char *source_pre_error;
+/* NOTE 1999-04-29: This variable will be static again, once we modify
+   gdb to use the event loop as the default command loop and we merge
+   event-top.c into this file, top.c */
+/* static */ char *source_pre_error;
 
 /* Clean up on error during a "source" command (or execution of a
    user-defined command).  */
 
 /* Clean up on error during a "source" command (or execution of a
    user-defined command).  */
@@ -581,18 +654,19 @@ read_command_file (stream)
 {
   struct cleanup *cleanups;
 
 {
   struct cleanup *cleanups;
 
-  cleanups = make_cleanup (source_cleanup, instream);
+  cleanups = make_cleanup ((make_cleanup_func) source_cleanup, instream);
   instream = stream;
   instream = stream;
-  command_loop ();
+  command_loop (); 
   do_cleanups (cleanups);
 }
 \f
   do_cleanups (cleanups);
 }
 \f
-extern void init_proc ();
+extern void init_proc PARAMS ((void));
 
 void (*pre_init_ui_hook) PARAMS ((void));
 
 void
 
 void (*pre_init_ui_hook) PARAMS ((void));
 
 void
-gdb_init ()
+gdb_init (argv0)
+     char *argv0;
 {
   if (pre_init_ui_hook)
     pre_init_ui_hook ();
 {
   if (pre_init_ui_hook)
     pre_init_ui_hook ();
@@ -607,9 +681,15 @@ gdb_init ()
   initialize_utils (); /* Make errors and warnings possible */
   initialize_all_files ();
   init_main ();                /* But that omits this file!  Do it now */
   initialize_utils (); /* Make errors and warnings possible */
   initialize_all_files ();
   init_main ();                /* But that omits this file!  Do it now */
-  init_signals ();
 
 
-  init_proc ();
+  /* The signal handling mechanism is different depending whether or
+     not the async version is run. NOTE: in the future we plan to make
+     the event loop be the default engine of gdb, and this difference
+     will disappear. */
+  if (async_p)
+    async_init_signals ();
+  else
+    init_signals (); 
 
   /* We need a default language for parsing expressions, so simple things like
      "set width 0" won't fail if no language is explicitly set in a config file
 
   /* We need a default language for parsing expressions, so simple things like
      "set width 0" won't fail if no language is explicitly set in a config file
@@ -617,8 +697,10 @@ gdb_init ()
   set_language (language_c);
   expected_language = current_language;        /* don't warn about the change.  */
 
   set_language (language_c);
   expected_language = current_language;        /* don't warn about the change.  */
 
+  /* All the interpreters should have had a look at things by now.
+     Initialize the selected interpreter. */
   if (init_ui_hook)
   if (init_ui_hook)
-    init_ui_hook ();
+    init_ui_hook (argv0);
 }
 
 /* Allocate, initialize a new command line structure for one of the
 }
 
 /* Allocate, initialize a new command line structure for one of the
@@ -631,6 +713,9 @@ build_command_line (type, args)
 {
   struct command_line *cmd;
 
 {
   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;
   cmd = (struct command_line *)xmalloc (sizeof (struct command_line));
   cmd->next = NULL;
   cmd->control_type = type;
@@ -658,7 +743,7 @@ get_command_line (type, arg)
   /* Allocate and build a new command line structure.  */
   cmd = build_command_line (type, arg);
 
   /* Allocate and build a new command line structure.  */
   cmd = build_command_line (type, arg);
 
-  old_chain = make_cleanup (free_command_lines, &cmd);
+  old_chain = make_cleanup ((make_cleanup_func) free_command_lines, &cmd);
 
   /* Read in the body of this command.  */
   if (recurse_read_control_structure (cmd) == invalid_control)
 
   /* Read in the body of this command.  */
   if (recurse_read_control_structure (cmd) == invalid_control)
@@ -674,23 +759,24 @@ get_command_line (type, arg)
 
 /* Recursively print a command (including full control structures).  */
 void
 
 /* Recursively print a command (including full control structures).  */
 void
-print_command_line (cmd, depth)
+print_command_line (cmd, depth, stream)
      struct command_line *cmd;
      unsigned int depth;
      struct command_line *cmd;
      unsigned int depth;
+     GDB_FILE *stream;
 {
   unsigned int i;
 
   if (depth)
     {
       for (i = 0; i < depth; i++)
 {
   unsigned int i;
 
   if (depth)
     {
       for (i = 0; i < depth; i++)
-       fputs_filtered ("  ", gdb_stdout);
+       fputs_filtered ("  ", stream);
     }
 
   /* A simple command, print it and return.  */
   if (cmd->control_type == simple_control)
     {
     }
 
   /* A simple command, print it and return.  */
   if (cmd->control_type == simple_control)
     {
-      fputs_filtered (cmd->line, gdb_stdout);
-      fputs_filtered ("\n", gdb_stdout);
+      fputs_filtered (cmd->line, stream);
+      fputs_filtered ("\n", stream);
       return;
     }
 
       return;
     }
 
@@ -698,14 +784,14 @@ print_command_line (cmd, depth)
      and return. */
   if (cmd->control_type == continue_control)
     {
      and return. */
   if (cmd->control_type == continue_control)
     {
-      fputs_filtered ("loop_continue\n", gdb_stdout);
+      fputs_filtered ("loop_continue\n", stream);
       return;
     }
 
   /* loop_break to break out of a while loop, print it and return.  */
   if (cmd->control_type == break_control)
     {
       return;
     }
 
   /* loop_break to break out of a while loop, print it and return.  */
   if (cmd->control_type == break_control)
     {
-      fputs_filtered ("loop_break\n", gdb_stdout);
+      fputs_filtered ("loop_break\n", stream);
       return;
     }
 
       return;
     }
 
@@ -713,13 +799,13 @@ print_command_line (cmd, depth)
   if (cmd->control_type == while_control)
     {
       struct command_line *list;
   if (cmd->control_type == while_control)
     {
       struct command_line *list;
-      fputs_filtered ("while ", gdb_stdout);
-      fputs_filtered (cmd->line, gdb_stdout);
-      fputs_filtered ("\n", gdb_stdout);
+      fputs_filtered ("while ", stream);
+      fputs_filtered (cmd->line, stream);
+      fputs_filtered ("\n", stream);
       list = *cmd->body_list;
       while (list)
        {
       list = *cmd->body_list;
       while (list)
        {
-         print_command_line (list, depth + 1);
+         print_command_line (list, depth + 1, stream);
          list = list->next;
        }
     }
          list = list->next;
        }
     }
@@ -727,11 +813,11 @@ print_command_line (cmd, depth)
   /* An if command.  Recursively print both arms before returning.  */
   if (cmd->control_type == if_control)
     {
   /* An if command.  Recursively print both arms before returning.  */
   if (cmd->control_type == if_control)
     {
-      fputs_filtered ("if ", gdb_stdout);
-      fputs_filtered (cmd->line, gdb_stdout);
-      fputs_filtered ("\n", gdb_stdout);
+      fputs_filtered ("if ", stream);
+      fputs_filtered (cmd->line, stream);
+      fputs_filtered ("\n", stream);
       /* The true arm. */
       /* The true arm. */
-      print_command_line (cmd->body_list[0], depth + 1);
+      print_command_line (cmd->body_list[0], depth + 1, stream);
 
       /* Show the false arm if it exists.  */
       if (cmd->body_count == 2)
 
       /* Show the false arm if it exists.  */
       if (cmd->body_count == 2)
@@ -739,17 +825,17 @@ print_command_line (cmd, depth)
            if (depth)
              {
                for (i = 0; i < depth; i++)
            if (depth)
              {
                for (i = 0; i < depth; i++)
-                 fputs_filtered ("  ", gdb_stdout);
+                 fputs_filtered ("  ", stream);
              }
              }
-           fputs_filtered ("else\n", gdb_stdout);
-           print_command_line (cmd->body_list[1], depth + 1);
+           fputs_filtered ("else\n", stream);
+           print_command_line (cmd->body_list[1], depth + 1, stream);
          }
       if (depth)
        {
          for (i = 0; i < depth; i++)
          }
       if (depth)
        {
          for (i = 0; i < depth; i++)
-           fputs_filtered ("  ", gdb_stdout);
+           fputs_filtered ("  ", stream);
        }
        }
-      fputs_filtered ("end\n", gdb_stdout);
+      fputs_filtered ("end\n", stream);
     }
 }
 
     }
 }
 
@@ -763,6 +849,7 @@ execute_control_command (cmd)
   struct command_line *current;
   struct cleanup *old_chain = 0;
   value_ptr val;
   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;
   int loop;
   enum command_control_type ret;
   char *new_line;
@@ -774,7 +861,8 @@ execute_control_command (cmd)
       new_line = insert_args (cmd->line);
       if (!new_line)
        return invalid_control;
       new_line = insert_args (cmd->line);
       if (!new_line)
        return invalid_control;
-      old_chain = make_cleanup (free_current_contents, &new_line);
+      old_chain = make_cleanup ((make_cleanup_func) free_current_contents, 
+                                &new_line);
       execute_command (new_line, 0);
       ret = cmd->control_type;
       break;
       execute_command (new_line, 0);
       ret = cmd->control_type;
       break;
@@ -792,21 +880,29 @@ execute_control_command (cmd)
        new_line = insert_args (cmd->line);
        if (!new_line)
          return invalid_control;
        new_line = insert_args (cmd->line);
        if (!new_line)
          return invalid_control;
-       old_chain = make_cleanup (free_current_contents, &new_line);
+       old_chain = make_cleanup ((make_cleanup_func) free_current_contents, 
+                                  &new_line);
        expr = parse_expression (new_line);
        expr = parse_expression (new_line);
-       make_cleanup (free_current_contents, &expr);
+       make_cleanup ((make_cleanup_func) free_current_contents, &expr);
        
        ret = simple_control;
        
        ret = simple_control;
-       loop = true;
+       loop = 1;
 
        /* Keep iterating so long as the expression is true.  */
 
        /* Keep iterating so long as the expression is true.  */
-       while (loop == true)
+       while (loop == 1)
          {
          {
+           int cond_result;
+
+           QUIT;
+
            /* Evaluate the expression.  */
            /* Evaluate the expression.  */
+           val_mark = value_mark ();
            val = evaluate_expression (expr);
            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 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.  */
              break;
 
            /* Execute the body of the while statement.  */
@@ -819,7 +915,7 @@ execute_control_command (cmd)
                   looping.  */
                if (ret == invalid_control || ret == break_control)
                  {
                   looping.  */
                if (ret == invalid_control || ret == break_control)
                  {
-                   loop = false;
+                   loop = 0;
                    break;
                  }
 
                    break;
                  }
 
@@ -845,15 +941,17 @@ execute_control_command (cmd)
        new_line = insert_args (cmd->line);
        if (!new_line)
          return invalid_control;
        new_line = insert_args (cmd->line);
        if (!new_line)
          return invalid_control;
-       old_chain = make_cleanup (free_current_contents, &new_line);
+       old_chain = make_cleanup ((make_cleanup_func) free_current_contents, 
+                                  &new_line);
        /* Parse the conditional for the if statement.  */
        expr = parse_expression (new_line);
        /* Parse the conditional for the if statement.  */
        expr = parse_expression (new_line);
-       make_cleanup (free_current_contents, &expr);
+       make_cleanup ((make_cleanup_func) free_current_contents, &expr);
 
        current = NULL;
        ret = simple_control;
 
        /* Evaluate the conditional.  */
 
        current = NULL;
        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
        val = evaluate_expression (expr);
 
        /* Choose which arm to take commands from based on the value of the
@@ -862,6 +960,7 @@ execute_control_command (cmd)
          current = *cmd->body_list;
        else if (cmd->body_count == 2)
          current = *(cmd->body_list + 1);
          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)
 
        /* Execute commands in the given arm.  */
        while (current)
@@ -959,7 +1058,7 @@ setup_user_args (p)
   args->next = user_args;
   user_args = args;
 
   args->next = user_args;
   user_args = args;
 
-  old_chain = make_cleanup (arg_cleanup, 0);
+  old_chain = make_cleanup ((make_cleanup_func) arg_cleanup, 0);
 
   if (p == NULL)
     return old_chain;
 
   if (p == NULL)
     return old_chain;
@@ -967,6 +1066,9 @@ setup_user_args (p)
   while (*p)
     {
       char *start_arg;
   while (*p)
     {
       char *start_arg;
+      int squote = 0;
+      int dquote = 0;
+      int bsquote = 0;
 
       if (arg_count >= MAXUSERARGS)
        {
 
       if (arg_count >= MAXUSERARGS)
        {
@@ -984,8 +1086,36 @@ setup_user_args (p)
       user_args->a[arg_count].arg = p;
 
       /* Get to the end of this argument.  */
       user_args->a[arg_count].arg = p;
 
       /* Get to the end of this argument.  */
-      while (*p && *p != ' ' && *p != '\t')
-       p++;
+      while (*p)
+       {
+         if (((*p == ' ' || *p == '\t')) && !squote && !dquote && !bsquote)
+           break;
+         else
+           {
+             if (bsquote)
+               bsquote = 0;
+             else if (*p == '\\')
+               bsquote = 1;
+             else if (squote)
+               {
+                 if (*p == '\'')
+                   squote = 0;
+               }
+             else if (dquote)
+               {
+                 if (*p == '"')
+                   dquote = 0;
+               }
+             else
+               {
+                 if (*p == '\'')
+                   squote = 1;
+                 else if (*p == '"')
+                   dquote = 1;
+               }
+             p++;
+           }
+       }
 
       user_args->a[arg_count].len = p - start_arg;
       arg_count++;
 
       user_args->a[arg_count].len = p - start_arg;
       arg_count++;
@@ -1092,7 +1222,7 @@ execute_user_command (c, args)
 
   /* Set the instream to 0, indicating execution of a
      user-defined function.  */
 
   /* Set the instream to 0, indicating execution of a
      user-defined function.  */
-  old_chain = make_cleanup (source_cleanup, instream);
+  old_chain = make_cleanup ((make_cleanup_func) source_cleanup, instream);
   instream = (FILE *) 0;
   while (cmdlines)
     {
   instream = (FILE *) 0;
   while (cmdlines)
     {
@@ -1118,22 +1248,49 @@ execute_command (p, from_tty)
   register struct cmd_list_element *c;
   register enum language flang;
   static int warned = 0;
   register struct cmd_list_element *c;
   register enum language flang;
   static int warned = 0;
+  /* FIXME: These should really be in an appropriate header file */
+  extern void serial_log_command PARAMS ((const char *));
 
   free_all_values ();
 
 
   free_all_values ();
 
+  /* Force cleanup of any alloca areas if using C alloca instead of
+     a builtin alloca.  */
+  alloca (0);
+
   /* This can happen when command_line_input hits end of file.  */
   if (p == NULL)
       return;
 
   /* This can happen when command_line_input hits end of file.  */
   if (p == NULL)
       return;
 
+  serial_log_command (p);
+
   while (*p == ' ' || *p == '\t') p++;
   if (*p)
     {
       char *arg;
 
       c = lookup_cmd (&p, cmdlist, "", 0, 1);
   while (*p == ' ' || *p == '\t') p++;
   if (*p)
     {
       char *arg;
 
       c = lookup_cmd (&p, cmdlist, "", 0, 1);
+
+      /* If the target is running, we allow only a limited set of
+         commands. */
+      if (async_p && target_has_async && target_executing)
+       if (!strcmp (c->name, "help")
+           && !strcmp (c->name, "pwd")
+           && !strcmp (c->name, "show")
+           && !strcmp (c->name, "stop"))
+         error ("Cannot execute this command while the target is running.");
+
       /* Pass null arg rather than an empty one.  */
       arg = *p ? p : 0;
 
       /* 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);
       /* If this command has been hooked, run the hook first. */
       if (c->hook)
        execute_user_command (c->hook, (char *)0);
@@ -1179,7 +1336,10 @@ execute_command (p, from_tty)
 }
 
 /* ARGSUSED */
 }
 
 /* ARGSUSED */
-static void
+/* NOTE 1999-04-29: This function will be static again, once we modify
+   gdb to use the event loop as the default command loop and we merge
+   event-top.c into this file, top.c */
+/* static */ void
 command_loop_marker (foo)
      int foo;
 {
 command_loop_marker (foo)
      int foo;
 {
@@ -1195,21 +1355,41 @@ command_loop ()
   char *command;
   int stdin_is_tty = ISATTY (stdin);
   long time_at_cmd_start;
   char *command;
   int stdin_is_tty = ISATTY (stdin);
   long time_at_cmd_start;
-  long space_at_cmd_start;
+#ifdef HAVE_SBRK
+  long space_at_cmd_start = 0;
+#endif
   extern int display_time;
   extern int display_space;
 
   extern int display_time;
   extern int display_space;
 
-  while (!feof (instream))
+  while (instream && !feof (instream))
     {
     {
+#if defined(TUI)
+      extern int insert_mode;
+#endif
       if (window_hook && instream == stdin)
       if (window_hook && instream == stdin)
-       (*window_hook) (instream, prompt);
+       (*window_hook) (instream, get_prompt ());
 
       quit_flag = 0;
       if (instream == stdin && stdin_is_tty)
        reinitialize_more_filter ();
 
       quit_flag = 0;
       if (instream == stdin && stdin_is_tty)
        reinitialize_more_filter ();
-      old_chain = make_cleanup (command_loop_marker, 0);
-      command = command_line_input (instream == stdin ? prompt : (char *) NULL,
+      old_chain = make_cleanup ((make_cleanup_func) command_loop_marker, 0);
+
+#if defined(TUI)
+      /* A bit of paranoia: I want to make sure the "insert_mode" global
+       * is clear except when it is being used for command-line editing
+       * (see tuiIO.c, utils.c); otherwise normal output will
+       * get messed up in the TUI. So clear it before/after
+       * the command-line-input call. - RT
+       */
+      insert_mode = 0;
+#endif
+      /* Get a command-line. This calls the readline package. */
+      command = command_line_input (instream == stdin ? 
+                                   get_prompt () : (char *) NULL,
                                    instream == stdin, "prompt");
                                    instream == stdin, "prompt");
+#if defined(TUI)
+      insert_mode = 0;
+#endif
       if (command == 0)
        return;
 
       if (command == 0)
        return;
 
@@ -1217,10 +1397,12 @@ command_loop ()
 
       if (display_space)
        {
 
       if (display_space)
        {
+#ifdef HAVE_SBRK
          extern char **environ;
          char *lim = (char *) sbrk (0);
 
          space_at_cmd_start = (long) (lim - (char *) &environ);
          extern char **environ;
          char *lim = (char *) sbrk (0);
 
          space_at_cmd_start = (long) (lim - (char *) &environ);
+#endif
        }
 
       execute_command (command, instream == stdin);
        }
 
       execute_command (command, instream == stdin);
@@ -1238,6 +1420,7 @@ command_loop ()
 
       if (display_space)
        {
 
       if (display_space)
        {
+#ifdef HAVE_SBRK
          extern char **environ;
          char *lim = (char *) sbrk (0);
          long space_now = lim - (char *) &environ;
          extern char **environ;
          char *lim = (char *) sbrk (0);
          long space_now = lim - (char *) &environ;
@@ -1247,9 +1430,11 @@ command_loop ()
                             space_now,
                             (space_diff >= 0 ? '+' : '-'),
                             space_diff);
                             space_now,
                             (space_diff >= 0 ? '+' : '-'),
                             space_diff);
+#endif
        }
     }
 }
        }
     }
 }
+
 \f
 /* Commands call this if they do not want to be repeated by null lines.  */
 
 \f
 /* Commands call this if they do not want to be repeated by null lines.  */
 
@@ -1268,33 +1453,31 @@ dont_repeat ()
 \f
 /* Read a line from the stream "instream" without command line editing.
 
 \f
 /* Read a line from the stream "instream" without command line editing.
 
-   It prints PRROMPT once at the start.
+   It prints PROMPT_ARG once at the start.
    Action is compatible with "readline", e.g. space for the result is
    malloc'd and should be freed by the caller.
 
    A NULL return means end of file.  */
 char *
    Action is compatible with "readline", e.g. space for the result is
    malloc'd and should be freed by the caller.
 
    A NULL return means end of file.  */
 char *
-gdb_readline (prrompt)
-     char *prrompt;
+gdb_readline (prompt_arg)
+     char *prompt_arg;
 {
   int c;
   char *result;
   int input_index = 0;
   int result_size = 80;
 
 {
   int c;
   char *result;
   int input_index = 0;
   int result_size = 80;
 
-  if (prrompt)
+  if (prompt_arg)
     {
       /* Don't use a _filtered function here.  It causes the assumed
         character position to be off, since the newline we read from
         the user is not accounted for.  */
     {
       /* Don't use a _filtered function here.  It causes the assumed
         character position to be off, since the newline we read from
         the user is not accounted for.  */
-      fputs_unfiltered (prrompt, gdb_stdout);
-/* start-sanitize-mpw */
+      fputs_unfiltered (prompt_arg, gdb_stdout);
 #ifdef MPW
       /* Move to a new line so the entered line doesn't have a prompt
         on the front of it. */
       fputs_unfiltered ("\n", gdb_stdout);
 #endif /* MPW */
 #ifdef MPW
       /* Move to a new line so the entered line doesn't have a prompt
         on the front of it. */
       fputs_unfiltered ("\n", gdb_stdout);
 #endif /* MPW */
-/* end-sanitize-mpw */
       gdb_flush (gdb_stdout);
     }
 
       gdb_flush (gdb_stdout);
     }
 
@@ -1318,7 +1501,15 @@ gdb_readline (prrompt)
        }
 
       if (c == '\n')
        }
 
       if (c == '\n')
+#ifndef CRLF_SOURCE_FILES
        break;
        break;
+#else
+       {
+         if (input_index > 0 && result[input_index - 1] == '\r')
+           input_index--;
+         break;
+       }
+#endif
 
       result[input_index++] = c;
       while (input_index >= result_size)
 
       result[input_index++] = c;
       while (input_index >= result_size)
@@ -1336,7 +1527,10 @@ gdb_readline (prrompt)
    substitution.  These variables are given default values at the end
    of this file.  */
 static int command_editing_p;
    substitution.  These variables are given default values at the end
    of this file.  */
 static int command_editing_p;
-static int history_expansion_p;
+/* NOTE 1999-04-29: This variable will be static again, once we modify
+   gdb to use the event loop as the default command loop and we merge
+   event-top.c into this file, top.c */
+/* static */ int history_expansion_p;
 static int write_history_p;
 static int history_size;
 static char *history_filename;
 static int write_history_p;
 static int history_size;
 static char *history_filename;
@@ -1390,7 +1584,7 @@ filename_completer (text, word)
      char *word;
 {
   /* From readline.  */
      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;
   int subsequent_name;
   char **return_val;
   int return_val_used;
@@ -1638,6 +1832,12 @@ line_completion_function (text, matches, line_buffer, point)
                      rl_completer_word_break_characters =
                        gdb_completer_command_word_break_characters;
                    }
                      rl_completer_word_break_characters =
                        gdb_completer_command_word_break_characters;
                    }
+                 else if (c->enums)
+                   {
+                     list = complete_on_enum (c->enums, p, word);
+                     rl_completer_word_break_characters =
+                       gdb_completer_command_word_break_characters;
+                   }
                  else
                    {
                      /* It is a normal command; what comes after it is
                  else
                    {
                      /* It is a normal command; what comes after it is
@@ -1681,6 +1881,10 @@ line_completion_function (text, matches, line_buffer, point)
                     e.g. "info adsfkdj".  */
                  list = NULL;
                }
                     e.g. "info adsfkdj".  */
                  list = NULL;
                }
+             else if (c->enums)
+               {
+                 list = complete_on_enum (c->enums, p, word);
+               }
              else
                {
                  /* It is a normal command.  */
              else
                {
                  /* It is a normal command.  */
@@ -1778,7 +1982,7 @@ int signo;
 #else
   signal (STOP_SIGNAL, stop_sig);
 #endif
 #else
   signal (STOP_SIGNAL, stop_sig);
 #endif
-  printf_unfiltered ("%s", prompt);
+  printf_unfiltered ("%s", get_prompt ());
   gdb_flush (gdb_stdout);
 
   /* Forget about any previous command -- null line now will do nothing.  */
   gdb_flush (gdb_stdout);
 
   /* Forget about any previous command -- null line now will do nothing.  */
@@ -1791,6 +1995,13 @@ static void
 do_nothing (signo)
 int signo;
 {
 do_nothing (signo)
 int signo;
 {
+  /* Under System V the default disposition of a signal is reinstated after
+     the signal is caught and delivered to an application process.  On such
+     systems one must restore the replacement signal handler if one wishes
+     to continue handling the signal in one's program.  On BSD systems this
+     is not needed but it is harmless, and it simplifies the code to just do
+     it unconditionally. */
+  signal (signo, do_nothing);
 }
 
 static void
 }
 
 static void
@@ -1798,6 +2009,12 @@ init_signals ()
 {
   signal (SIGINT, request_quit);
 
 {
   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
   /* 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
@@ -1807,8 +2024,10 @@ init_signals ()
      a handler for SIGQUIT, when we call exec it will set the signal
      to SIG_DFL for us.  */
   signal (SIGQUIT, do_nothing);
      a handler for SIGQUIT, when we call exec it will set the signal
      to SIG_DFL for us.  */
   signal (SIGQUIT, do_nothing);
+#ifdef SIGHUP
   if (signal (SIGHUP, do_nothing) != SIG_IGN)
     signal (SIGHUP, disconnect);
   if (signal (SIGHUP, do_nothing) != SIG_IGN)
     signal (SIGHUP, disconnect);
+#endif
   signal (SIGFPE, float_handler);
 
 #if defined(SIGWINCH) && defined(SIGWINCH_HANDLER)
   signal (SIGFPE, float_handler);
 
 #if defined(SIGWINCH) && defined(SIGWINCH_HANDLER)
@@ -1832,8 +2051,8 @@ init_signals ()
    simple input as the user has requested.  */
 
 char *
    simple input as the user has requested.  */
 
 char *
-command_line_input (prrompt, repeat, annotation_suffix)
-     char *prrompt;
+command_line_input (prompt_arg, repeat, annotation_suffix)
+     char *prompt_arg;
      int repeat;
      char *annotation_suffix;
 {
      int repeat;
      char *annotation_suffix;
 {
@@ -1842,8 +2061,7 @@ command_line_input (prrompt, repeat, annotation_suffix)
   register char *p;
   char *p1;
   char *rl;
   register char *p;
   char *p1;
   char *rl;
-  char *local_prompt = prrompt;
-  register int c;
+  char *local_prompt = prompt_arg;
   char *nline;
   char got_eof = 0;
 
   char *nline;
   char got_eof = 0;
 
@@ -1853,12 +2071,12 @@ command_line_input (prrompt, repeat, annotation_suffix)
 
   if (annotation_level > 1 && instream == stdin)
     {
 
   if (annotation_level > 1 && instream == stdin)
     {
-      local_prompt = alloca ((prrompt == NULL ? 0 : strlen (prrompt))
+      local_prompt = alloca ((prompt_arg == NULL ? 0 : strlen (prompt_arg))
                             + strlen (annotation_suffix) + 40);
                             + strlen (annotation_suffix) + 40);
-      if (prrompt == NULL)
+      if (prompt_arg == NULL)
        local_prompt[0] = '\0';
       else
        local_prompt[0] = '\0';
       else
-       strcpy (local_prompt, prrompt);
+       strcpy (local_prompt, prompt_arg);
       strcat (local_prompt, "\n\032\032");
       strcat (local_prompt, annotation_suffix);
       strcat (local_prompt, "\n");
       strcat (local_prompt, "\n\032\032");
       strcat (local_prompt, annotation_suffix);
       strcat (local_prompt, "\n");
@@ -1877,7 +2095,12 @@ command_line_input (prrompt, repeat, annotation_suffix)
   immediate_quit++;
 #ifdef STOP_SIGNAL
   if (job_control)
   immediate_quit++;
 #ifdef STOP_SIGNAL
   if (job_control)
-    signal (STOP_SIGNAL, stop_sig);
+    {
+      if (async_p)
+       signal (STOP_SIGNAL, handle_stop_sig);
+      else
+       signal (STOP_SIGNAL, stop_sig);
+    }
 #endif
 
   while (1)
 #endif
 
   while (1)
@@ -1907,11 +2130,18 @@ command_line_input (prrompt, repeat, annotation_suffix)
        }
 
       /* Don't use fancy stuff if not talking to stdin.  */
        }
 
       /* Don't use fancy stuff if not talking to stdin.  */
-      if (command_editing_p && instream == stdin
-         && ISATTY (instream))
-       rl = readline (local_prompt);
+      if (readline_hook && instream == NULL)
+       {
+         rl = (*readline_hook) (local_prompt);
+       }
+      else if (command_editing_p && instream == stdin && ISATTY (instream))
+       {
+         rl = readline (local_prompt);
+       }
       else
       else
-       rl = gdb_readline (local_prompt);
+       {
+         rl = gdb_readline (local_prompt);
+       }
 
       if (annotation_level > 1 && instream == stdin)
        {
 
       if (annotation_level > 1 && instream == stdin)
        {
@@ -1987,7 +2217,7 @@ command_line_input (prrompt, repeat, annotation_suffix)
          if (expanded < 0)
            {
              free (history_value);
          if (expanded < 0)
            {
              free (history_value);
-             return command_line_input (prrompt, repeat, annotation_suffix);
+             return command_line_input (prompt_arg, repeat, annotation_suffix);
            }
          if (strlen (history_value) > linelength)
            {
            }
          if (strlen (history_value) > linelength)
            {
@@ -2003,16 +2233,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 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;
 
 
   *p = 0;
 
@@ -2027,36 +2252,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.  */
      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)
 
   /* Save into global buffer if appropriate.  */
   if (repeat)
@@ -2116,7 +2313,7 @@ read_next_line (command)
     error ("Control nesting too deep!\n");
 
   /* Set a prompt based on the nesting of the control commands.  */
     error ("Control nesting too deep!\n");
 
   /* Set a prompt based on the nesting of the control commands.  */
-  if (instream == stdin)
+  if (instream == stdin || (instream == 0 && readline_hook != NULL))
     {
       for (i = 0; i < control_level; i++)
        control_prompt[i] = ' ';
     {
       for (i = 0; i < control_level; i++)
        control_prompt[i] = ' ';
@@ -2161,7 +2358,7 @@ read_next_line (command)
     *command = build_command_line (while_control, p + 6);
   else if (p1 - p > 2 && !strncmp (p, "if", 2))
     *command = build_command_line (if_control, p + 3);
     *command = build_command_line (while_control, p + 6);
   else if (p1 - p > 2 && !strncmp (p, "if", 2))
     *command = build_command_line (if_control, p + 3);
-  else if (p1 - p == 5 && !strncmp (p, "loop_break", 5))
+  else if (p1 - p == 10 && !strncmp (p, "loop_break", 10))
     {
       *command = (struct command_line *)
        xmalloc (sizeof (struct command_line));
     {
       *command = (struct command_line *)
        xmalloc (sizeof (struct command_line));
@@ -2171,7 +2368,7 @@ read_next_line (command)
       (*command)->body_count = 0;
       (*command)->body_list = NULL;
     }
       (*command)->body_count = 0;
       (*command)->body_list = NULL;
     }
-  else if (p1 - p == 8 && !strncmp (p, "loop_continue", 8))
+  else if (p1 - p == 13 && !strncmp (p, "loop_continue", 13))
     {
       *command = (struct command_line *)
        xmalloc (sizeof (struct command_line));
     {
       *command = (struct command_line *)
        xmalloc (sizeof (struct command_line));
@@ -2198,7 +2395,7 @@ read_next_line (command)
 }
 
 /* Recursively read in the control structures and create a command_line 
 }
 
 /* Recursively read in the control structures and create a command_line 
-   tructure from them.
+   structure from them.
 
    The parent_control parameter is the control structure in which the
    following commands are nested.  */
 
    The parent_control parameter is the control structure in which the
    following commands are nested.  */
@@ -2211,9 +2408,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;
   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;
 
   child_tail = NULL;
   current_body = 1;
 
@@ -2282,19 +2477,12 @@ recurse_read_control_structure (current_cmd)
        }
       else
        {
        }
       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;
 
          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;
        }
 
       child_tail = next;
@@ -2314,27 +2502,39 @@ recurse_read_control_structure (current_cmd)
     }
 
   dont_repeat ();
     }
 
   dont_repeat ();
-  if (ret == invalid_control && old_chains)
-    do_cleanups (old_chains);
-  else if (old_chains)
-    discard_cleanups (old_chains);
 
   return ret;
 }
 
 
   return ret;
 }
 
+/* Read lines from the input stream and accumulate them in a chain of
+   struct command_line's, which is then returned.  For input from a
+   terminal, the special command "end" is used to mark the end of the
+   input, and is not included in the returned chain of commands. */
 
 
-/* Read lines from the input stream
-   and accumulate them in a chain of struct command_line's
-   which is then returned.  */
+#define END_MESSAGE "End with a line saying just \"end\"."
 
 struct command_line *
 
 struct command_line *
-read_command_lines ()
+read_command_lines (prompt_arg, from_tty)
+     char *prompt_arg;
+     int from_tty;
 {
   struct command_line *head, *tail, *next;
   struct cleanup *old_chain;
   enum command_control_type ret;
   enum misc_command_type val;
 
 {
   struct command_line *head, *tail, *next;
   struct cleanup *old_chain;
   enum command_control_type ret;
   enum misc_command_type val;
 
+  control_level = 0; 
+  if (readline_begin_hook)
+    {
+      /* Note - intentional to merge messages with no newline */
+      (*readline_begin_hook) ("%s  %s\n", prompt_arg, END_MESSAGE);
+    }
+  else if (from_tty && input_from_terminal_p ())
+    {
+      printf_unfiltered ("%s\n%s\n", prompt_arg, END_MESSAGE);
+      gdb_flush (gdb_stdout);
+    }
+
   head = tail = NULL;
   old_chain = NULL;
 
   head = tail = NULL;
   old_chain = NULL;
 
@@ -2376,7 +2576,8 @@ read_command_lines ()
       else
        {
          head = next;
       else
        {
          head = next;
-         old_chain = make_cleanup (free_command_lines, &head);
+         old_chain = make_cleanup ((make_cleanup_func) free_command_lines, 
+                                    &head);
        }
       tail = next;
     }
        }
       tail = next;
     }
@@ -2388,13 +2589,16 @@ read_command_lines ()
       if (ret != invalid_control)
        {
          discard_cleanups (old_chain);
       if (ret != invalid_control)
        {
          discard_cleanups (old_chain);
-         return head;
        }
       else
        do_cleanups (old_chain);
     }
 
        }
       else
        do_cleanups (old_chain);
     }
 
-  return NULL;
+  if (readline_end_hook)
+    {
+      (*readline_end_hook) ();
+    }
+  return (head);
 }
 
 /* Free a chain of struct command_line's.  */
 }
 
 /* Free a chain of struct command_line's.  */
@@ -2548,7 +2752,7 @@ validate_comname (comname)
   p = comname;
   while (*p)
     {
   p = comname;
   while (*p)
     {
-      if (!isalnum(*p) && *p != '-')
+      if (!isalnum(*p) && *p != '-' && *p != '_')
        error ("Junk in argument list: \"%s\"", p);
       p++;
     }
        error ("Junk in argument list: \"%s\"", p);
       p++;
     }
@@ -2570,6 +2774,7 @@ define_command (comname, from_tty)
   register struct command_line *cmds;
   register struct cmd_list_element *c, *newc, *hookc = 0;
   char *tem = comname;
   register struct command_line *cmds;
   register struct cmd_list_element *c, *newc, *hookc = 0;
   char *tem = comname;
+  char tmpbuf[128];
 #define        HOOK_STRING     "hook-"
 #define        HOOK_LEN 5
 
 #define        HOOK_STRING     "hook-"
 #define        HOOK_LEN 5
 
@@ -2605,7 +2810,7 @@ define_command (comname, from_tty)
        {
          warning ("Your new `%s' command does not hook any existing command.",
                   comname);
        {
          warning ("Your new `%s' command does not hook any existing command.",
                   comname);
-         if (!query ("Proceed? ", (char *)0))
+         if (!query ("Proceed? "))
            error ("Not confirmed.");
        }
     }
            error ("Not confirmed.");
        }
     }
@@ -2617,15 +2822,8 @@ define_command (comname, from_tty)
   for (tem = comname; *tem; tem++)
     if (isupper(*tem)) *tem = tolower(*tem);
 
   for (tem = comname; *tem; tem++)
     if (isupper(*tem)) *tem = tolower(*tem);
 
-  if (from_tty)
-    {
-      printf_unfiltered ("Type commands for definition of \"%s\".\n\
-End with a line saying just \"end\".\n", comname);
-      gdb_flush (gdb_stdout);
-    }
-
-  control_level = 0;
-  cmds = read_command_lines ();
+  sprintf (tmpbuf, "Type commands for definition of \"%s\".", comname);
+  cmds = read_command_lines (tmpbuf, from_tty);
 
   if (c && c->class == class_user)
     free_command_lines (&c->user_commands);
 
   if (c && c->class == class_user)
     free_command_lines (&c->user_commands);
@@ -2652,6 +2850,7 @@ document_command (comname, from_tty)
   struct command_line *doclines;
   register struct cmd_list_element *c;
   char *tem = comname;
   struct command_line *doclines;
   register struct cmd_list_element *c;
   char *tem = comname;
+  char tmpbuf[128];
 
   validate_comname (comname);
 
 
   validate_comname (comname);
 
@@ -2660,11 +2859,8 @@ document_command (comname, from_tty)
   if (c->class != class_user)
     error ("Command \"%s\" is built-in.", comname);
 
   if (c->class != class_user)
     error ("Command \"%s\" is built-in.", comname);
 
-  if (from_tty)
-    printf_unfiltered ("Type documentation for \"%s\".\n\
-End with a line saying just \"end\".\n", comname);
-
-  doclines = read_command_lines ();
+  sprintf (tmpbuf, "Type documentation for \"%s\".", comname);
+  doclines = read_command_lines (tmpbuf, from_tty);
 
   if (c->doc) free (c->doc);
 
 
   if (c->doc) free (c->doc);
 
@@ -2689,29 +2885,44 @@ End with a line saying just \"end\".\n", comname);
   free_command_lines (&doclines);
 }
 \f
   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\
-");
-}
-
+/* Print the GDB banner. */
 void
 print_gdb_version (stream)
   GDB_FILE *stream;
 {
 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 1998 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, "\
   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 1994 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 */
 }
 
 /* ARGSUSED */
@@ -2721,44 +2932,342 @@ show_version (args, from_tty)
      int from_tty;
 {
   immediate_quit++;
      int from_tty;
 {
   immediate_quit++;
-  print_gnu_advertisement ();
   print_gdb_version (gdb_stdout);
   printf_filtered ("\n");
   immediate_quit--;
 }
 \f
   print_gdb_version (gdb_stdout);
   printf_filtered ("\n");
   immediate_quit--;
 }
 \f
-/* xgdb calls this to reprint the usual GDB prompt.  Obsolete now that xgdb
-   is obsolete.  */
+/* get_prompt: access method for the GDB prompt string.  */
 
 
-void
-print_prompt ()
+#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 (formatted_prompt)
+     char *formatted_prompt;
 {
 {
-  printf_unfiltered ("%s", prompt);
-  gdb_flush (gdb_stdout);
+  char *local_prompt;
+
+  if (async_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;
+      value_ptr 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_pointer (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);
+                     free (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, "%d", (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 ()
+{
+  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 */
+    }
+  else
+    {
+      /* Prompt could not be formatted.  */
+      if (async_p)
+       return PROMPT (0);
+      else
+       return gdb_prompt_string;
+    }
+}
+
+void
+set_prompt (s)
+     char *s;
+{
+/* ??rehrauer: I don't know why this fails, since it looks as though
+   assignments to prompt are wrapped in calls to savestring...
+  if (prompt != NULL)
+    free (prompt);
+*/
+  if (async_p)
+    PROMPT (0) = savestring (s, strlen (s));
+  else
+    gdb_prompt_string = savestring (s, strlen (s));
+}
+
 \f
 \f
+/* If necessary, make the user confirm that we should quit.  Return
+   non-zero if we should quit, zero if we shouldn't.  */
+
+int
+quit_confirm ()
+{
+  if (inferior_pid != 0 && target_has_execution)
+    {
+      char *s;
+
+      /* This is something of a hack.  But there's no reliable way to
+        see if a GUI is running.  The `use_windows' variable doesn't
+        cut it.  */
+      if (init_ui_hook)
+       s = "A debugging session is active.\nDo you still want to close the debugger?";
+      else if (attach_flag)
+       s = "The program is running.  Quit anyway (and detach it)? ";
+      else
+       s = "The program is running.  Exit anyway? ";
+
+      if (! query (s))
+       return 0;
+    }
+
+  return 1;
+}
+
+/* Quit without asking for confirmation.  */
+
 void
 void
-quit_command (args, from_tty)
+quit_force (args, from_tty)
      char *args;
      int from_tty;
 {
      char *args;
      int from_tty;
 {
+  int exit_code = 0;
+
+  /* An optional expression may be used to cause gdb to terminate with the 
+     value of that expression. */
+  if (args)
+    {
+      value_ptr val = parse_and_eval (args);
+
+      exit_code = (int) value_as_long (val);
+    }
+
   if (inferior_pid != 0 && target_has_execution)
     {
       if (attach_flag)
   if (inferior_pid != 0 && target_has_execution)
     {
       if (attach_flag)
-       {
-         if (query ("The program is running.  Quit anyway (and detach it)? "))
-           target_detach (args, from_tty);
-         else
-           error ("Not confirmed.");
-       }
+       target_detach (args, from_tty);
       else
       else
-       {
-         if (query ("The program is running.  Quit anyway (and kill it)? "))
-           target_kill ();
-         else
-           error ("Not confirmed.");
-       }
+       target_kill ();
     }
     }
+
   /* UDI wants this, to kill the TIP.  */
   target_close (1);
 
   /* UDI wants this, to kill the TIP.  */
   target_close (1);
 
@@ -2766,7 +3275,31 @@ quit_command (args, from_tty)
   if (write_history_p && history_filename)
     write_history (history_filename);
 
   if (write_history_p && history_filename)
     write_history (history_filename);
 
-  exit (0);
+  do_final_cleanups(ALL_CLEANUPS);     /* Do any final cleanups before exiting */
+
+#if defined(TUI)
+  /* tuiDo((TuiOpaqueFuncPtr)tuiCleanUp); */
+  /* The above does not need to be inside a tuiDo(), since
+   * it is not manipulating the curses screen, but rather,
+   * it is tearing it down.
+   */
+  if (tui_version)
+    tuiCleanUp();
+#endif
+
+  exit (exit_code);
+}
+
+/* Handle the quit command.  */
+
+void
+quit_command (args, from_tty)
+     char *args;
+     int from_tty;
+{
+  if (! quit_confirm ())
+    error ("Not confirmed.");
+  quit_force (args, from_tty);
 }
 
 /* Returns whether GDB is running on a terminal and whether the user
 }
 
 /* Returns whether GDB is running on a terminal and whether the user
@@ -2818,15 +3351,15 @@ cd_command (dir, from_tty)
     perror_with_name (dir);
 
   len = strlen (dir);
     perror_with_name (dir);
 
   len = strlen (dir);
-  dir = savestring (dir, len - (len > 1 && dir[len-1] == '/'));
-  if (dir[0] == '/')
+  dir = savestring (dir, len - (len > 1 && SLASH_P(dir[len-1])));
+  if (ROOTED_P(dir))
     current_directory = dir;
   else
     {
     current_directory = dir;
   else
     {
-      if (current_directory[0] == '/' && current_directory[1] == '\0')
+      if (SLASH_P (current_directory[0]) && current_directory[1] == '\0')
        current_directory = concat (current_directory, dir, NULL);
       else
        current_directory = concat (current_directory, dir, NULL);
       else
-       current_directory = concat (current_directory, "/", dir, NULL);
+       current_directory = concat (current_directory, SLASH_STRING, dir, NULL);
       free (dir);
     }
 
       free (dir);
     }
 
@@ -2835,17 +3368,17 @@ cd_command (dir, from_tty)
   found_real_path = 0;
   for (p = current_directory; *p;)
     {
   found_real_path = 0;
   for (p = current_directory; *p;)
     {
-      if (p[0] == '/' && p[1] == '.' && (p[2] == 0 || p[2] == '/'))
+      if (SLASH_P (p[0]) && p[1] == '.' && (p[2] == 0 || SLASH_P (p[2])))
        strcpy (p, p + 2);
        strcpy (p, p + 2);
-      else if (p[0] == '/' && p[1] == '.' && p[2] == '.'
-              && (p[3] == 0 || p[3] == '/'))
+      else if (SLASH_P (p[0]) && p[1] == '.' && p[2] == '.'
+              && (p[3] == 0 || SLASH_P (p[3])))
        {
          if (found_real_path)
            {
              /* Search backwards for the directory just before the "/.."
                 and obliterate it and the "/..".  */
              char *q = p;
        {
          if (found_real_path)
            {
              /* Search backwards for the directory just before the "/.."
                 and obliterate it and the "/..".  */
              char *q = p;
-             while (q != current_directory && q[-1] != '/')
+             while (q != current_directory && ! SLASH_P (q[-1]))
                --q;
 
              if (q == current_directory)
                --q;
 
              if (q == current_directory)
@@ -2916,10 +3449,15 @@ source_command (args, from_tty)
   old_cleanups = make_cleanup (free, file);
 
   stream = fopen (file, FOPEN_RT);
   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);
+  make_cleanup ((make_cleanup_func) fclose, stream);
 
   old_lines.old_line = source_line_number;
   old_lines.old_file = source_file_name;
 
   old_lines.old_line = source_line_number;
   old_lines.old_file = source_file_name;
@@ -2984,102 +3522,14 @@ echo_command (text, from_tty)
   gdb_flush (gdb_stdout);
 }
 
   gdb_flush (gdb_stdout);
 }
 
-\f
-#ifdef TARGET_BYTE_ORDER_SELECTABLE
-
-/* Functions to manipulate the endianness of the target.  */
-
-#ifndef TARGET_BYTE_ORDER_DEFAULT
-#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN
-#endif
-
-int target_byte_order = TARGET_BYTE_ORDER_DEFAULT;
-
-static int target_byte_order_auto = 1;
-
-/* Called if the user enters ``set endian'' without an argument.  */
-static void
-set_endian (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  printf_unfiltered ("\"set endian\" must be followed by \"auto\", \"big\" or \"little\".\n");
-  show_endian (args, from_tty);
-}
-
-/* Called by ``set endian big''.  */
-static void
-set_endian_big (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  target_byte_order = BIG_ENDIAN;
-  target_byte_order_auto = 0;
-}
-
-/* Called by ``set endian little''.  */
-static void
-set_endian_little (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  target_byte_order = LITTLE_ENDIAN;
-  target_byte_order_auto = 0;
-}
-
-/* Called by ``set endian auto''.  */
-static void
-set_endian_auto (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  target_byte_order_auto = 1;
-}
-
-/* Called by ``show endian''.  */
+/* ARGSUSED */
 static void
 static void
-show_endian (args, from_tty)
-     char *args;
+dont_repeat_command (ignored, from_tty)
+     char *ignored;
      int from_tty;
 {
      int from_tty;
 {
-  const char *msg =
-    (target_byte_order_auto
-     ? "The target endianness is set automatically (currently %s endian)\n"
-     : "The target is assumed to be %s endian\n");
-  printf_unfiltered (msg, TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little");
-}
-
-#endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */
-
-/* Set the endianness from a BFD.  */
-void
-set_endian_from_file (abfd)
-     bfd *abfd;
-{
-#ifdef TARGET_BYTE_ORDER_SELECTABLE
-  int want;
-
-  if (abfd->xvec->byteorder_big_p)
-    want = BIG_ENDIAN;
-  else
-    want = LITTLE_ENDIAN;
-  if (target_byte_order_auto)
-    target_byte_order = want;
-  else if (target_byte_order != want)
-    warning ("%s endian file does not match %s endian target.",
-            want == BIG_ENDIAN ? "big" : "little",
-            TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little");
-
-#else /* ! defined (TARGET_BYTE_ORDER_SELECTABLE) */
-
-  if (abfd->xvec->byteorder_big_p
-      ? 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",
-            TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little");
-
-#endif /* ! defined (TARGET_BYTE_ORDER_SELECTABLE) */
+  *line = 0;           /* Can't call dont_repeat here because we're not
+                          necessarily reading from stdin.  */
 }
 \f
 /* Functions to manipulate command line editing control variables.  */
 }
 \f
 /* Functions to manipulate command line editing control variables.  */
@@ -3246,22 +3696,19 @@ init_cmd_lists ()
   infolist = NULL;
   enablelist = NULL;
   disablelist = NULL;
   infolist = NULL;
   enablelist = NULL;
   disablelist = NULL;
+  togglelist = NULL;
+  stoplist = NULL;
   deletelist = NULL;
   enablebreaklist = NULL;
   setlist = NULL;
   unsetlist = NULL;
   showlist = NULL;
   deletelist = NULL;
   enablebreaklist = NULL;
   setlist = NULL;
   unsetlist = NULL;
   showlist = NULL;
-#ifdef TARGET_BYTE_ORDER_SELECTABLE
-  endianlist = NULL;
-#endif
   sethistlist = NULL;
   showhistlist = NULL;
   unsethistlist = NULL;
   sethistlist = NULL;
   showhistlist = NULL;
   unsethistlist = NULL;
-#if MAINTENANCE_CMDS
   maintenancelist = NULL;
   maintenanceinfolist = NULL;
   maintenanceprintlist = NULL;
   maintenancelist = NULL;
   maintenanceinfolist = NULL;
   maintenanceprintlist = NULL;
-#endif
   setprintlist = NULL;
   showprintlist = NULL;
   setchecklist = NULL;
   setprintlist = NULL;
   showprintlist = NULL;
   setchecklist = NULL;
@@ -3304,27 +3751,35 @@ init_main ()
 {
   struct cmd_list_element *c;
 
 {
   struct cmd_list_element *c;
 
-#ifdef TARGET_BYTE_ORDER_SELECTABLE
-
-  add_prefix_cmd ("endian", class_support, set_endian,
-                 "Set endianness of target.",
-                 &endianlist, "set endian ", 0, &setlist);
-  add_cmd ("big", class_support, set_endian_big,
-          "Set target as being big endian.", &endianlist);
-  add_cmd ("little", class_support, set_endian_little,
-          "Set target as being little endian.", &endianlist);
-  add_cmd ("auto", class_support, set_endian_auto,
-          "Select target endianness automatically.", &endianlist);
-  add_cmd ("endian", class_support, show_endian,
-          "Show endianness of target.", &showlist);
-
-#endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */
-
+  /* If we are running the asynchronous version,
+     we initialize the prompts differently. */
+  if (!async_p)
+    {
 #ifdef DEFAULT_PROMPT
 #ifdef DEFAULT_PROMPT
-  prompt = savestring (DEFAULT_PROMPT, strlen(DEFAULT_PROMPT));
+      gdb_prompt_string = savestring (DEFAULT_PROMPT, strlen(DEFAULT_PROMPT));
 #else
 #else
-  prompt = savestring ("(gdb) ", 6);
+      gdb_prompt_string = savestring ("(gdb) ", 6);
 #endif
 #endif
+    }
+  else
+    {
+      /* initialize the prompt stack to a simple "(gdb) " prompt or to
+        whatever the DEFULAT_PROMPT is. */
+      the_prompts.top = 0;
+      PREFIX(0) = "";
+#ifdef DEFAULT_PROMPT
+      PROMPT(0) = savestring (DEFAULT_PROMPT, strlen(DEFAULT_PROMPT));
+#else
+      PROMPT(0) = savestring ("(gdb) ", 6);
+#endif
+      SUFFIX(0) = "";
+      /* Set things up for annotation_level > 1, if the user ever decides
+        to use it. */
+      async_annotation_suffix = "prompt";
+      /* Set the variable associated with the setshow prompt command. */
+      new_async_prompt = savestring (PROMPT (0), strlen (PROMPT (0)));
+    }
+  gdb_prompt_escape = 0;       /* default to none.  */
 
   /* Set the important stuff up for command editing.  */
   command_editing_p = 1;
 
   /* Set the important stuff up for command editing.  */
   command_editing_p = 1;
@@ -3352,7 +3807,8 @@ well documented as user commands.",
 The commands in this class are those defined by the user.\n\
 Use the \"define\" command to define a command.", &cmdlist);
   add_cmd ("support", class_support, NO_FUNCTION, "Support facilities.", &cmdlist);
 The commands in this class are those defined by the user.\n\
 Use the \"define\" command to define a command.", &cmdlist);
   add_cmd ("support", class_support, NO_FUNCTION, "Support facilities.", &cmdlist);
-  add_cmd ("status", class_info, NO_FUNCTION, "Status inquiries.", &cmdlist);
+  if (!dbx_commands)
+    add_cmd ("status", class_info, NO_FUNCTION, "Status inquiries.", &cmdlist);
   add_cmd ("files", class_files, NO_FUNCTION, "Specifying and examining files.", &cmdlist);
   add_cmd ("breakpoints", class_breakpoint, NO_FUNCTION, "Making program stop at certain points.", &cmdlist);
   add_cmd ("data", class_vars, NO_FUNCTION, "Examining data.", &cmdlist);
   add_cmd ("files", class_files, NO_FUNCTION, "Specifying and examining files.", &cmdlist);
   add_cmd ("breakpoints", class_breakpoint, NO_FUNCTION, "Making program stop at certain points.", &cmdlist);
   add_cmd ("data", class_vars, NO_FUNCTION, "Examining data.", &cmdlist);
@@ -3374,10 +3830,32 @@ The change does not take effect for the program being debugged\n\
 until the next time it is started.", &cmdlist);
   c->completer = filename_completer;
 
 until the next time it is started.", &cmdlist);
   c->completer = filename_completer;
 
+  /* The set prompt command is different depending whether or not the
+     async version is run. NOTE: this difference is going to
+     disappear as we make the event loop be the default engine of
+     gdb. */
+  if (!async_p)
+    {
+      add_show_from_set
+       (add_set_cmd ("prompt", class_support, var_string, 
+                     (char *) &gdb_prompt_string, "Set gdb's prompt",
+                     &setlist),
+        &showlist);
+    }
+  else
+    {
+      c = add_set_cmd ("prompt", class_support, var_string, 
+                     (char *)&new_async_prompt, "Set gdb's prompt",
+                      &setlist);
+      add_show_from_set (c, &showlist);
+      c->function.sfunc = set_async_prompt;
+    }
+
   add_show_from_set
   add_show_from_set
-    (add_set_cmd ("prompt", class_support, var_string, (char *)&prompt,
-          "Set gdb's prompt",
-          &setlist),
+    (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 ("echo", class_support, echo_command,
      &showlist);
 
   add_com ("echo", class_support, echo_command,
@@ -3418,6 +3896,9 @@ when gdb is started.", &cmdlist);
   add_com_alias ("q", "quit", class_support, 1);
   add_com_alias ("h", "help", class_support, 1);
 
   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 ",
 
   c = add_set_cmd ("verbose", class_support, var_boolean, (char *)&info_verbose,
                   "Set ",
@@ -3426,13 +3907,30 @@ when gdb is started.", &cmdlist);
   c->function.sfunc = set_verbose;
   set_verbose (NULL, 0, c);
 
   c->function.sfunc = set_verbose;
   set_verbose (NULL, 0, c);
 
-  add_show_from_set
-    (add_set_cmd ("editing", class_support, var_boolean, (char *)&command_editing_p,
-          "Set editing of command lines as they are typed.\n\
-Use \"on\" to enable to enable the editing, and \"off\" to disable it.\n\
+  /* The set editing command is different depending whether or not the
+     async version is run. NOTE: this difference is going to disappear
+     as we make the event loop be the default engine of gdb. */
+  if (!async_p)
+    {
+      add_show_from_set
+       (add_set_cmd ("editing", class_support, var_boolean, (char *)&command_editing_p,
+                     "Set editing of command lines as they are typed.\n\
+Use \"on\" to enable the editing, and \"off\" to disable it.\n\
 Without an argument, command line editing is enabled.  To edit, use\n\
 EMACS-like or VI-like commands like control-P or ESC.", &setlist),
 Without an argument, command line editing is enabled.  To edit, use\n\
 EMACS-like or VI-like commands like control-P or ESC.", &setlist),
-     &showlist);
+        &showlist);
+    }
+  else
+    {
+      c = add_set_cmd ("editing", class_support, var_boolean, (char *)&async_command_editing_p,
+                      "Set editing of command lines as they are typed.\n\
+Use \"on\" to enable the editing, and \"off\" to disable it.\n\
+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;
+    }
 
   add_prefix_cmd ("history", class_support, set_history,
                  "Generic command for setting command history parameters.",
 
   add_prefix_cmd ("history", class_support, set_history,
                  "Generic command for setting command history parameters.",
@@ -3450,7 +3948,7 @@ Without an argument, history expansion is enabled.", &sethistlist),
   add_show_from_set
     (add_set_cmd ("save", no_class, var_boolean, (char *)&write_history_p,
           "Set saving of the history record on exit.\n\
   add_show_from_set
     (add_set_cmd ("save", no_class, var_boolean, (char *)&write_history_p,
           "Set saving of the history record on exit.\n\
-Use \"on\" to enable to enable the saving, and \"off\" to disable it.\n\
+Use \"on\" to enable the saving, and \"off\" to disable it.\n\
 Without an argument, saving is enabled.", &sethistlist),
      &showhistlist);
 
 Without an argument, saving is enabled.", &sethistlist),
      &showhistlist);
 
@@ -3488,7 +3986,7 @@ ie. the number of previous commands to keep a record of.", &sethistlist);
   add_info ("set", show_command, "Show all GDB settings.");
 
   add_cmd ("commands", no_class, show_commands,
   add_info ("set", show_command, "Show all GDB settings.");
 
   add_cmd ("commands", no_class, show_commands,
-          "Show the the history of commands you typed.\n\
+          "Show the history of commands you typed.\n\
 You can supply a command number to start with, or a `+' to start after\n\
 the previous command number shown.",
           &showlist);
 You can supply a command number to start with, or a `+' to start after\n\
 the previous command number shown.",
           &showlist);
@@ -3498,15 +3996,15 @@ the previous command number shown.",
 
   add_com ("while", class_support, while_command,
 "Execute nested commands WHILE the conditional expression is non zero.\n\
 
   add_com ("while", class_support, while_command,
 "Execute nested commands WHILE the conditional expression is non zero.\n\
-The conditional expression must follow the word `while' and must in turn be\
-followed by a new line.  The nested commands must be entered one per line,\
+The conditional expression must follow the word `while' and must in turn be\n\
+followed by a new line.  The nested commands must be entered one per line,\n\
 and should be terminated by the word `end'.");
 
   add_com ("if", class_support, if_command,
 "Execute nested commands once IF the conditional expression is non zero.\n\
 and should be terminated by the word `end'.");
 
   add_com ("if", class_support, if_command,
 "Execute nested commands once IF the conditional expression is non zero.\n\
-The conditional expression must follow the word `if' and must in turn be\
-followed by a new line.  The nested commands must be entered one per line,\
-and should be terminated by the word 'else' or `end'.  If an else clause\
+The conditional expression must follow the word `if' and must in turn be\n\
+followed by a new line.  The nested commands must be entered one per line,\n\
+and should be terminated by the word 'else' or `end'.  If an else clause\n\
 is used, the same rules apply to its nested commands as to the first ones.");
 
   /* If target is open when baud changes, it doesn't take effect until the
 is used, the same rules apply to its nested commands as to the first ones.");
 
   /* If target is open when baud changes, it doesn't take effect until the
@@ -3524,4 +4022,35 @@ using remote targets.", &setlist),
 When enabled, each packet sent or received with the remote target\n\
 is displayed.", &setlist),
                     &showlist);
 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 the target.", &setlist),
+                    &showlist);
+
+  /* The set annotate command is different depending whether or not
+     the async version is run. NOTE: this difference is going to
+     disappear as we make the event loop be the default engine of
+     gdb. */
+  if (!async_p)
+    {
+      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);
+    }
+  else
+    {
+      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);     
+      add_show_from_set (c, &showlist);
+      c->function.sfunc = set_async_annotation_level;
+    }
 }
 }
This page took 0.049479 seconds and 4 git commands to generate.