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

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