From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway23.websitewelcome.com (gateway23.websitewelcome.com [192.185.49.219]) by sourceware.org (Postfix) with ESMTPS id C62B6385840B for ; Tue, 5 Oct 2021 00:14:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C62B6385840B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tromey.com Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 506B11390E for ; Mon, 4 Oct 2021 19:14:56 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id XY6imBc78ejmuXY6im9hGT; Mon, 04 Oct 2021 19:14:56 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=i0mt4EGA9/73KphdKKb2WSW5NUgN2Z14QYQdkY4hP2s=; b=GgEOduU8jiUuRDmUzNyaxlwRSI CbZR0miZmHgozsl8Pmv8FEnOWUIYa5ElT4c6eovsCQZDpSd/aH8N819VyB1xbnAHfGWstuXcH1sqY /odsVQpq6Uskj/ONF6pSEGuaQ; Received: from 174-16-0-219.hlrn.qwest.net ([174.16.0.219]:43158 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mXY6i-00196D-0J; Mon, 04 Oct 2021 18:14:56 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 4/6] Use unique_xmalloc_ptr in bp_location Date: Mon, 4 Oct 2021 18:14:51 -0600 Message-Id: <20211005001453.2957929-5-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211005001453.2957929-1-tom@tromey.com> References: <20211005001453.2957929-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 174.16.0.219 X-Source-L: No X-Exim-ID: 1mXY6i-00196D-0J X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-0-219.hlrn.qwest.net (localhost.localdomain) [174.16.0.219]:43158 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.9 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_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Tue, 05 Oct 2021 00:14:58 -0000 This changes struct bp_location to use a unique_xmalloc_ptr, removing a bit of manual memory management. --- gdb/breakpoint.c | 12 ++++-------- gdb/breakpoint.h | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 477c03b7de3..5c3a6c6e4aa 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7192,7 +7192,7 @@ set_breakpoint_location_function (struct bp_location *loc) find_pc_partial_function (loc->address, &function_name, NULL, NULL); if (function_name) - loc->function_name = xstrdup (function_name); + loc->function_name = make_unique_xstrdup (function_name); } } @@ -12234,11 +12234,6 @@ say_where (struct breakpoint *b) } } -bp_location::~bp_location () -{ - xfree (function_name); -} - /* Destructor for the breakpoint base class. */ breakpoint::~breakpoint () @@ -13323,7 +13318,7 @@ ambiguous_names_p (struct bp_location *loc) for (l = loc; l != NULL; l = l->next) { const char **slot; - const char *name = l->function_name; + const char *name = l->function_name.get (); /* Allow for some names to be NULL, ignore them. */ if (name == NULL) @@ -13642,7 +13637,8 @@ update_breakpoint_locations (struct breakpoint *b, { for (bp_location *l : b->locations ()) if (l->function_name - && strcmp (e->function_name, l->function_name) == 0) + && strcmp (e->function_name.get (), + l->function_name.get ()) == 0) { l->enabled = e->enabled; l->disabled_by_cond = e->disabled_by_cond; diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index ad64f8320e9..304e2c1fca4 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -328,7 +328,7 @@ class bp_location : public refcounted_object /* Construct a bp_location with type TYPE. */ bp_location (breakpoint *owner, bp_loc_type type); - virtual ~bp_location (); + virtual ~bp_location () = default; /* Chain pointer to the next breakpoint location for the same parent breakpoint. */ @@ -467,7 +467,7 @@ class bp_location : public refcounted_object with it. */ bound_probe probe {}; - char *function_name = NULL; + gdb::unique_xmalloc_ptr function_name; /* Details of the placed breakpoint, when inserted. */ bp_target_info target_info {}; -- 2.31.1