From patchwork Sun May 19 22:06:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 32762 Received: (qmail 92897 invoked by alias); 19 May 2019 22:06:28 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 92718 invoked by uid 89); 19 May 2019 22:06:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Alves, alves, HX-Spam-Relays-External:2a00, H*RU:209.85.221.65 X-HELO: mail-wr1-f65.google.com Received: from mail-wr1-f65.google.com (HELO mail-wr1-f65.google.com) (209.85.221.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 19 May 2019 22:06:27 +0000 Received: by mail-wr1-f65.google.com with SMTP id w8so12423198wrl.6 for ; Sun, 19 May 2019 15:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=fCMsmP72x6Tn/rM3763O7nNuiDCqe/Le5xd7y31+h2s=; b=TQxYpK3ssVRhaKdX4ZDjHMefiARXW2mn3OxEmxP0Dp03MwKw4p6c/XWB7g/f9uIlN2 zQrlj+0JbaA6M4zLm7+LuAymOdTbQsxGPbDV5Xm902+h7qbnNi2ObLqy1WR+1hyc1s3v 6m2Gp2/v6X5SyQOOHIypvpmotM7zojf3MIvsOjuWaQnzk8lxaHRO2nepWibDIw4KLi5Q d4H3JfApqgD7JJYpEzQMmORU5xUMh287wjTriRNc+I7f08WkWUS8+PjDyzn3OJmIHGTV IF83ypDAvOgGdf+Y9L/OY3H+obsDmA2zFRzN/T1yaVUFsL0w74cKicT0w2wjXsVbgE0t awGw== Return-Path: Received: from localhost ([2a00:23c5:3e8d:6c00:9cd0:87cb:29bd:5b8f]) by smtp.gmail.com with ESMTPSA id s18sm13233645wmc.41.2019.05.19.15.06.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 May 2019 15:06:23 -0700 (PDT) Date: Sun, 19 May 2019 23:06:22 +0100 From: Andrew Burgess To: Andreas Schwab Cc: Alan Hayward , "gdb-patches@sourceware.org" , nd , Pedro Alves Subject: Re: [PATCH] Supress SIGTTOU when handling errors Message-ID: <20190519220622.GB2568@embecosm.com> References: <20190516155150.71826-1-alan.hayward@arm.com> <87y333ev6j.fsf@igel.home> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87y333ev6j.fsf@igel.home> X-Fortune: You have the body of a 19 year old. Please return it before it gets wrinkled. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes * Andreas Schwab [2019-05-18 15:41:56 +0200]: > On Mai 16 2019, Alan Hayward wrote: > > > [I've seen this on and off over many months on AArch64 and Arm, and am > > assuming it isn't the intended behaviour. Not sure if this should be at > > tcdrain or it should be done at a higher level - eg in the terminal > > handling code] > > > > 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 > > e671cd59d74cec9f53e110ce887128d1eeadb7f2 is the first bad commit > commit e671cd59d74cec9f53e110ce887128d1eeadb7f2 > Author: Pedro Alves > Date: Tue Jan 30 14:23:51 2018 +0000 > > Per-inferior target_terminal state, fix PR gdb/13211, more > > Andreas. Andreas, Thanks for tracking this down. It appears that the change in this patch that seems to be responsible would correspond to Alan's patch #2 option. I wonder if we should just apply something like the below to revert part of Pedro's patch? This will fix this problems we're seeing (as Alan already pointed out) as this effectively makes 'ours_for_output ()' the same as 'ours ()' again. My concern would be whether there's going to be some place in GDB that calls 'ours_for_output ()' and assumes Ctrl-C / Ctrl-Z will be automatically passed to the inferior. This change means they are now passed to GDB instead, will GDB always forward these to the inferior correctly? Thanks, Andrew diff --git a/gdb/inflow.c b/gdb/inflow.c index 339b55c0bc6..6ed22c14b6b 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -506,10 +506,11 @@ child_terminal_ours_1 (target_terminal_state desired_state) /* Set tty state to our_ttystate. */ serial_set_tty_state (stdin_serial, our_terminal_info.ttystate); - /* If we only want output, then leave the inferior's pgrp in the - foreground, so that Ctrl-C/Ctrl-Z reach the inferior - directly. */ - if (job_control && desired_state == target_terminal_state::is_ours) + /* If might be tempting to think that we can leave the inferior's + pgrp in the foreground if we only want ours_for_output, however, + calls to tcdrain within GDB will result in SIGTTOU unless GDB's + process group is in the foreground. */ + if (job_control) { #ifdef HAVE_TERMIOS_H result = tcsetpgrp (0, our_terminal_info.process_group); @@ -526,7 +527,7 @@ child_terminal_ours_1 (target_terminal_state desired_state) #endif /* termios */ } - if (!job_control && desired_state == target_terminal_state::is_ours) + if (!job_control) { signal (SIGINT, sigint_ours); #ifdef SIGQUIT