From patchwork Sun Jul 9 17:01:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 72398 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 6382938555A9 for ; Sun, 9 Jul 2023 17:03:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id B02793858000 for ; Sun, 9 Jul 2023 17:01:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B02793858000 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id E756D10047B47 for ; Sun, 9 Jul 2023 17:01:48 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IXnAqEcxvzvSbIXnAqJsLd; Sun, 09 Jul 2023 17:01:48 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=bKrTnNyZ c=1 sm=1 tr=0 ts=64aae7fc a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=ws7JD89P4LkA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=5efsIrjiF1FUNUa43-cA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=SeSht7nmOiJ1qhcs4msuS4inl+b+Nnvq5SjetNcm7lA=; b=fbXNGJVNtYx5LKWsqRP8P2UDYi sQzespuNmPhEwdCUdO8edK/+QskoYNZOsTgW6KjA7XuX6n3+baNy0Py2XMCeo2jarVoiIsjGcWc0/ omsAsm0KtMnafsiIMHmkR7Nff; Received: from 75-166-135-140.hlrn.qwest.net ([75.166.135.140]:52250 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qIXnA-001oeb-2C for gdb-patches@sourceware.org; Sun, 09 Jul 2023 11:01:48 -0600 From: Tom Tromey Date: Sun, 09 Jul 2023 11:01:47 -0600 Subject: [PATCH 1/8] Remove a use of xfree MIME-Version: 1.0 Message-Id: <20230709-trace-cleanups-v1-1-c410e1072fab@tromey.com> References: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> In-Reply-To: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.135.140 X-Source-L: No X-Exim-ID: 1qIXnA-001oeb-2C X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-135-140.hlrn.qwest.net ([192.168.0.21]) [75.166.135.140]:52250 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This removes a use of xfree from tracefile-tfile.c, replacing it with a unique_xmalloc_ptr. --- gdb/tracefile-tfile.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index 9203bcc2e4b..ff451c79e88 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -225,22 +225,19 @@ static void tfile_write_uploaded_tsv (struct trace_file_writer *self, struct uploaded_tsv *utsv) { - char *buf = NULL; + gdb::unique_xmalloc_ptr buf; struct tfile_trace_file_writer *writer = (struct tfile_trace_file_writer *) self; if (utsv->name) { - buf = (char *) xmalloc (strlen (utsv->name) * 2 + 1); - bin2hex ((gdb_byte *) (utsv->name), buf, strlen (utsv->name)); + buf.reset ((char *) xmalloc (strlen (utsv->name) * 2 + 1)); + bin2hex ((gdb_byte *) (utsv->name), buf.get (), strlen (utsv->name)); } fprintf (writer->fp, "tsv %x:%s:%x:%s\n", utsv->number, phex_nz (utsv->initial_value, 8), - utsv->builtin, buf != NULL ? buf : ""); - - if (utsv->name) - xfree (buf); + utsv->builtin, buf != NULL ? buf.get () : ""); } #define MAX_TRACE_UPLOAD 2000 From patchwork Sun Jul 9 17:01:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 72391 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 43839385AFA0 for ; Sun, 9 Jul 2023 17:02:08 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 8AB443858C2C for ; Sun, 9 Jul 2023 17:01:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8AB443858C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id EE31F10047FB5 for ; Sun, 9 Jul 2023 17:01:48 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IXnAqeK0ZSPQoIXnAqCquz; Sun, 09 Jul 2023 17:01:48 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=YNRadTKx c=1 sm=1 tr=0 ts=64aae7fc a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=ws7JD89P4LkA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=gtlUT0WRCpVhFSZFmH8A:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=FqTzI0FFQUed/9fkZGTjJG+4fIH70PXqgeCeUheEaUs=; b=cO6bj+SPVOjJ8+nbJF7BA1gWYx 4JkZehWblj/0ibu8L0E3OhVadxR3Ko6F3xY4RKSjdjYazHuaaCeHrRU9ckdQhy0er3AK0qYYs/D/7 yTb+JKWqb3WeNFyV/2Gj5k/UO; Received: from 75-166-135-140.hlrn.qwest.net ([75.166.135.140]:52250 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qIXnA-001oeb-2d for gdb-patches@sourceware.org; Sun, 09 Jul 2023 11:01:48 -0600 From: Tom Tromey Date: Sun, 09 Jul 2023 11:01:48 -0600 Subject: [PATCH 2/8] Replace use of xfree with byte_vector MIME-Version: 1.0 Message-Id: <20230709-trace-cleanups-v1-2-c410e1072fab@tromey.com> References: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> In-Reply-To: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.135.140 X-Source-L: No X-Exim-ID: 1qIXnA-001oeb-2d X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-135-140.hlrn.qwest.net ([192.168.0.21]) [75.166.135.140]:52250 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This replaces a use of xfree with a byte_vector. --- gdb/tracectf.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gdb/tracectf.c b/gdb/tracectf.c index 16461711da1..8f6ea250f61 100644 --- a/gdb/tracectf.c +++ b/gdb/tracectf.c @@ -1358,10 +1358,9 @@ ctf_target::xfer_partial (enum target_object object, { const struct bt_definition *array = bt_ctf_get_field (event, scope, "contents"); - gdb_byte *contents; int k; - contents = (gdb_byte *) xmalloc (mlen); + gdb::byte_vector contents (mlen); for (k = 0; k < mlen; k++) { @@ -1377,8 +1376,6 @@ ctf_target::xfer_partial (enum target_object object, memcpy (readbuf, &contents[offset - maddr], amt); - xfree (contents); - /* Restore the position. */ bt_iter_set_pos (bt_ctf_get_iter (ctf_iter), pos); From patchwork Sun Jul 9 17:01:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 72392 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 6F524385AF8D for ; Sun, 9 Jul 2023 17:02:08 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 8D7153858C30 for ; Sun, 9 Jul 2023 17:01:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8D7153858C30 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id 2D4B310047FB3 for ; Sun, 9 Jul 2023 17:01:49 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IXnBqAmUONX2aIXnBqcVfv; Sun, 09 Jul 2023 17:01:49 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=64aae7fd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=ws7JD89P4LkA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=cTMaWx_JMQxhfjUJ5IIA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0WYhLlr0XQWmJuvWQRUd5y6g5C/cYGcnrzXNCArjSak=; b=s4mkuCEhC26JdjPEkSZH7z+WUX vHk/W5dXCC2uCR6Imniz69YholUre2D6f42So3lakGxjNut/3DkTsX4gsvGOTSB016uzgrAYnwFxz TlGLj9EZPHKJd4320kC3ePecg; Received: from 75-166-135-140.hlrn.qwest.net ([75.166.135.140]:52250 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qIXnA-001oeb-31 for gdb-patches@sourceware.org; Sun, 09 Jul 2023 11:01:48 -0600 From: Tom Tromey Date: Sun, 09 Jul 2023 11:01:49 -0600 Subject: [PATCH 3/8] Use unique_ptr for trace_filename MIME-Version: 1.0 Message-Id: <20230709-trace-cleanups-v1-3-c410e1072fab@tromey.com> References: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> In-Reply-To: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.135.140 X-Source-L: No X-Exim-ID: 1qIXnA-001oeb-31 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-135-140.hlrn.qwest.net ([192.168.0.21]) [75.166.135.140]:52250 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This changes trace_filename to use unique_ptr, removing some manual memory management. --- gdb/tracefile-tfile.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index ff451c79e88..364f8c1f08e 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -415,7 +415,7 @@ static tfile_target tfile_ops; #define TFILE_PID (1) -static char *trace_filename; +static gdb::unique_xmalloc_ptr trace_filename; static int trace_fd = -1; static off_t trace_frames_offset; static off_t cur_offset; @@ -441,7 +441,7 @@ tfile_read (gdb_byte *readbuf, int size) gotten = read (trace_fd, readbuf, size); if (gotten < 0) - perror_with_name (trace_filename); + perror_with_name (trace_filename.get ()); else if (gotten < size) error (_("Premature end of file while reading trace file")); } @@ -479,7 +479,7 @@ tfile_target_open (const char *arg, int from_tty) current_inferior ()->unpush_target (&tfile_ops); - trace_filename = filename.release (); + trace_filename = std::move (filename); trace_fd = scratch_chan; /* Make sure this is clear. */ @@ -499,7 +499,7 @@ tfile_target_open (const char *arg, int from_tty) trace_regblock_size = 0; ts = current_trace_status (); /* We know we're working with a file. Record its name. */ - ts->filename = trace_filename; + ts->filename = trace_filename.get (); /* Set defaults in case there is no status line. */ ts->running_known = 0; ts->stop_reason = trace_stop_reason_unknown; @@ -620,8 +620,7 @@ tfile_target::close () ::close (trace_fd); trace_fd = -1; - xfree (trace_filename); - trace_filename = NULL; + trace_filename.reset (); trace_tdesc.clear (); trace_reset_local_state (); @@ -630,7 +629,7 @@ tfile_target::close () void tfile_target::files_info () { - gdb_printf ("\t`%s'\n", trace_filename); + gdb_printf ("\t`%s'\n", trace_filename.get ()); } void From patchwork Sun Jul 9 17:01:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 72395 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 6F322385AF8E for ; Sun, 9 Jul 2023 17:03:06 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id 9E19F385842E for ; Sun, 9 Jul 2023 17:01:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E19F385842E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 5721D100482B2 for ; Sun, 9 Jul 2023 17:01:49 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IXnBqO72r76PwIXnBqwfDj; Sun, 09 Jul 2023 17:01:49 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=FYLyeLy6 c=1 sm=1 tr=0 ts=64aae7fd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=ws7JD89P4LkA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=f2I-0AVsDXALEDwm0cYA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=RgUSBXXwLoreWwH3g3VgAlUtepLZ2/NhlNC17nO3FvA=; b=kp9aOrI0voxSfR/9oBszufjjfE wj1W/xku+WQFC4LtK05F8Nm0yJWqwdqMD9LxyPvtoint4FtgNjMWvufwxpwJZExMCYAxY44F707bC LwY9cVr95UDHbCb+0cOv5MPCa; Received: from 75-166-135-140.hlrn.qwest.net ([75.166.135.140]:52250 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qIXnB-001oeb-07 for gdb-patches@sourceware.org; Sun, 09 Jul 2023 11:01:49 -0600 From: Tom Tromey Date: Sun, 09 Jul 2023 11:01:50 -0600 Subject: [PATCH 4/8] Use unique_ptr for trace_dirname MIME-Version: 1.0 Message-Id: <20230709-trace-cleanups-v1-4-c410e1072fab@tromey.com> References: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> In-Reply-To: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.135.140 X-Source-L: No X-Exim-ID: 1qIXnB-001oeb-07 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-135-140.hlrn.qwest.net ([192.168.0.21]) [75.166.135.140]:52250 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This changes trace_dirname to use unique_ptr, removing some manual memory management. --- gdb/tracectf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gdb/tracectf.c b/gdb/tracectf.c index 8f6ea250f61..fca623b3f21 100644 --- a/gdb/tracectf.c +++ b/gdb/tracectf.c @@ -862,7 +862,7 @@ static struct bt_ctf_iter *ctf_iter = NULL; static struct bt_iter_pos *start_pos; /* The name of CTF directory. */ -static char *trace_dirname; +static gdb::unique_xmalloc_ptr trace_dirname; static ctf_target ctf_ops; @@ -1164,7 +1164,7 @@ ctf_target_open (const char *dirname, int from_tty) start_pos = bt_iter_get_pos (bt_ctf_get_iter (ctf_iter)); gdb_assert (start_pos->type == BT_SEEK_RESTORE); - trace_dirname = xstrdup (dirname); + trace_dirname = make_unique_xstrdup (dirname); current_inferior ()->push_target (&ctf_ops); inferior_appeared (current_inferior (), CTF_PID); @@ -1185,8 +1185,7 @@ void ctf_target::close () { ctf_destroy (); - xfree (trace_dirname); - trace_dirname = NULL; + trace_dirname.reset (); switch_to_no_thread (); /* Avoid confusion from thread stuff. */ exit_inferior_silent (current_inferior ()); @@ -1200,7 +1199,7 @@ ctf_target::close () void ctf_target::files_info () { - gdb_printf ("\t`%s'\n", trace_dirname); + gdb_printf ("\t`%s'\n", trace_dirname.get ()); } /* This is the implementation of target_ops method to_fetch_registers. From patchwork Sun Jul 9 17:01:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 72397 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 330DA385AF9F for ; Sun, 9 Jul 2023 17:03:25 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id AD1873858438 for ; Sun, 9 Jul 2023 17:01:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD1873858438 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 5B93C100482B3 for ; Sun, 9 Jul 2023 17:01:49 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IXnBqAmUXNX2aIXnBqcVg4; Sun, 09 Jul 2023 17:01:49 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=64aae7fd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=ws7JD89P4LkA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=SmtZPBz3_MideT66nMwA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=uDz7ChImXeW2ZqD1WMn1wPgjg5AYgXrcBAPWmrP2yE4=; b=PonkND+L9xWqGRcJyuGL1PQyfG 0cpi6lMb7OuSMBwQ8CA+b0B4oQe+QoVZg1/PMhgoyQYDXC3gjfkwzbbK8Iylz77VElhwh0ia9EERR uLfDkyEvAId/01ytNPdrexsOJ; Received: from 75-166-135-140.hlrn.qwest.net ([75.166.135.140]:52250 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qIXnB-001oeb-0a for gdb-patches@sourceware.org; Sun, 09 Jul 2023 11:01:49 -0600 From: Tom Tromey Date: Sun, 09 Jul 2023 11:01:51 -0600 Subject: [PATCH 5/8] Use function_view in traceframe_walk_blocks MIME-Version: 1.0 Message-Id: <20230709-trace-cleanups-v1-5-c410e1072fab@tromey.com> References: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> In-Reply-To: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.135.140 X-Source-L: No X-Exim-ID: 1qIXnB-001oeb-0a X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-135-140.hlrn.qwest.net ([192.168.0.21]) [75.166.135.140]:52250 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This change traceframe_walk_blocks to take a function_view. This simplifies the code somewhat and lets us entirely remove one helper function. --- gdb/tracefile-tfile.c | 50 ++++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index 364f8c1f08e..d3304b0b355 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -773,33 +773,15 @@ tfile_target::trace_find (enum trace_find_type type, int num, return -1; } -/* Prototype of the callback passed to tframe_walk_blocks. */ -typedef int (*walk_blocks_callback_func) (char blocktype, void *data); - -/* Callback for traceframe_walk_blocks, used to find a given block - type in a traceframe. */ - -static int -match_blocktype (char blocktype, void *data) -{ - char *wantedp = (char *) data; - - if (*wantedp == blocktype) - return 1; - - return 0; -} - /* Walk over all traceframe block starting at POS offset from - CUR_OFFSET, and call CALLBACK for each block found, passing in DATA - unmodified. If CALLBACK returns true, this returns the position in - the traceframe where the block is found, relative to the start of - the traceframe (cur_offset). Returns -1 if no callback call - returned true, indicating that all blocks have been walked. */ + CUR_OFFSET, and call CALLBACK for each block found. If CALLBACK + returns true, this returns the position in the traceframe where the + block is found, relative to the start of the traceframe + (cur_offset). Returns -1 if no callback call returned true, + indicating that all blocks have been walked. */ static int -traceframe_walk_blocks (walk_blocks_callback_func callback, - int pos, void *data) +traceframe_walk_blocks (gdb::function_view callback, int pos) { /* Iterate through a traceframe's blocks, looking for a block of the requested type. */ @@ -814,7 +796,7 @@ traceframe_walk_blocks (walk_blocks_callback_func callback, ++pos; - if ((*callback) (block_type, data)) + if (callback (block_type)) return pos; switch (block_type) @@ -854,7 +836,10 @@ traceframe_walk_blocks (walk_blocks_callback_func callback, static int traceframe_find_block_type (char type_wanted, int pos) { - return traceframe_walk_blocks (match_blocktype, pos, &type_wanted); + return traceframe_walk_blocks ([&] (char blocktype) + { + return blocktype == type_wanted; + }, pos); } /* Look for a block of saved registers in the traceframe, and get the @@ -1060,11 +1045,9 @@ tfile_target::get_trace_state_variable_value (int tsvnum, LONGEST *val) /* Callback for traceframe_walk_blocks. Builds a traceframe_info object for the tfile target's current traceframe. */ -static int -build_traceframe_info (char blocktype, void *data) +static bool +build_traceframe_info (char blocktype, struct traceframe_info *info) { - struct traceframe_info *info = (struct traceframe_info *) data; - switch (blocktype) { case 'M': @@ -1104,7 +1087,7 @@ build_traceframe_info (char blocktype, void *data) break; } - return 0; + return false; } traceframe_info_up @@ -1112,7 +1095,10 @@ tfile_target::traceframe_info () { traceframe_info_up info (new struct traceframe_info); - traceframe_walk_blocks (build_traceframe_info, 0, info.get ()); + traceframe_walk_blocks ([&] (char blocktype) + { + return build_traceframe_info (blocktype, info.get ()); + }, 0); return info; } From patchwork Sun Jul 9 17:01:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 72394 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 59D9C385AFB1 for ; Sun, 9 Jul 2023 17:02:56 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id B38C43858024 for ; Sun, 9 Jul 2023 17:01:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B38C43858024 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id 889F410046D2D for ; Sun, 9 Jul 2023 17:01:49 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IXnBqxjofUoBjIXnBq5kQ2; Sun, 09 Jul 2023 17:01:49 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=N7fsq0xB c=1 sm=1 tr=0 ts=64aae7fd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=ws7JD89P4LkA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=T6p9nEhGbJGsQZp6h6AA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=LA1Pb8i/STYsK8OlzfLWyiUu3+UvX7LHZHOgobb55cE=; b=YoZF478GlP2CdFUtLrlju5C2cx 1oDKbBoSM6PDQAVWr0fsWAN8olecP3MY1oU7XXNnEO1HjMmiaDvg8Hr2pYtaiQnMCS8K9nCwdCL97 2tVrJn2dcfWWUZTv8Y4OGrCZs; Received: from 75-166-135-140.hlrn.qwest.net ([75.166.135.140]:52250 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qIXnB-001oeb-0x for gdb-patches@sourceware.org; Sun, 09 Jul 2023 11:01:49 -0600 From: Tom Tromey Date: Sun, 09 Jul 2023 11:01:52 -0600 Subject: [PATCH 6/8] Constify tfile_interp_line MIME-Version: 1.0 Message-Id: <20230709-trace-cleanups-v1-6-c410e1072fab@tromey.com> References: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> In-Reply-To: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.135.140 X-Source-L: No X-Exim-ID: 1qIXnB-001oeb-0x X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-135-140.hlrn.qwest.net ([192.168.0.21]) [75.166.135.140]:52250 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This adds 'const' to tfile_interp_line. --- gdb/tracefile-tfile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index d3304b0b355..59055e7ea1a 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -424,7 +424,7 @@ int trace_regblock_size; static std::string trace_tdesc; static void tfile_append_tdesc_line (const char *line); -static void tfile_interp_line (char *line, +static void tfile_interp_line (const char *line, struct uploaded_tp **utpp, struct uploaded_tsv **utsvp); @@ -574,15 +574,15 @@ tfile_target_open (const char *arg, int from_tty) file. */ static void -tfile_interp_line (char *line, struct uploaded_tp **utpp, +tfile_interp_line (const char *line, struct uploaded_tp **utpp, struct uploaded_tsv **utsvp) { - char *p = line; + const char *p = line; if (startswith (p, "R ")) { p += strlen ("R "); - trace_regblock_size = strtol (p, &p, 16); + trace_regblock_size = strtol (p, nullptr, 16); } else if (startswith (p, "status ")) { From patchwork Sun Jul 9 17:01:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 72396 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 F11C73857702 for ; Sun, 9 Jul 2023 17:03:15 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id A82B23858433 for ; Sun, 9 Jul 2023 17:01:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A82B23858433 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 8D14F10047B55 for ; Sun, 9 Jul 2023 17:01:49 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IXnBqEcyHzvSbIXnBqJsM1; Sun, 09 Jul 2023 17:01:49 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=bKrTnNyZ c=1 sm=1 tr=0 ts=64aae7fd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=ws7JD89P4LkA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=HlbNiMs3RppMAC9iD7sA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=lR3SeWh6tU2xjhYNFDw1i4mt7k8rQb06zO2scjqOGNM=; b=h961dcor1orvWbNAtcboBN0jYo naFHm+QI2FGGH/bue8ikw5K7ITzvWcJBBzWhuwVowlGTaqeX0ewVecu5UvSiaUScgaw8VclJl/xiT 4Ndqu9DroGTSbAz/uNPCUP2uj; Received: from 75-166-135-140.hlrn.qwest.net ([75.166.135.140]:52250 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qIXnB-001oeb-1N for gdb-patches@sourceware.org; Sun, 09 Jul 2023 11:01:49 -0600 From: Tom Tromey Date: Sun, 09 Jul 2023 11:01:53 -0600 Subject: [PATCH 7/8] Move definition of ctf_target type MIME-Version: 1.0 Message-Id: <20230709-trace-cleanups-v1-7-c410e1072fab@tromey.com> References: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> In-Reply-To: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.135.140 X-Source-L: No X-Exim-ID: 1qIXnB-001oeb-1N X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-135-140.hlrn.qwest.net ([192.168.0.21]) [75.166.135.140]:52250 X-Source-Auth: tom+tromey.com X-Email-Count: 8 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This moves the definition of the ctf_target type into the HAVE_LIBBABELTRACE block. This type is only used in this block, so it makes sense to only define it there. --- gdb/tracectf.c | 60 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/gdb/tracectf.c b/gdb/tracectf.c index fca623b3f21..c2b55426b41 100644 --- a/gdb/tracectf.c +++ b/gdb/tracectf.c @@ -34,36 +34,6 @@ #include "gdbsupport/filestuff.h" #include "gdbarch.h" -/* The CTF target. */ - -static const target_info ctf_target_info = { - "ctf", - N_("CTF file"), - N_("(Use a CTF directory as a target.\n\ -Specify the filename of the CTF directory.") -}; - -class ctf_target final : public tracefile_target -{ -public: - const target_info &info () const override - { return ctf_target_info; } - - void close () override; - void fetch_registers (struct regcache *, int) override; - enum target_xfer_status xfer_partial (enum target_object object, - const char *annex, - gdb_byte *readbuf, - const gdb_byte *writebuf, - ULONGEST offset, ULONGEST len, - ULONGEST *xfered_len) override; - void files_info () override; - int trace_find (enum trace_find_type type, int num, - CORE_ADDR addr1, CORE_ADDR addr2, int *tpp) override; - bool get_trace_state_variable_value (int tsv, LONGEST *val) override; - traceframe_info_up traceframe_info () override; -}; - /* GDB saves trace buffers and other information (such as trace status) got from the remote target into Common Trace Format (CTF). The following types of information are expected to save in CTF: @@ -854,6 +824,36 @@ ctf_trace_file_writer_new (void) #include #include +/* The CTF target. */ + +static const target_info ctf_target_info = { + "ctf", + N_("CTF file"), + N_("(Use a CTF directory as a target.\n\ +Specify the filename of the CTF directory.") +}; + +class ctf_target final : public tracefile_target +{ +public: + const target_info &info () const override + { return ctf_target_info; } + + void close () override; + void fetch_registers (struct regcache *, int) override; + enum target_xfer_status xfer_partial (enum target_object object, + const char *annex, + gdb_byte *readbuf, + const gdb_byte *writebuf, + ULONGEST offset, ULONGEST len, + ULONGEST *xfered_len) override; + void files_info () override; + int trace_find (enum trace_find_type type, int num, + CORE_ADDR addr1, CORE_ADDR addr2, int *tpp) override; + bool get_trace_state_variable_value (int tsv, LONGEST *val) override; + traceframe_info_up traceframe_info () override; +}; + /* The struct pointer for current CTF directory. */ static int handle_id = -1; static struct bt_context *ctx = NULL; From patchwork Sun Jul 9 17:01:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 72393 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 E84CA3858C2C for ; Sun, 9 Jul 2023 17:02:42 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id 9B67D3858409 for ; Sun, 9 Jul 2023 17:01:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B67D3858409 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id D7C0110047418 for ; Sun, 9 Jul 2023 17:01:49 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IXnBqeK0uSPQoIXnBqCqvN; Sun, 09 Jul 2023 17:01:49 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=YNRadTKx c=1 sm=1 tr=0 ts=64aae7fd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=ws7JD89P4LkA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=w3fqXnBjIZip1TvppMgA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0F8w9B/rlG+R3xurZc7SeDrlJOZ/8yhMZTNdL/2TXzw=; b=CL0d6cl+kLIvOt8HZgy3c9Fa6O 3/S3KVRr/bVjRFHz2V/X7GsljcbFFrUQjZdetV9f6bSuBKERc/nZP/T96E4CtOJMb7Gi1spufUBj9 3qAydrom3tpuIYl6OtH+fTVPr; Received: from 75-166-135-140.hlrn.qwest.net ([75.166.135.140]:52250 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qIXnB-001oeb-1k for gdb-patches@sourceware.org; Sun, 09 Jul 2023 11:01:49 -0600 From: Tom Tromey Date: Sun, 09 Jul 2023 11:01:54 -0600 Subject: [PATCH 8/8] Change 'handle_id' to be a local variable MIME-Version: 1.0 Message-Id: <20230709-trace-cleanups-v1-8-c410e1072fab@tromey.com> References: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> In-Reply-To: <20230709-trace-cleanups-v1-0-c410e1072fab@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.135.140 X-Source-L: No X-Exim-ID: 1qIXnB-001oeb-1k X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-135-140.hlrn.qwest.net ([192.168.0.21]) [75.166.135.140]:52250 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" The global variable 'handle_id' in tracectf.c is only used in a single function, so change it to be a local variable. --- gdb/tracectf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gdb/tracectf.c b/gdb/tracectf.c index c2b55426b41..0ed2092c32b 100644 --- a/gdb/tracectf.c +++ b/gdb/tracectf.c @@ -855,7 +855,6 @@ class ctf_target final : public tracefile_target }; /* The struct pointer for current CTF directory. */ -static int handle_id = -1; static struct bt_context *ctx = NULL; static struct bt_ctf_iter *ctf_iter = NULL; /* The position of the first packet containing trace frame. */ @@ -895,7 +894,7 @@ ctf_open_dir (const char *dirname) ctx = bt_context_create (); if (ctx == NULL) error (_("Unable to create bt_context")); - handle_id = bt_context_add_trace (ctx, dirname, "ctf", NULL, NULL, NULL); + int handle_id = bt_context_add_trace (ctx, dirname, "ctf", NULL, NULL, NULL); if (handle_id < 0) { ctf_destroy ();