From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GOC8BKXJx2AYUQAAWB0awg (envelope-from ) for ; Mon, 14 Jun 2021 17:27:01 -0400 Received: by simark.ca (Postfix, from userid 112) id 116A51F163; Mon, 14 Jun 2021 17:27:01 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=MAILING_LIST_MULTI, RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 509731E54D for ; Mon, 14 Jun 2021 17:27:00 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1CCE6397EC0E for ; Mon, 14 Jun 2021 21:27:00 +0000 (GMT) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by sourceware.org (Postfix) with ESMTPS id E5CAB3973027 for ; Mon, 14 Jun 2021 21:24:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E5CAB3973027 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-wr1-f44.google.com with SMTP id f2so15976322wri.11 for ; Mon, 14 Jun 2021 14:24:33 -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=sICKUDMwuaeYJ9k81aUjqOzD7/Vy7A1MoEiw1Ee4Me4=; b=PF6rzc4A80jsLQ/z/ne+lgQYUzdf1JFpqgI+aAQQpmcPcWa/u3bidF549q4jQjkKDv e5KqMqWdkrgVZuxhb+LctJ33oLqfvXFKlPyo2idqDyuAGqDSubtdq2h4FDwu3jtamVo2 4hCMsL5TJA73783hn83lAbGkOtVdXNubN+iOT9KrpmWW+fe6T+C1AET19T5AHIhKSCAm KMUp8SGMmhckQoP0vcdDiZcpPZeOUTcvoOtNkneRIhoDrD0jUDthELRdzJVIvjHZsXfc xiTSj/2bdsPQ8ZGEsh4B0drBritQDNqZFVQZoNQuyz8qWtQ73gkMFOu1Am//gMAtniNR FbFA== X-Gm-Message-State: AOAM530BauImQpHCNr60RS7QazD77TgWU3eev6YQ0ry9hXOLI8/Rc0bE ni04fyBgNmbfbLBGg6oqNsdMnzw6mzlJRA== X-Google-Smtp-Source: ABdhPJzYvDBmgqDSwhl9ZCpGItnUQ4E0D+2MMcpoWIJLR/3jvOitOlKCw9XhAcQHFCk+kmn6lVHC0g== X-Received: by 2002:a5d:630f:: with SMTP id i15mr20730408wru.155.1623705872539; Mon, 14 Jun 2021 14:24:32 -0700 (PDT) Received: from localhost ([2001:8a0:f932:6a00:6b6e:c7b6:c5a7:aac3]) by smtp.gmail.com with ESMTPSA id o9sm16449711wri.68.2021.06.14.14.24.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Jun 2021 14:24:31 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 10/16] target_terminal::ours_for_output before printing signal received Date: Mon, 14 Jun 2021 22:24:04 +0100 Message-Id: <20210614212410.1612666-11-pedro@palves.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210614212410.1612666-1-pedro@palves.net> References: <20210614212410.1612666-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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 4bd21fde590..1eb7526d246 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8537,7 +8537,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