aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2023-05-09 10:27:04 +0100
committerPedro Alves <pedro@palves.net>2024-05-08 00:39:56 +0100
commit552616cbb7d24d81690da17a30d067f59993f289 (patch)
treed42f45f3d0c29083d5595697c901f245eb4e87bc /gdbserver
parent87e727c0c64e2a45ef48452884b2c07f3a79c516 (diff)
downloadfsf-binutils-gdb-552616cbb7d24d81690da17a30d067f59993f289.zip
fsf-binutils-gdb-552616cbb7d24d81690da17a30d067f59993f289.tar.gz
fsf-binutils-gdb-552616cbb7d24d81690da17a30d067f59993f289.tar.bz2
Windows gdb+gdbserver: Move suspending thread to when returning event
The current code suspends a thread just before calling GetThreadContext. You can only call GetThreadContext if the thread is suspended. But, after WaitForDebugEvent, all threads are implicitly suspended. So I don't think we even needed to call SuspendThread explictly at all before our GetThreadContext calls. However, suspending threads when we're about to present a stop to gdb simplifies adding non-stop support later. This way, the windows SuspendThread state corresponds to whether a thread is suspended or resumed from the core's perspective. Curiously, I noticed that Wine's winedbg does something similar: https://github.com/wine-mirror/wine/blob/234943344f7495d1e072338f0e06fa2d5cbf0aa1/programs/winedbg/gdbproxy.c#L651 This makes it much easier to reason about a thread's suspend state, and simplifies adding non-stop mode later on. Change-Id: Ifd6889a8afc041fad33cd1c4500e38941da6781b
Diffstat (limited to 'gdbserver')
-rw-r--r--gdbserver/win32-low.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 0d67cd9..8dd8f21 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1226,6 +1226,11 @@ win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
OUTMSG2 (("Child Stopped with signal = %d \n",
ourstatus->sig ()));
maybe_adjust_pc ();
+
+ /* All-stop, suspend all threads until they are explicitly
+ resumed. */
+ for_each_thread (suspend_one_thread);
+
return debug_event_ptid (&windows_process.current_event);
}
default: