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

75 lines
2.6 KiB
Diff
Raw Normal View History

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).
Index: gdb-7.6.50.20130731-cvs/gdb/defs.h
===================================================================
--- gdb-7.6.50.20130731-cvs.orig/gdb/defs.h 2013-08-02 16:58:31.453016573 +0200
+++ gdb-7.6.50.20130731-cvs/gdb/defs.h 2013-08-02 16:58:41.221030412 +0200
@@ -177,6 +177,7 @@ extern int check_quit_flag (void);
/* Set the quit flag. */
extern void set_quit_flag (void);
+extern int quit_flag_cleanup;
extern int immediate_quit;
extern void quit (void);
Index: gdb-7.6.50.20130731-cvs/gdb/top.c
===================================================================
--- gdb-7.6.50.20130731-cvs.orig/gdb/top.c 2013-08-02 16:58:41.222030414 +0200
+++ gdb-7.6.50.20130731-cvs/gdb/top.c 2013-08-02 16:59:06.321066228 +0200
@@ -1415,7 +1415,9 @@ quit_force (char *args, int from_tty)
if (ex.reason < 0) \
exception_print (gdb_stderr, ex)
- /* We want to handle any quit errors and exit regardless. */
+ /* 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;
/* Get out of tfind mode, and kill or detach all inferiors. */
DO_TRY
Index: gdb-7.6.50.20130731-cvs/gdb/utils.c
===================================================================
--- gdb-7.6.50.20130731-cvs.orig/gdb/utils.c 2013-08-02 16:58:31.455016575 +0200
+++ gdb-7.6.50.20130731-cvs/gdb/utils.c 2013-08-02 16:58:41.223030415 +0200
@@ -136,6 +136,11 @@ int quit_flag;
int immediate_quit;
+/* Nonzero means we are already processing the quitting cleanups and we should
+ no longer get aborted. */
+
+int quit_flag_cleanup;
+
#ifndef HAVE_PYTHON
/* Clear the quit flag. */
@@ -159,6 +164,9 @@ set_quit_flag (void)
int
check_quit_flag (void)
{
+ if (quit_flag_cleanup)
+ return 0;
+
/* This is written in a particular way to avoid races. */
if (quit_flag)
{
Index: gdb-7.6.50.20130731-cvs/gdb/python/python.c
===================================================================
--- gdb-7.6.50.20130731-cvs.orig/gdb/python/python.c 2013-08-02 16:58:31.456016577 +0200
+++ gdb-7.6.50.20130731-cvs/gdb/python/python.c 2013-08-02 16:58:41.224030416 +0200
@@ -191,6 +191,9 @@ set_quit_flag (void)
int
check_quit_flag (void)
{
+ if (quit_flag_cleanup)
+ return 0;
+
return PyOS_InterruptOccurred ();
}