From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yEXwJun29mJc9SUAWB0awg (envelope-from ) for ; Fri, 12 Aug 2022 20:57:13 -0400 Received: by simark.ca (Postfix, from userid 112) id 93F1D1E5EA; Fri, 12 Aug 2022 20:57:13 -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=M0PyjhV7; 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 0BE4D1E227 for ; Fri, 12 Aug 2022 20:57:13 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B13B6385781E for ; Sat, 13 Aug 2022 00:57:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B13B6385781E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660352232; bh=/WWMuxcnOvP8o5OQ14KW4OmBZF7edZ1+5HISqRHtPGM=; 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=M0PyjhV7q/uOm67nuXmFQ94IecV26zFJoz4eCsq+be76vQ//9w25U3NUMgBnI3o4I X3SgiwpkBbcfgUNHh7oI392GU27aTTNHBuy2c8GUb+kce2tF1Vsws3zCbS8oLGdyhq kr45THtFE2LAsaLUYAaQn6vT/MkdcWLfjbBJKv6w= Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by sourceware.org (Postfix) with ESMTPS id BCC8D3858400 for ; Sat, 13 Aug 2022 00:54:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BCC8D3858400 Received: by mail-io1-xd2e.google.com with SMTP id e69so2079162iof.5 for ; Fri, 12 Aug 2022 17:54:51 -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=/WWMuxcnOvP8o5OQ14KW4OmBZF7edZ1+5HISqRHtPGM=; b=PYjILFPfSzgoxSzXcteR5lKtJVR4k75kuH/LiOIPQIpi189h0rb8BYNkI6dKbhI5MB TgXgPMdRAyXWrkyzgkXghvisyXQkY0QczIs3INNvhUm++BVZlyoVhNXPS9KyH/1ojQSi MSUCZsvqpDCXnRcAhyPGFf43nUawO1Ep44fl4oYAV8ObDkeDZDauEIC8mhtghgrdvkWn n3XuBStxyhyVU5zemje4HCkV6oBNYNeDf//enpAdWxPzzl5ZRBe+C4hqci0LPhKXtHwq e2/WxDyp9zJSsW06cZGqZORj+HguOhMN4SORCH3jc/TYDzJFeSG5c6pokhnVeIThl9xE xZag== X-Gm-Message-State: ACgBeo1lkxo+jRm8pvU1dEy/U1jAgkuvkzzM+PsoiKunc+nxYxvQ1Q7e 8RhviNmCBU5HVVKdTHEycnug1gAGzQmBRg== X-Google-Smtp-Source: AA6agR7/kY32lbibSLi5b7vll1qP79FxtXbo17DDMSiDpIRa3USdTevvvRNBx/CCHubUoamKYvMR9A== X-Received: by 2002:a05:6602:1491:b0:67c:1732:d703 with SMTP id a17-20020a056602149100b0067c1732d703mr2602167iow.122.1660352091154; 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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 17:54:50 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 10/14] Remove a ui-related memory leak Date: Fri, 12 Aug 2022 18:54:38 -0600 Message-Id: <20220813005442.4163512-11-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" gdb_setup_readline makes new streams and assigns to the various stream members of struct ui. However, these assignments cause the previous values to leak. As far as I can, this code is simply unnecessary and can be removed -- with the exception of the assignment to gdb_stdtarg, which is not initialized anywhere else. --- gdb/event-top.c | 11 ----------- gdb/main.c | 1 + 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/gdb/event-top.c b/gdb/event-top.c index 3d7bf4ad560..151849c01ea 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -1328,17 +1328,6 @@ gdb_setup_readline (int editing) { struct ui *ui = current_ui; - /* This function is a noop for the sync case. The assumption is - that the sync setup is ALL done in gdb_init, and we would only - mess it up here. The sync stuff should really go away over - time. */ - if (!batch_silent) - gdb_stdout = new pager_file (new stdio_file (ui->outstream)); - gdb_stderr = new stderr_file (ui->errstream); - gdb_stdlog = new timestamped_file (gdb_stderr); - gdb_stdtarg = gdb_stderr; - gdb_stdtargerr = gdb_stderr; - /* If the input stream is connected to a terminal, turn on editing. However, that is only allowed on the main UI, as we can only have one instance of readline. */ diff --git a/gdb/main.c b/gdb/main.c index 91fa1966738..8d2666ecc95 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -676,6 +676,7 @@ captured_main_1 (struct captured_main_args *context) main_ui = new ui (stdin, stdout, stderr); current_ui = main_ui; + gdb_stdtarg = gdb_stderr; gdb_stdtargerr = gdb_stderr; gdb_stdtargin = gdb_stdin; -- 2.34.1