From d935c6d43e035c15ba64c1e8094943ac63d8e711 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 8 Apr 2014 11:37:26 +0100 Subject: [PATCH] Force the next resume to fail when SuspendThread fails --- gdb/gdbserver/win32-low.c | 19 +++++++++++++++---- gdb/windows-nat.c | 11 +++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index bc2506c..ea3d70b 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -177,8 +177,11 @@ thread_rec (ptid_t ptid, int get_context) if (SuspendThread (th->h) == (DWORD) -1) { DWORD err = GetLastError (); - OUTMSG (("warning: SuspendThread failed in thread_rec, " - "(error %d): %s\n", (int) err, strwinerror (err))); + OUTMSG (("warning: SuspendThread failed in thread_rec(%s), " + "(error %d): %s\n", + target_pid_to_str (ptid), + (int) err, strwinerror (err))); + th->suspended = -1; } else th->suspended = 1; @@ -420,8 +423,15 @@ continue_one_thread (struct inferior_list_entry *this_thread, void *id_ptr) int thread_id = * (int *) id_ptr; win32_thread_info *th = inferior_target_data (thread); - if ((thread_id == -1 || thread_id == th->tid) - && th->suspended) + if ((thread_id == -1 || thread_id == th->tid)) + { + if (th->suspended == -1) + { + th->suspended = 1; + error ("SuspendThread had failed for thread %d.\n", (int) th->tid); + } + + if (th->suspended) { if (th->context.ContextFlags) { @@ -437,6 +447,7 @@ continue_one_thread (struct inferior_list_entry *this_thread, void *id_ptr) } th->suspended = 0; } + } return 0; } diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index fe40c4d..6a0c861 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -312,9 +312,10 @@ thread_rec (DWORD id, int get_context) warning (_("SuspendThread (tid=0x%x) failed." " (winerr %u)"), (unsigned) id, (unsigned) err); - return NULL; + th->suspended = -2; } - th->suspended = 1; + else + th->suspended = 1; } else if (get_context < 0) th->suspended = -1; @@ -1200,6 +1201,12 @@ windows_continue (DWORD continue_status, int id) if ((id == -1 || id == (int) th->id) && th->suspended) { + if (th->suspended == -2) + { + th->suspended = 1; + error ("SuspendThread had failed.\n"); + } + if (debug_registers_changed) { th->context.ContextFlags |= CONTEXT_DEBUG_REGISTERS; -- 1.7.11.7