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

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