From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.145.239]) by sourceware.org (Postfix) with ESMTPS id EE8213858436 for ; Tue, 5 Oct 2021 00:14:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EE8213858436 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 cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 638FE59D17 for ; Mon, 4 Oct 2021 19:14:55 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id XY6hmCtrk6dDyXY6hmljJp; Mon, 04 Oct 2021 19:14:55 -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=Y7sccAjTG4cLiGZp9c4VuYIwbcHJoZLI23xFs9NZm58=; b=HTBxdD2VVGigUDj58OvJ1XhpcJ mWYWHbie+7ueQMrrQAj37fFBKR5LC1a6KQfwXz9dLkF6IKgOJlIWoIsM/xttilK3HBg5gdSt2ygIw QB1SZ2XsC5Y8dRHmXclU9NsDy; 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 1mXY6h-00196D-Ek; Mon, 04 Oct 2021 18:14:55 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/6] Use unique_xmalloc_ptr in exec_catchpoint Date: Mon, 4 Oct 2021 18:14:49 -0600 Message-Id: <20211005001453.2957929-3-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: 1mXY6h-00196D-Ek 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: 3 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_H2, 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:59 -0000 This changes struct exec_catchpoint to use a unique_xmalloc_ptr, removing a bit of manual memory management. --- gdb/breakpoint.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 7a9541836c9..8016dd3b83f 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8250,21 +8250,12 @@ create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch, struct exec_catchpoint : public breakpoint { - ~exec_catchpoint () override; - /* Filename of a program whose exec triggered this catchpoint. This field is only valid immediately after this catchpoint has triggered. */ - char *exec_pathname; + gdb::unique_xmalloc_ptr exec_pathname; }; -/* Exec catchpoint destructor. */ - -exec_catchpoint::~exec_catchpoint () -{ - xfree (this->exec_pathname); -} - static int insert_catch_exec (struct bp_location *bl) { @@ -8287,7 +8278,7 @@ breakpoint_hit_catch_exec (const struct bp_location *bl, if (ws->kind != TARGET_WAITKIND_EXECD) return 0; - c->exec_pathname = xstrdup (ws->value.execd_pathname); + c->exec_pathname = make_unique_xstrdup (ws->value.execd_pathname); return 1; } @@ -8311,7 +8302,7 @@ print_it_catch_exec (bpstat bs) } uiout->field_signed ("bkptno", b->number); uiout->text (" (exec'd "); - uiout->field_string ("new-exec", c->exec_pathname); + uiout->field_string ("new-exec", c->exec_pathname.get ()); uiout->text ("), "); return PRINT_SRC_AND_LOC; @@ -8336,7 +8327,7 @@ print_one_catch_exec (struct breakpoint *b, struct bp_location **last_loc) if (c->exec_pathname != NULL) { uiout->text (", program \""); - uiout->field_string ("what", c->exec_pathname); + uiout->field_string ("what", c->exec_pathname.get ()); uiout->text ("\" "); } @@ -11324,7 +11315,7 @@ catch_exec_command_1 (const char *arg, int from_tty, std::unique_ptr c (new exec_catchpoint ()); init_catchpoint (c.get (), gdbarch, temp, cond_string, &catch_exec_breakpoint_ops); - c->exec_pathname = NULL; + c->exec_pathname.reset (); install_breakpoint (0, std::move (c), 1); } -- 2.31.1