Simplify .spec: Remove conditional revert of: gdb-6.8-attach-signalled-detach-stopped.patch

- Simplify .spec: Remove conditional revert of: gdb-6.8-quit-never-aborts.patch
This commit is contained in:
Jan Kratochvil 2016-01-09 15:11:44 +01:00
parent ccd56ac8c9
commit 5d173531c0
3 changed files with 89 additions and 67 deletions

View File

@ -1,29 +1,50 @@
Index: gdb-7.9.50.20150531/gdb/linux-nat.c
===================================================================
--- gdb-7.9.50.20150531.orig/gdb/linux-nat.c 2015-05-31 18:23:56.147494790 +0200
+++ gdb-7.9.50.20150531/gdb/linux-nat.c 2015-05-31 18:24:01.935530759 +0200
@@ -168,6 +168,9 @@ blocked. */
diff -dup -rup gdb-7.10.50.20160106-orig/gdb/infrun.c gdb-7.10.50.20160106/gdb/infrun.c
--- gdb-7.10.50.20160106-orig/gdb/infrun.c 2016-01-09 15:05:06.127481758 +0100
+++ gdb-7.10.50.20160106/gdb/infrun.c 2016-01-09 15:05:24.054593048 +0100
@@ -626,6 +626,13 @@ holding the child stopped. Try \"set de
target_pid_to_str (process_ptid));
}
+#ifdef NEED_DETACH_SIGSTOP
+ /* We should check PID_WAS_STOPPED and detach it stopped accordingly.
+ In this point of code it cannot be 1 as we would not get FORK
+ executed without CONTINUE first which resets PID_WAS_STOPPED.
+ We would have to first TARGET_STOP and WAITPID it as with running
+ inferior PTRACE_DETACH, SIGSTOP will ignore the signal. */
+#endif
target_detach (NULL, 0);
}
diff -dup -rup gdb-7.10.50.20160106-orig/gdb/linux-nat.c gdb-7.10.50.20160106/gdb/linux-nat.c
--- gdb-7.10.50.20160106-orig/gdb/linux-nat.c 2016-01-09 15:05:06.225482366 +0100
+++ gdb-7.10.50.20160106/gdb/linux-nat.c 2016-01-09 15:05:24.050593023 +0100
@@ -194,6 +194,11 @@ enum tribool have_ptrace_getregset = TRI
static struct target_ops *linux_ops;
static struct target_ops linux_ops_saved;
+#ifdef NEED_DETACH_SIGSTOP
+/* PID of the inferior stopped by SIGSTOP before attaching (or zero). */
+static pid_t pid_was_stopped;
+
+#endif
/* The method to call, if any, when a new thread is attached. */
static void (*linux_nat_new_thread) (struct lwp_info *);
@@ -981,6 +984,7 @@ linux_nat_post_attach_wait (ptid_t ptid,
@@ -961,6 +966,9 @@ linux_nat_post_attach_wait (ptid_t ptid,
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"LNPAW: Attaching to a stopped process\n");
+#ifdef NEED_DETACH_SIGSTOP
+ pid_was_stopped = ptid_get_pid (ptid);
+#endif
/* The process is definitely stopped. It is in a job control
stop, unless the kernel predates the TASK_STOPPED /
@@ -1529,6 +1529,23 @@ get_pending_status (struct lwp_info *lp,
@@ -1303,6 +1311,25 @@ get_pending_status (struct lwp_info *lp,
gdb_signal_to_string (signo));
}
+#ifdef NEED_DETACH_SIGSTOP
+ /* Workaround RHEL-5 kernel which has unreliable PTRACE_DETACH, SIGSTOP (that
+ many TIDs are left unstopped). See RH Bug 496732. */
+ if (ptid_get_pid (lp->ptid) == pid_was_stopped)
@ -41,22 +62,26 @@ Index: gdb-7.9.50.20150531/gdb/linux-nat.c
+ }
+ }
+
+#endif
return 0;
}
@@ -1581,6 +1588,8 @@ linux_nat_detach (struct target_ops *ops
@@ -1416,6 +1443,10 @@ linux_nat_detach (struct target_ops *ops
}
else
linux_ops->to_detach (ops, args, from_tty);
+#ifdef NEED_DETACH_SIGSTOP
+
+ pid_was_stopped = 0;
+#endif
}
/* Resume execution of the inferior process. If STEP is nonzero,
@@ -1839,6 +1848,14 @@ linux_nat_resume (struct target_ops *ops
@@ -1674,6 +1705,16 @@ linux_nat_resume (struct target_ops *ops
return;
}
+#ifdef NEED_DETACH_SIGSTOP
+ /* At this point, we are going to resume the inferior and if we
+ have attached to a stopped process, we no longer should leave
+ it as stopped if the user detaches. PTID variable has PID set to LWP
@ -65,23 +90,25 @@ Index: gdb-7.9.50.20150531/gdb/linux-nat.c
+ if (!step && lp && pid_was_stopped == ptid_get_pid (lp->ptid))
+ pid_was_stopped = 0;
+
+#endif
if (resume_many)
iterate_over_lwps (ptid, linux_nat_resume_callback, lp);
@@ -3935,6 +3952,8 @@ linux_nat_mourn_inferior (struct target_
@@ -3618,6 +3659,10 @@ linux_nat_mourn_inferior (struct target_
/* Let the arch-specific native code know this process is gone. */
linux_nat_forget_process (pid);
+#ifdef NEED_DETACH_SIGSTOP
+
+ pid_was_stopped = 0;
+#endif
}
/* Convert a native/host siginfo object, into/from the siginfo in the
Index: gdb-7.9.50.20150531/gdb/testsuite/gdb.threads/attach-stopped.exp
===================================================================
--- gdb-7.9.50.20150531.orig/gdb/testsuite/gdb.threads/attach-stopped.exp 2015-05-31 18:23:56.148494796 +0200
+++ gdb-7.9.50.20150531/gdb/testsuite/gdb.threads/attach-stopped.exp 2015-05-31 18:24:01.935530759 +0200
@@ -61,7 +61,65 @@ proc corefunc { threadtype } {
diff -dup -rup gdb-7.10.50.20160106-orig/gdb/testsuite/gdb.threads/attach-stopped.exp gdb-7.10.50.20160106/gdb/testsuite/gdb.threads/attach-stopped.exp
--- gdb-7.10.50.20160106-orig/gdb/testsuite/gdb.threads/attach-stopped.exp 2016-01-06 02:48:38.000000000 +0100
+++ gdb-7.10.50.20160106/gdb/testsuite/gdb.threads/attach-stopped.exp 2016-01-09 15:05:48.917747101 +0100
@@ -56,7 +56,65 @@ proc corefunc { threadtype } {
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
@ -148,19 +175,3 @@ Index: gdb-7.9.50.20150531/gdb/testsuite/gdb.threads/attach-stopped.exp
set test "$threadtype: attach2 to stopped, after setting file"
gdb_test_multiple "attach $testpid" "$test" {
Index: gdb-7.9.50.20150531/gdb/infrun.c
===================================================================
--- gdb-7.9.50.20150531.orig/gdb/infrun.c 2015-05-31 18:23:56.150494809 +0200
+++ gdb-7.9.50.20150531/gdb/infrun.c 2015-05-31 18:24:01.938530778 +0200
@@ -591,6 +591,11 @@ holding the child stopped. Try \"set de
target_pid_to_str (process_ptid));
}
+ /* We should check PID_WAS_STOPPED and detach it stopped accordingly.
+ In this point of code it cannot be 1 as we would not get FORK
+ executed without CONTINUE first which resets PID_WAS_STOPPED.
+ We would have to first TARGET_STOP and WAITPID it as with running
+ inferior PTRACE_DETACH, SIGSTOP will ignore the signal. */
target_detach (NULL, 0);
}

View File

@ -5,60 +5,65 @@ 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.9.50.20150520/gdb/defs.h
===================================================================
--- gdb-7.9.50.20150520.orig/gdb/defs.h 2015-05-31 18:06:24.579002757 +0200
+++ gdb-7.9.50.20150520/gdb/defs.h 2015-05-31 18:06:29.253031613 +0200
@@ -145,6 +145,7 @@ extern void set_quit_flag (void);
diff -dup -rup gdb-7.10.50.20160106-orig/gdb/defs.h gdb-7.10.50.20160106/gdb/defs.h
--- gdb-7.10.50.20160106-orig/gdb/defs.h 2016-01-09 15:06:57.658172875 +0100
+++ gdb-7.10.50.20160106/gdb/defs.h 2016-01-09 15:07:12.431264378 +0100
@@ -145,6 +145,9 @@ extern void set_quit_flag (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 int immediate_quit;
extern void quit (void);
Index: gdb-7.9.50.20150520/gdb/top.c
===================================================================
--- gdb-7.9.50.20150520.orig/gdb/top.c 2015-05-31 18:06:24.580002763 +0200
+++ gdb-7.9.50.20150520/gdb/top.c 2015-05-31 18:06:29.254031619 +0200
@@ -1463,7 +1463,9 @@ quit_force (char *args, int from_tty)
diff -dup -rup gdb-7.10.50.20160106-orig/gdb/extension.c gdb-7.10.50.20160106/gdb/extension.c
--- gdb-7.10.50.20160106-orig/gdb/extension.c 2016-01-06 02:48:37.000000000 +0100
+++ gdb-7.10.50.20160106/gdb/extension.c 2016-01-09 15:07:12.434264396 +0100
@@ -833,6 +833,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 -dup -rup gdb-7.10.50.20160106-orig/gdb/top.c gdb-7.10.50.20160106/gdb/top.c
--- gdb-7.10.50.20160106-orig/gdb/top.c 2016-01-06 02:48:38.000000000 +0100
+++ gdb-7.10.50.20160106/gdb/top.c 2016-01-09 15:07:12.432264384 +0100
@@ -1557,7 +1557,13 @@ quit_force (char *args, int from_tty)
qt.args = args;
qt.from_tty = from_tty;
- /* We want to handle any quit errors and exit regardless. */
+#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
Index: gdb-7.9.50.20150520/gdb/utils.c
===================================================================
--- gdb-7.9.50.20150520.orig/gdb/utils.c 2015-05-31 18:06:24.582002776 +0200
+++ gdb-7.9.50.20150520/gdb/utils.c 2015-05-31 18:06:29.255031625 +0200
@@ -122,6 +122,11 @@ int job_control;
diff -dup -rup gdb-7.10.50.20160106-orig/gdb/utils.c gdb-7.10.50.20160106/gdb/utils.c
--- gdb-7.10.50.20160106-orig/gdb/utils.c 2016-01-09 15:06:57.654172850 +0100
+++ gdb-7.10.50.20160106/gdb/utils.c 2016-01-09 15:07:12.433264390 +0100
@@ -122,6 +122,13 @@ int job_control;
int immediate_quit;
+#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.) */
Index: gdb-7.9.50.20150520/gdb/extension.c
===================================================================
--- gdb-7.9.50.20150520.orig/gdb/extension.c 2015-05-31 18:06:24.582002776 +0200
+++ gdb-7.9.50.20150520/gdb/extension.c 2015-05-31 18:06:29.256031632 +0200
@@ -833,6 +833,9 @@ check_quit_flag (void)
int i, result = 0;
const struct extension_language_defn *extlang;
+ if (quit_flag_cleanup)
+ return 0;
+
ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
{
if (extlang->ops->check_quit_flag != NULL)

View File

@ -27,7 +27,7 @@ Version: 7.10.50.%{snapsrc}
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 40%{?dist}
Release: 41%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain and GFDL
Group: Development/Debuggers
@ -878,13 +878,9 @@ find -name "*.info*"|xargs rm -f
%patch848 -p1
%patch833 -p1
%patch642 -p1
%patch337 -p1
%patch331 -p1
%if 0%{!?rhel:1} || 0%{?rhel} > 6
%patch331 -p1 -R
%patch337 -p1 -R
%endif
%patch1044 -p1
%if 0%{!?rhel:1} || 0%{?rhel} > 7
%patch1044 -p1 -R
@ -954,6 +950,12 @@ CFLAGS="$CFLAGS -DGDB_INDEX_VERIFY_VENDOR"
CFLAGS="$CFLAGS -DNEED_RL_STATE_FEDORA_GDB"
%endif
# Patch337: gdb-6.8-attach-signalled-detach-stopped.patch
# Patch331: gdb-6.8-quit-never-aborts.patch
%if 0%{?rhel:1} && 0%{?rhel} <= 6
CFLAGS="$CFLAGS -DNEED_DETACH_SIGSTOP"
%endif
# --htmldir and --pdfdir are not used as they are used from %{gdb_build}.
../configure \
--prefix=%{_prefix} \
@ -1396,6 +1398,10 @@ then
fi
%changelog
* Sat Jan 9 2016 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.10.50.20160106-41.fc24
- Simplify .spec: Remove conditional revert of: gdb-6.8-attach-signalled-detach-stopped.patch
- Simplify .spec: Remove conditional revert of: gdb-6.8-quit-never-aborts.patch
* Sat Jan 9 2016 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.10.50.20160106-40.fc24
- Merge gdb-rhel5-compat.patch into: gdb-6.8-attach-signalled-detach-stopped.patch