Move start_event_loop out of event-loop.c
authorTom Tromey <tom@tromey.com>
Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 13 Apr 2020 20:10:03 +0000 (14:10 -0600)
A subsequent patch is going to move event-loop.c to gdbsupport.  In a
review of an earlier version of this series, Pedro pointed out that
the resulting code would be cleaner if start_event_loop were not
shared -- because gdb and gdbserver have some different needs here --
and so this moves start_event_loop to main.c.  Because the only caller
is there, it is also now static.

gdb/ChangeLog
2020-04-13  Tom Tromey  <tom@tromey.com>

* event-loop.h (start_event_loop): Don't declare.
* event-loop.c (start_event_loop): Move...
* main.c (start_event_loop): ...here.  Now static.

gdb/ChangeLog
gdb/event-loop.c
gdb/event-loop.h
gdb/main.c

index 632bb943fc8860f2e3a6dc331bd1914028b63ee4..8489fa31f65d20e1dbc084a62f09a22690dc53fb 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-13  Tom Tromey  <tom@tromey.com>
+
+       * event-loop.h (start_event_loop): Don't declare.
+       * event-loop.c (start_event_loop): Move...
+       * main.c (start_event_loop): ...here.  Now static.
+
 2020-04-13  Sergio Durigan Junior  <sergiodj@sergiodj.net>
 
        * MAINTAINERS: Update my email address.
index af8f80b6a2cdf76ae4ed525f778794943d0c00a8..36df4767aa931d2006c41be1ffdd8b0e41fbdb23 100644 (file)
@@ -318,60 +318,6 @@ gdb_do_one_event (void)
   return 1;
 }
 
-/* Start up the event loop.  This is the entry point to the event loop
-   from the command loop.  */
-
-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 will process one event
-     for each invocation.  It blocks waiting for an event and then
-     processes it.  */
-  while (1)
-    {
-      int result = 0;
-
-      try
-       {
-         result = gdb_do_one_event ();
-       }
-      catch (const gdb_exception &ex)
-       {
-         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.  */
-         SWITCH_THRU_ALL_UIS ()
-           {
-             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.  */
-         current_ui->prompt_state = PROMPT_NEEDED;
-         gdb::observers::command_error.notify ();
-         /* 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.  */
-       }
-
-      if (result < 0)
-       break;
-    }
-
-  /* We are done with the event loop.  There are no more event sources
-     to listen to.  So we exit GDB.  */
-  return;
-}
 \f
 
 /* Wrapper function for create_file_handler, so that the caller
index 64f3712786d9e727fdee8689d41df1cc18c03fbd..52740c3b9af349c3fe0a3ebfced19704dcfe2cd1 100644 (file)
@@ -80,7 +80,6 @@ typedef void (timer_handler_func) (gdb_client_data);
 
 /* Exported functions from event-loop.c */
 
-extern void start_event_loop (void);
 extern int gdb_do_one_event (void);
 extern void delete_file_handler (int fd);
 extern void add_file_handler (int fd, handler_func *proc, 
index a03ed8117ab6daca61c300b9031714102e86447b..67a3d0027e13703c38668a94a426e5abe2cc1074 100644 (file)
@@ -53,6 +53,7 @@
 #include "gdbtk/generic/gdbtk.h"
 #endif
 #include "gdbsupport/alt-stack.h"
+#include "observable.h"
 
 /* The selected interpreter.  This will be used as a set command
    variable, so it should always be malloc'ed - since
@@ -336,6 +337,61 @@ get_init_files (std::vector<std::string> *system_gdbinit,
   *local_gdbinit = localinit;
 }
 
+/* Start up the event loop.  This is the entry point to the event loop
+   from the command loop.  */
+
+static void
+start_event_loop ()
+{
+  /* 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 result = 0;
+
+      try
+       {
+         result = gdb_do_one_event ();
+       }
+      catch (const gdb_exception &ex)
+       {
+         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.  */
+         SWITCH_THRU_ALL_UIS ()
+           {
+             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.  */
+         current_ui->prompt_state = PROMPT_NEEDED;
+         gdb::observers::command_error.notify ();
+         /* 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.  */
+       }
+
+      if (result < 0)
+       break;
+    }
+
+  /* We are done with the event loop.  There are no more event sources
+     to listen to.  So we exit GDB.  */
+  return;
+}
+
 /* Call command_loop.  */
 
 /* Prevent inlining this function for the benefit of GDB's selftests
This page took 0.03084 seconds and 4 git commands to generate.