[17/34] Windows gdb: Can't pass signal to thread other than last stopped thread

Message ID 20240507234233.371123-18-pedro@palves.net
State New
Headers
Series Windows non-stop mode |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Pedro Alves May 7, 2024, 11:42 p.m. UTC
  Passing a signal to a thread other than the one that last reported an
event would be later possible with DBG_REPLY_LATER and a backend
working in non-stop mode.

With an all-stop backend that isn't possible, so at least don't
incorrectly consider passing DBG_EXCEPTION_NOT_HANDLED if the thread
that we're going to call ContinueDebugEvent for is not the one that
the user issued "signal SIG" on.

Change-Id: I32915623b5036fb902f9830ce2d6f0b1ccf1f5cf
---
 gdb/windows-nat.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 888f85b1862..a34e230f66e 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1421,10 +1421,21 @@  windows_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
 
   if (sig != GDB_SIGNAL_0)
     {
-      if (windows_process.current_event.dwDebugEventCode
+      /* Note it is OK to call get_last_debug_event_ptid() from the
+	 main thread here, because we know the process_thread thread
+	 isn't waiting for an event at this point, so there's no data
+	 race.  */
+      if (inferior_ptid != get_last_debug_event_ptid ())
+	{
+	  /* ContinueDebugEvent will be for a different thread.  */
+	  DEBUG_EXCEPT ("Cannot continue with signal %d here.  "
+			"Not last-event thread", sig);
+	}
+      else if (windows_process.current_event.dwDebugEventCode
 	  != EXCEPTION_DEBUG_EVENT)
 	{
-	  DEBUG_EXCEPT ("Cannot continue with signal %d here.", sig);
+	  DEBUG_EXCEPT ("Cannot continue with signal %d here.  "
+			"Not stopped for EXCEPTION_DEBUG_EVENT", sig);
 	}
       else if (sig == windows_process.last_sig)
 	continue_status = DBG_EXCEPTION_NOT_HANDLED;