Blame SOURCES/gdb-6.8-quit-never-aborts.patch

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