[review] Move wait_for_debug_event to nat/windows-nat.c

Message ID gerrit.1574788288000.I94347cefeeab99cacf713b1f8f09427319da0caa@gnutoolchain-gerrit.osci.io
State New
Headers show
Series
  • [review] Move wait_for_debug_event to nat/windows-nat.c
Related show

Commit Message

Simon Marchi (Code Review) Nov. 26, 2019, 5:11 p.m.
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  <tromey@adacore.com>

	* 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  <tromey@adacore.com>

	* 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(-)




-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I94347cefeeab99cacf713b1f8f09427319da0caa
Gerrit-Change-Number: 719
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange

Comments

Simon Marchi (Code Review) Nov. 29, 2019, 8:10 p.m. | #1
Pedro Alves has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/719
......................................................................


Patch Set 1: Code-Review+2


-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I94347cefeeab99cacf713b1f8f09427319da0caa
Gerrit-Change-Number: 719
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Comment-Date: Fri, 29 Nov 2019 20:10:55 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Patch

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  <tromey@adacore.com>
 
+	* 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  <tromey@adacore.com>
+
 	* 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  <tromey@adacore.com>
 
+	* win32-low.c (win32_kill, get_child_debug_event): Use
+	wait_for_debug_event.
+
+2019-11-26  Tom Tromey  <tromey@adacore.com>
+
 	* win32-low.c (child_continue): Call continue_last_debug_event.
 
 2019-11-26  Tom Tromey  <tromey@adacore.com>
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 (&current_event, INFINITE))
+      if (!wait_for_debug_event (&current_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 (&current_event, 0))
+      if (!wait_for_debug_event (&current_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 (&current_event, 250))
+      if (!wait_for_debug_event (&current_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