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