From patchwork Fri May 3 23:12:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32519 Received: (qmail 403 invoked by alias); 3 May 2019 23:12:45 -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 130675 invoked by uid 89); 3 May 2019 23:12:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.7 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=remotec, remote.c, UD:remote.c X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.46.126) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 May 2019 23:12:38 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 55491440A for ; Fri, 3 May 2019 18:12:37 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id MhM5hZYi0YTGMMhM5hdooh; Fri, 03 May 2019 18:12:37 -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=GcolE/JIiTZL3yPcukaSRnmkSkiU5xppr8VFWZza75w=; b=MHfLP+RSde9J4mOuhCNxUCO1a0 a1a9LPovkfVhd4ebjcvr5VgZ1xksJM2A+PNpzS3/f3kpo4jgiNeYEWv9MqFvAr1nuX/auUsq3qOd0 LoTEww595MDgDA2XqdTwuz4h4; 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 1hMhM5-003AAO-0H; Fri, 03 May 2019 18:12:37 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 14/31] Convert remote.c to type-safe registry API Date: Fri, 3 May 2019 17:12:14 -0600 Message-Id: <20190503231231.8954-15-tom@tromey.com> In-Reply-To: <20190503231231.8954-1-tom@tromey.com> References: <20190503231231.8954-1-tom@tromey.com> This changes remote.c to use the type-safe registry API. 2019-04-22 Tom Tromey * remote.c (remote_pspace_data): Change type. (remote_pspace_data_cleanup): Remove. (get_remote_exec_file, set_pspace_remote_exec_file) (_initialize_remote): Update. --- gdb/ChangeLog | 7 +++++++ gdb/remote.c | 28 ++++++---------------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index 5e5fbbf8c34..dd129b3407a 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -969,7 +969,8 @@ public: }; /* Per-program-space data key. */ -static const struct program_space_data *remote_pspace_data; +static const struct program_space_key> + remote_pspace_data; /* The variable registered as the control variable used by the remote exec-file commands. While the remote exec-file setting is @@ -1229,16 +1230,6 @@ remote_target::get_remote_state () return &m_remote_state; } -/* Cleanup routine for the remote module's pspace data. */ - -static void -remote_pspace_data_cleanup (struct program_space *pspace, void *arg) -{ - char *remote_exec_file = (char *) arg; - - xfree (remote_exec_file); -} - /* Fetch the remote exec-file from the current program space. */ static const char * @@ -1246,9 +1237,7 @@ get_remote_exec_file (void) { char *remote_exec_file; - remote_exec_file - = (char *) program_space_data (current_program_space, - remote_pspace_data); + remote_exec_file = remote_pspace_data.get (current_program_space); if (remote_exec_file == NULL) return ""; @@ -1259,13 +1248,12 @@ get_remote_exec_file (void) static void set_pspace_remote_exec_file (struct program_space *pspace, - char *remote_exec_file) + const char *remote_exec_file) { - char *old_file = (char *) program_space_data (pspace, remote_pspace_data); + char *old_file = remote_pspace_data.get (pspace); xfree (old_file); - set_program_space_data (pspace, remote_pspace_data, - xstrdup (remote_exec_file)); + remote_pspace_data.set (pspace, xstrdup (remote_exec_file)); } /* The "set/show remote exec-file" set command hook. */ @@ -14263,10 +14251,6 @@ _initialize_remote (void) remote_g_packet_data_handle = gdbarch_data_register_pre_init (remote_g_packet_data_init); - remote_pspace_data - = register_program_space_data_with_cleanup (NULL, - remote_pspace_data_cleanup); - add_target (remote_target_info, remote_target::open); add_target (extended_remote_target_info, extended_remote_target::open);