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

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