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

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