From patchwork Fri May 3 23:12:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32517 Received: (qmail 343 invoked by alias); 3 May 2019 23:12:44 -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 130543 invoked by uid 89); 3 May 2019 23:12:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.6 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: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.54.2) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 May 2019 23:12:38 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway20.websitewelcome.com (Postfix) with ESMTP id E22C1400C44FD for ; Fri, 3 May 2019 18:12:36 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id MhM4h1y1M4FKpMhM4hS2mV; Fri, 03 May 2019 18:12:36 -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=E1vR4q6oFFzmLruI74cWZNsCwT5R+4oYAIFNlMa8vPU=; b=K9m88gGQniAtgLiOv+yYzLRPa5 7vw4d5kf4RZBMKlV58pRjfw/WsF08OhEf3g2I82RmvnRFBh8n0GI0cZUAh4+dpZ9TaIpa6VUdQ5u2 GcTYJ+eThUfvh4K0OJy4XqeCJ; Received: from 97-122-168-123.hlrn.qwest.net ([97.122.168.123]:37502 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hMhM4-003AAO-NM; Fri, 03 May 2019 18:12:36 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 13/31] Convert breakpoint.c to type-safe registry API Date: Fri, 3 May 2019 17:12:13 -0600 Message-Id: <20190503231231.8954-14-tom@tromey.com> In-Reply-To: <20190503231231.8954-1-tom@tromey.com> References: <20190503231231.8954-1-tom@tromey.com> This changes breakpoint.c to use the type-safe registry API. 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 f6d2f36d0a4..35da97bd041 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. */