From patchwork Tue Apr 23 02:09:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32374 Received: (qmail 17625 invoked by alias); 23 Apr 2019 02:10:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 17109 invoked by uid 89); 23 Apr 2019 02:10:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Apr 2019 02:10:04 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 02DA39CC80 for ; Mon, 22 Apr 2019 21:10:02 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id Iksjhwn4V4FKpIksjhOxey; Mon, 22 Apr 2019 21:10:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=WK2xzyTzlr5zuAvnep0V0J3S7qZw5yMDjwBTa57E7G8=; b=S/PeQXdROn+SIZEGR3hmjfxqoe P7mKzPHQP/cqnPNalDlFjUA3bpj1Gx5CZ0gVMC2djRmiQ2zfO3gWf8t8WrxiEDx8WrgB/3En8zRUT vlfU2ERAZy/y0THpZWm2d3ol9; Received: from 97-122-168-123.hlrn.qwest.net ([97.122.168.123]:43470 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hIksj-000jpC-Om; Mon, 22 Apr 2019 21:10:01 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 13/14] Convert breakpoint.c to type-safe registry API Date: Mon, 22 Apr 2019 20:09:54 -0600 Message-Id: <20190423020955.17356-14-tom@tromey.com> In-Reply-To: <20190423020955.17356-1-tom@tromey.com> References: <20190423020955.17356-1-tom@tromey.com> This changes breakpoint.c to use the type-safe registry API. gdb/ChangeLog 2019-04-22 Tom Tromey * breakpoint.c (breakpoint_objfile_key): Change type. (get_breakpoint_objfile_data): Update. (free_breakpoint_objfile_data): Remove. (_initialize_breakpoint): Update. --- gdb/ChangeLog | 7 +++++++ gdb/breakpoint.c | 23 ++++------------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 3047ef3827d..6097b62e81f 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3156,7 +3156,8 @@ struct breakpoint_objfile_data std::vector exception_probes; }; -static const struct objfile_data *breakpoint_objfile_key; +static const struct objfile_key + breakpoint_objfile_key; /* Minimal symbol not found sentinel. */ static struct minimal_symbol msym_not_found; @@ -3177,25 +3178,12 @@ get_breakpoint_objfile_data (struct objfile *objfile) { struct breakpoint_objfile_data *bp_objfile_data; - bp_objfile_data = ((struct breakpoint_objfile_data *) - objfile_data (objfile, breakpoint_objfile_key)); + bp_objfile_data = breakpoint_objfile_key.get (objfile); if (bp_objfile_data == NULL) - { - bp_objfile_data = new breakpoint_objfile_data (); - set_objfile_data (objfile, breakpoint_objfile_key, bp_objfile_data); - } + bp_objfile_data = breakpoint_objfile_key.emplace (objfile); return bp_objfile_data; } -static void -free_breakpoint_objfile_data (struct objfile *obj, void *data) -{ - struct breakpoint_objfile_data *bp_objfile_data - = (struct breakpoint_objfile_data *) data; - - delete bp_objfile_data; -} - static void create_overlay_event_breakpoint (void) { @@ -15448,9 +15436,6 @@ _initialize_breakpoint (void) gdb::observers::free_objfile.attach (disable_breakpoints_in_freed_objfile); gdb::observers::memory_changed.attach (invalidate_bp_value_on_memory_change); - breakpoint_objfile_key - = register_objfile_data_with_cleanup (NULL, free_breakpoint_objfile_data); - breakpoint_chain = 0; /* Don't bother to call set_breakpoint_count. $bpnum isn't useful before a breakpoint is set. */