From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by sourceware.org (Postfix) with ESMTPS id 9142D3990004 for ; Thu, 3 Jun 2021 19:03:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9142D3990004 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f46.google.com with SMTP id g204so4017734wmf.5 for ; Thu, 03 Jun 2021 12:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PnwJjcy6AMpc3NK8yRdbVpqCvR4k/QWzLKz0iqkIxZI=; b=pKGlkNhs3kD6v9ewh4U44VkJoUEqW7+yxSa1Hg7drR2dlZLsxWqE7Gp79MSgJ+xVK5 4UAbVJkubZA5DjRuBHW10p/f+3naYdkiL3ro27+vw0dctsJ+AA+5SZFb9YVWVggqC7mk fo3TNOdfYF1/95rOHNcDqs5NOhlvmYkZnVajFbfuwsjlgxmCVHjkTTpfVw3rKoS618OH z1IQSWRgkWyySilMTyw5A+0rx9b8I/RdRGJPdiCr7eKLRl+SWFCQDg+D2eIPmJiMtt0X jICHaj2gMX+FbvSTvE6IIcgHRerc58Hpj7iX31hEme/joDiMvX4SfWAI+D8GTns3ays/ 46Aw== X-Gm-Message-State: AOAM532BVN4HWRYJRbKmEuuZdb8xRnVmZ0Lr3l/Spmp7rPQ4mgUnYhrS IvOw4s2xrL7tsdXiNF7iYQ/9dWUk7d4OHA== X-Google-Smtp-Source: ABdhPJzrqd2+6dSEeNIb4u1sYwN1EoI5cumOf//r/Gks7P02HBclr2e43Xh5e/v2D3jo2QPLEcu/YA== X-Received: by 2002:a7b:c4d0:: with SMTP id g16mr485286wmk.181.1622746990071; Thu, 03 Jun 2021 12:03:10 -0700 (PDT) Received: from localhost ([2001:8a0:f932:6a00:6b6e:c7b6:c5a7:aac3]) by smtp.gmail.com with ESMTPSA id v16sm3600530wrr.6.2021.06.03.12.03.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Jun 2021 12:03:09 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 11/17] target_terminal::ours_for_output before printing signal received Date: Thu, 3 Jun 2021 20:02:37 +0100 Message-Id: <20210603190243.2609886-12-pedro@palves.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210603190243.2609886-1-pedro@palves.net> References: <20210603190243.2609886-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jun 2021 19:03:12 -0000 A following patch will make GDB put spawned inferiors in their own terminal/session (on GNU/Linux). In that case, GDB is in control of when is the inferior's output flushed to the screen. A sync point is when target_terminal state goes from inferior -> ours/ours_for_output. The gdb.multi/multi-term-settings.exp testcase exposed a bug where an inferior output flush is missing, resulting in this regression: Good: (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: info inferiors continue Continuing. pid=1275538, count=0 pid=1276069, count=0 Thread 1.1 "multi-term-sett" received signal SIGTTOU, Stopped (tty output). [Switching to process 1275538] 0x00007ffff7ecda14 in __tcsetattr (fd=0, optional_actions=0, termios_p=0x7fffffffd450) at ../sysdeps/unix/sysv/linux/tcsetattr.c:83 83 ../sysdeps/unix/sysv/linux/tcsetattr.c: No such file or directory. (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: continue (expected SIGTTOU) Quit (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: stop with control-c (Quit) Bad: (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: info inferiors continue Continuing. pid=1287638, count=0 Thread 1.1 "multi-term-sett" received signal SIGTTOU, Stopped (tty output). pid=1287663, count=0 <<<<<< HERE [Switching to process 1287638] 0x00007ffff7ecda14 in __tcsetattr (fd=0, optional_actions=0, termios_p=0x7fffffffd450) at ../sysdeps/unix/sysv/linux/tcsetattr.c:83 83 ../sysdeps/unix/sysv/linux/tcsetattr.c: No such file or directory. (gdb) FAIL: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: continue Quit (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=run-share: inf2_how=run-session: stop with control-c (Quit) Notice the "<<<<<< HERE" line in the "Bad" output above -- that is inferior output being printed on the screen _after_ GDB says the thread stopped... That's obviously bogus, the output was printed by the inferior before it was stopped. The fix is to claim back the terminal for output before printing the "signal received SIGTTOU" message. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * infrun.c (normal_stop): Call target_terminal::ours_for_output before calling signal_received observers. Change-Id: Iea106c33b4c585562fc3579ca85d43481fa214f0 --- gdb/infrun.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 488bcc1e10b..222063850b3 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8532,7 +8532,10 @@ normal_stop (void) update_thread_list (); if (last.kind == TARGET_WAITKIND_STOPPED && stopped_by_random_signal) - gdb::observers::signal_received.notify (inferior_thread ()->suspend.stop_signal); + { + target_terminal::ours_for_output (); + gdb::observers::signal_received.notify (inferior_thread ()->suspend.stop_signal); + } /* As with the notification of thread events, we want to delay notifying the user that we've switched thread context until -- 2.26.2