2011-08-04 Pedro Alves <pedro@codesourcery.com>
authorPedro Alves <palves@redhat.com>
Thu, 4 Aug 2011 20:09:46 +0000 (20:09 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 4 Aug 2011 20:09:46 +0000 (20:09 +0000)
* event-loop.c (gdb_do_one_event): Remove `data' parameter.
(start_event_loop): Use TRY_CATCH instead of catch_errors.
* event-loop.h (gdb_do_one_event): Remove `data' parameter.
* top.c (gdb_readline_wrapper): Adjust.
* tui/tui-interp.c (tui_command_loop):
(_initialize_tui_interp): Don't install it.

gdb/ChangeLog
gdb/event-loop.c
gdb/event-loop.h
gdb/top.c
gdb/tui/tui-interp.c

index 60ad1aa8c6f1d533957ed585852fe1026670210b..0fb109b986bd375662ad3dd48d0385b1c907c15c 100644 (file)
@@ -1,3 +1,12 @@
+2011-08-04  Pedro Alves  <pedro@codesourcery.com>
+
+       * event-loop.c (gdb_do_one_event): Remove `data' parameter.
+       (start_event_loop): Use TRY_CATCH instead of catch_errors.
+       * event-loop.h (gdb_do_one_event): Remove `data' parameter.
+       * top.c (gdb_readline_wrapper): Adjust.
+       * tui/tui-interp.c (tui_command_loop):
+       (_initialize_tui_interp): Don't install it.
+
 2011-08-04  Pedro Alves  <pedro@codesourcery.com>
 
        * ui-out.h (uiout): Rename to ...
index b6702f868d366d501889fff40b2f7e010ecbb6e9..ea69ccf0a60dde546896767ff567d0488f45e202 100644 (file)
@@ -410,11 +410,10 @@ process_event (void)
 /* Process one high level event.  If nothing is ready at this time,
    wait for something to happen (via gdb_wait_for_event), then process
    it.  Returns >0 if something was done otherwise returns <0 (this
-   can happen if there are no event sources to wait for).  If an error
-   occurs catch_errors() which calls this function returns zero.  */
+   can happen if there are no event sources to wait for).  */
 
 int
-gdb_do_one_event (void *data)
+gdb_do_one_event (void)
 {
   static int event_source_head = 0;
   const int number_of_sources = 3;
@@ -478,30 +477,30 @@ gdb_do_one_event (void *data)
 void
 start_event_loop (void)
 {
-  /* Loop until there is nothing to do.  This is the entry point to the
-     event loop engine.  gdb_do_one_event, called via catch_errors()
-     will process one event for each invocation.  It blocks waits for
-     an event and then processes it.  >0 when an event is processed, 0
-     when catch_errors() caught an error and <0 when there are no
-     longer any event sources registered.  */
+  /* Loop until there is nothing to do.  This is the entry point to
+     the event loop engine.  gdb_do_one_event will process one event
+     for each invocation.  It blocks waiting for an event and then
+     processes it.  */
   while (1)
     {
-      int gdb_result;
+      volatile struct gdb_exception ex;
+      int result = 0;
 
-      gdb_result = catch_errors (gdb_do_one_event, 0, "", RETURN_MASK_ALL);
-      if (gdb_result < 0)
-       break;
-
-      /* If we long-jumped out of do_one_event, we probably
-         didn't get around to resetting the prompt, which leaves
-         readline in a messed-up state.  Reset it here.  */
-
-      if (gdb_result == 0)
+      TRY_CATCH (ex, RETURN_MASK_ALL)
        {
+         result = gdb_do_one_event ();
+       }
+      if (ex.reason < 0)
+       {
+         exception_print (gdb_stderr, ex);
+
          /* If any exception escaped to here, we better enable
             stdin.  Otherwise, any command that calls async_disable_stdin,
             and then throws, will leave stdin inoperable.  */
          async_enable_stdin ();
+         /* If we long-jumped out of do_one_event, we probably didn't
+            get around to resetting the prompt, which leaves readline
+            in a messed-up state.  Reset it here.  */
          /* FIXME: this should really be a call to a hook that is
             interface specific, because interfaces can display the
             prompt in their own way.  */
@@ -517,6 +516,8 @@ start_event_loop (void)
          /* Maybe better to set a flag to be checked somewhere as to
             whether display the prompt or not.  */
        }
+      if (result < 0)
+       break;
     }
 
   /* We are done with the event loop.  There are no more event sources
index 54d83c469e560ee4902af8d59a1bd1e37d58da6d..e519852e03085570fe710b5efc2fbf7243fddb0e 100644 (file)
@@ -91,7 +91,7 @@ queue_position;
 /* Exported functions from event-loop.c */
 
 extern void start_event_loop (void);
-extern int gdb_do_one_event (void *data);
+extern int gdb_do_one_event (void);
 extern void delete_file_handler (int fd);
 extern void add_file_handler (int fd, handler_func *proc, 
                              gdb_client_data client_data);
index 7b98353de54d4ae2608d241c51fa1ea91940d1d1..da930ca28893f91082256d21d166c1016bb7f8ff 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -797,8 +797,7 @@ gdb_readline_wrapper (char *prompt)
     (*after_char_processing_hook) ();
   gdb_assert (after_char_processing_hook == NULL);
 
-  /* gdb_do_one_event argument is unused.  */
-  while (gdb_do_one_event (NULL) >= 0)
+  while (gdb_do_one_event () >= 0)
     if (gdb_readline_wrapper_done)
       break;
 
index 2f0dd3d4366c4900a6c38da173f11f2982c6a9e1..78b8aca3d022ada2cc609413d16db728aa7dd984 100644 (file)
@@ -132,84 +132,6 @@ tui_exec (void *data, const char *command_str)
   internal_error (__FILE__, __LINE__, _("tui_exec called"));
 }
 
-
-/* Initialize all the necessary variables, start the event loop,
-   register readline, and stdin, start the loop.  */
-
-static void
-tui_command_loop (void *data)
-{
-  /* If we are using readline, set things up and display the first
-     prompt, otherwise just print the prompt.  */
-  if (async_command_editing_p)
-    {
-      int length;
-      char *a_prompt;
-      char *gdb_prompt = get_prompt (0);
-
-      /* Tell readline what the prompt to display is and what function
-         it will need to call after a whole line is read. This also
-         displays the first prompt.  */
-      length = strlen (get_prefix (0))
-       + strlen (gdb_prompt) + strlen (get_suffix (0)) + 1;
-      a_prompt = (char *) alloca (length);
-      strcpy (a_prompt, get_prefix (0));
-      strcat (a_prompt, gdb_prompt);
-      strcat (a_prompt, get_suffix (0));
-      rl_callback_handler_install (a_prompt, input_handler);
-    }
-  else
-    display_gdb_prompt (0);
-
-  /* Loop until there is nothing to do. This is the entry point to the
-     event loop engine. gdb_do_one_event, called via catch_errors()
-     will process one event for each invocation.  It blocks waits for
-     an event and then processes it.  >0 when an event is processed, 0
-     when catch_errors() caught an error and <0 when there are no
-     longer any event sources registered.  */
-  while (1)
-    {
-      int result = catch_errors (gdb_do_one_event, 0, "", RETURN_MASK_ALL);
-
-      if (result < 0)
-       break;
-
-      /* Update gdb output according to TUI mode.  Since catch_errors
-         preserves the uiout from changing, this must be done at top
-         level of event loop.  */
-      if (tui_active)
-        current_uiout = tui_out;
-      else
-        current_uiout = tui_old_uiout;
-
-      if (result == 0)
-       {
-         /* If any exception escaped to here, we better enable
-            stdin.  Otherwise, any command that calls async_disable_stdin,
-            and then throws, will leave stdin inoperable.  */
-         async_enable_stdin ();
-         /* FIXME: this should really be a call to a hook that is
-            interface specific, because interfaces can display the
-            prompt in their own way.  */
-         display_gdb_prompt (0);
-         /* This call looks bizarre, but it is required.  If the user
-            entered a command that caused an error,
-            after_char_processing_hook won't be called from
-            rl_callback_read_char_wrapper.  Using a cleanup there
-            won't work, since we want this function to be called
-            after a new prompt is printed.  */
-         if (after_char_processing_hook)
-           (*after_char_processing_hook) ();
-         /* Maybe better to set a flag to be checked somewhere as to
-            whether display the prompt or not.  */
-       }
-    }
-
-  /* We are done with the event loop. There are no more event sources
-     to listen to.  So we exit GDB.  */
-  return;
-}
-
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 extern initialize_file_ftype _initialize_tui_interp;
 
@@ -222,7 +144,6 @@ _initialize_tui_interp (void)
     tui_suspend,
     tui_exec,
     tui_display_prompt_p,
-    tui_command_loop,
   };
 
   /* Create a default uiout builder for the TUI.  */
This page took 0.034779 seconds and 4 git commands to generate.