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

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