689258
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
689258
From: Fedora GDB patches <invalid@email.com>
689258
Date: Fri, 27 Oct 2017 21:07:50 +0200
689258
Subject: gdb-6.8-quit-never-aborts.patch
689258
689258
;; Make the GDB quit processing non-abortable to cleanup everything properly.
689258
;;=fedora: It was useful only after gdb-6.8-attach-signalled-detach-stopped.patch .
689258
689258
We may abort the process of detaching threads with multiple SIGINTs - which are
689258
being sent during a testcase terminating its child GDB.
689258
689258
Some of the threads may not be properly PTRACE_DETACHed which hurts if they
689258
should have been detached with SIGSTOP (as they are accidentally left running
689258
on the debugger termination).
689258
689258
diff --git a/gdb/defs.h b/gdb/defs.h
689258
--- a/gdb/defs.h
689258
+++ b/gdb/defs.h
689258
@@ -168,6 +168,10 @@ extern void default_quit_handler (void);
689258
 /* Flag that function quit should call quit_force.  */
689258
 extern volatile int sync_quit_force_run;
689258
 
689258
+#ifdef NEED_DETACH_SIGSTOP
689258
+extern int quit_flag_cleanup;
689258
+#endif
689258
+
689258
 extern void quit (void);
689258
 
689258
 /* Helper for the QUIT macro.  */
689258
diff --git a/gdb/extension.c b/gdb/extension.c
689258
--- a/gdb/extension.c
689258
+++ b/gdb/extension.c
689258
@@ -820,6 +820,11 @@ check_quit_flag (void)
689258
   int i, result = 0;
689258
   const struct extension_language_defn *extlang;
689258
 
689258
+#ifdef NEED_DETACH_SIGSTOP
689258
+  if (quit_flag_cleanup)
689258
+    return 0;
689258
+#endif
689258
+
689258
   ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
689258
     {
689258
       if (extlang->ops->check_quit_flag != NULL)
689258
diff --git a/gdb/top.c b/gdb/top.c
689258
--- a/gdb/top.c
689258
+++ b/gdb/top.c
689258
@@ -1606,7 +1606,13 @@ quit_force (int *exit_arg, int from_tty)
689258
 
689258
   qt.from_tty = from_tty;
689258
 
689258
+#ifndef NEED_DETACH_SIGSTOP
689258
   /* We want to handle any quit errors and exit regardless.  */
689258
+#else
689258
+  /* We want to handle any quit errors and exit regardless but we should never
689258
+     get user-interrupted to properly detach the inferior.  */
689258
+  quit_flag_cleanup = 1;
689258
+#endif
689258
 
689258
   /* Get out of tfind mode, and kill or detach all inferiors.  */
689258
   TRY
689258
diff --git a/gdb/utils.c b/gdb/utils.c
689258
--- a/gdb/utils.c
689258
+++ b/gdb/utils.c
689258
@@ -108,6 +108,13 @@ static std::chrono::steady_clock::duration prompt_for_continue_wait_time;
689258
 
689258
 static int debug_timestamp = 0;
689258
 
689258
+#ifdef NEED_DETACH_SIGSTOP
689258
+/* Nonzero means we are already processing the quitting cleanups and we should
689258
+   no longer get aborted.  */
689258
+
689258
+int quit_flag_cleanup;
689258
+#endif
689258
+
689258
 /* Nonzero means that strings with character values >0x7F should be printed
689258
    as octal escapes.  Zero means just print the value (e.g. it's an
689258
    international character, and the terminal or window can cope.)  */