From patchwork Tue Nov 26 17:11:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36233 Received: (qmail 119088 invoked by alias); 26 Nov 2019 17:21:55 -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 119076 invoked by uid 89); 26 Nov 2019 17:21:55 -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 autolearn=ham version=3.3.1 spammy=2316 X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Nov 2019 17:21:53 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id ED10320387; Tue, 26 Nov 2019 12:12:00 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id A342C2226C for ; Tue, 26 Nov 2019 12:11:33 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 861E52817B for ; Tue, 26 Nov 2019 12:11:33 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Tue, 26 Nov 2019 12:11:33 -0500 From: "Tom Tromey (Code Review)" To: gdb-patches@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Move wait_for_debug_event to nat/windows-nat.c X-Gerrit-Change-Id: I94347cefeeab99cacf713b1f8f09427319da0caa X-Gerrit-Change-Number: 719 X-Gerrit-ChangeURL: X-Gerrit-Commit: 5bd88ce00a936368ec9172b2c72cfc13f3845f9a References: Reply-To: tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/719 ...................................................................... Move wait_for_debug_event to nat/windows-nat.c This moves the wait_for_debug_event helper function to nat/windows-nat.c, and changes gdbserver to use it. wait_for_debug_event is a wrapper for WaitForDebugEvent that also sets last_wait_event when appropriate. This is needed to properly handle queued stops. 2019-11-26 Tom Tromey * windows-nat.c (wait_for_debug_event): Move to nat/windows-nat.c. * nat/windows-nat.h (wait_for_debug_event): Declare. * nat/windows-nat.c (wait_for_debug_event): Move from windows-nat.c. No longer static. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey * win32-low.c (win32_kill, get_child_debug_event): Use wait_for_debug_event. Change-Id: I94347cefeeab99cacf713b1f8f09427319da0caa --- M gdb/ChangeLog M gdb/gdbserver/ChangeLog M gdb/gdbserver/win32-low.c M gdb/nat/windows-nat.c M gdb/nat/windows-nat.h M gdb/windows-nat.c 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 29ef0db..afe6ae9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2019-11-26 Tom Tromey + * windows-nat.c (wait_for_debug_event): Move to + nat/windows-nat.c. + * nat/windows-nat.h (wait_for_debug_event): Declare. + * nat/windows-nat.c (wait_for_debug_event): Move from + windows-nat.c. No longer static. + +2019-11-26 Tom Tromey + * windows-nat.c (get_windows_debug_event): Use fetch_pending_stop. * nat/windows-nat.h (fetch_pending_stop): Declare. diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index b31abf1..d05734a 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,10 @@ 2019-11-26 Tom Tromey + * win32-low.c (win32_kill, get_child_debug_event): Use + wait_for_debug_event. + +2019-11-26 Tom Tromey + * win32-low.c (child_continue): Call continue_last_debug_event. 2019-11-26 Tom Tromey diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index d41e0e0..7b5ae07 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -785,7 +785,7 @@ { if (!child_continue (DBG_CONTINUE, -1)) break; - if (!WaitForDebugEvent (¤t_event, INFINITE)) + if (!wait_for_debug_event (¤t_event, INFINITE)) break; if (current_event.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT) break; @@ -1219,7 +1219,7 @@ happen is the user will see a spurious breakpoint. */ current_event.dwDebugEventCode = 0; - if (!WaitForDebugEvent (¤t_event, 0)) + if (!wait_for_debug_event (¤t_event, 0)) { OUTMSG2(("no attach events left\n")); fake_breakpoint_event (); @@ -1234,7 +1234,7 @@ /* Keep the wait time low enough for comfortable remote interruption, but high enough so gdbserver doesn't become a bottleneck. */ - if (!WaitForDebugEvent (¤t_event, 250)) + if (!wait_for_debug_event (¤t_event, 250)) { DWORD e = GetLastError(); diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c index 126a329..8b00142 100644 --- a/gdb/nat/windows-nat.c +++ b/gdb/nat/windows-nat.c @@ -365,5 +365,15 @@ continue_status); } +/* See nat/windows-nat.h. */ + +BOOL +wait_for_debug_event (DEBUG_EVENT *event, DWORD timeout) +{ + BOOL result = WaitForDebugEvent (event, timeout); + if (result) + last_wait_event = *event; + return result; +} } diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h index 702aebc..ebdbacd 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -231,6 +231,11 @@ extern BOOL continue_last_debug_event (DWORD continue_status, bool debug_events); +/* A simple wrapper for WaitForDebugEvent that also sets + 'last_wait_event' on success. */ + +extern BOOL wait_for_debug_event (DEBUG_EVENT *event, DWORD timeout); + } #endif diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index bbae172..7fd6589 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1298,17 +1298,6 @@ return TRUE; } -/* A wrapper for WaitForDebugEvent that sets "last_wait_event" - appropriately. */ -static BOOL -wait_for_debug_event (DEBUG_EVENT *event, DWORD timeout) -{ - BOOL result = WaitForDebugEvent (event, timeout); - if (result) - last_wait_event = *event; - return result; -} - /* Get the next event from the child. Returns a non-zero thread id if the event requires handling by WFI (or whatever). */ static int