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]

make attaching to stopped processes work under windows


hi,

the rationale is in the patch itself; i can factor it out to the commit
message if preferred.

	* windows-nat.c (get_windows_debug_event): If we find the thread
	  from the CREATE_PROCESS_DEBUG_EVENT suspended, resume it.
Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.179
diff -U2 -r1.179 windows-nat.c
--- windows-nat.c	6 Feb 2009 22:21:26 -0000	1.179
+++ windows-nat.c	13 Feb 2009 15:39:41 -0000
@@ -1331,4 +1331,21 @@
 	break;
 
+      /* Resume main thread if we are attaching to a suspended
+	 process.
+	 Note that we are not trying to handle multi-threaded
+	 situations, as these are likely to be too complex anyway.
+	 This is primarily meant to cover the case where someone
+	 creates a process in suspended state and hands it over
+	 to gdb (this is an abstraction - you cannot actually do
+	 that due to Windows bugs. You need to start debugging the
+	 process yourself, and once it has started up, you suspend
+	 it and detach from it). */
+      if (SuspendThread (current_event.u.CreateProcessInfo.hThread) == 2)
+	{
+	  printf_unfiltered ("gdb: thawing initially frozen thread.\n");
+	  ResumeThread (current_event.u.CreateProcessInfo.hThread);
+	}
+      CHECK (ResumeThread (current_event.u.CreateProcessInfo.hThread));
+
       current_process_handle = current_event.u.CreateProcessInfo.hProcess;
       if (main_thread_id)

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