From patchwork Fri May 3 23:12:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32527 Received: (qmail 1053 invoked by alias); 3 May 2019 23:12:48 -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 477 invoked by uid 89); 3 May 2019 23:12:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.4 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=*thread, dat X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.143.38) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 May 2019 23:12:40 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 5B39CCBB6 for ; Fri, 3 May 2019 18:12:39 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id MhM7hLRlV2qH7MhM7he37r; Fri, 03 May 2019 18:12:39 -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=aPwZu3+gTDm++HvbNHmwD4+hYBwM9dG3gi0f1uQ07FY=; b=q4XQ8irScpiUzVaNQM4t8G8MbV NDIwwzha1dFfRCeq5iOmDUiRIeAn11LEo/kZ8VnVE9ZE5hW9rO2HNC9YC01wJkhzVCV4ZLd6Y5caL 9/jWy8cleg7uDQUkV1R3boZNU; 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 1hMhM7-003AAO-5i; Fri, 03 May 2019 18:12:39 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 22/31] Convert nto-tdep.c to type-safe registry API Date: Fri, 3 May 2019 17:12:22 -0600 Message-Id: <20190503231231.8954-23-tom@tromey.com> In-Reply-To: <20190503231231.8954-1-tom@tromey.com> References: <20190503231231.8954-1-tom@tromey.com> This changes nto-tdep.c to use the type-safe registry API. 2019-05-01 Tom Tromey * nto-tdep.c (nto_inferior_data_reg): Change type. (nto_inferior_data): Update. (nto_inferior_data_cleanup, nto_new_inferior_data) (_initialize_nto_tdep): Remove. * nto-tdep.h (struct nto_inferior_data): Add initializers. --- gdb/ChangeLog | 8 ++++++++ gdb/nto-tdep.c | 37 ++++--------------------------------- gdb/nto-tdep.h | 4 ++-- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c index 0caa55c2493..48e731acd05 100644 --- a/gdb/nto-tdep.c +++ b/gdb/nto-tdep.c @@ -51,7 +51,8 @@ static char default_nto_target[] = ""; struct nto_target_ops current_nto_target; -static const struct inferior_data *nto_inferior_data_reg; +static const struct inferior_key + nto_inferior_data_reg; static char * nto_target (void) @@ -498,25 +499,6 @@ nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack, gdb_byte *readbuf, return len_read; } -/* Allocate new nto_inferior_data object. */ - -static struct nto_inferior_data * -nto_new_inferior_data (void) -{ - struct nto_inferior_data *const inf_data - = XCNEW (struct nto_inferior_data); - - return inf_data; -} - -/* Free inferior data. */ - -static void -nto_inferior_data_cleanup (struct inferior *const inf, void *const dat) -{ - xfree (dat); -} - /* Return nto_inferior_data for the given INFERIOR. If not yet created, construct it. */ @@ -528,20 +510,9 @@ nto_inferior_data (struct inferior *const inferior) gdb_assert (inf != NULL); - inf_data - = (struct nto_inferior_data *) inferior_data (inf, nto_inferior_data_reg); + inf_data = nto_inferior_data_reg.get (inf); if (inf_data == NULL) - { - set_inferior_data (inf, nto_inferior_data_reg, - (inf_data = nto_new_inferior_data ())); - } + inf_data = nto_inferior_data_reg.emplace (inf); return inf_data; } - -void -_initialize_nto_tdep (void) -{ - nto_inferior_data_reg - = register_inferior_data_with_cleanup (NULL, nto_inferior_data_cleanup); -} diff --git a/gdb/nto-tdep.h b/gdb/nto-tdep.h index 5127ab3f9ed..2410a03a4a6 100644 --- a/gdb/nto-tdep.h +++ b/gdb/nto-tdep.h @@ -152,10 +152,10 @@ get_nto_thread_info (thread_info *thread) struct nto_inferior_data { /* Last stopped flags result from wait function */ - unsigned int stopped_flags; + unsigned int stopped_flags = 0; /* Last known stopped PC */ - CORE_ADDR stopped_pc; + CORE_ADDR stopped_pc = 0; }; /* Generic functions in nto-tdep.c. */