gdbserver/win32, fix ctrl-c handling.

Pedro Alves pedro@codesourcery.com
Thu Nov 26 22:30:00 GMT 2009


On Thursday 26 November 2009 22:28:04, Pedro Alves wrote:
> Sometimes, a win32 gdbserver would ignore a ctrl-c, because
> this
> 
>  remote-utils.c:input_interrupt:
> 
>       if (cc != 1 || c != '\003' || current_inferior == NULL)
> 	{
> 	  fprintf (stderr, "input_interrupt, count = %d c = %d ('%c')\n",
> 		   cc, c, c);
> 	  return;
> 	}
> 
> was being reached with current_inferior == NULL.  current_inferior
> ends up set to NULL after a EXIT_THREAD_DEBUG_EVENT event.  Between
> a thread exit event and any other event that forced a curren_inferiot
> switch, ctrl-c's where ignored.  I've applied this patch to handle it
> like linux-low.c does.  When a thread exits, switch to any thread
> other thread (always the first in the thread list, just because it's
> simple and handy).
> 

Here's the patch.

2009-11-26  Pedro Alves  <pedro@codesourcery.com>

	Issue #7133.

	gdb/gdbserver/
	* win32-low.c (get_child_debug_event): On EXIT_THREAD_DEBUG_EVENT
	events, don't leave current_inferior pointing at null.

-- 
Pedro Alves

---
 gdb/gdbserver/win32-low.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Index: src/gdb/gdbserver/win32-low.c
===================================================================
--- src.orig/gdb/gdbserver/win32-low.c	2009-11-26 19:20:21.000000000 +0000
+++ src/gdb/gdbserver/win32-low.c	2009-11-26 19:20:27.000000000 +0000
@@ -1438,10 +1438,6 @@ get_child_debug_event (struct target_wai
 
  gotevent:
 
-  ptid = debug_event_ptid (&current_event);
-  current_inferior =
-    (struct thread_info *) find_inferior_id (&all_threads, ptid);
-
   switch (current_event.dwDebugEventCode)
     {
     case CREATE_THREAD_DEBUG_EVENT:
@@ -1463,7 +1459,9 @@ get_child_debug_event (struct target_wai
 		(unsigned) current_event.dwThreadId));
       child_delete_thread (current_event.dwProcessId,
 			   current_event.dwThreadId);
-      break;
+
+      current_inferior = (struct thread_info *) all_threads.head;
+      return 1;
 
     case CREATE_PROCESS_DEBUG_EVENT:
       OUTMSG2 (("gdbserver: kernel event CREATE_PROCESS_DEBUG_EVENT "
@@ -1558,6 +1556,7 @@ get_child_debug_event (struct target_wai
       break;
     }
 
+  ptid = debug_event_ptid (&current_event);
   current_inferior =
     (struct thread_info *) find_inferior_id (&all_threads, ptid);
   return 1;



More information about the Gdb-patches mailing list