summaryrefslogtreecommitdiff
path: root/gdb/gdbserver/win32-low.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2007-05-10 21:05:15 +0000
committerPedro Alves <palves@redhat.com>2007-05-10 21:05:15 +0000
commit444d61395b63ff0474e8d150497ac709cf6702f6 (patch)
tree5cd2142151c86c22047df4e3095d3ba89bd96503 /gdb/gdbserver/win32-low.c
parent1d5315fee9335ecba7d345e41e451caa1d604114 (diff)
downloadbinutils-gdb-444d61395b63ff0474e8d150497ac709cf6702f6.tar.gz
* target.h (target_ops): Change return type of detach to int.
Add join. (join_inferior): New. * server.c (main): Don't skip detach support on mingw32. If the inferior doesn't support detaching return error. Call join_inferior instead of using waitpid. * linux-low.c (linux_join): New. (linux_target_op): Add linux_join. * spu-low.c (spu_join): New. (spu_target_ops): Add spu_join. * win32-low.c (win32_detach): Adapt to new interface. Reopen current_process_handle before detaching. Issue a child resume before detaching. (win32_join): New. (win32_target_op): Add win32_join.
Diffstat (limited to 'gdb/gdbserver/win32-low.c')
-rw-r--r--gdb/gdbserver/win32-low.c57
1 files changed, 50 insertions, 7 deletions
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 265c91691fb..e980db4c85e 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -683,9 +683,11 @@ win32_kill (void)
}
/* Detach from all inferiors. */
-static void
+static int
win32_detach (void)
{
+ HANDLE h;
+
winapi_DebugActiveProcessStop DebugActiveProcessStop = NULL;
winapi_DebugSetProcessKillOnExit DebugSetProcessKillOnExit = NULL;
#ifdef _WIN32_WCE
@@ -696,13 +698,53 @@ win32_detach (void)
DebugActiveProcessStop = GETPROCADDRESS (dll, DebugActiveProcessStop);
DebugSetProcessKillOnExit = GETPROCADDRESS (dll, DebugSetProcessKillOnExit);
- if (DebugSetProcessKillOnExit != NULL)
- DebugSetProcessKillOnExit (FALSE);
+ if (DebugSetProcessKillOnExit == NULL
+ || DebugActiveProcessStop == NULL)
+ return -1;
- if (DebugActiveProcessStop != NULL)
- DebugActiveProcessStop (current_process_id);
- else
- win32_kill ();
+ /* We need a new handle, since DebugActiveProcessStop
+ closes all the ones that came through the events. */
+ if ((h = OpenProcess (PROCESS_ALL_ACCESS,
+ FALSE,
+ current_process_id)) == NULL)
+ {
+ /* The process died. */
+ return -1;
+ }
+
+ {
+ struct thread_resume resume;
+ resume.thread = -1;
+ resume.step = 0;
+ resume.sig = 0;
+ resume.leave_stopped = 0;
+ win32_resume (&resume);
+ }
+
+ if (!DebugActiveProcessStop (current_process_id))
+ {
+ CloseHandle (h);
+ return -1;
+ }
+ DebugSetProcessKillOnExit (FALSE);
+
+ current_process_handle = h;
+ return 0;
+}
+
+/* Wait for inferiors to end. */
+static void
+win32_join (void)
+{
+ if (current_process_id == 0
+ || current_process_handle == NULL)
+ return;
+
+ WaitForSingleObject (current_process_handle, INFINITE);
+ CloseHandle (current_process_handle);
+
+ current_process_handle = NULL;
+ current_process_id = 0;
}
/* Return 1 iff the thread with thread ID TID is alive. */
@@ -1160,6 +1202,7 @@ static struct target_ops win32_target_ops = {
win32_attach,
win32_kill,
win32_detach,
+ win32_join,
win32_thread_alive,
win32_resume,
win32_wait,