]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
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>
Mon, 19 May 2025 13:12:37 +0000 (14:12 +0100)
commit7b579b4a3342c5c515c06092fc377c5d9260a808
tree52cda591a594cd47e4cc63c32ad7f9b935614b90
parentb006068cc5631a0f881d7d764d6aa2f5c0255793
Windows gdb+gdbserver: Eliminate DONT_SUSPEND

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