From patchwork Thu Nov 17 18:29:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 60791 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2786D3852212 for ; Thu, 17 Nov 2022 18:29:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2786D3852212 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668709781; bh=NgeAu17YjkrM4j+JNfjfZ52s14Ul/btYxBn6etTjOXM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Zjp0GnJQWW7jz6rAEdCB2HW55HLTzANTPKFRkUKPlQFONH57/UfBd0cS0PXd/+Zyu VfjE/YIn7ZYf4Mnq2NJHpq9PyahBJ3CkMSDRD45eCUIzRIPDj+JVebdtcr0xxYBHh9 oRZtblAOKUsKQKa3gKciWsSJNjJuB3TpWlW+WIyc= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 7BB00385457E for ; Thu, 17 Nov 2022 18:29:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7BB00385457E Received: by mail-io1-xd36.google.com with SMTP id n188so2026064iof.8 for ; Thu, 17 Nov 2022 10:29:15 -0800 (PST) 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 :subject:date:message-id:reply-to; bh=NgeAu17YjkrM4j+JNfjfZ52s14Ul/btYxBn6etTjOXM=; b=PgBzNlU9koocVW7PrJDo0bskmqW91uqZYPEogdwWrpzf3+fvZihxlB/1CFOApZQ/A/ zP14uTcF5lYK38qeruEyqb665lV+ga6T2nCY4tSMxI2B+Qpl0YqPdSJbfi/Gjt3ZOMc8 qqG/b9tkMREpjBWvKOnkIUDsfU4biGJDgjcJEa3DnV1S9vbZ32ChpWdBJnZGPbrcmi8x kQBRL0Yjf9kjG3/NzP73dunqvbWuyWA2TmsixOv0cUsNJqG1FGWUUfb8xyD8+rUWOVKD qictnraiOyeyMm61tDjk8/ichI01L1Ot4Te1RciwUZlac6loPuYadk4VGzzjTKP8cOrS zs9g== X-Gm-Message-State: ANoB5plT7jcVdlycaOgqc0I6HHUrL11E2Q1Zyog0mK+GLBouvCbAmM14 fFDT0RSdBlfigjp/wSaMkFwP2lUp9f0J0A== X-Google-Smtp-Source: AA0mqf4RuBfgk4rT9PAQZsJ8TsqIQDsPNVJ+5j953C31LkKwRyWq6Hhb43P8CsMiEPAGIIibmHleZw== X-Received: by 2002:a5d:8741:0:b0:6cd:6e75:69fd with SMTP id k1-20020a5d8741000000b006cd6e7569fdmr1994324iol.49.1668709754747; Thu, 17 Nov 2022 10:29:14 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id g68-20020a025b47000000b00365c1bd9ac7sm469409jab.113.2022.11.17.10.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:29:14 -0800 (PST) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/3] Remove 'saved_output' global Date: Thu, 17 Nov 2022 11:29:02 -0700 Message-Id: <20221117182904.1291713-2-tromey@adacore.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221117182904.1291713-1-tromey@adacore.com> References: <20221117182904.1291713-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" CLI redirect uses a global variable, 'saved_output'. However, globals are generally bad, and there is no need for this one -- it can be a member of cli_interp_base. This patch makes this change. --- gdb/cli/cli-interp.c | 47 ++++++++++++++++---------------------------- gdb/cli/cli-interp.h | 16 +++++++++++++++ 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index ca3a1abcaae..8c2fb207486 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -370,20 +370,6 @@ cli_interp::interp_ui_out () return m_cli_uiout.get (); } -/* These hold the pushed copies of the gdb output files. - If NULL then nothing has yet been pushed. */ -struct saved_output_files -{ - ui_file *out; - ui_file *err; - ui_file *log; - ui_file *targ; - ui_file *targerr; - ui_file_up file_to_delete; - ui_file_up log_to_delete; -}; -static std::unique_ptr saved_output; - /* See cli-interp.h. */ void @@ -392,12 +378,13 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect, { if (logfile != nullptr) { - saved_output.reset (new saved_output_files); - saved_output->out = gdb_stdout; - saved_output->err = gdb_stderr; - saved_output->log = gdb_stdlog; - saved_output->targ = gdb_stdtarg; - saved_output->targerr = gdb_stdtargerr; + gdb_assert (m_saved_output == nullptr); + m_saved_output.reset (new saved_output_files); + m_saved_output->out = gdb_stdout; + m_saved_output->err = gdb_stderr; + m_saved_output->log = gdb_stdlog; + m_saved_output->targ = gdb_stdtarg; + m_saved_output->targerr = gdb_stdtargerr; /* If something is not being redirected, then a tee containing both the logfile and stdout. */ @@ -406,29 +393,29 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect, if (!logging_redirect || !debug_redirect) { tee = new tee_file (gdb_stdout, std::move (logfile)); - saved_output->file_to_delete.reset (tee); + m_saved_output->file_to_delete.reset (tee); } else - saved_output->file_to_delete = std::move (logfile); + m_saved_output->file_to_delete = std::move (logfile); - saved_output->log_to_delete.reset + m_saved_output->log_to_delete.reset (new timestamped_file (debug_redirect ? logfile_p : tee)); gdb_stdout = logging_redirect ? logfile_p : tee; - gdb_stdlog = saved_output->log_to_delete.get (); + gdb_stdlog = m_saved_output->log_to_delete.get (); gdb_stderr = logging_redirect ? logfile_p : tee; gdb_stdtarg = logging_redirect ? logfile_p : tee; gdb_stdtargerr = logging_redirect ? logfile_p : tee; } else { - gdb_stdout = saved_output->out; - gdb_stderr = saved_output->err; - gdb_stdlog = saved_output->log; - gdb_stdtarg = saved_output->targ; - gdb_stdtargerr = saved_output->targerr; + gdb_stdout = m_saved_output->out; + gdb_stderr = m_saved_output->err; + gdb_stdlog = m_saved_output->log; + gdb_stdtarg = m_saved_output->targ; + gdb_stdtargerr = m_saved_output->targerr; - saved_output.reset (nullptr); + m_saved_output.reset (nullptr); } } diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h index 1620305c26b..3c233c0a229 100644 --- a/gdb/cli/cli-interp.h +++ b/gdb/cli/cli-interp.h @@ -32,6 +32,22 @@ class cli_interp_base : public interp bool debug_redirect) override; void pre_command_loop () override; bool supports_command_editing () override; + +private: + struct saved_output_files + { + ui_file *out; + ui_file *err; + ui_file *log; + ui_file *targ; + ui_file *targerr; + ui_file_up file_to_delete; + ui_file_up log_to_delete; + }; + + /* These hold the pushed copies of the gdb output files. If NULL + then nothing has yet been pushed. */ + std::unique_ptr m_saved_output; }; /* Returns true if the current stop should be printed to From patchwork Thu Nov 17 18:29:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 60793 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3D4E13853D62 for ; Thu, 17 Nov 2022 18:30:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D4E13853D62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668709809; bh=JsZaGGQc8EW50OUuhGR43n/3To/wiVJpbPC9lq9CF1g=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=eZTK+FYQLWmdBCOjJsdjdDd1tigjdF2i1g1cvsUFoLu5BU+qOVjg05eYjqvfrpKir 0oqMtfc21NU/KlI5yWE4DDHffeyb1JE1txsuyVd5elHp4oeYOwYXFv6U5QJMZebwUp TZKde3thxMt6DQX5wNRVC1ylf6VZpNGk8If4VKKc= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by sourceware.org (Postfix) with ESMTPS id 3B7683853D41 for ; Thu, 17 Nov 2022 18:29:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3B7683853D41 Received: by mail-io1-xd31.google.com with SMTP id d123so2027809iof.7 for ; Thu, 17 Nov 2022 10:29:16 -0800 (PST) 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 :subject:date:message-id:reply-to; bh=JsZaGGQc8EW50OUuhGR43n/3To/wiVJpbPC9lq9CF1g=; b=jZs8r0s4Z7lFHrBXmdxM61mtRRHszakLCOwZpWdmkH0sbQfIhjkLZZoGyOleQUDiWI kncc8rETR2sf1hH3lAXL/YEf7Ic8r8cCGfuBL7UYGG613OtOiBAsoMwzxMlz6+TFBsjk DWROwb2oRwpBaYUvGjknJASdNPKQEcybme2pC/rptw6i5XWw/TMNy/BZjI7RBjD9kxT/ 3SeUaqFzOaF/ghcr/k2qBzpdPMwSrcxdChZg8PwVNoeGwky86V62EYrLnGADf1pT+QoE rRt94rEMnOwlZDCaQSrepoPGMXX80dPW1p2BwMGbyWMpYU8XedPUxW0DtC7cZnXwAySD 2IMw== X-Gm-Message-State: ANoB5pkDmOuN20tRZq2NZGDGjJEFGmqVODbNcwxq8/Ce0OaVZBF3mmHM t2VvqSua3/ji8iusJ75oSvdvKHOBz6BPwA== X-Google-Smtp-Source: AA0mqf6QKYeure8LPMQSPdFAuOdE8rVAfOgIJNcQnl5yVSFr9oclbKVgd0W3nSdG1YFjfsPWpq44oA== X-Received: by 2002:a6b:c844:0:b0:6db:fe34:6948 with SMTP id y65-20020a6bc844000000b006dbfe346948mr1890365iof.209.1668709755473; Thu, 17 Nov 2022 10:29:15 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id g68-20020a025b47000000b00365c1bd9ac7sm469409jab.113.2022.11.17.10.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:29:15 -0800 (PST) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/3] Don't let tee_file own a stream Date: Thu, 17 Nov 2022 11:29:03 -0700 Message-Id: <20221117182904.1291713-3-tromey@adacore.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221117182904.1291713-1-tromey@adacore.com> References: <20221117182904.1291713-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Right now, tee_file owns the second stream it writes to. This is done for the convenience of the users. In a subsequent patch, this will no longer be convenient, so this patch moves the responsibility for ownership to the users of tee_file. --- gdb/cli/cli-interp.c | 11 ++++++----- gdb/cli/cli-interp.h | 1 + gdb/mi/mi-interp.c | 15 ++++++--------- gdb/mi/mi-interp.h | 2 +- gdb/ui-file.c | 4 ++-- gdb/ui-file.h | 8 ++++---- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 8c2fb207486..2e8f6135405 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -386,17 +386,18 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect, m_saved_output->targ = gdb_stdtarg; m_saved_output->targerr = gdb_stdtargerr; + ui_file *logfile_p = logfile.get (); + m_saved_output->file_to_delete = std::move (logfile); + /* If something is not being redirected, then a tee containing both the logfile and stdout. */ - ui_file *logfile_p = logfile.get (); ui_file *tee = nullptr; if (!logging_redirect || !debug_redirect) { - tee = new tee_file (gdb_stdout, std::move (logfile)); - m_saved_output->file_to_delete.reset (tee); + m_saved_output->tee_to_delete.reset + (new tee_file (gdb_stdout, logfile_p)); + tee = m_saved_output->tee_to_delete.get (); } - else - m_saved_output->file_to_delete = std::move (logfile); m_saved_output->log_to_delete.reset (new timestamped_file (debug_redirect ? logfile_p : tee)); diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h index 3c233c0a229..fa007d78621 100644 --- a/gdb/cli/cli-interp.h +++ b/gdb/cli/cli-interp.h @@ -41,6 +41,7 @@ class cli_interp_base : public interp ui_file *log; ui_file *targ; ui_file *targerr; + ui_file_up tee_to_delete; ui_file_up file_to_delete; ui_file_up log_to_delete; }; diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index af242208a0b..482166ea3a5 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -1275,21 +1275,16 @@ mi_interp::set_logging (ui_file_up logfile, bool logging_redirect, { mi->saved_raw_stdout = mi->raw_stdout; - /* If something is being redirected, then grab logfile. */ - ui_file *logfile_p = nullptr; - if (logging_redirect || debug_redirect) - { - logfile_p = logfile.get (); - mi->saved_raw_file_to_delete = logfile_p; - } + ui_file *logfile_p = logfile.get (); + mi->saved_raw_file_to_delete = logfile.release (); /* If something is not being redirected, then a tee containing both the logfile and stdout. */ ui_file *tee = nullptr; if (!logging_redirect || !debug_redirect) { - tee = new tee_file (mi->raw_stdout, std::move (logfile)); - mi->saved_raw_file_to_delete = tee; + tee = new tee_file (mi->raw_stdout, logfile_p); + mi->saved_tee_to_delete = tee; } mi->raw_stdout = logging_redirect ? logfile_p : tee; @@ -1297,9 +1292,11 @@ mi_interp::set_logging (ui_file_up logfile, bool logging_redirect, else { delete mi->saved_raw_file_to_delete; + delete mi->saved_tee_to_delete; mi->raw_stdout = mi->saved_raw_stdout; mi->saved_raw_stdout = nullptr; mi->saved_raw_file_to_delete = nullptr; + mi->saved_tee_to_delete = nullptr; } mi->out->set_raw (mi->raw_stdout); diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h index d89439f54c5..d118ffb41e5 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -57,7 +57,7 @@ class mi_interp final : public interp done. */ struct ui_file *saved_raw_stdout; struct ui_file *saved_raw_file_to_delete; - + struct ui_file *saved_tee_to_delete; /* MI's builder. */ struct ui_out *mi_uiout; diff --git a/gdb/ui-file.c b/gdb/ui-file.c index 47044e42a67..3343b6b8fc5 100644 --- a/gdb/ui-file.c +++ b/gdb/ui-file.c @@ -384,9 +384,9 @@ stderr_file::stderr_file (FILE *stream) -tee_file::tee_file (ui_file *one, ui_file_up &&two) +tee_file::tee_file (ui_file *one, ui_file *two) : m_one (one), - m_two (std::move (two)) + m_two (two) {} tee_file::~tee_file () diff --git a/gdb/ui-file.h b/gdb/ui-file.h index e33ae79e753..4a006bbba4c 100644 --- a/gdb/ui-file.h +++ b/gdb/ui-file.h @@ -329,9 +329,9 @@ class stderr_file : public stdio_file class tee_file : public ui_file { public: - /* Create a file which writes to both ONE and TWO. ONE will remain - open when this object is destroyed; but TWO will be closed. */ - tee_file (ui_file *one, ui_file_up &&two); + /* Create a file which writes to both ONE and TWO. Ownership of + both files is up to the user. */ + tee_file (ui_file *one, ui_file *two); ~tee_file () override; void write (const char *buf, long length_buf) override; @@ -364,7 +364,7 @@ class tee_file : public ui_file private: /* The two underlying ui_files. */ ui_file *m_one; - ui_file_up m_two; + ui_file *m_two; }; /* A ui_file implementation that filters out terminal escape From patchwork Thu Nov 17 18:29:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 60792 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B36B73852C57 for ; Thu, 17 Nov 2022 18:29:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B36B73852C57 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668709786; bh=gpY27NP9v2xVd47LZAMdKPDZZlZ1+L5+aFpUZM254hA=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=iKLuB6E36nH6EqmbKgLHk7Z0ZZ0Khzva3RdAtPycs8ZC5GnPgBTlZ1yMhv3LMKA+w taJ+YKIcqcNV/cgZvcA9UxpzUDa/2gh3Qa93+LcKWiTC7pX+X4HTFr0/GX4u2nkaHf HnSkWx2bBcd7jaX8dcVbqdrJ9kcpxPTnFzPFzQN4= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id D97C03853D46 for ; Thu, 17 Nov 2022 18:29:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D97C03853D46 Received: by mail-il1-x133.google.com with SMTP id d3so1354126ils.1 for ; Thu, 17 Nov 2022 10:29:16 -0800 (PST) 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 :subject:date:message-id:reply-to; bh=gpY27NP9v2xVd47LZAMdKPDZZlZ1+L5+aFpUZM254hA=; b=wuwli4/kWktUTQ3F+9m1yStO7GG9OXkKLXnWjDvpP/ot9iKQ8WaDCRG4ehIg2Gfxb8 wPhLq0km7YZIF7/V0XdQis9pqqlJFF9UiZo1NEQYP82+peLOZEKuBlnUmu1q84RVDTWG 5OE6qa2JoQ5t8jxbKfnp3Q9XtIcfq6w2orZYW+Wxd4f5goXWIH75k17I5Hq519hdpHGB vJRAEKAyxGitDiBws/fpuBBm6jS2hPxkSerILu/xk5+q5G+gi/eqlnjvJLp17nSELKb6 RegQDKX85Att4uYFXojrcbSOv+uLIarspi6Y5nW3av4yGOFZdk/b6B7KHr2N+HXBPzO4 CGMQ== X-Gm-Message-State: ANoB5plsufg7cpvuVBLewBzkcaOVpaSq50asMEQOPyyMghTGjlijVwHj muEGZ6SqVZDXaZnvNQQiINuP7m50QrJVFQ== X-Google-Smtp-Source: AA0mqf6TaoaC/pQfivIZQQIxbXNhCTqOD74Rqr7zdqCd9DNQnwK/llmRp6O3e6I1PQsREhNIeYMm5w== X-Received: by 2002:a92:d685:0:b0:300:d794:1f00 with SMTP id p5-20020a92d685000000b00300d7941f00mr1872989iln.63.1668709756174; Thu, 17 Nov 2022 10:29:16 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id g68-20020a025b47000000b00365c1bd9ac7sm469409jab.113.2022.11.17.10.29.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:29:15 -0800 (PST) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/3] Don't let gdb_stdlog use pager Date: Thu, 17 Nov 2022 11:29:04 -0700 Message-Id: <20221117182904.1291713-4-tromey@adacore.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221117182904.1291713-1-tromey@adacore.com> References: <20221117182904.1291713-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" When using the "set logging" commands, cli_interp_base::set_logging will send gdb_stdlog output (among others) to the tee it makes for gdb_stdout. However, this has the side effect of also causing logging to use the pager. This is PR gdb/29787. This patch fixes the problem by keeping stderr and stdlog separate from stdout, preserving the rule that only gdb_stdout should page. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29787 --- gdb/cli/cli-interp.c | 24 ++++++++++++++---------- gdb/cli/cli-interp.h | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 2e8f6135405..3254efc3581 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -389,24 +389,28 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect, ui_file *logfile_p = logfile.get (); m_saved_output->file_to_delete = std::move (logfile); - /* If something is not being redirected, then a tee containing both the - logfile and stdout. */ - ui_file *tee = nullptr; - if (!logging_redirect || !debug_redirect) + /* The new stdout and stderr only depend on whether logging + redirection is being done. */ + ui_file *new_stdout = logfile_p; + ui_file *new_stderr = logfile_p; + if (!logging_redirect) { m_saved_output->tee_to_delete.reset (new tee_file (gdb_stdout, logfile_p)); - tee = m_saved_output->tee_to_delete.get (); + new_stdout = m_saved_output->tee_to_delete.get (); + m_saved_output->stderr_to_delete.reset + (new tee_file (gdb_stderr, logfile_p)); + new_stderr = m_saved_output->stderr_to_delete.get (); } m_saved_output->log_to_delete.reset - (new timestamped_file (debug_redirect ? logfile_p : tee)); + (new timestamped_file (debug_redirect ? logfile_p : new_stderr)); - gdb_stdout = logging_redirect ? logfile_p : tee; + gdb_stdout = new_stdout; gdb_stdlog = m_saved_output->log_to_delete.get (); - gdb_stderr = logging_redirect ? logfile_p : tee; - gdb_stdtarg = logging_redirect ? logfile_p : tee; - gdb_stdtargerr = logging_redirect ? logfile_p : tee; + gdb_stderr = new_stderr; + gdb_stdtarg = new_stderr; + gdb_stdtargerr = new_stderr; } else { diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h index fa007d78621..978e7f291e4 100644 --- a/gdb/cli/cli-interp.h +++ b/gdb/cli/cli-interp.h @@ -42,6 +42,7 @@ class cli_interp_base : public interp ui_file *targ; ui_file *targerr; ui_file_up tee_to_delete; + ui_file_up stderr_to_delete; ui_file_up file_to_delete; ui_file_up log_to_delete; };