public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFC 12/17] Add the ability to stop the event loop
Date: Sun, 24 Feb 2019 16:52:00 -0000	[thread overview]
Message-ID: <20190224165153.5062-13-tom@tromey.com> (raw)
In-Reply-To: <20190224165153.5062-1-tom@tromey.com>

gdbserver needs a way to stop the event loop.  This patch adds it.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* common/event-loop.h (stop_event_loop): Declare.
	* common/event-loop.c (event_looping): New global.
	(start_event_loop): Check it.
	(stop_event_loop): New function.
---
 gdb/ChangeLog           |  7 +++++++
 gdb/common/event-loop.c | 13 ++++++++++++-
 gdb/common/event-loop.h |  5 +++++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/gdb/common/event-loop.c b/gdb/common/event-loop.c
index a2563414dfd..b8d5b007163 100644
--- a/gdb/common/event-loop.c
+++ b/gdb/common/event-loop.c
@@ -256,6 +256,8 @@ gdb_do_one_event (void)
   return 1;
 }
 
+static bool event_looping = true;
+
 /* Start up the event loop.  This is the entry point to the event loop
    from the command loop.  */
 
@@ -266,7 +268,8 @@ start_event_loop ()
      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)
+  event_looping = true;
+  while (event_looping)
     {
       int result = 0;
 
@@ -288,6 +291,14 @@ start_event_loop ()
      to listen to.  So we exit GDB.  */
   return;
 }
+
+/* See event-loop.h.  */
+
+void
+stop_event_loop ()
+{
+  event_looping = false;
+}
 \f
 
 /* Wrapper function for create_file_handler, so that the caller
diff --git a/gdb/common/event-loop.h b/gdb/common/event-loop.h
index 1eec1ed2cd9..9ace0c46f6c 100644
--- a/gdb/common/event-loop.h
+++ b/gdb/common/event-loop.h
@@ -79,6 +79,11 @@ typedef void (timer_handler_func) (gdb_client_data);
 /* Exported functions from event-loop.c */
 
 extern void start_event_loop ();
+
+/* Request that the event loop stop.  */
+
+extern void stop_event_loop ();
+
 extern int gdb_do_one_event (void);
 extern void delete_file_handler (int fd);
 extern void add_file_handler (int fd, handler_func *proc, 
-- 
2.17.2

  parent reply	other threads:[~2019-02-24 16:52 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
2019-02-24 16:52 ` [RFC 17/17] Simplify gdbserver's serial event handling Tom Tromey
2019-09-26 17:36   ` Pedro Alves
2019-10-04 22:08     ` Tom Tromey
2019-02-24 16:52 ` [RFC 08/17] Introduce and use flush_streams Tom Tromey
2019-02-24 16:52 ` [RFC 09/17] Introduce async-event.[ch] Tom Tromey
2019-09-26 14:06   ` Pedro Alves
2019-10-04 22:17     ` Tom Tromey
2019-02-24 16:52 ` [RFC 01/17] Remove include from event-loop.c Tom Tromey
2019-02-24 16:52 ` [RFC 06/17] Include <chrono> in event-loop.c Tom Tromey
2019-09-26 14:02   ` Pedro Alves
2019-02-24 16:52 ` [RFC 10/17] Move event-loop.[ch] to common/ Tom Tromey
2019-09-26 14:06   ` Pedro Alves
2019-10-04 22:06     ` Tom Tromey
2019-02-24 16:52 ` [RFC 04/17] Move gdb_select.h " Tom Tromey
2019-02-24 16:52 ` [RFC 03/17] Move event-loop configury to common.m4 Tom Tromey
2019-02-24 16:52 ` [RFC 13/17] Switch gdbserver to common event loop Tom Tromey
2019-02-24 16:52 ` [RFC 15/17] Move gdb_notifier comment Tom Tromey
2019-09-26 14:06   ` Pedro Alves
2019-02-24 16:52 ` [RFC 11/17] Implement event-loop glue for gdbserver Tom Tromey
2019-02-24 16:52 ` [RFC 02/17] Move gdb-specific code out of start_event_loop Tom Tromey
2019-09-26 14:02   ` Pedro Alves
2019-02-24 16:52 ` [RFC 16/17] Remove gdb_fildes_t Tom Tromey
2019-02-24 16:52 ` [RFC 05/17] Remove gdb_usleep.c Tom Tromey
2019-09-26 14:02   ` Pedro Alves
2019-09-26 14:43     ` Tom Tromey
2019-02-24 16:52 ` [RFC 14/17] Remove some dead code from event-loop.c Tom Tromey
2019-02-24 16:52 ` Tom Tromey [this message]
2019-02-24 16:52 ` [RFC 07/17] Use warning in event-loop Tom Tromey
2019-09-26 14:02   ` Pedro Alves
2019-02-24 17:14 ` [RFC 00/17] Merge event loop implementations Eli Zaretskii
2019-02-24 17:26   ` Tom Tromey
2019-02-24 17:45     ` Eli Zaretskii
2019-02-25 19:57       ` Tom Tromey
2019-02-25 20:30         ` Eli Zaretskii
2019-02-25 20:55           ` Tom Tromey
2019-02-26 16:04             ` Eli Zaretskii
2019-02-26 16:23               ` Tom Tromey
2019-02-26 16:46                 ` Eli Zaretskii
2019-09-26 17:47 ` Pedro Alves
2019-09-26 23:09   ` Tom Tromey
2019-09-27 13:53     ` Pedro Alves
2019-09-27 14:05       ` Pedro Alves
2019-09-27 14:21         ` Eli Zaretskii
2019-09-27 14:53           ` Pedro Alves
2019-09-27 15:32             ` Eli Zaretskii
2019-09-27 19:10       ` Tom Tromey
2020-02-14  2:22         ` Tom Tromey
2020-02-14 17:58           ` Pedro Alves
2020-02-14 18:36             ` Tom Tromey
2019-10-04 22:25   ` Tom Tromey
2020-02-14 18:20     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190224165153.5062-13-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).