[binutils-gdb] Windows gdb: Can't pass signal to thread other than last stopped thread

Pedro Alves via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c74e2b803117c3b8da0d7b873caa755f22c8624e

commit c74e2b803117c3b8da0d7b873caa755f22c8624e
Author: Pedro Alves <[email protected]>
Date:   Thu May 11 12:27:27 2023 +0100

    Windows gdb: Can't pass signal to thread other than last stopped thread
    
    Passing a signal to a thread other than the one that last reported an
    event will be later possible with DBG_REPLY_LATER and the Windows
    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.
    
    Approved-By: Tom Tromey <[email protected]>
    Change-Id: I27092ecfbf0904ebce02dff07d9104d22f3d8f0e
    commit-id:30c8d0ce

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

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 2a61953f439..614d85ac8f7 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -790,10 +790,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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.