diff options
Diffstat (limited to 'gdb/dwarf2/frame.c')
-rw-r--r-- | gdb/dwarf2/frame.c | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index 387a2bc..0e681f0 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -580,23 +580,39 @@ execute_cfa_program_test (struct gdbarch *gdbarch) /* Architecture-specific operations. */ -/* Per-architecture data key. */ -static struct gdbarch_data *dwarf2_frame_data; +static void dwarf2_frame_default_init_reg (struct gdbarch *gdbarch, + int regnum, + struct dwarf2_frame_state_reg *reg, + struct frame_info *this_frame); struct dwarf2_frame_ops { /* Pre-initialize the register state REG for register REGNUM. */ void (*init_reg) (struct gdbarch *, int, struct dwarf2_frame_state_reg *, - struct frame_info *); + struct frame_info *) + = dwarf2_frame_default_init_reg; /* Check whether the THIS_FRAME is a signal trampoline. */ - int (*signal_frame_p) (struct gdbarch *, struct frame_info *); + int (*signal_frame_p) (struct gdbarch *, struct frame_info *) = nullptr; /* Convert .eh_frame register number to DWARF register number, or adjust .debug_frame register number. */ - int (*adjust_regnum) (struct gdbarch *, int, int); + int (*adjust_regnum) (struct gdbarch *, int, int) = nullptr; }; +/* Per-architecture data key. */ +static const registry<gdbarch>::key<dwarf2_frame_ops> dwarf2_frame_data; + +/* Get or initialize the frame ops. */ +static dwarf2_frame_ops * +get_frame_ops (struct gdbarch *gdbarch) +{ + dwarf2_frame_ops *result = dwarf2_frame_data.get (gdbarch); + if (result == nullptr) + result = dwarf2_frame_data.emplace (gdbarch); + return result; +} + /* Default architecture-specific register state initialization function. */ @@ -637,18 +653,6 @@ dwarf2_frame_default_init_reg (struct gdbarch *gdbarch, int regnum, reg->how = DWARF2_FRAME_REG_CFA; } -/* Return a default for the architecture-specific operations. */ - -static void * -dwarf2_frame_init (struct obstack *obstack) -{ - struct dwarf2_frame_ops *ops; - - ops = OBSTACK_ZALLOC (obstack, struct dwarf2_frame_ops); - ops->init_reg = dwarf2_frame_default_init_reg; - return ops; -} - /* Set the architecture-specific register state initialization function for GDBARCH to INIT_REG. */ @@ -658,8 +662,7 @@ dwarf2_frame_set_init_reg (struct gdbarch *gdbarch, struct dwarf2_frame_state_reg *, struct frame_info *)) { - struct dwarf2_frame_ops *ops - = (struct dwarf2_frame_ops *) gdbarch_data (gdbarch, dwarf2_frame_data); + struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch); ops->init_reg = init_reg; } @@ -671,8 +674,7 @@ dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, struct frame_info *this_frame) { - struct dwarf2_frame_ops *ops - = (struct dwarf2_frame_ops *) gdbarch_data (gdbarch, dwarf2_frame_data); + struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch); ops->init_reg (gdbarch, regnum, reg, this_frame); } @@ -685,8 +687,7 @@ dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch, int (*signal_frame_p) (struct gdbarch *, struct frame_info *)) { - struct dwarf2_frame_ops *ops - = (struct dwarf2_frame_ops *) gdbarch_data (gdbarch, dwarf2_frame_data); + struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch); ops->signal_frame_p = signal_frame_p; } @@ -698,8 +699,7 @@ static int dwarf2_frame_signal_frame_p (struct gdbarch *gdbarch, struct frame_info *this_frame) { - struct dwarf2_frame_ops *ops - = (struct dwarf2_frame_ops *) gdbarch_data (gdbarch, dwarf2_frame_data); + struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch); if (ops->signal_frame_p == NULL) return 0; @@ -714,8 +714,7 @@ dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch, int (*adjust_regnum) (struct gdbarch *, int, int)) { - struct dwarf2_frame_ops *ops - = (struct dwarf2_frame_ops *) gdbarch_data (gdbarch, dwarf2_frame_data); + struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch); ops->adjust_regnum = adjust_regnum; } @@ -727,8 +726,7 @@ static int dwarf2_frame_adjust_regnum (struct gdbarch *gdbarch, int regnum, int eh_frame_p) { - struct dwarf2_frame_ops *ops - = (struct dwarf2_frame_ops *) gdbarch_data (gdbarch, dwarf2_frame_data); + struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch); if (ops->adjust_regnum == NULL) return regnum; @@ -2201,8 +2199,6 @@ void _initialize_dwarf2_frame (); void _initialize_dwarf2_frame () { - dwarf2_frame_data = gdbarch_data_register_pre_init (dwarf2_frame_init); - add_setshow_boolean_cmd ("unwinders", class_obscure, &dwarf2_frame_unwinders_enabled_p , _("\ Set whether the DWARF stack frame unwinders are used."), _("\ |