Add a symbol's value to the computed frag offset, rather than overwriting it.
[deliverable/binutils-gdb.git] / gdb / top.c
index 8a26c9ec0b849ede5f2ddeecf5d0e4a5fc27a899..9747d4929127b7a3c392af4f0beceb28a0e277ea 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
 #include "gdb_string.h"
 #include "gdb_stat.h"
 #include <ctype.h>
+#ifdef UI_OUT
+#include "ui-out.h"
+#include "cli-out.h"
+#endif
 
 /* Prototypes for local functions */
 
@@ -304,7 +308,25 @@ int baud_rate = -1;
 
 /* Timeout limit for response from target. */
 
-int remote_timeout = 20;       /* Set default to 20 */
+/* The default value has been changed many times over the years.  It 
+   was originally 5 seconds.  But that was thought to be a long time 
+   to sit and wait, so it was changed to 2 seconds.  That was thought
+   to be plenty unless the connection was going through some terminal 
+   server or multiplexer or other form of hairy serial connection.
+
+   In mid-1996, remote_timeout was moved from remote.c to top.c and 
+   it began being used in other remote-* targets.  It appears that the
+   default was changed to 20 seconds at that time, perhaps because the
+   Hitachi E7000 ICE didn't always respond in a timely manner.
+
+   But if 5 seconds is a long time to sit and wait for retransmissions,
+   20 seconds is far worse.  This demonstrates the difficulty of using 
+   a single variable for all protocol timeouts.
+
+   As remote.c is used much more than remote-e7000.c, it was changed 
+   back to 2 seconds in 1999. */
+
+int remote_timeout = 2;
 
 /* Non-zero tells remote* modules to output debugging info.  */
 
@@ -774,8 +796,11 @@ gdb_init (argv0)
   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. */
+#ifdef UI_OUT
+  /* Install the default UI */
+  uiout = cli_out_new (gdb_stdout);
+#endif
+
   if (init_ui_hook)
     init_ui_hook (argv0);
 }
@@ -835,6 +860,97 @@ get_command_line (type, arg)
 }
 
 /* Recursively print a command (including full control structures).  */
+#ifdef UI_OUT
+void
+print_command_lines (uiout, cmd, depth)
+     struct ui_out *uiout;
+     struct command_line *cmd;
+     unsigned int depth;
+{
+  struct command_line *list;
+
+  list = cmd;
+  while (list)
+    {
+
+      if (depth)
+       ui_out_spaces (uiout, 2 * depth);
+
+      /* A simple command, print it and continue.  */
+      if (list->control_type == simple_control)
+       {
+         ui_out_field_string (uiout, NULL, list->line);
+         ui_out_text (uiout, "\n");
+         list = list->next;
+         continue;
+       }
+
+      /* loop_continue to jump to the start of a while loop, print it
+         and continue. */
+      if (list->control_type == continue_control)
+       {
+         ui_out_field_string (uiout, NULL, "loop_continue");
+         ui_out_text (uiout, "\n");
+         list = list->next;
+         continue;
+       }
+
+      /* loop_break to break out of a while loop, print it and continue.  */
+      if (list->control_type == break_control)
+       {
+         ui_out_field_string (uiout, NULL, "loop_break");
+         ui_out_text (uiout, "\n");
+         list = list->next;
+         continue;
+       }
+
+      /* A while command.  Recursively print its subcommands and continue.  */
+      if (list->control_type == while_control)
+       {
+         ui_out_text (uiout, "while ");
+         ui_out_field_fmt (uiout, NULL, "while %s", list->line);
+         ui_out_text (uiout, "\n");
+         print_command_lines (uiout, *list->body_list, depth + 1);
+         ui_out_field_string (uiout, NULL, "end");
+         if (depth)
+           ui_out_spaces (uiout, 2 * depth);
+         ui_out_text (uiout, "end\n");
+         list = list->next;
+         continue;
+       }
+
+      /* An if command.  Recursively print both arms before continueing.  */
+      if (list->control_type == if_control)
+       {
+         ui_out_text (uiout, "if ");
+         ui_out_field_fmt (uiout, NULL, "if %s", list->line);
+         ui_out_text (uiout, "\n");
+         /* The true arm. */
+         print_command_lines (uiout, list->body_list[0], depth + 1);
+
+         /* Show the false arm if it exists.  */
+         if (list->body_count == 2)
+           {
+             if (depth)
+               ui_out_spaces (uiout, 2 * depth);
+             ui_out_field_string (uiout, NULL, "else");
+             ui_out_text (uiout, "else\n");
+             print_command_lines (uiout, list->body_list[1], depth + 1);
+           }
+
+         ui_out_field_string (uiout, NULL, "end");
+         if (depth)
+           ui_out_spaces (uiout, 2 * depth);
+         ui_out_text (uiout, "end\n");
+         list = list->next;
+         continue;
+       }
+
+      /* ignore illegal command type and try next */
+      list = list->next;
+    }                          /* while (list) */
+}
+#else
 void
 print_command_line (cmd, depth, stream)
      struct command_line *cmd;
@@ -915,6 +1031,7 @@ print_command_line (cmd, depth, stream)
       fputs_filtered ("end\n", stream);
     }
 }
+#endif
 
 /* Execute the command in CMD.  */
 
@@ -1514,6 +1631,41 @@ command_loop ()
     }
 }
 
+/* Read commands from `instream' and execute them until end of file or
+   error reading instream. This command loop doesnt care about any
+   such things as displaying time and space usage. If the user asks
+   for those, they won't work. */
+void
+simplified_command_loop (read_input_func, execute_command_func)
+     char *(*read_input_func) (char *);
+     void (*execute_command_func) (char *, int);
+{
+  struct cleanup *old_chain;
+  char *command;
+  int stdin_is_tty = ISATTY (stdin);
+
+  while (instream && !feof (instream))
+    {
+      quit_flag = 0;
+      if (instream == stdin && stdin_is_tty)
+       reinitialize_more_filter ();
+      old_chain = make_cleanup ((make_cleanup_func) command_loop_marker, 0);
+
+      /* Get a command-line. */
+      command = (*read_input_func) (instream == stdin ?
+                                   get_prompt () : (char *) NULL);
+
+      if (command == 0)
+       return;
+
+      (*execute_command_func) (command, instream == stdin);
+
+      /* Do any commands attached to breakpoint we stopped at.  */
+      bpstat_do_actions (&stop_bpstat);
+
+      do_cleanups (old_chain);
+    }
+}
 \f
 /* Commands call this if they do not want to be repeated by null lines.  */
 
@@ -2975,7 +3127,12 @@ print_gdb_version (stream)
      program to parse, and is just canonical program name and version
      number, which starts after last space. */
 
+#ifdef UI_OUT
+  /* Print it console style until a format is defined */
+  fprintf_filtered (stream, "GNU gdb %s (UI_OUT)\n", version);
+#else
   fprintf_filtered (stream, "GNU gdb %s\n", version);
+#endif
 
   /* Second line is a copyright notice. */
 
This page took 0.02523 seconds and 4 git commands to generate.