* win32-low.c (win32_attach): Call OpenProcess before
authorPedro Alves <palves@redhat.com>
Mon, 3 Dec 2007 01:30:59 +0000 (01:30 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 3 Dec 2007 01:30:59 +0000 (01:30 +0000)
DebugActiveProcess, not after.  Add last error output to error
call.

gdb/gdbserver/ChangeLog
gdb/gdbserver/win32-low.c

index 2e9530a0e79b52a20f14d63daaea569b19a8dbc2..645db3076b43855ed2588f45a7ee14cb1fae83e6 100644 (file)
@@ -1,3 +1,9 @@
+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)
index e0fb7772bfaf0b4b906f9e73b5ea3d59c26bcd71..3ff7c17e2bfebfb113f806fce69d5c75af8fd8e1 100644 (file)
@@ -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.  */
This page took 0.028781 seconds and 4 git commands to generate.