From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id E33253AAA091 for ; Fri, 13 Mar 2020 19:09:04 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id DD15F561B7; Fri, 13 Mar 2020 15:09:04 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7XUjEFnVvVTV; Fri, 13 Mar 2020 15:09:04 -0400 (EDT) Received: from murgatroyd.Home (184-96-250-69.hlrn.qwest.net [184.96.250.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 9B4C6561B4; Fri, 13 Mar 2020 15:09:04 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v3 24/29] Move wait_for_debug_event to nat/windows-nat.c Date: Fri, 13 Mar 2020 13:08:50 -0600 Message-Id: <20200313190855.28662-25-tromey@adacore.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200313190855.28662-1-tromey@adacore.com> References: <20200313190855.28662-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-25.0 required=5.0 tests=GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2020 19:09:05 -0000 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. gdb/ChangeLog 2020-03-13 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. gdbserver/ChangeLog 2020-03-13 Tom Tromey * win32-low.c (win32_kill, get_child_debug_event): Use wait_for_debug_event. --- gdb/ChangeLog | 8 ++++++++ gdb/nat/windows-nat.c | 10 ++++++++++ gdb/nat/windows-nat.h | 5 +++++ gdb/windows-nat.c | 11 ----------- gdbserver/ChangeLog | 5 +++++ gdbserver/win32-low.cc | 6 +++--- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c index 823471eb4da..bb28e9b13c7 100644 --- a/gdb/nat/windows-nat.c +++ b/gdb/nat/windows-nat.c @@ -385,5 +385,15 @@ continue_last_debug_event (DWORD continue_status, bool debug_events) 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 68b72d4bbd2..846fa67f407 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -245,6 +245,11 @@ extern gdb::optional fetch_pending_stop (bool debug_events); 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 9a1dd49a42b..23bc9b1714f 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1495,17 +1495,6 @@ ctrl_c_handler (DWORD event_type) 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). */ diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index 33f64700153..d151505e9f8 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -797,7 +797,7 @@ win32_process_target::kill (process_info *process) { 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; @@ -1231,7 +1231,7 @@ get_child_debug_event (DWORD *continue_status, 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 (); @@ -1246,7 +1246,7 @@ get_child_debug_event (DWORD *continue_status, /* 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(); -- 2.21.1