From ff8c7e40a6b1caceb4bd74655a78aae5c2bf6bf972e97f6609a16d0e4f864038 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Wed, 5 Jun 2019 12:50:01 +0000 Subject: [PATCH] Accepting request 707836 from home:Andreas_Schwab:Factory - gdb-suppress-sigttou-when-handling-errors.patch: Suppress SIGTTOU when handling errors - Enable ada tests on ppc64le and riscv64 - Enable multitarget build on riscv64 - Add ia64 and riscv64 to target_list - Enable -Werror on riscv64 and aarch64 - Don't remove %{buildroot} OBS-URL: https://build.opensuse.org/request/show/707836 OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=207 --- ...uppress-sigttou-when-handling-errors.patch | 173 ++++++++++++++++++ gdb.changes | 11 ++ gdb.spec | 12 +- 3 files changed, 190 insertions(+), 6 deletions(-) create mode 100644 gdb-suppress-sigttou-when-handling-errors.patch diff --git a/gdb-suppress-sigttou-when-handling-errors.patch b/gdb-suppress-sigttou-when-handling-errors.patch new file mode 100644 index 0000000..1e536d7 --- /dev/null +++ b/gdb-suppress-sigttou-when-handling-errors.patch @@ -0,0 +1,173 @@ +From 766f883622ef008230250aa5aecef9fb9b29f233 Mon Sep 17 00:00:00 2001 +From: Alan Hayward +Date: Tue, 28 May 2019 10:07:54 +0100 +Subject: [PATCH] Suppress SIGTTOU when handling errors + +Calls to error () can cause SIGTTOU to send gdb to the background. + +For example, on an Arm build: + (gdb) b main + Breakpoint 1 at 0x10774: file /build/gdb/testsuite/../../../src/binutils-gdb/gdb/testsuite/gdb.base/watchpoint.c, line 174. + (gdb) r + Starting program: /build/gdb/testsuite/outputs/gdb.base/watchpoint/watchpoint + + [1]+ Stopped ../gdb ./outputs/gdb.base/watchpoint/watchpoint + localhost$ fg + ../gdb ./outputs/gdb.base/watchpoint/watchpoint + Cannot parse expression `.L1199 4@r4'. + warning: Probes-based dynamic linker interface failed. + Reverting to original interface. + +The SIGTTOU is raised whilst inside a syscall during the call to tcdrain. +Fix is to use scoped_ignore_sigttou to ensure SIGTTOU is blocked. + +In addition fix include comments - job_control is not included via terminal.h + +gdb/ChangeLog: + + * event-top.c: Remove include comment. + * inflow.c (class scoped_ignore_sigttou): Move from here... + * inflow.h (class scoped_ignore_sigttou): ...to here. + * ser-unix.c (hardwire_drain_output): Block SIGTTOU during drain. + * top.c: Remove include comment. +--- + gdb/ChangeLog | 8 ++++++++ + gdb/event-top.c | 2 +- + gdb/inflow.c | 29 ----------------------------- + gdb/inflow.h | 31 +++++++++++++++++++++++++++++++ + gdb/ser-unix.c | 4 ++++ + gdb/top.c | 2 +- + 6 files changed, 45 insertions(+), 31 deletions(-) + +diff --git a/gdb/event-top.c b/gdb/event-top.c +index 3ccf136ff12..93b7d2d28bc 100644 +--- a/gdb/event-top.c ++++ b/gdb/event-top.c +@@ -24,7 +24,7 @@ + #include "inferior.h" + #include "infrun.h" + #include "target.h" +-#include "terminal.h" /* for job_control */ ++#include "terminal.h" + #include "event-loop.h" + #include "event-top.h" + #include "interps.h" +diff --git a/gdb/inflow.c b/gdb/inflow.c +index 339b55c0bc6..eba7a931f46 100644 +--- a/gdb/inflow.c ++++ b/gdb/inflow.c +@@ -106,35 +106,6 @@ static serial_ttystate initial_gdb_ttystate; + + static struct terminal_info *get_inflow_inferior_data (struct inferior *); + +-/* RAII class used to ignore SIGTTOU in a scope. */ +- +-class scoped_ignore_sigttou +-{ +-public: +- scoped_ignore_sigttou () +- { +-#ifdef SIGTTOU +- if (job_control) +- m_osigttou = signal (SIGTTOU, SIG_IGN); +-#endif +- } +- +- ~scoped_ignore_sigttou () +- { +-#ifdef SIGTTOU +- if (job_control) +- signal (SIGTTOU, m_osigttou); +-#endif +- } +- +- DISABLE_COPY_AND_ASSIGN (scoped_ignore_sigttou); +- +-private: +-#ifdef SIGTTOU +- sighandler_t m_osigttou = NULL; +-#endif +-}; +- + /* While the inferior is running, we want SIGINT and SIGQUIT to go to the + inferior only. If we have job control, that takes care of it. If not, + we save our handlers in these two variables and set SIGINT and SIGQUIT +diff --git a/gdb/inflow.h b/gdb/inflow.h +index c32aa144331..5dd5c37bd2b 100644 +--- a/gdb/inflow.h ++++ b/gdb/inflow.h +@@ -21,5 +21,36 @@ + #define INFLOW_H + + #include ++#include ++#include "common/job-control.h" ++ ++/* RAII class used to ignore SIGTTOU in a scope. */ ++ ++class scoped_ignore_sigttou ++{ ++public: ++ scoped_ignore_sigttou () ++ { ++#ifdef SIGTTOU ++ if (job_control) ++ m_osigttou = signal (SIGTTOU, SIG_IGN); ++#endif ++ } ++ ++ ~scoped_ignore_sigttou () ++ { ++#ifdef SIGTTOU ++ if (job_control) ++ signal (SIGTTOU, m_osigttou); ++#endif ++ } ++ ++ DISABLE_COPY_AND_ASSIGN (scoped_ignore_sigttou); ++ ++private: ++#ifdef SIGTTOU ++ sighandler_t m_osigttou = NULL; ++#endif ++}; + + #endif /* inflow.h */ +diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c +index 5a9965bf744..3492619f2d6 100644 +--- a/gdb/ser-unix.c ++++ b/gdb/ser-unix.c +@@ -32,6 +32,7 @@ + #include "gdbcmd.h" + #include "common/filestuff.h" + #include ++#include "inflow.h" + + struct hardwire_ttystate + { +@@ -164,6 +165,9 @@ hardwire_print_tty_state (struct serial *scb, + static int + hardwire_drain_output (struct serial *scb) + { ++ /* Ignore SIGTTOU which may occur during the drain. */ ++ scoped_ignore_sigttou ignore_sigttou; ++ + return tcdrain (scb->fd); + } + +diff --git a/gdb/top.c b/gdb/top.c +index bacd684dbaa..1e17ebee87c 100644 +--- a/gdb/top.c ++++ b/gdb/top.c +@@ -34,7 +34,7 @@ + #include "expression.h" + #include "value.h" + #include "language.h" +-#include "terminal.h" /* For job_control. */ ++#include "terminal.h" + #include "common/job-control.h" + #include "annotate.h" + #include "completer.h" +-- +2.21.0 + diff --git a/gdb.changes b/gdb.changes index aafd388..fcb31bd 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Wed Jun 5 09:53:09 UTC 2019 - Andreas Schwab + +- gdb-suppress-sigttou-when-handling-errors.patch: Suppress SIGTTOU when + handling errors +- Enable ada tests on ppc64le and riscv64 +- Enable multitarget build on riscv64 +- Add ia64 and riscv64 to target_list +- Enable -Werror on riscv64 and aarch64 +- Don't remove %{buildroot} + ------------------------------------------------------------------- Wed May 22 16:01:13 UTC 2019 - Tom de Vries diff --git a/gdb.spec b/gdb.spec index 5ae0cce..cc96990 100644 --- a/gdb.spec +++ b/gdb.spec @@ -225,6 +225,7 @@ Patch1007: gdb-fix-s390-build.diff Patch2000: gdb-handle-vfork-in-thread-with-follow-fork-mode-child.patch Patch2001: gdb-fix-riscv-tdep.patch Patch2002: gdb-x86_64-i386-syscall-restart-master.patch +Patch2003: gdb-suppress-sigttou-when-handling-errors.patch # Submitted for master @@ -308,7 +309,7 @@ BuildRequires: %{gcc}-java %endif BuildRequires: %{gcc}-objc # Copied from gcc-4.1.2-32. -%ifarch %{ix86} x86_64 ia64 ppc ppc64 s390 alpha +%ifarch %{ix86} x86_64 ia64 ppc ppc64 ppc64le riscv64 s390 alpha BuildRequires: %{gcc}-ada %endif %ifarch aarch64 @@ -542,6 +543,7 @@ find -name "*.info*"|xargs rm -f %patch2000 -p1 %patch2001 -p1 %patch2002 -p1 +%patch2003 -p1 %patch2500 -p1 %patch2501 -p1 @@ -567,7 +569,6 @@ rm -f gdb/doc/*.info rm -f gdb/doc/*.info-* %build -rm -rf %{buildroot} # Identify the build directory with the version of gdb as well as the # architecture, to allow for mutliple versions to be installed and @@ -643,13 +644,12 @@ fi if test -f /usr/%{_lib}/librpm.so.3; then export LIBRPM=librpm.so.3 fi -%ifarch %ix86 ia64 ppc ppc64 ppc64le s390 s390x x86_64 aarch64 +%ifarch %ix86 ia64 ppc ppc64 ppc64le s390 s390x x86_64 aarch64 riscv64 %define build_multitarget 1 %else %define build_multitarget 0 %endif -# For now disable ia64 until ia64-tdep.c is fixed -%define target_list i686 powerpc powerpc64 powerpc64le s390 s390x x86_64 arm aarch64 m68k +%define target_list i686 powerpc powerpc64 powerpc64le s390 s390x x86_64 arm aarch64 m68k ia64 riscv64 %define DIST %(echo '%distribution' | sed 's, /.*,,') %if %build_multitarget EXTRA_TARGETS="%(printf ,%%s-suse-linux %target_list)" @@ -669,7 +669,7 @@ EXTRA_TARGETS= --with-system-gdbinit=%{_sysconfdir}/gdbinit \ --with-gdb-datadir=%{_datadir}/gdb \ --enable-gdb-build-warnings=,-Wno-unused \ -%ifnarch %{ix86} alpha ia64 ppc s390 s390x x86_64 ppc64 ppc64le sparc sparcv9 sparc64 +%ifnarch %{ix86} alpha ia64 ppc s390 s390x x86_64 ppc64 ppc64le sparc sparcv9 sparc64 riscv64 aarch64 --disable-werror \ %else %if %{suse_version} <= 1110