From patchwork Sun Feb 24 16:51:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31581 Received: (qmail 114181 invoked by alias); 24 Feb 2019 16:52:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 114073 invoked by uid 89); 24 Feb 2019 16:52:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.196.18) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 24 Feb 2019 16:52:00 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway30.websitewelcome.com (Postfix) with ESMTP id D104A81BA for ; Sun, 24 Feb 2019 10:51:58 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id xx0Qg40WGYTGMxx0QgLRMs; Sun, 24 Feb 2019 10:51:58 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=mLpFX7+0Kja5cj2hhkEL+3wt3HMSKvrD8Uj7h9fMZa8=; b=bHTPuLkSXt0hCuAIPUuU0bPeVW IWoVIuSgTBsWJ2AVlWwPhBS9WSgYsyq9La6IIs0DUX9xgF00jA0zqJ5qcshnkhSVlAKXohq0dHHrN H+kqcVuDpvuRhdkzYIqZLNmqp; Received: from 75-166-72-210.hlrn.qwest.net ([75.166.72.210]:44502 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gxx0Q-001AKk-KT; Sun, 24 Feb 2019 10:51:58 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC 12/17] Add the ability to stop the event loop Date: Sun, 24 Feb 2019 09:51:48 -0700 Message-Id: <20190224165153.5062-13-tom@tromey.com> In-Reply-To: <20190224165153.5062-1-tom@tromey.com> References: <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 * 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; +} /* 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,