diff options
-rw-r--r-- | gdb/ChangeLog | 30 | ||||
-rw-r--r-- | gdb/aarch64-tdep.c | 19 | ||||
-rw-r--r-- | gdb/arc-tdep.c | 17 | ||||
-rw-r--r-- | gdb/arm-tdep.c | 61 | ||||
-rw-r--r-- | gdb/i386-tdep.c | 10 | ||||
-rw-r--r-- | gdb/m68k-tdep.c | 26 | ||||
-rw-r--r-- | gdb/microblaze-tdep.c | 15 | ||||
-rw-r--r-- | gdb/mips-tdep.c | 74 | ||||
-rw-r--r-- | gdb/nds32-tdep.c | 14 | ||||
-rw-r--r-- | gdb/nios2-tdep.c | 13 | ||||
-rw-r--r-- | gdb/or1k-tdep.c | 11 | ||||
-rw-r--r-- | gdb/riscv-tdep.c | 19 | ||||
-rw-r--r-- | gdb/rs6000-tdep.c | 184 | ||||
-rw-r--r-- | gdb/rx-tdep.c | 13 | ||||
-rw-r--r-- | gdb/s390-tdep.c | 10 | ||||
-rw-r--r-- | gdb/sparc-tdep.c | 17 | ||||
-rw-r--r-- | gdb/target-descriptions.c | 17 | ||||
-rw-r--r-- | gdb/target-descriptions.h | 22 | ||||
-rw-r--r-- | gdb/tic6x-tdep.c | 40 |
19 files changed, 250 insertions, 362 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4b54f4e..45940b9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,33 @@ +2020-09-17 Tom Tromey <tromey@adacore.com> + + * tic6x-tdep.c (tic6x_gdbarch_init): Update. + * target-descriptions.h (struct tdesc_arch_data_deleter): New. + (tdesc_arch_data_up): New typedef. + (tdesc_use_registers, tdesc_data_alloc): Update. + (tdesc_data_cleanup): Don't declare. + * target-descriptions.c (tdesc_data_alloc): Return a + tdesc_arch_data_up. + (tdesc_arch_data_deleter::operator()): Rename from + tdesc_data_cleanup. Change argument type. + (tdesc_use_registers): Change early_data to an rvalue reference. + (tdesc_use_registers): Don't use delete. + * sparc-tdep.c (sparc32_gdbarch_init): Update. + * s390-tdep.c (s390_gdbarch_init): Update. + * rx-tdep.c (rx_gdbarch_init): Update. + * rs6000-tdep.c (rs6000_gdbarch_init): Update. + * riscv-tdep.c (riscv_gdbarch_init): Update. + * or1k-tdep.c (or1k_gdbarch_init): Update. + * nios2-tdep.c (nios2_gdbarch_init): Update. + * nds32-tdep.c (nds32_gdbarch_init): Update. + * mips-tdep.c (mips_gdbarch_init): Update. + * microblaze-tdep.c (microblaze_gdbarch_init): Update. + * m68k-tdep.c (m68k_gdbarch_init): Update. + * i386-tdep.c (i386_gdbarch_init): Update. + * arm-tdep.c (arm_gdbarch_init): Update. + * arc-tdep.c (arc_tdesc_init): Update. + (arc_gdbarch_init): Update. + * aarch64-tdep.c (aarch64_gdbarch_init): Update. + 2020-09-17 Hannes Domani <ssbssa@yahoo.de> * windows-nat.c (ctrl_c_handler): Use 32bit DbgUiRemoteBreakin diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index a2547d1..cbc7038 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -3403,12 +3403,12 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (feature_core == nullptr) return nullptr; - struct tdesc_arch_data *tdesc_data = tdesc_data_alloc (); + tdesc_arch_data_up tdesc_data = tdesc_data_alloc (); /* Validate the description provides the mandatory core R registers and allocate their numbers. */ for (i = 0; i < ARRAY_SIZE (aarch64_r_register_names); i++) - valid_p &= tdesc_numbered_register (feature_core, tdesc_data, + valid_p &= tdesc_numbered_register (feature_core, tdesc_data.get (), AARCH64_X0_REGNUM + i, aarch64_r_register_names[i]); @@ -3423,7 +3423,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Validate the description provides the mandatory V registers and allocate their numbers. */ for (i = 0; i < ARRAY_SIZE (aarch64_v_register_names); i++) - valid_p &= tdesc_numbered_register (feature_fpu, tdesc_data, + valid_p &= tdesc_numbered_register (feature_fpu, tdesc_data.get (), AARCH64_V0_REGNUM + i, aarch64_v_register_names[i]); @@ -3436,7 +3436,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Validate the description provides the mandatory SVE registers and allocate their numbers. */ for (i = 0; i < ARRAY_SIZE (aarch64_sve_register_names); i++) - valid_p &= tdesc_numbered_register (feature_sve, tdesc_data, + valid_p &= tdesc_numbered_register (feature_sve, tdesc_data.get (), AARCH64_SVE_Z0_REGNUM + i, aarch64_sve_register_names[i]); @@ -3461,7 +3461,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Validate the descriptor provides the mandatory PAUTH registers and allocate their numbers. */ for (i = 0; i < ARRAY_SIZE (aarch64_pauth_register_names); i++) - valid_p &= tdesc_numbered_register (feature_pauth, tdesc_data, + valid_p &= tdesc_numbered_register (feature_pauth, tdesc_data.get (), first_pauth_regnum + i, aarch64_pauth_register_names[i]); @@ -3470,10 +3470,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return nullptr; - } + return nullptr; /* AArch64 code is always little-endian. */ info.byte_order_for_code = BFD_ENDIAN_LITTLE; @@ -3554,7 +3551,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Hook in the ABI-specific overrides, if they have been registered. */ info.target_desc = tdesc; - info.tdesc_data = tdesc_data; + info.tdesc_data = tdesc_data.get (); gdbarch_init_osabi (info, gdbarch); dwarf2_frame_set_init_reg (gdbarch, aarch64_dwarf2_frame_init_reg); @@ -3583,7 +3580,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_get_pc_address_flags (gdbarch, aarch64_get_pc_address_flags); - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); /* Add standard register aliases. */ for (i = 0; i < ARRAY_SIZE (aarch64_register_aliases); i++) diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index 6f544bf..6878875 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -2076,7 +2076,7 @@ arc_check_for_hw_loops (const struct target_desc *tdesc, static bool arc_tdesc_init (struct gdbarch_info info, const struct target_desc **tdesc, - struct tdesc_arch_data **tdesc_data) + tdesc_arch_data_up *tdesc_data) { const struct target_desc *tdesc_loc = info.target_desc; if (arc_debug) @@ -2125,15 +2125,15 @@ arc_tdesc_init (struct gdbarch_info info, const struct target_desc **tdesc, const arc_register_feature *arc_aux_reg_feature = determine_aux_reg_feature_set (); - struct tdesc_arch_data *tdesc_data_loc = tdesc_data_alloc (); + tdesc_arch_data_up tdesc_data_loc = tdesc_data_alloc (); arc_update_acc_reg_names (info.byte_order); - bool valid_p = arc_check_tdesc_feature (tdesc_data_loc, + bool valid_p = arc_check_tdesc_feature (tdesc_data_loc.get (), feature_core, arc_core_reg_feature); - valid_p &= arc_check_tdesc_feature (tdesc_data_loc, + valid_p &= arc_check_tdesc_feature (tdesc_data_loc.get (), feature_aux, arc_aux_reg_feature); @@ -2141,12 +2141,11 @@ arc_tdesc_init (struct gdbarch_info info, const struct target_desc **tdesc, { if (arc_debug) debug_printf ("arc: Target description is not valid\n"); - tdesc_data_cleanup (tdesc_data_loc); return false; } *tdesc = tdesc_loc; - *tdesc_data = tdesc_data_loc; + *tdesc_data = std::move (tdesc_data_loc); return true; } @@ -2185,7 +2184,7 @@ static struct gdbarch * arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { const struct target_desc *tdesc; - struct tdesc_arch_data *tdesc_data; + tdesc_arch_data_up tdesc_data; if (arc_debug) debug_printf ("arc: Architecture initialization.\n"); @@ -2198,7 +2197,7 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) gdb::unique_xmalloc_ptr<struct gdbarch_tdep> tdep (XCNEW (struct gdbarch_tdep)); tdep->jb_pc = -1; /* No longjmp support by default. */ - tdep->has_hw_loops = arc_check_for_hw_loops (tdesc, tdesc_data); + tdep->has_hw_loops = arc_check_for_hw_loops (tdesc, tdesc_data.get ()); struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep.release ()); /* Data types. */ @@ -2338,7 +2337,7 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } } - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); return gdbarch; } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 5470332..23da42f 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -8967,7 +8967,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) struct gdbarch_list *best_arch; enum arm_abi_kind arm_abi = arm_abi_global; enum arm_float_model fp_model = arm_fp_model; - struct tdesc_arch_data *tdesc_data = NULL; + tdesc_arch_data_up tdesc_data; int i; bool is_m = false; int vfp_register_count = 0; @@ -9156,29 +9156,26 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < ARM_SP_REGNUM; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, i, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, arm_register_names[i]); - valid_p &= tdesc_numbered_register_choices (feature, tdesc_data, + valid_p &= tdesc_numbered_register_choices (feature, tdesc_data.get (), ARM_SP_REGNUM, arm_sp_names); - valid_p &= tdesc_numbered_register_choices (feature, tdesc_data, + valid_p &= tdesc_numbered_register_choices (feature, tdesc_data.get (), ARM_LR_REGNUM, arm_lr_names); - valid_p &= tdesc_numbered_register_choices (feature, tdesc_data, + valid_p &= tdesc_numbered_register_choices (feature, tdesc_data.get (), ARM_PC_REGNUM, arm_pc_names); if (is_m) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), ARM_PS_REGNUM, "xpsr"); else - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), ARM_PS_REGNUM, "cpsr"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; feature = tdesc_find_feature (tdesc, "org.gnu.gdb.arm.fpa"); @@ -9186,13 +9183,10 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { valid_p = 1; for (i = ARM_F0_REGNUM; i <= ARM_FPS_REGNUM; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, i, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, arm_register_names[i]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; } else have_fpa_registers = false; @@ -9211,25 +9205,22 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = ARM_WR0_REGNUM; i <= ARM_WR15_REGNUM; i++) valid_p - &= tdesc_numbered_register (feature, tdesc_data, i, + &= tdesc_numbered_register (feature, tdesc_data.get (), i, iwmmxt_names[i - ARM_WR0_REGNUM]); /* Check for the control registers, but do not fail if they are missing. */ for (i = ARM_WC0_REGNUM; i <= ARM_WCASF_REGNUM; i++) - tdesc_numbered_register (feature, tdesc_data, i, + tdesc_numbered_register (feature, tdesc_data.get (), i, iwmmxt_names[i - ARM_WR0_REGNUM]); for (i = ARM_WCGR0_REGNUM; i <= ARM_WCGR3_REGNUM; i++) valid_p - &= tdesc_numbered_register (feature, tdesc_data, i, + &= tdesc_numbered_register (feature, tdesc_data.get (), i, iwmmxt_names[i - ARM_WR0_REGNUM]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_wmmx_registers = true; } @@ -9253,7 +9244,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < 32; i++) { - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), ARM_D0_REGNUM + i, vfp_double_names[i]); if (!valid_p) @@ -9263,13 +9254,10 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; /* Also require FPSCR. */ - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), ARM_FPSCR_REGNUM, "fpscr"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; if (tdesc_unnumbered_register (feature, "s0") == 0) have_vfp_pseudos = true; @@ -9285,10 +9273,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { /* NEON requires 32 double-precision registers. */ if (i != 32) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; /* If there are quad registers defined by the stub, use their type; otherwise (normally) provide them with @@ -9328,11 +9313,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } if (best_arch != NULL) - { - if (tdesc_data != NULL) - tdesc_data_cleanup (tdesc_data); - return best_arch->gdbarch; - } + return best_arch->gdbarch; tdep = XCNEW (struct gdbarch_tdep); gdbarch = gdbarch_alloc (&info, tdep); @@ -9534,11 +9515,11 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_pseudo_register_write (gdbarch, arm_pseudo_write); } - if (tdesc_data) + if (tdesc_data != nullptr) { set_tdesc_pseudo_register_name (gdbarch, arm_register_name); - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); /* Override tdesc_register_type to adjust the types of VFP registers for NEON. */ diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 14e5b31..95cfe5b 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -8430,7 +8430,6 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch_tdep *tdep; struct gdbarch *gdbarch; - struct tdesc_arch_data *tdesc_data; const struct target_desc *tdesc; int mm0_regnum; int ymm0_regnum; @@ -8669,7 +8668,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* No segment base registers. */ tdep->fsbase_regnum = -1; - tdesc_data = tdesc_data_alloc (); + tdesc_arch_data_up tdesc_data = tdesc_data_alloc (); set_gdbarch_relocate_instruction (gdbarch, i386_relocate_instruction); @@ -8682,12 +8681,11 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Hook in ABI-specific overrides, if they have been registered. Note: If INFO specifies a 64 bit arch, this is where we turn a 32-bit i386 into a 64-bit amd64. */ - info.tdesc_data = tdesc_data; + info.tdesc_data = tdesc_data.get (); gdbarch_init_osabi (info, gdbarch); - if (!i386_validate_tdesc_p (tdep, tdesc_data)) + if (!i386_validate_tdesc_p (tdep, tdesc_data.get ())) { - tdesc_data_cleanup (tdesc_data); xfree (tdep); gdbarch_free (gdbarch); return NULL; @@ -8709,7 +8707,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Target description may be changed. */ tdesc = tdep->tdesc; - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); /* Override gdbarch_register_reggroup_p set in tdesc_use_registers. */ set_gdbarch_register_reggroup_p (gdbarch, tdep->register_reggroup_p); diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 76046c0..193916d 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -1130,7 +1130,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) struct gdbarch_tdep *tdep = NULL; struct gdbarch *gdbarch; struct gdbarch_list *best_arch; - struct tdesc_arch_data *tdesc_data = NULL; + tdesc_arch_data_up tdesc_data; int i; enum m68k_flavour flavour = m68k_no_flavour; int has_fp = 1; @@ -1168,14 +1168,11 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i <= M68K_PC_REGNUM; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, i, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, m68k_register_names[i]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; feature = tdesc_find_feature (info.target_desc, "org.gnu.gdb.coldfire.fp"); @@ -1183,13 +1180,10 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { valid_p = 1; for (i = M68K_FP0_REGNUM; i <= M68K_FPI_REGNUM; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, i, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, m68k_register_names[i]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; } else has_fp = 0; @@ -1246,11 +1240,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } if (best_arch != NULL) - { - if (tdesc_data != NULL) - tdesc_data_cleanup (tdesc_data); - return best_arch->gdbarch; - } + return best_arch->gdbarch; tdep = XCNEW (struct gdbarch_tdep); gdbarch = gdbarch_alloc (&info, tdep); @@ -1327,8 +1317,8 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) frame_unwind_append_unwinder (gdbarch, &m68k_frame_unwind); - if (tdesc_data) - tdesc_use_registers (gdbarch, info.target_desc, tdesc_data); + if (tdesc_data != nullptr) + tdesc_use_registers (gdbarch, info.target_desc, std::move (tdesc_data)); return gdbarch; } diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c index edabe9e..b5da32e 100644 --- a/gdb/microblaze-tdep.c +++ b/gdb/microblaze-tdep.c @@ -651,7 +651,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch_tdep *tdep; struct gdbarch *gdbarch; - struct tdesc_arch_data *tdesc_data = NULL; + tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; /* If there is already a candidate, use it. */ @@ -676,26 +676,23 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < MICROBLAZE_NUM_CORE_REGS; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, i, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, microblaze_register_names[i]); feature = tdesc_find_feature (tdesc, "org.gnu.gdb.microblaze.stack-protect"); if (feature != NULL) { valid_p = 1; - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), MICROBLAZE_SLR_REGNUM, "rslr"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), MICROBLAZE_SHR_REGNUM, "rshr"); } if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; } /* Allocate space for the new architecture. */ @@ -748,7 +745,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) frame_unwind_append_unwinder (gdbarch, µblaze_frame_unwind); frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer); if (tdesc_data != NULL) - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); return gdbarch; } diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 48ee822..b4ed734 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -8047,7 +8047,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) enum mips_abi mips_abi, found_abi, wanted_abi; int i, num_regs; enum mips_fpu_type fpu_type; - struct tdesc_arch_data *tdesc_data = NULL; + tdesc_arch_data_up tdesc_data; int elf_fpu_type = Val_GNU_MIPS_ABI_FP_ANY; const char * const *reg_names; struct mips_regnum mips_regnum, *regnum; @@ -8310,73 +8310,58 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = MIPS_ZERO_REGNUM; i <= MIPS_RA_REGNUM; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, i, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, mips_gprs[i]); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), mips_regnum.lo, "lo"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), mips_regnum.hi, "hi"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), mips_regnum.pc, "pc"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; feature = tdesc_find_feature (info.target_desc, "org.gnu.gdb.mips.cp0"); if (feature == NULL) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; valid_p = 1; - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), mips_regnum.badvaddr, "badvaddr"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), MIPS_PS_REGNUM, "status"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), mips_regnum.cause, "cause"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; /* FIXME drow/2007-05-17: The FPU should be optional. The MIPS backend is not prepared for that, though. */ feature = tdesc_find_feature (info.target_desc, "org.gnu.gdb.mips.fpu"); if (feature == NULL) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; valid_p = 1; for (i = 0; i < 32; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i + mips_regnum.fp0, mips_fprs[i]); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), mips_regnum.fp_control_status, "fcsr"); valid_p - &= tdesc_numbered_register (feature, tdesc_data, + &= tdesc_numbered_register (feature, tdesc_data.get (), mips_regnum.fp_implementation_revision, "fir"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; num_regs = mips_regnum.fp_implementation_revision + 1; @@ -8389,27 +8374,24 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { i = 0; valid_p = 1; - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), dspacc + i++, "hi1"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), dspacc + i++, "lo1"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), dspacc + i++, "hi2"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), dspacc + i++, "lo2"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), dspacc + i++, "hi3"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), dspacc + i++, "lo3"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), dspctl, "dspctl"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; mips_regnum.dspacc = dspacc; mips_regnum.dspctl = dspctl; @@ -8445,8 +8427,6 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (MIPS_FPU_TYPE (arches->gdbarch) != fpu_type) continue; - if (tdesc_data != NULL) - tdesc_data_cleanup (tdesc_data); return arches->gdbarch; } @@ -8743,7 +8723,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) mips_register_g_packet_guesses (gdbarch); /* Hook in OS ABI-specific overrides, if they have been registered. */ - info.tdesc_data = tdesc_data; + info.tdesc_data = tdesc_data.get (); gdbarch_init_osabi (info, gdbarch); /* The hook may have adjusted num_regs, fetch the final value and @@ -8764,10 +8744,10 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) frame_base_append_sniffer (gdbarch, mips_micro_frame_base_sniffer); frame_base_append_sniffer (gdbarch, mips_insn32_frame_base_sniffer); - if (tdesc_data) + if (tdesc_data != nullptr) { set_tdesc_pseudo_register_type (gdbarch, mips_pseudo_register_type); - tdesc_use_registers (gdbarch, info.target_desc, tdesc_data); + tdesc_use_registers (gdbarch, info.target_desc, std::move (tdesc_data)); /* Override the normal target description methods to handle our dual real and pseudo registers. */ diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index fc90797..afc7c61 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -1955,7 +1955,7 @@ nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) struct gdbarch *gdbarch; struct gdbarch_tdep *tdep; struct gdbarch_list *best_arch; - struct tdesc_arch_data *tdesc_data = NULL; + tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; int elf_abi = E_NDS_ABI_AABI; int fpu_freg = -1; @@ -1988,11 +1988,9 @@ nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdesc_data = tdesc_data_alloc (); - if (!nds32_validate_tdesc_p (tdesc, tdesc_data, &fpu_freg, &use_pseudo_fsrs)) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + if (!nds32_validate_tdesc_p (tdesc, tdesc_data.get (), &fpu_freg, + &use_pseudo_fsrs)) + return NULL; /* Allocate space for the new architecture. */ tdep = XCNEW (struct gdbarch_tdep); @@ -2022,7 +2020,7 @@ nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) num_regs = NDS32_NUM_REGS + num_fdr_map[fpu_freg] + num_fsr_map[fpu_freg]; set_gdbarch_num_regs (gdbarch, num_regs); - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); /* Cache the register number of fs0. */ if (fpu_freg != -1) @@ -2061,7 +2059,7 @@ nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) nds32_add_reggroups (gdbarch); /* Hook in ABI-specific overrides, if they have been registered. */ - info.tdesc_data = tdesc_data; + info.tdesc_data = tdesc_data.get (); gdbarch_init_osabi (info, gdbarch); /* Override tdesc_register callbacks for system registers. */ diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c index acc2873..09eb6fc 100644 --- a/gdb/nios2-tdep.c +++ b/gdb/nios2-tdep.c @@ -2275,7 +2275,7 @@ nios2_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) struct gdbarch *gdbarch; struct gdbarch_tdep *tdep; int i; - struct tdesc_arch_data *tdesc_data = NULL; + tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; if (!tdesc_has_registers (tdesc)) @@ -2297,14 +2297,11 @@ nios2_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < NIOS2_NUM_REGS; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, i, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, nios2_reg_names[i]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; } /* Find a candidate among the list of pre-declared architectures. */ @@ -2384,8 +2381,8 @@ nios2_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Enable inferior call support. */ set_gdbarch_push_dummy_call (gdbarch, nios2_push_dummy_call); - if (tdesc_data) - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + if (tdesc_data != nullptr) + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); return gdbarch; } diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index 6ba6503..7b16cdb 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -1113,7 +1113,7 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) struct gdbarch *gdbarch; struct gdbarch_tdep *tdep; const struct bfd_arch_info *binfo; - struct tdesc_arch_data *tdesc_data = NULL; + tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; /* Find a candidate among the list of pre-declared architectures. */ @@ -1221,14 +1221,11 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < OR1K_NUM_REGS; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, i, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, or1k_reg_names[i]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; } if (tdesc_data != NULL) @@ -1243,7 +1240,7 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) reggroup_add (gdbarch, save_reggroup); reggroup_add (gdbarch, restore_reggroup); - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); } /* Hook in ABI-specific overrides, if they have been registered. */ diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index ac4ac1b..2c4eeab 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -3320,10 +3320,10 @@ riscv_gdbarch_init (struct gdbarch_info info, if (feature_cpu == NULL) return NULL; - struct tdesc_arch_data *tdesc_data = tdesc_data_alloc (); + tdesc_arch_data_up tdesc_data = tdesc_data_alloc (); std::vector<riscv_pending_register_alias> pending_aliases; - bool valid_p = riscv_check_tdesc_feature (tdesc_data, + bool valid_p = riscv_check_tdesc_feature (tdesc_data.get (), feature_cpu, feature_csr, &riscv_xreg_feature, &pending_aliases); @@ -3345,7 +3345,7 @@ riscv_gdbarch_init (struct gdbarch_info info, if (feature_fpu != NULL) { - valid_p &= riscv_check_tdesc_feature (tdesc_data, feature_fpu, + valid_p &= riscv_check_tdesc_feature (tdesc_data.get (), feature_fpu, feature_csr, &riscv_freg_feature, &pending_aliases); @@ -3383,12 +3383,12 @@ riscv_gdbarch_init (struct gdbarch_info info, } if (feature_virtual) - riscv_check_tdesc_feature (tdesc_data, feature_virtual, feature_csr, + riscv_check_tdesc_feature (tdesc_data.get (), feature_virtual, feature_csr, &riscv_virtual_feature, &pending_aliases); if (feature_csr) - riscv_check_tdesc_feature (tdesc_data, feature_csr, nullptr, + riscv_check_tdesc_feature (tdesc_data.get (), feature_csr, nullptr, &riscv_csr_feature, &pending_aliases); @@ -3396,7 +3396,6 @@ riscv_gdbarch_init (struct gdbarch_info info, { if (riscv_debug_gdbarch) fprintf_unfiltered (gdb_stdlog, "Target description is not valid\n"); - tdesc_data_cleanup (tdesc_data); return NULL; } @@ -3442,10 +3441,7 @@ riscv_gdbarch_init (struct gdbarch_info info, } if (arches != NULL) - { - tdesc_data_cleanup (tdesc_data); - return arches->gdbarch; - } + return arches->gdbarch; /* None found, so create a new architecture from the information provided. */ tdep = new (struct gdbarch_tdep); @@ -3511,7 +3507,8 @@ riscv_gdbarch_init (struct gdbarch_info info, set_gdbarch_print_registers_info (gdbarch, riscv_print_registers_info); /* Finalise the target description registers. */ - tdesc_use_registers (gdbarch, tdesc, tdesc_data, riscv_tdesc_unknown_reg); + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data), + riscv_tdesc_unknown_reg); /* Override the register type callback setup by the target description mechanism. This allows us to provide special type for floating point diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index adb39d9..7e65151 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -6138,7 +6138,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) int have_htm_tar = 0; int tdesc_wordsize = -1; const struct target_desc *tdesc = info.target_desc; - struct tdesc_arch_data *tdesc_data = NULL; + tdesc_arch_data_up tdesc_data; int num_pseudoregs = 0; int cur_reg; @@ -6235,31 +6235,29 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < ppc_num_gprs; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, i, gprs[i]); - valid_p &= tdesc_numbered_register (feature, tdesc_data, PPC_PC_REGNUM, - "pc"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, PPC_LR_REGNUM, - "lr"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, PPC_XER_REGNUM, - "xer"); + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), + i, gprs[i]); + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), + PPC_PC_REGNUM, "pc"); + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), + PPC_LR_REGNUM, "lr"); + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), + PPC_XER_REGNUM, "xer"); /* Allow alternate names for these registers, to accomodate GDB's historic naming. */ - valid_p &= tdesc_numbered_register_choices (feature, tdesc_data, + valid_p &= tdesc_numbered_register_choices (feature, tdesc_data.get (), PPC_MSR_REGNUM, msr_names); - valid_p &= tdesc_numbered_register_choices (feature, tdesc_data, + valid_p &= tdesc_numbered_register_choices (feature, tdesc_data.get (), PPC_CR_REGNUM, cr_names); - valid_p &= tdesc_numbered_register_choices (feature, tdesc_data, + valid_p &= tdesc_numbered_register_choices (feature, tdesc_data.get (), PPC_CTR_REGNUM, ctr_names); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; - have_mq = tdesc_numbered_register (feature, tdesc_data, PPC_MQ_REGNUM, - "mq"); + have_mq = tdesc_numbered_register (feature, tdesc_data.get (), + PPC_MQ_REGNUM, "mq"); tdesc_wordsize = tdesc_register_bitsize (feature, "pc") / 8; if (wordsize == -1) @@ -6277,16 +6275,13 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) }; valid_p = 1; for (i = 0; i < ppc_num_fprs; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_F0_REGNUM + i, fprs[i]); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_FPSCR_REGNUM, "fpscr"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_fpu = 1; /* The fpscr register was expanded in isa 2.05 to 64 bits @@ -6311,19 +6306,16 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < ppc_num_gprs; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_VR0_REGNUM + i, vector_regs[i]); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_VSCR_REGNUM, "vscr"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_VRSAVE_REGNUM, "vrsave"); if (have_spe || !valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_altivec = 1; } else @@ -6347,15 +6339,12 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < ppc_num_vshrs; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_VSR0_UPPER_REGNUM + i, vsx_regs[i]); if (!valid_p || !have_fpu || !have_altivec) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_vsx = 1; } @@ -6392,19 +6381,16 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < ppc_num_gprs; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_SPE_UPPER_GP0_REGNUM + i, upper_spe[i]); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_SPE_ACC_REGNUM, "acc"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_SPE_FSCR_REGNUM, "spefscr"); if (have_mq || have_fpu || !valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_spe = 1; } else @@ -6416,14 +6402,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (feature != NULL) { valid_p = 1; - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_PPR_REGNUM, "ppr"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_ppr = 1; } else @@ -6435,14 +6418,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (feature != NULL) { valid_p = 1; - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_DSCR_REGNUM, "dscr"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_dscr = 1; } else @@ -6454,14 +6434,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (feature != NULL) { valid_p = 1; - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_TAR_REGNUM, "tar"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_tar = 1; } else @@ -6478,14 +6455,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < ARRAY_SIZE (ebb_regs); i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_BESCR_REGNUM + i, ebb_regs[i]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_ebb = 1; } else @@ -6499,27 +6473,24 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { valid_p = 1; - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_MMCR0_REGNUM, "mmcr0"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_MMCR2_REGNUM, "mmcr2"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_SIAR_REGNUM, "siar"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_SDAR_REGNUM, "sdar"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_SIER_REGNUM, "sier"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_pmu = 1; } else @@ -6536,14 +6507,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < ARRAY_SIZE (tm_spr_regs); i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_TFHAR_REGNUM + i, tm_spr_regs[i]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_htm_spr = 1; } @@ -6565,14 +6533,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < ARRAY_SIZE (cgprs); i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_CR0_REGNUM + i, cgprs[i]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_htm_core = 1; } @@ -6594,15 +6559,12 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) }; for (i = 0; i < ARRAY_SIZE (cfprs); i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_CF0_REGNUM + i, cfprs[i]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_htm_fpu = 1; } else @@ -6624,15 +6586,12 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) }; for (i = 0; i < ARRAY_SIZE (cvmx); i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), PPC_CVR0_REGNUM + i, cvmx[i]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_htm_altivec = 1; } else @@ -6654,16 +6613,13 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) }; for (i = 0; i < ARRAY_SIZE (cvsx); i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), (PPC_CVSR0_UPPER_REGNUM + i), cvsx[i]); if (!valid_p || !have_htm_fpu || !have_htm_altivec) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_htm_vsx = 1; } else @@ -6673,14 +6629,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) "org.gnu.gdb.power.htm.ppr"); if (feature != NULL) { - valid_p = tdesc_numbered_register (feature, tdesc_data, + valid_p = tdesc_numbered_register (feature, tdesc_data.get (), PPC_CPPR_REGNUM, "cppr"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_htm_ppr = 1; } else @@ -6690,14 +6643,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) "org.gnu.gdb.power.htm.dscr"); if (feature != NULL) { - valid_p = tdesc_numbered_register (feature, tdesc_data, + valid_p = tdesc_numbered_register (feature, tdesc_data.get (), PPC_CDSCR_REGNUM, "cdscr"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_htm_dscr = 1; } else @@ -6707,14 +6657,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) "org.gnu.gdb.power.htm.tar"); if (feature != NULL) { - valid_p = tdesc_numbered_register (feature, tdesc_data, + valid_p = tdesc_numbered_register (feature, tdesc_data.get (), PPC_CTAR_REGNUM, "ctar"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; have_htm_tar = 1; } else @@ -6733,10 +6680,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) supplies a 64-bit description while debugging a 32-bit binary. */ if (tdesc_wordsize != -1 && tdesc_wordsize != wordsize) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; #ifdef HAVE_ELF if (from_elf_exec) @@ -6872,11 +6816,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (tdep && tdep->vector_abi != vector_abi) continue; if (tdep && tdep->wordsize == wordsize) - { - if (tdesc_data != NULL) - tdesc_data_cleanup (tdesc_data); - return arches->gdbarch; - } + return arches->gdbarch; } /* None found, create a new architecture from INFO, whose bfd_arch_info @@ -7070,7 +7010,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Hook in ABI-specific overrides, if they have been registered. */ info.target_desc = tdesc; - info.tdesc_data = tdesc_data; + info.tdesc_data = tdesc_data.get (); gdbarch_init_osabi (info, gdbarch); switch (info.osabi) @@ -7093,7 +7033,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_tdesc_pseudo_register_type (gdbarch, rs6000_pseudo_register_type); set_tdesc_pseudo_register_reggroup_p (gdbarch, rs6000_pseudo_register_reggroup_p); - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); /* Override the normal target description method to make the SPE upper halves anonymous. */ diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 6401ef2..4696327 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -944,7 +944,7 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) struct gdbarch *gdbarch; struct gdbarch_tdep *tdep; int elf_flags; - struct tdesc_arch_data *tdesc_data = NULL; + tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; /* Extract the elf_flags if available. */ @@ -982,15 +982,12 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { tdesc_data = tdesc_data_alloc (); for (int i = 0; i < RX_NUM_REGS; i++) - valid_p &= tdesc_numbered_register (feature, tdesc_data, i, - rx_register_names[i]); + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, + rx_register_names[i]); } if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; } gdb_assert(tdesc_data != NULL); @@ -1000,7 +997,7 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->elf_flags = elf_flags; set_gdbarch_num_regs (gdbarch, RX_NUM_REGS); - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); set_gdbarch_num_pseudo_regs (gdbarch, 0); set_gdbarch_pc_regnum (gdbarch, RX_PC_REGNUM); diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index b95c8c1..4d3644e 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -7022,8 +7022,8 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) struct gdbarch_tdep *tdep = s390_gdbarch_tdep_alloc (); struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep); - struct tdesc_arch_data *tdesc_data = tdesc_data_alloc (); - info.tdesc_data = tdesc_data; + tdesc_arch_data_up tdesc_data = tdesc_data_alloc (); + info.tdesc_data = tdesc_data.get (); set_gdbarch_believe_pcc_promotion (gdbarch, 0); set_gdbarch_char_signed (gdbarch, 0); @@ -7149,9 +7149,8 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->tdesc = tdesc; /* Check any target description for validity. */ - if (!s390_tdesc_valid (tdep, tdesc_data)) + if (!s390_tdesc_valid (tdep, tdesc_data.get ())) { - tdesc_data_cleanup (tdesc_data); xfree (tdep); gdbarch_free (gdbarch); return NULL; @@ -7182,13 +7181,12 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (tmp->vector_abi != tdep->vector_abi) continue; - tdesc_data_cleanup (tdesc_data); xfree (tdep); gdbarch_free (gdbarch); return arches->gdbarch; } - tdesc_use_registers (gdbarch, tdep->tdesc, tdesc_data); + tdesc_use_registers (gdbarch, tdep->tdesc, std::move (tdesc_data)); set_gdbarch_register_name (gdbarch, s390_register_name); /* Assign pseudo register numbers. */ diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index e3401fe..e9636cd 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -1898,35 +1898,32 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (tdesc_has_registers (tdesc)) { - struct tdesc_arch_data *tdesc_data = tdesc_data_alloc (); + tdesc_arch_data_up tdesc_data = tdesc_data_alloc (); /* Validate that the descriptor provides the mandatory registers and allocate their numbers. */ - valid_p &= validate_tdesc_registers (tdesc, tdesc_data, + valid_p &= validate_tdesc_registers (tdesc, tdesc_data.get (), "org.gnu.gdb.sparc.cpu", sparc_core_register_names, ARRAY_SIZE (sparc_core_register_names), SPARC_G0_REGNUM); - valid_p &= validate_tdesc_registers (tdesc, tdesc_data, + valid_p &= validate_tdesc_registers (tdesc, tdesc_data.get (), "org.gnu.gdb.sparc.fpu", tdep->fpu_register_names, tdep->fpu_registers_num, SPARC_F0_REGNUM); - valid_p &= validate_tdesc_registers (tdesc, tdesc_data, + valid_p &= validate_tdesc_registers (tdesc, tdesc_data.get (), "org.gnu.gdb.sparc.cp0", tdep->cp0_register_names, tdep->cp0_registers_num, SPARC_F0_REGNUM + tdep->fpu_registers_num); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; /* Target description may have changed. */ - info.tdesc_data = tdesc_data; - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + info.tdesc_data = tdesc_data.get (); + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); } /* If we have register sets, enable the generic core file support. */ diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 91cbeb5..19dbcbe 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -779,21 +779,17 @@ tdesc_data_init (struct obstack *obstack) /* Similar, but for the temporary copy used during architecture initialization. */ -struct tdesc_arch_data * +tdesc_arch_data_up tdesc_data_alloc (void) { - return new tdesc_arch_data (); + return tdesc_arch_data_up (new tdesc_arch_data ()); } -/* Free something allocated by tdesc_data_alloc, if it is not going - to be used (for instance if it was unsuitable for the - architecture). */ +/* See target-descriptions.h. */ void -tdesc_data_cleanup (void *data_untyped) +tdesc_arch_data_deleter::operator() (struct tdesc_arch_data *data) const { - struct tdesc_arch_data *data = (struct tdesc_arch_data *) data_untyped; - delete data; } @@ -1103,7 +1099,7 @@ set_tdesc_pseudo_register_reggroup_p void tdesc_use_registers (struct gdbarch *gdbarch, const struct target_desc *target_desc, - struct tdesc_arch_data *early_data, + tdesc_arch_data_up &&early_data, tdesc_unknown_register_ftype unk_reg_cb) { int num_regs = gdbarch_num_regs (gdbarch); @@ -1116,8 +1112,7 @@ tdesc_use_registers (struct gdbarch *gdbarch, gdb_assert (tdesc_has_registers (target_desc)); data = (struct tdesc_arch_data *) gdbarch_data (gdbarch, tdesc_data); - data->arch_regs = early_data->arch_regs; - delete early_data; + data->arch_regs = std::move (early_data->arch_regs); /* Build up a set of all registers, so that we can assign register numbers where needed. The hash table expands as necessary, so diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h index 66a2c21..171ef76 100644 --- a/gdb/target-descriptions.h +++ b/gdb/target-descriptions.h @@ -104,6 +104,18 @@ typedef int (*tdesc_unknown_register_ftype) (struct gdbarch *gdbarch, tdesc_feature *feature, const char *reg_name, int possible_regnum); +/* A deleter adapter for a target arch data. */ + +struct tdesc_arch_data_deleter +{ + void operator() (struct tdesc_arch_data *data) const; +}; + +/* A unique pointer specialization that holds a target_desc. */ + +typedef std::unique_ptr<tdesc_arch_data, tdesc_arch_data_deleter> + tdesc_arch_data_up; + /* Update GDBARCH to use the TARGET_DESC for registers. TARGET_DESC may be GDBARCH's target description or (if GDBARCH does not have one which describes registers) another target description @@ -119,19 +131,13 @@ typedef int (*tdesc_unknown_register_ftype) void tdesc_use_registers (struct gdbarch *gdbarch, const struct target_desc *target_desc, - struct tdesc_arch_data *early_data, + tdesc_arch_data_up &&early_data, tdesc_unknown_register_ftype unk_reg_cb = NULL); /* Allocate initial data for validation of a target description during gdbarch initialization. */ -struct tdesc_arch_data *tdesc_data_alloc (void); - -/* Clean up data allocated by tdesc_data_alloc. This should only - be called to discard the data; tdesc_use_registers takes ownership - of its EARLY_DATA argument. */ - -void tdesc_data_cleanup (void *data_untyped); +tdesc_arch_data_up tdesc_data_alloc (); /* Search FEATURE for a register named NAME. Record REGNO and the register in DATA; when tdesc_use_registers is called, REGNO will be diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c index 4227e71..17e6e65 100644 --- a/gdb/tic6x-tdep.c +++ b/gdb/tic6x-tdep.c @@ -1140,7 +1140,7 @@ tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; struct gdbarch_tdep *tdep; - struct tdesc_arch_data *tdesc_data = NULL; + tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; int has_gp = 0; @@ -1159,20 +1159,17 @@ tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) valid_p = 1; for (i = 0; i < 32; i++) /* A0 - A15, B0 - B15 */ - valid_p &= tdesc_numbered_register (feature, tdesc_data, i, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, tic6x_register_names[i]); /* CSR */ - valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i++, tic6x_register_names[TIC6X_CSR_REGNUM]); - valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i++, tic6x_register_names[TIC6X_PC_REGNUM]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; feature = tdesc_find_feature (tdesc, "org.gnu.gdb.tic6x.gp"); if (feature) @@ -1189,28 +1186,25 @@ tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) has_gp = 1; valid_p = 1; for (j = 0; j < 32; j++) /* A16 - A31, B16 - B31 */ - valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, - gp[j]); + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), + i++, gp[j]); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; } feature = tdesc_find_feature (tdesc, "org.gnu.gdb.tic6x.c6xp"); if (feature) { - valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, "TSR"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, "ILC"); - valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, "RILC"); + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), + i++, "TSR"); + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), + i++, "ILC"); + valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), + i++, "RILC"); if (!valid_p) - { - tdesc_data_cleanup (tdesc_data); - return NULL; - } + return NULL; } } @@ -1295,8 +1289,8 @@ tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Hook in ABI-specific overrides, if they have been registered. */ gdbarch_init_osabi (info, gdbarch); - if (tdesc_data) - tdesc_use_registers (gdbarch, tdesc, tdesc_data); + if (tdesc_data != nullptr) + tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data)); return gdbarch; } |