aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2007-12-03 01:30:59 +0000
committerPedro Alves <palves@redhat.com>2007-12-03 01:30:59 +0000
commit5ca906e670f32a201fa670a56705a3284659a206 (patch)
treebd35547fd9da444b9a46cd065ddab60968be47c0 /gdb/gdbserver
parent9c6c8194694da164762ba5ad7553ca73c65ede1d (diff)
downloadgdb-5ca906e670f32a201fa670a56705a3284659a206.zip
gdb-5ca906e670f32a201fa670a56705a3284659a206.tar.gz
gdb-5ca906e670f32a201fa670a56705a3284659a206.tar.bz2
* win32-low.c (win32_attach): Call OpenProcess before
DebugActiveProcess, not after. Add last error output to error call.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog6
-rw-r--r--gdb/gdbserver/win32-low.c36
2 files changed, 25 insertions, 17 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 2e9530a..645db30 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,11 @@
2007-12-03 Pedro Alves <pedro_alves@portugalmail.pt>
+ * win32-low.c (win32_attach): Call OpenProcess before
+ DebugActiveProcess, not after. Add last error output to error
+ call.
+
+2007-12-03 Pedro Alves <pedro_alves@portugalmail.pt>
+
* win32-low.c (win32_get_thread_context)
(win32_set_thread_context): New functions.
(thread_rec): Use win32_get_thread_context.
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index e0fb777..3ff7c17 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -582,34 +582,36 @@ win32_create_inferior (char *program, char **program_args)
static int
win32_attach (unsigned long pid)
{
- winapi_DebugActiveProcessStop DebugActiveProcessStop = NULL;
+ HANDLE h;
winapi_DebugSetProcessKillOnExit DebugSetProcessKillOnExit = NULL;
+ DWORD err;
#ifdef _WIN32_WCE
HMODULE dll = GetModuleHandle (_T("COREDLL.DLL"));
#else
HMODULE dll = GetModuleHandle (_T("KERNEL32.DLL"));
#endif
- DebugActiveProcessStop = GETPROCADDRESS (dll, DebugActiveProcessStop);
DebugSetProcessKillOnExit = GETPROCADDRESS (dll, DebugSetProcessKillOnExit);
- if (DebugActiveProcess (pid))
+ h = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid);
+ if (h != NULL)
{
- if (DebugSetProcessKillOnExit != NULL)
- DebugSetProcessKillOnExit (FALSE);
-
- current_process_handle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid);
-
- if (current_process_handle != NULL)
- {
- current_process_id = pid;
- do_initial_child_stuff (pid);
- return 0;
- }
- if (DebugActiveProcessStop != NULL)
- DebugActiveProcessStop (current_process_id);
+ if (DebugActiveProcess (pid))
+ {
+ if (DebugSetProcessKillOnExit != NULL)
+ DebugSetProcessKillOnExit (FALSE);
+
+ current_process_handle = h;
+ current_process_id = pid;
+ do_initial_child_stuff (pid);
+ return 0;
+ }
+
+ CloseHandle (h);
}
- error ("Attach to process failed.");
+ err = GetLastError ();
+ error ("Attach to process failed (error %d): %s\n",
+ (int) err, strwinerror (err));
}
/* Handle OUTPUT_DEBUG_STRING_EVENT from child process. */