This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] gdb/win32-nat.c: do not call CloseHandle on process and thread handles


  Following the discussion 
http://sourceware.org/ml/gdb/2007-10/msg00131.html
and
http://sourceware.org/ml/gdb-patches/2007-10/msg00502.html

  I resubmit a part of my original patch that only contains the
removal of all calls to the win32 API CloseHandle
with thread or process handles.

  This patch allows to debug gdb with itself on mingw32
port. 

  The patch was tested for cygwin target, by running
the testsuite with and without this patch.

  The testsuite shows no changes.

Pierre Muller

PS: I am unsure about the proper way to decribe the change 
in the ChangeLog...


ChangeLog entry:

2007-11-22  Pierre Muller  <muller@ics.u-strasbg.fr>

	*win32-nat.c: Remove calls to CloseHandle for thread and process
handles.
	(win32_init_thread_list): Ditto.
	(win32_delete_thread): Ditto.
	(get_win32_debug_event): Ditto.
	(win32_create_inferior): Ditto.
	(win32_kill_inferior): Ditto.

Index: gdb/win32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/win32-nat.c,v
retrieving revision 1.139
diff -u -p -r1.139 win32-nat.c
--- gdb/win32-nat.c     16 Nov 2007 04:53:46 -0000      1.139
+++ gdb/win32-nat.c     22 Nov 2007 10:07:30 -0000
@@ -316,7 +316,6 @@ win32_init_thread_list (void)
     {
       thread_info *here = th->next;
       th->next = here->next;
-      (void) CloseHandle (here->h);
       xfree (here);
     }
   thread_head.next = NULL;
@@ -341,7 +340,6 @@ win32_delete_thread (DWORD id)
     {
       thread_info *here = th->next;
       th->next = here->next;
-      CloseHandle (here->h);
       xfree (here);
     }
 }
@@ -1323,7 +1321,6 @@ get_win32_debug_event (int pid, struct t
       CloseHandle (current_event.u.CreateProcessInfo.hFile);
       if (++saw_create != 1)
        {
-         CloseHandle (current_event.u.CreateProcessInfo.hProcess);
          break;
        }

@@ -1346,7 +1343,6 @@ get_win32_debug_event (int pid, struct t
        break;
       ourstatus->kind = TARGET_WAITKIND_EXITED;
       ourstatus->value.integer = current_event.u.ExitProcess.dwExitCode;
-      CloseHandle (current_process_handle);
       retval = main_thread_id;
       break;

@@ -1876,9 +1872,6 @@ win32_create_inferior (char *exec_file,
     error (_("Error creating process %s, (error %d)."),
           exec_file, (unsigned) GetLastError ());

-  CloseHandle (pi.hThread);
-  CloseHandle (pi.hProcess);
-
   if (useshell && shell[0] != '\0')
     saw_create = -1;
   else
@@ -1950,11 +1943,6 @@ win32_kill_inferior (void)
        break;
     }

-  CHECK (CloseHandle (current_process_handle));
-
-  /* this may fail in an attached process so don't check. */
-  if (current_thread && current_thread->h)
-    (void) CloseHandle (current_thread->h);
   target_mourn_inferior ();    /* or just win32_mourn_inferior? */
 }





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]