]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Windows gdb+gdbserver: Eliminate DONT_SUSPEND
authorPedro Alves <pedro@palves.net>
Tue, 9 May 2023 09:13:08 +0000 (10:13 +0100)
committerPedro Alves <pedro@palves.net>
Fri, 24 Apr 2026 20:28:44 +0000 (21:28 +0100)
There's a single call to thread_rec(DONT_SUSPEND), in
windows_process_info::handle_exception.

In GDB, the windows-nat.c thread_rec implementation avoids actually
calling SuspendThread on the event thread by doing:

               th->suspended = -1;

I am not exactly sure why, but it kind of looks like it is done as an
optimization, avoiding a SuspendThread call?  It is probably done for
the same reason as the code touched in the previous patch avoided
suspending the event thread.

This however gets in the way of non-stop mode, which will really want
to SuspendThread the event thread for DBG_REPLY_LATER.

In gdbserver's thread_rec implementation DONT_SUSPEND is ignored, and
thread_rec actually always suspends, which really suggests that
SuspendThread on the event thread is really not a problem.  I really
can't imagine why it would be.

DONT_SUSPEND invalidates the thread's context, but there is no need to
invalidate the context when we get an event for a thread, because we
invalidate it when we previously resumed the thread.

So, we can just remove the thread_rec call from
windows_process_info::handle_exception.  That's what this patch does.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I0f328542bda6d8268814ca1ee4ae7a478098ecf2

gdb/nat/windows-nat.c
gdb/nat/windows-nat.h
gdb/windows-nat.c

index cefd335f6526175fa2705e48ac5f6d99d129d93b..16d4acae569a34e94d9af7f8f39919a1279ea9b1 100644 (file)
@@ -356,10 +356,6 @@ windows_process_info::handle_exception (struct target_waitstatus *ourstatus,
 
   memcpy (&siginfo_er, rec, sizeof siginfo_er);
 
-  /* Record the context of the current thread.  */
-  thread_rec (ptid_t (current_event.dwProcessId, current_event.dwThreadId, 0),
-             DONT_SUSPEND);
-
   last_sig = GDB_SIGNAL_0;
 
   switch (code)
index 1a564fbf11b530e09178839645daff4ed0510aca..2cc665fb53c57232e6313165e37a08d451f08faf 100644 (file)
@@ -107,8 +107,6 @@ struct windows_thread_info
 /* Possible values to pass to 'thread_rec'.  */
 enum thread_disposition_type
 {
-  /* Invalidate the context, but do not suspend the thread.  */
-  DONT_SUSPEND,
 };
 
 /* A single pending stop.  See "pending_stops" for more
index ca9a197d64ef1fc4b27f8195d246bbec1c437ba1..aae4de42a73267cd46097761519003f0f3b4a739 100644 (file)
@@ -279,17 +279,6 @@ windows_per_inferior::thread_rec (ptid_t ptid,
                                  thread_disposition_type disposition)
 {
   windows_thread_info *th = find_thread (ptid);
-
-  if (th != nullptr && !th->suspended)
-    {
-      switch (disposition)
-       {
-       case DONT_SUSPEND:
-         th->suspended = -1;
-         invalidate_thread_context (th);
-         break;
-       }
-    }
   return th;
 }