From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 663 invoked by alias); 3 May 2019 23:12:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 130951 invoked by uid 89); 3 May 2019 23:12:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.45.133) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 May 2019 23:12:39 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 8B3AF400D2835 for ; Fri, 3 May 2019 18:12:38 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id MhM6hZYj3YTGMMhM6hdope; Fri, 03 May 2019 18:12:38 -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=Y40pAV6B/lXVjK6gkHqtDhrIGyqvcvhx4vkGEpi3PZA=; b=Qkx9C5Rc1CuRwq60Vk5X4qd59S MtgJjPR05fTg9RwqbhJjz+V6RO11v/AoH/7pYWjvXXIflqhF+MOhifMWgUaJFHarQTF8iXUzjs1rD iwUTlTOs3OpV5W1TEJxaRbQXi; 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 1hMhM6-003AAO-Bg; Fri, 03 May 2019 18:12:38 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 19/31] Convert fbsd-tdep.c to type-safe registry API Date: Fri, 03 May 2019 23:12:00 -0000 Message-Id: <20190503231231.8954-20-tom@tromey.com> In-Reply-To: <20190503231231.8954-1-tom@tromey.com> References: <20190503231231.8954-1-tom@tromey.com> X-SW-Source: 2019-05/txt/msg00096.txt.bz2 This changes fbsd-tdep.c to use the type-safe registry API. 2019-05-01 Tom Tromey * fbsd-tdep.c (struct fbsd_pspace_data): Add initializers. (fbsd_pspace_data_handle): Move lower. Change type. (get_fbsd_pspace_data): Update. (fbsd_pspace_data_cleanup): Remove. (_initialize_fbsd_tdep): Update. --- gdb/ChangeLog | 8 ++++++++ gdb/fbsd-tdep.c | 31 +++++++++---------------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 4efa0f7ae11..cc7c2b7ab2f 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -445,41 +445,30 @@ get_fbsd_gdbarch_data (struct gdbarch *gdbarch) gdbarch_data (gdbarch, fbsd_gdbarch_data_handle)); } -/* Per-program-space data for FreeBSD architectures. */ -static const struct program_space_data *fbsd_pspace_data_handle; - struct fbsd_pspace_data { /* Offsets in the runtime linker's 'Obj_Entry' structure. */ - LONGEST off_linkmap; - LONGEST off_tlsindex; - bool rtld_offsets_valid; + LONGEST off_linkmap = 0; + LONGEST off_tlsindex = 0; + bool rtld_offsets_valid = false; }; +/* Per-program-space data for FreeBSD architectures. */ +static const struct program_space_key + fbsd_pspace_data_handle; + static struct fbsd_pspace_data * get_fbsd_pspace_data (struct program_space *pspace) { struct fbsd_pspace_data *data; - data = ((struct fbsd_pspace_data *) - program_space_data (pspace, fbsd_pspace_data_handle)); + data = fbsd_pspace_data_handle.get (pspace); if (data == NULL) - { - data = XCNEW (struct fbsd_pspace_data); - set_program_space_data (pspace, fbsd_pspace_data_handle, data); - } + data = fbsd_pspace_data_handle.emplace (pspace); return data; } -/* The cleanup callback for FreeBSD architecture per-program-space data. */ - -static void -fbsd_pspace_data_cleanup (struct program_space *pspace, void *data) -{ - xfree (data); -} - /* This is how we want PTIDs from core files to be printed. */ static std::string @@ -2100,6 +2089,4 @@ _initialize_fbsd_tdep (void) { fbsd_gdbarch_data_handle = gdbarch_data_register_post_init (init_fbsd_gdbarch_data); - fbsd_pspace_data_handle - = register_program_space_data_with_cleanup (NULL, fbsd_pspace_data_cleanup); } -- 2.17.2