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

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