From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117467 invoked by alias); 10 Jul 2019 20:35:38 -0000 Mailing-List: contact gdb-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: , Sender: gdb-cvs-owner@sourceware.org List-Subscribe: Sender: gdb-cvs-owner@sourceware.org Received: (qmail 117448 invoked by uid 306); 10 Jul 2019 20:35:38 -0000 Date: Wed, 10 Jul 2019 20:35:00 -0000 Message-ID: <20190710203538.117447.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Change jit.c to use type-safe registry X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 51df2ae3029caafd2b832e19d2978114a7e25a8a X-Git-Newrev: cb60f4208b2b920614306937b62bf15700824ee0 X-SW-Source: 2019-07/txt/msg00049.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cb60f4208b2b920614306937b62bf15700824ee0 commit cb60f4208b2b920614306937b62bf15700824ee0 Author: Tom Tromey Date: Wed Jun 26 12:47:44 2019 -0600 Change jit.c to use type-safe registry This changes jit.c to use the type-safe registry. Only one of the registry keys in jit.c is converted; the other is trickier and so I've left it be for now. gdb/ChangeLog 2019-07-10 Tom Tromey * jit.c (jit_program_space_key): Change type. Move lower. (get_jit_program_space_data): Update. (jit_program_space_data_cleanup): Remove. (jit_breakpoint_deleted, free_objfile_data, _initialize_jit): Update. (struct jit_program_space_data): Add initializers. Diff: --- gdb/ChangeLog | 9 +++++++++ gdb/jit.c | 39 ++++++++++----------------------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a4379f5..41311c8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2019-07-10 Tom Tromey + * jit.c (jit_program_space_key): Change type. Move lower. + (get_jit_program_space_data): Update. + (jit_program_space_data_cleanup): Remove. + (jit_breakpoint_deleted, free_objfile_data, _initialize_jit): + Update. + (struct jit_program_space_data): Add initializers. + +2019-07-10 Tom Tromey + * solib-darwin.c (struct darwin_info): Add initializers. (solib_darwin_pspace_data): Change type. (darwin_pspace_data_cleanup): Remove. diff --git a/gdb/jit.c b/gdb/jit.c index 62942fc..ce73e3f 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -50,8 +50,6 @@ static const char *const jit_break_name = "__jit_debug_register_code"; static const char *const jit_descriptor_name = "__jit_debug_descriptor"; -static const struct program_space_data *jit_program_space_data = NULL; - static void jit_inferior_init (struct gdbarch *gdbarch); static void jit_inferior_exit_hook (struct inferior *inf); @@ -249,20 +247,22 @@ struct jit_program_space_data /* The objfile. This is NULL if no objfile holds the JIT symbols. */ - struct objfile *objfile; + struct objfile *objfile = nullptr; /* If this program space has __jit_debug_register_code, this is the cached address from the minimal symbol. This is used to detect relocations requiring the breakpoint to be re-created. */ - CORE_ADDR cached_code_address; + CORE_ADDR cached_code_address = 0; /* This is the JIT event breakpoint, or NULL if it has not been set. */ - struct breakpoint *jit_breakpoint; + struct breakpoint *jit_breakpoint = nullptr; }; +static program_space_key jit_program_space_key; + /* Per-objfile structure recording the addresses in the program space. This object serves two purposes: for ordinary objfiles, it may cache some symbols related to the JIT interface; and for @@ -316,29 +316,16 @@ add_objfile_entry (struct objfile *objfile, CORE_ADDR entry) if not already present. */ static struct jit_program_space_data * -get_jit_program_space_data (void) +get_jit_program_space_data () { struct jit_program_space_data *ps_data; - ps_data - = ((struct jit_program_space_data *) - program_space_data (current_program_space, jit_program_space_data)); + ps_data = jit_program_space_key.get (current_program_space); if (ps_data == NULL) - { - ps_data = XCNEW (struct jit_program_space_data); - set_program_space_data (current_program_space, jit_program_space_data, - ps_data); - } - + ps_data = jit_program_space_key.emplace (current_program_space); return ps_data; } -static void -jit_program_space_data_cleanup (struct program_space *ps, void *arg) -{ - xfree (arg); -} - /* Helper function for reading the global JIT descriptor from remote memory. Returns 1 if all went well, 0 otherwise. */ @@ -1008,8 +995,7 @@ jit_breakpoint_deleted (struct breakpoint *b) { struct jit_program_space_data *ps_data; - ps_data = ((struct jit_program_space_data *) - program_space_data (iter->pspace, jit_program_space_data)); + ps_data = jit_program_space_key.get (iter->pspace); if (ps_data != NULL && ps_data->jit_breakpoint == iter->owner) { ps_data->cached_code_address = 0; @@ -1448,9 +1434,7 @@ free_objfile_data (struct objfile *objfile, void *data) { struct jit_program_space_data *ps_data; - ps_data - = ((struct jit_program_space_data *) - program_space_data (objfile->pspace, jit_program_space_data)); + ps_data = jit_program_space_key.get (objfile->pspace); if (ps_data != NULL && ps_data->objfile == objfile) { ps_data->objfile = NULL; @@ -1496,9 +1480,6 @@ _initialize_jit (void) jit_objfile_data = register_objfile_data_with_cleanup (NULL, free_objfile_data); - jit_program_space_data = - register_program_space_data_with_cleanup (NULL, - jit_program_space_data_cleanup); jit_gdbarch_data = gdbarch_data_register_pre_init (jit_gdbarch_data_init); if (is_dl_available ()) {