From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6BWVOpD29mKv9CUAWB0awg (envelope-from ) for ; Fri, 12 Aug 2022 20:55:44 -0400 Received: by simark.ca (Postfix, from userid 112) id ECBFE1E5EA; Fri, 12 Aug 2022 20:55:44 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=RzgtBrzr; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 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 986921E13B for ; Fri, 12 Aug 2022 20:55:44 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 49E6F385380B for ; Sat, 13 Aug 2022 00:55:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49E6F385380B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660352144; bh=WHh93hpLglXpVJUGZzpnw7Z8zd+JtAnHoXyCwBKfqzA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=RzgtBrzrFcbDzNiCT58/B6EIFxTVOsrNBoHkFLMCEUG5IE+DkVGnAZHoekfTo58DU xiJmOu1Cqw2BLO5+SJxVPmL+TFfpFXgaNdhyZZuKk8sfkmCz5m/uPPVTDGmxMYOboU GbuWz0faayD8FlTGFgaDqCMvsCfcO2gNt3bo70wM= Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by sourceware.org (Postfix) with ESMTPS id 7777C3857C56 for ; Sat, 13 Aug 2022 00:54:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7777C3857C56 Received: by mail-io1-xd36.google.com with SMTP id q124so2081366iod.3 for ; Fri, 12 Aug 2022 17:54:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=WHh93hpLglXpVJUGZzpnw7Z8zd+JtAnHoXyCwBKfqzA=; b=YU07f1eCgtYHuFQEfoKmGl8eSwrUwaQTXopqiWzwtMoDTvpkUAmG8P4UvqpHAGWnUj MEW8Mb2LUZWih7rU1YW9i6ausCG+I29zPuuSEwmmUTHOkeHvBH6s61JCTPJVAstaSws/ QzIobefgwjfDwWcP9r3CCfw20dF8w7Q4u/MDtVlSCHyuKzBohKmk7oP3H42KDMgrFlZR jLL6vNHHEl8hOLMW3bAzdZllP/x5/ST4yil2hXTKsxd4a/o+0OKrbrztrm1I4L/p6dKm UM8dROMJjVipNXwXawASc9Xe5GaQBp1pWdL8JqsJpnEpPe4wpPE7X6uPEgymCbU3KTNT MRtg== X-Gm-Message-State: ACgBeo1//gOGu1zGGqLEt275y+DhOFIqnEmiQbxFJ+6bqOofxu8xSBj1 1NRmfp/S/MUABDxxM/tBIBZ3lsyc5mp6Iw== X-Google-Smtp-Source: AA6agR7QfaSIrJdtokik5d/zNIrk7YQjMCQ04ej0BPnWgk5SnjbFFHiMSV3f8hzkuFdEerjqZmB8HQ== X-Received: by 2002:a5d:97c5:0:b0:684:bdde:9839 with SMTP id k5-20020a5d97c5000000b00684bdde9839mr2553770ios.21.1660352091725; Fri, 12 Aug 2022 17:54:51 -0700 (PDT) Received: from murgatroyd.Home (71-211-185-228.hlrn.qwest.net. [71.211.185.228]) by smtp.gmail.com with ESMTPSA id p17-20020a056638217100b00343455007f7sm494366jak.110.2022.08.12.17.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 17:54:51 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 11/14] TUI stdout buffering cleanup Date: Fri, 12 Aug 2022 18:54:39 -0600 Message-Id: <20220813005442.4163512-12-tromey@adacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220813005442.4163512-1-tromey@adacore.com> References: <20220813005442.4163512-1-tromey@adacore.com> 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: , From: Tom Tromey via Gdb-patches Reply-To: Tom Tromey Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" The TUI checks against gdb_stdout to decide when to buffer. It seems much cleaner to me to simply record this as an attribute of the stream itself. --- gdb/tui/tui-file.c | 23 +++-------------------- gdb/tui/tui-file.h | 10 +++++++++- gdb/tui/tui-io.c | 4 ++-- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/gdb/tui/tui-file.c b/gdb/tui/tui-file.c index 49dafce112c..3cf3dbc171a 100644 --- a/gdb/tui/tui-file.c +++ b/gdb/tui/tui-file.c @@ -22,24 +22,11 @@ #include "tui/tui-command.h" #include "tui.h" -tui_file::tui_file (FILE *stream) - : stdio_file (stream) -{} - -/* All TUI I/O sent to the *_filtered and *_unfiltered functions - eventually ends up here. The fputs_unfiltered_hook is primarily - used by GUIs to collect all output and send it to the GUI, instead - of the controlling terminal. Only output to gdb_stdout and - gdb_stderr are sent to the hook. Everything else is sent on to - fputs to allow file I/O to be handled appropriately. */ - void tui_file::puts (const char *linebuffer) { tui_puts (linebuffer); - /* gdb_stdout is buffered, and the caller must gdb_flush it at - appropriate times. Other streams are not so buffered. */ - if (this != gdb_stdout) + if (!m_buffered) tui_refresh_cmd_win (); } @@ -47,18 +34,14 @@ void tui_file::write (const char *buf, long length_buf) { tui_write (buf, length_buf); - /* gdb_stdout is buffered, and the caller must gdb_flush it at - appropriate times. Other streams are not so buffered. */ - if (this != gdb_stdout) + if (!m_buffered) tui_refresh_cmd_win (); } void tui_file::flush () { - /* gdb_stdout is buffered. Other files are always flushed on - every write. */ - if (this == gdb_stdout) + if (m_buffered) tui_refresh_cmd_win (); stdio_file::flush (); } diff --git a/gdb/tui/tui-file.h b/gdb/tui/tui-file.h index 1b28780c51b..ff60ded71c1 100644 --- a/gdb/tui/tui-file.h +++ b/gdb/tui/tui-file.h @@ -26,11 +26,19 @@ class tui_file : public stdio_file { public: - explicit tui_file (FILE *stream); + tui_file (FILE *stream, bool buffered) + : stdio_file (stream), + m_buffered (buffered) + {} void write (const char *buf, long length_buf) override; void puts (const char *) override; void flush () override; + +private: + + /* True if this stream is buffered. */ + bool m_buffered; }; #endif /* TUI_TUI_FILE_H */ diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 9f27f8bcc01..0efaf69335c 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -904,8 +904,8 @@ tui_initialize_io (void) #endif /* Create tui output streams. */ - tui_stdout = new pager_file (new tui_file (stdout)); - tui_stderr = new tui_file (stderr); + tui_stdout = new pager_file (new tui_file (stdout, true)); + tui_stderr = new tui_file (stderr, false); tui_stdlog = new timestamped_file (tui_stderr); tui_out = new tui_ui_out (tui_stdout); -- 2.34.1