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