From patchwork Wed Jul 10 15:39:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33660 Received: (qmail 88338 invoked by alias); 10 Jul 2019 15:49:11 -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 88323 invoked by uid 89); 10 Jul 2019 15:49:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.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_PASS autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 Jul 2019 15:49:09 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 93924561E0; Wed, 10 Jul 2019 11:39:51 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id NUG2vGsIlahr; Wed, 10 Jul 2019 11:39:51 -0400 (EDT) Received: from murgatroyd.Home (97-122-178-82.hlrn.qwest.net [97.122.178.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 3F9E156128; Wed, 10 Jul 2019 11:39:51 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 5/9] Change spu-tdep.c to use type-safe registry Date: Wed, 10 Jul 2019 09:39:43 -0600 Message-Id: <20190710153947.25721-6-tromey@adacore.com> In-Reply-To: <20190710153947.25721-1-tromey@adacore.com> References: <20190710153947.25721-1-tromey@adacore.com> MIME-Version: 1.0 This changes spu-tdep.c to use the type-safe registry. gdb/ChangeLog 2019-07-10 Tom Tromey * spu-tdep.c (spu_overlay_data): Change type. (spu_get_overlay_table, spu_overlay_new_objfile) (_initialize_spu_tdep): Update. --- gdb/ChangeLog | 6 ++++++ gdb/spu-tdep.c | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c index a2ac3149d4d..69ffb69fcb9 100644 --- a/gdb/spu-tdep.c +++ b/gdb/spu-tdep.c @@ -1767,14 +1767,15 @@ gdb_print_insn_spu (bfd_vma memaddr, struct disassemble_info *info) a target address. The overlay section is mapped iff the target integer at this location equals MAPPED_VAL. */ -static const struct objfile_data *spu_overlay_data; - struct spu_overlay_table { CORE_ADDR mapped_ptr; CORE_ADDR mapped_val; }; +static objfile_key> spu_overlay_data; + /* Retrieve the overlay table for OBJFILE. If not already cached, read the _ovly_table data structure from the target and initialize the spu_overlay_table data structure from it. */ @@ -1791,7 +1792,7 @@ spu_get_overlay_table (struct objfile *objfile) gdb_byte *ovly_table; int i; - tbl = (struct spu_overlay_table *) objfile_data (objfile, spu_overlay_data); + tbl = spu_overlay_data.get (objfile); if (tbl) return tbl; @@ -1843,7 +1844,7 @@ spu_get_overlay_table (struct objfile *objfile) } xfree (ovly_table); - set_objfile_data (objfile, spu_overlay_data, tbl); + spu_overlay_data.set (objfile, tbl); return tbl; } @@ -1901,7 +1902,7 @@ spu_overlay_new_objfile (struct objfile *objfile) struct obj_section *osect; /* If we've already touched this file, do nothing. */ - if (!objfile || objfile_data (objfile, spu_overlay_data) != NULL) + if (!objfile || spu_overlay_data.get (objfile) != NULL) return; /* Consider only SPU objfiles. */ @@ -2765,7 +2766,6 @@ _initialize_spu_tdep (void) /* Add ourselves to objfile event chain. */ gdb::observers::new_objfile.attach (spu_overlay_new_objfile); - spu_overlay_data = register_objfile_data (); /* Install spu stop-on-load handler. */ gdb::observers::new_objfile.attach (spu_catch_start);