From patchwork Wed Jul 10 15:39:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33656 Received: (qmail 125273 invoked by alias); 10 Jul 2019 15:39:57 -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 125111 invoked by uid 89); 10 Jul 2019 15:39:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 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=HX-Languages-Length:3176 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:39:54 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 08236561E1; Wed, 10 Jul 2019 11:39:52 -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 SJUuLo6YBSvr; 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 A6ABB56128; Wed, 10 Jul 2019 11:39:51 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 6/9] Change solib-dsbt.c to use type-safe registry Date: Wed, 10 Jul 2019 09:39:44 -0600 Message-Id: <20190710153947.25721-7-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 solib-dsbt.c to use the type-safe registry. gdb/ChangeLog 2019-07-10 Tom Tromey * solib-dsbt.c (struct dsbt_info): Add initializers. (solib_dsbt_pspace_data): Change type. (dsbt_pspace_data_cleanup): Remove. (get_dsbt_info, _initialize_dsbt_solib): Update. --- gdb/ChangeLog | 7 +++++++ gdb/solib-dsbt.c | 40 ++++++++++++---------------------------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 3053c189802..59b195f491e 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -142,35 +142,29 @@ struct dsbt_info of loaded shared objects. ``main_executable_lm_info'' provides a way to get at this information so that it doesn't need to be frequently recomputed. Initialized by dsbt_relocate_main_executable. */ - struct lm_info_dsbt *main_executable_lm_info; + struct lm_info_dsbt *main_executable_lm_info = nullptr; /* Load maps for the main executable and the interpreter. These are obtained from ptrace. They are the starting point for getting into the program, and are required to find the solib list with the individual load maps for each module. */ - struct int_elf32_dsbt_loadmap *exec_loadmap; - struct int_elf32_dsbt_loadmap *interp_loadmap; + struct int_elf32_dsbt_loadmap *exec_loadmap = nullptr; + struct int_elf32_dsbt_loadmap *interp_loadmap = nullptr; /* Cached value for lm_base, below. */ - CORE_ADDR lm_base_cache; + CORE_ADDR lm_base_cache = 0; /* Link map address for main module. */ - CORE_ADDR main_lm_addr; + CORE_ADDR main_lm_addr = 0; - CORE_ADDR interp_text_sect_low; - CORE_ADDR interp_text_sect_high; - CORE_ADDR interp_plt_sect_low; - CORE_ADDR interp_plt_sect_high; + CORE_ADDR interp_text_sect_low = 0; + CORE_ADDR interp_text_sect_high = 0; + CORE_ADDR interp_plt_sect_low = 0; + CORE_ADDR interp_plt_sect_high = 0; }; /* Per-program-space data key. */ -static const struct program_space_data *solib_dsbt_pspace_data; - -static void -dsbt_pspace_data_cleanup (struct program_space *pspace, void *arg) -{ - xfree (arg); -} +static program_space_key solib_dsbt_pspace_data; /* Get the current dsbt data. If none is found yet, add it now. This function always returns a valid object. */ @@ -180,18 +174,11 @@ get_dsbt_info (void) { struct dsbt_info *info; - info = (struct dsbt_info *) program_space_data (current_program_space, - solib_dsbt_pspace_data); + info = solib_dsbt_pspace_data.get (current_program_space); if (info != NULL) return info; - info = XCNEW (struct dsbt_info); - set_program_space_data (current_program_space, solib_dsbt_pspace_data, info); - - info->lm_base_cache = 0; - info->main_lm_addr = 0; - - return info; + return solib_dsbt_pspace_data.emplace (current_program_space); } @@ -1043,9 +1030,6 @@ struct target_so_ops dsbt_so_ops; void _initialize_dsbt_solib (void) { - solib_dsbt_pspace_data - = register_program_space_data_with_cleanup (NULL, dsbt_pspace_data_cleanup); - dsbt_so_ops.relocate_section_addresses = dsbt_relocate_section_addresses; dsbt_so_ops.free_so = dsbt_free_so; dsbt_so_ops.clear_solib = dsbt_clear_solib;