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
Jan Kratochvil 5677fb2
We may abort the process of detaching threads with multiple SIGINTs - which are
Jan Kratochvil 5677fb2
being sent during a testcase terminating its child GDB.
Jan Kratochvil 5677fb2
Jan Kratochvil 5677fb2
Some of the threads may not be properly PTRACE_DETACHed which hurts if they
Jan Kratochvil 5677fb2
should have been detached with SIGSTOP (as they are accidentally left running
Jan Kratochvil 5677fb2
on the debugger termination).
Jan Kratochvil 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);
Jan Kratochvil eb6cb2d
 /* Flag that function quit should call quit_force.  */
Jan Kratochvil eb6cb2d
 extern volatile int sync_quit_force_run;
Jan Kratochvil 5677fb2
 
Jan Kratochvil 5d17353
+#ifdef NEED_DETACH_SIGSTOP
Jan Kratochvil 5677fb2
+extern int quit_flag_cleanup;
Jan Kratochvil 5d17353
+#endif
Jan Kratochvil 7306e88
+
Jan Kratochvil 5677fb2
 extern void quit (void);
Jan Kratochvil 7306e88
 
Jan Kratochvil 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
f637971
@@ -830,6 +830,11 @@ check_quit_flag (void)
Jan Kratochvil 5d17353
   int i, result = 0;
Jan Kratochvil 5d17353
   const struct extension_language_defn *extlang;
Jan Kratochvil 5d17353
 
Jan Kratochvil 5d17353
+#ifdef NEED_DETACH_SIGSTOP
Jan Kratochvil 5d17353
+  if (quit_flag_cleanup)
Jan Kratochvil 5d17353
+    return 0;
Jan Kratochvil 5d17353
+#endif
Jan Kratochvil 7306e88
+
Jan Kratochvil 5d17353
   ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
Jan Kratochvil 5d17353
     {
Jan Kratochvil 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
4632e1f
@@ -1580,7 +1580,13 @@ quit_force (int *exit_arg, int from_tty)
Jan Kratochvil af2c2a5
   qt.args = NULL;
Jan Kratochvil 32f92b2
   qt.from_tty = from_tty;
Jan Kratochvil 5677fb2
 
Jan Kratochvil 5d17353
+#ifndef NEED_DETACH_SIGSTOP
Jan Kratochvil 5d17353
   /* We want to handle any quit errors and exit regardless.  */
Jan Kratochvil 5d17353
+#else
Jan Kratochvil 5677fb2
+  /* We want to handle any quit errors and exit regardless but we should never
Jan Kratochvil 5677fb2
+     get user-interrupted to properly detach the inferior.  */
Jan Kratochvil 5677fb2
+  quit_flag_cleanup = 1;
Jan Kratochvil 5d17353
+#endif
Jan Kratochvil 5677fb2
 
Jan Kratochvil 872aab0
   /* Get out of tfind mode, and kill or detach all inferiors.  */
Jan Kratochvil 32f92b2
   TRY
f637971
diff --git a/gdb/utils.c b/gdb/utils.c
f637971
--- a/gdb/utils.c
f637971
+++ b/gdb/utils.c
ad19172
@@ -108,6 +108,13 @@ static std::chrono::steady_clock::duration prompt_for_continue_wait_time;
Jan Kratochvil 5677fb2
 
f637971
 static int debug_timestamp = 0;
Jan Kratochvil 5677fb2
 
Jan Kratochvil 5d17353
+#ifdef NEED_DETACH_SIGSTOP
Jan Kratochvil 5677fb2
+/* Nonzero means we are already processing the quitting cleanups and we should
Jan Kratochvil 5677fb2
+   no longer get aborted.  */
Jan Kratochvil 5677fb2
+
Jan Kratochvil 5677fb2
+int quit_flag_cleanup;
Jan Kratochvil 5d17353
+#endif
Jan Kratochvil 7306e88
+
Jan Kratochvil eb6cb2d
 /* Nonzero means that strings with character values >0x7F should be printed
Jan Kratochvil eb6cb2d
    as octal escapes.  Zero means just print the value (e.g. it's an
Jan Kratochvil eb6cb2d
    international character, and the terminal or window can cope.)  */