From patchwork Tue Apr 23 02:09:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32371 Received: (qmail 16707 invoked by alias); 23 Apr 2019 02:10:04 -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 16587 invoked by uid 89); 23 Apr 2019 02:10:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.0 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=caching, operating, events, auxiliary X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (192.185.185.36) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Apr 2019 02:10:02 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 52FFC400C6C59 for ; Mon, 22 Apr 2019 20:28:18 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id IksjhXLSRdnCeIksjhJ54p; 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=C3WrsZOPx1tEpTRsnA7Va9ElsjdGrJTNUppMN5v9fTs=; b=p+4Q/IQZRUtRyCnQm/8/Pdh/WX xwbECqLBcftFC+ACk0/emls1LQHOo/gm/Eb0UG+HNkiK2tezCxb8y7iiPhUv5u5ksY1saGC0DnvHk Q5CJOD082tWqZUNsPmEL3/FPo; 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-6X; Mon, 22 Apr 2019 21:10:01 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 11/14] Convert auxv.c to type-safe registry API Date: Mon, 22 Apr 2019 20:09:52 -0600 Message-Id: <20190423020955.17356-12-tom@tromey.com> In-Reply-To: <20190423020955.17356-1-tom@tromey.com> References: <20190423020955.17356-1-tom@tromey.com> This changes auxv.c to use the type-safe registry API. gdb/ChangeLog 2019-04-22 Tom Tromey * auxv.c (auxv_inferior_data): Move. Change type. (auxv_inferior_data_cleanup): Remove. (invalidate_auxv_cache_inf): Rewrite. (get_auxv_inferior_data, _initialize_auxv): Update. --- gdb/ChangeLog | 7 +++++++ gdb/auxv.c | 36 ++++++++---------------------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/gdb/auxv.c b/gdb/auxv.c index 13caa936651..d861d9319a1 100644 --- a/gdb/auxv.c +++ b/gdb/auxv.c @@ -293,9 +293,6 @@ target_auxv_parse (gdb_byte **readptr, } -/* Per-inferior data key for auxv. */ -static const struct inferior_data *auxv_inferior_data; - /* Auxiliary Vector information structure. This is used by GDB for caching purposes for each inferior. This helps reduce the overhead of transfering data from a remote target to the local host. */ @@ -304,34 +301,22 @@ struct auxv_info gdb::optional data; }; -/* Handles the cleanup of the auxv cache for inferior INF. ARG is ignored. - Frees whatever allocated space there is to be freed and sets INF's auxv cache - data pointer to NULL. +/* Per-inferior data key for auxv. */ +static const struct inferior_key auxv_inferior_data; - This function is called when the following events occur: inferior_appeared, - inferior_exit and executable_changed. */ +/* Invalidate INF's auxv cache. */ static void -auxv_inferior_data_cleanup (struct inferior *inf, void *arg) +invalidate_auxv_cache_inf (struct inferior *inf) { - struct auxv_info *info; - - info = (struct auxv_info *) inferior_data (inf, auxv_inferior_data); + struct auxv_info *info = auxv_inferior_data.get (inf); if (info != NULL) { delete info; - set_inferior_data (inf, auxv_inferior_data, NULL); + auxv_inferior_data.set (inf, NULL); } } -/* Invalidate INF's auxv cache. */ - -static void -invalidate_auxv_cache_inf (struct inferior *inf) -{ - auxv_inferior_data_cleanup (inf, NULL); -} - /* Invalidate current inferior's auxv cache. */ static void @@ -350,12 +335,11 @@ get_auxv_inferior_data (struct target_ops *ops) struct auxv_info *info; struct inferior *inf = current_inferior (); - info = (struct auxv_info *) inferior_data (inf, auxv_inferior_data); + info = auxv_inferior_data.get (inf); if (info == NULL) { - info = new auxv_info; + info = auxv_inferior_data.emplace (inf); info->data = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL); - set_inferior_data (inf, auxv_inferior_data, info); } return info; @@ -574,10 +558,6 @@ _initialize_auxv (void) _("Display the inferior's auxiliary vector.\n\ This is information provided by the operating system at program startup.")); - /* Set an auxv cache per-inferior. */ - auxv_inferior_data - = register_inferior_data_with_cleanup (NULL, auxv_inferior_data_cleanup); - /* Observers used to invalidate the auxv cache when needed. */ gdb::observers::inferior_exit.attach (invalidate_auxv_cache_inf); gdb::observers::inferior_appeared.attach (invalidate_auxv_cache_inf);