aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2007-12-03 01:10:30 +0000
committerPedro Alves <palves@redhat.com>2007-12-03 01:10:30 +0000
commitc436e841ffe6de640cb19bd7915d117309ed079e (patch)
treec315752cf01aa2a447c9b0969f0706c996a67626 /gdb/gdbserver
parent0421e13edb5307146de9a31648f40218162145a6 (diff)
downloadgdb-c436e841ffe6de640cb19bd7915d117309ed079e.zip
gdb-c436e841ffe6de640cb19bd7915d117309ed079e.tar.gz
gdb-c436e841ffe6de640cb19bd7915d117309ed079e.tar.bz2
* win32-low.h (win32_thread_info): Add descriptions to the
structure members. Replace `suspend_count' counter by a `suspended' flag. * win32-low.c (thread_rec): Update condition of when to get the context from the inferior. Rely on ContextFlags being set if it has already been retrieved. Only suspend the inferior thread if we haven't already. Warn if that fails. (continue_one_thread): s/suspend_count/suspended/. Only call ResumeThread once. Warn if that fails.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog13
-rw-r--r--gdb/gdbserver/win32-low.c28
-rw-r--r--gdb/gdbserver/win32-low.h9
3 files changed, 41 insertions, 9 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 09a46d4..86f4d72 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,16 @@
+2007-12-03 Leo Zayas
+ Pedro Alves <pedro_alves@portugalmail.pt>
+
+ * win32-low.h (win32_thread_info): Add descriptions to the
+ structure members. Replace `suspend_count' counter by a
+ `suspended' flag.
+ * win32-low.c (thread_rec): Update condition of when to get the
+ context from the inferior. Rely on ContextFlags being set if it
+ has already been retrieved. Only suspend the inferior thread if
+ we haven't already. Warn if that fails.
+ (continue_one_thread): s/suspend_count/suspended/. Only call
+ ResumeThread once. Warn if that fails.
+
2007-12-02 Pedro Alves <pedro_alves@portugalmail.pt>
* win32-low.c (win32_wait): Don't read from the inferior when it
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 188d555..cc95981 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -105,10 +105,19 @@ thread_rec (DWORD id, int get_context)
return NULL;
th = inferior_target_data (thread);
- if (!th->suspend_count && get_context)
+ if (get_context && th->context.ContextFlags == 0)
{
- if (id != current_event.dwThreadId)
- th->suspend_count = SuspendThread (th->h) + 1;
+ if (!th->suspended)
+ {
+ if (SuspendThread (th->h) == (DWORD) -1)
+ {
+ DWORD err = GetLastError ();
+ OUTMSG (("warning: SuspendThread failed in thread_rec, "
+ "(error %d): %s\n", (int) err, strwinerror (err)));
+ }
+ else
+ th->suspended = 1;
+ }
(*the_low_target.get_thread_context) (th, &current_event);
}
@@ -259,10 +268,9 @@ continue_one_thread (struct inferior_list_entry *this_thread, void *id_ptr)
struct thread_info *thread = (struct thread_info *) this_thread;
int thread_id = * (int *) id_ptr;
win32_thread_info *th = inferior_target_data (thread);
- int i;
if ((thread_id == -1 || thread_id == th->tid)
- && th->suspend_count)
+ && th->suspended)
{
if (th->context.ContextFlags)
{
@@ -270,9 +278,13 @@ continue_one_thread (struct inferior_list_entry *this_thread, void *id_ptr)
th->context.ContextFlags = 0;
}
- for (i = 0; i < th->suspend_count; i++)
- (void) ResumeThread (th->h);
- th->suspend_count = 0;
+ if (ResumeThread (th->h) == (DWORD) -1)
+ {
+ DWORD err = GetLastError ();
+ OUTMSG (("warning: ResumeThread failed in continue_one_thread, "
+ "(error %d): %s\n", (int) err, strwinerror (err)));
+ }
+ th->suspended = 0;
}
return 0;
diff --git a/gdb/gdbserver/win32-low.h b/gdb/gdbserver/win32-low.h
index cef57c5..c2bf06a 100644
--- a/gdb/gdbserver/win32-low.h
+++ b/gdb/gdbserver/win32-low.h
@@ -22,9 +22,16 @@
each thread. */
typedef struct win32_thread_info
{
+ /* The Win32 thread identifier. */
DWORD tid;
+
+ /* The handle to the thread. */
HANDLE h;
- int suspend_count;
+
+ /* Non zero if SuspendThread was called on this thread. */
+ int suspended;
+
+ /* The context of the thread. */
CONTEXT context;
} win32_thread_info;