e3c8b47
We may abort the process of detaching threads with multiple SIGINTs - which are
e3c8b47
being sent during a testcase terminating its child GDB.
e3c8b47
e3c8b47
Some of the threads may not be properly PTRACE_DETACHed which hurts if they
e3c8b47
should have been detached with SIGSTOP (as they are accidentally left running
e3c8b47
on the debugger termination).
e3c8b47
Jan Kratochvil b0e03f5
Index: gdb-7.2.50.20110117/gdb/defs.h
407ebe9
===================================================================
Jan Kratochvil b0e03f5
--- gdb-7.2.50.20110117.orig/gdb/defs.h	2011-01-17 15:47:37.000000000 +0100
Jan Kratochvil b0e03f5
+++ gdb-7.2.50.20110117/gdb/defs.h	2011-01-17 15:53:05.000000000 +0100
Jan Kratochvil 6fa2f55
@@ -165,6 +165,7 @@ extern char *python_libdir;
e3c8b47
 extern char *debug_file_directory;
e3c8b47
 
e3c8b47
 extern int quit_flag;
e3c8b47
+extern int quit_flag_cleanup;
e3c8b47
 extern int immediate_quit;
e3c8b47
 extern int sevenbit_strings;
e3c8b47
 
Jan Kratochvil 6fa2f55
@@ -178,7 +179,7 @@ extern void quit (void);
Jan Kratochvil b0e03f5
    needed.  */
407ebe9
 
e3c8b47
 #define QUIT { \
e3c8b47
-  if (quit_flag) quit (); \
e3c8b47
+  if (quit_flag && !quit_flag_cleanup) quit (); \
e3c8b47
   if (deprecated_interactive_hook) deprecated_interactive_hook (); \
e3c8b47
 }
407ebe9
 
Jan Kratochvil b0e03f5
Index: gdb-7.2.50.20110117/gdb/event-top.c
407ebe9
===================================================================
Jan Kratochvil b0e03f5
--- gdb-7.2.50.20110117.orig/gdb/event-top.c	2011-01-17 15:52:39.000000000 +0100
Jan Kratochvil b0e03f5
+++ gdb-7.2.50.20110117/gdb/event-top.c	2011-01-17 15:52:49.000000000 +0100
Jan Kratochvil 6fa2f55
@@ -904,7 +904,7 @@ async_request_quit (gdb_client_data arg)
e3c8b47
      is no reason to call quit again here, unless immediate_quit is
Jan Kratochvil 6fa2f55
      set.  */
e3c8b47
 
e3c8b47
-  if (quit_flag || immediate_quit)
e3c8b47
+  if ((quit_flag || immediate_quit) && !quit_flag_cleanup)
e3c8b47
     quit ();
e3c8b47
 }
e3c8b47
 
Jan Kratochvil b0e03f5
Index: gdb-7.2.50.20110117/gdb/top.c
407ebe9
===================================================================
Jan Kratochvil b0e03f5
--- gdb-7.2.50.20110117.orig/gdb/top.c	2011-01-17 15:47:37.000000000 +0100
Jan Kratochvil b0e03f5
+++ gdb-7.2.50.20110117/gdb/top.c	2011-01-17 15:52:49.000000000 +0100
Jan Kratochvil b0e03f5
@@ -1257,7 +1257,9 @@ quit_force (char *args, int from_tty)
e3c8b47
   qt.args = args;
e3c8b47
   qt.from_tty = from_tty;
e3c8b47
 
e3c8b47
-  /* We want to handle any quit errors and exit regardless.  */
e3c8b47
+  /* We want to handle any quit errors and exit regardless but we should never
e3c8b47
+     get user-interrupted to properly detach the inferior.  */
e3c8b47
+  quit_flag_cleanup = 1;
e3c8b47
   catch_errors (quit_target, &qt,
e3c8b47
 	        "Quitting: ", RETURN_MASK_ALL);
e3c8b47
 
Jan Kratochvil b0e03f5
Index: gdb-7.2.50.20110117/gdb/utils.c
407ebe9
===================================================================
Jan Kratochvil b0e03f5
--- gdb-7.2.50.20110117.orig/gdb/utils.c	2011-01-17 15:47:37.000000000 +0100
Jan Kratochvil b0e03f5
+++ gdb-7.2.50.20110117/gdb/utils.c	2011-01-17 15:52:49.000000000 +0100
Jan Kratochvil 6fa2f55
@@ -121,6 +121,11 @@ int job_control;
e3c8b47
 
e3c8b47
 int quit_flag;
e3c8b47
 
e3c8b47
+/* Nonzero means we are already processing the quitting cleanups and we should
e3c8b47
+   no longer get aborted.  */
e3c8b47
+
e3c8b47
+int quit_flag_cleanup;
e3c8b47
+
e3c8b47
 /* Nonzero means quit immediately if Control-C is typed now, rather
e3c8b47
    than waiting until QUIT is executed.  Be careful in setting this;
e3c8b47
    code which executes with immediate_quit set has to be very careful