keiths / rpms / gdb

Forked from rpms/gdb 5 months ago
Clone
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
Jan Kratochvil 32f92b2
Index: gdb-7.9.50.20150520/gdb/defs.h
Jan Kratochvil 5677fb2
===================================================================
Jan Kratochvil 32f92b2
--- gdb-7.9.50.20150520.orig/gdb/defs.h	2015-05-31 18:06:24.579002757 +0200
Jan Kratochvil 32f92b2
+++ gdb-7.9.50.20150520/gdb/defs.h	2015-05-31 18:06:29.253031613 +0200
Jan Kratochvil 32f92b2
@@ -145,6 +145,7 @@ extern void set_quit_flag (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 5677fb2
+extern int quit_flag_cleanup;
Jan Kratochvil 5677fb2
 extern int immediate_quit;
Jan Kratochvil 5677fb2
 
Jan Kratochvil 5677fb2
 extern void quit (void);
Jan Kratochvil 32f92b2
Index: gdb-7.9.50.20150520/gdb/top.c
Jan Kratochvil 5677fb2
===================================================================
Jan Kratochvil 32f92b2
--- gdb-7.9.50.20150520.orig/gdb/top.c	2015-05-31 18:06:24.580002763 +0200
Jan Kratochvil 32f92b2
+++ gdb-7.9.50.20150520/gdb/top.c	2015-05-31 18:06:29.254031619 +0200
Jan Kratochvil 32f92b2
@@ -1463,7 +1463,9 @@ quit_force (char *args, int from_tty)
Jan Kratochvil 32f92b2
   qt.args = args;
Jan Kratochvil 32f92b2
   qt.from_tty = from_tty;
Jan Kratochvil 5677fb2
 
Jan Kratochvil 5677fb2
-  /* We want to handle any quit errors and exit regardless.  */
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 5677fb2
 
Jan Kratochvil 872aab0
   /* Get out of tfind mode, and kill or detach all inferiors.  */
Jan Kratochvil 32f92b2
   TRY
Jan Kratochvil 32f92b2
Index: gdb-7.9.50.20150520/gdb/utils.c
Jan Kratochvil 5677fb2
===================================================================
Jan Kratochvil 32f92b2
--- gdb-7.9.50.20150520.orig/gdb/utils.c	2015-05-31 18:06:24.582002776 +0200
Jan Kratochvil 32f92b2
+++ gdb-7.9.50.20150520/gdb/utils.c	2015-05-31 18:06:29.255031625 +0200
Jan Kratochvil 32f92b2
@@ -122,6 +122,11 @@ int job_control;
Jan Kratochvil 5677fb2
 
Jan Kratochvil 5677fb2
 int immediate_quit;
Jan Kratochvil 5677fb2
 
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 5677fb2
+
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.)  */
Jan Kratochvil 32f92b2
Index: gdb-7.9.50.20150520/gdb/extension.c
Jan Kratochvil eb6cb2d
===================================================================
Jan Kratochvil 32f92b2
--- gdb-7.9.50.20150520.orig/gdb/extension.c	2015-05-31 18:06:24.582002776 +0200
Jan Kratochvil 32f92b2
+++ gdb-7.9.50.20150520/gdb/extension.c	2015-05-31 18:06:29.256031632 +0200
Jan Kratochvil 32f92b2
@@ -833,6 +833,9 @@ check_quit_flag (void)
Jan Kratochvil eb6cb2d
   int i, result = 0;
Jan Kratochvil eb6cb2d
   const struct extension_language_defn *extlang;
Jan Kratochvil 5677fb2
 
Jan Kratochvil 5677fb2
+  if (quit_flag_cleanup)
Jan Kratochvil 5677fb2
+    return 0;
Jan Kratochvil 5677fb2
+
Jan Kratochvil eb6cb2d
   ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
Jan Kratochvil 5677fb2
     {
Jan Kratochvil eb6cb2d
       if (extlang->ops->check_quit_flag != NULL)