This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 3/9] Change jit.c to use type-safe registry
> diff --git a/gdb/jit.c b/gdb/jit.c
> index 62942fc7ab0..fba2482ff13 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);
>
> @@ -263,6 +261,8 @@ struct jit_program_space_data
> struct breakpoint *jit_breakpoint;
> };
>
> +static program_space_key<jit_program_space_data> 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;
> }
Do the fields of jit_program_space_data need to be initialized? The previous code used
XCNEW, initializing them to 0.
Simon