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

Message ID gerrit.1572371871000.I74ad1eccae65859a7dbaa5910bc424838a4175bc@gnutoolchain-gerrit.osci.io
State New, archived
Headers

Commit Message

Simon Marchi (Code Review) Oct. 29, 2019, 5:57 p.m. UTC
  Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/428
......................................................................

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.

Change-Id: I94347cefeeab99cacf713b1f8f09427319da0caa

gdb/ChangeLog
2019-10-29  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-10-29  Tom Tromey  <tromey@adacore.com>

	* win32-low.c (win32_kill, get_child_debug_event): Use
	wait_for_debug_event.

Change-Id: I74ad1eccae65859a7dbaa5910bc424838a4175bc
---
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(-)
  

Comments

Simon Marchi (Code Review) Nov. 21, 2019, 6:41 p.m. UTC | #1
Pedro Alves has posted comments on this change.

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


Patch Set 1: Code-Review+2

OK.
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e4bdd16..6ac74cd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@ 
 2019-10-29  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-10-29  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 40262d0..c36dcb0 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,10 @@ 
 2019-10-29  Tom Tromey  <tromey@adacore.com>
 
+	* win32-low.c (win32_kill, get_child_debug_event): Use
+	wait_for_debug_event.
+
+2019-10-29  Tom Tromey  <tromey@adacore.com>
+
 	* win32-low.c (child_continue): Call continue_last_debug_event.
 
 2019-10-29  Tom Tromey  <tromey@adacore.com>
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index b58f6f6..10b14df 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 7ac06f4..133fc9c 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -363,5 +363,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 2a5d4a1..3ab1af6 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -228,6 +228,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 e91e052..3e91b89 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1276,17 +1276,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