*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / event-loop.c
index 7f81bb30062655702c6c5aa0c5c8d7f3a08540cb..279335a192a503b609d500e9642ed025f0344383 100644 (file)
@@ -1,6 +1,5 @@
 /* Event loop machinery for GDB, the GNU debugger.
-   Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006, 2007, 2008, 2009, 2010,
-   2011 Free Software Foundation, Inc.
+   Copyright (C) 1999-2002, 2005-2012 Free Software Foundation, Inc.
    Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions.
 
    This file is part of GDB.
@@ -410,11 +409,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 +476,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 +515,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
@@ -759,7 +759,6 @@ handle_file_event (event_data data)
   int mask;
 #ifdef HAVE_POLL
   int error_mask;
-  int error_mask_returned;
 #endif
   int event_file_desc = data.integer;
 
@@ -783,22 +782,19 @@ handle_file_event (event_data data)
          if (use_poll)
            {
 #ifdef HAVE_POLL
+             /* POLLHUP means EOF, but can be combined with POLLIN to
+                signal more data to read.  */
              error_mask = POLLHUP | POLLERR | POLLNVAL;
-             mask = (file_ptr->ready_mask & file_ptr->mask) |
-               (file_ptr->ready_mask & error_mask);
-             error_mask_returned = mask & error_mask;
+             mask = file_ptr->ready_mask & (file_ptr->mask | error_mask);
 
-             if (error_mask_returned != 0)
+             if ((mask & (POLLERR | POLLNVAL)) != 0)
                {
                  /* Work in progress.  We may need to tell somebody
                     what kind of error we had.  */
-                 if (error_mask_returned & POLLHUP)
-                   printf_unfiltered (_("Hangup detected on fd %d\n"),
-                                      file_ptr->fd);
-                 if (error_mask_returned & POLLERR)
+                 if (mask & POLLERR)
                    printf_unfiltered (_("Error detected on fd %d\n"),
                                       file_ptr->fd);
-                 if (error_mask_returned & POLLNVAL)
+                 if (mask & POLLNVAL)
                    printf_unfiltered (_("Invalid or non-`poll'able fd %d\n"),
                                       file_ptr->fd);
                  file_ptr->error = 1;
@@ -1077,6 +1073,7 @@ delete_async_signal_handler (async_signal_handler ** async_handler_ptr)
       prev_ptr = sighandler_list.first_handler;
       while (prev_ptr && prev_ptr->next_handler != (*async_handler_ptr))
        prev_ptr = prev_ptr->next_handler;
+      gdb_assert (prev_ptr);
       prev_ptr->next_handler = (*async_handler_ptr)->next_handler;
       if (sighandler_list.last_handler == (*async_handler_ptr))
        sighandler_list.last_handler = prev_ptr;
@@ -1185,6 +1182,7 @@ delete_async_event_handler (async_event_handler **async_handler_ptr)
       prev_ptr = async_event_handler_list.first_handler;
       while (prev_ptr && prev_ptr->next_handler != *async_handler_ptr)
        prev_ptr = prev_ptr->next_handler;
+      gdb_assert (prev_ptr);
       prev_ptr->next_handler = (*async_handler_ptr)->next_handler;
       if (async_event_handler_list.last_handler == (*async_handler_ptr))
        async_event_handler_list.last_handler = prev_ptr;
This page took 0.028558 seconds and 4 git commands to generate.