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

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