+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
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]);
/* 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]);
/* 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]);
/* 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]);
}
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;
/* 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);
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++)
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)
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);
{
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;
}
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");
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. */
}
}
- tdesc_use_registers (gdbarch, tdesc, tdesc_data);
+ tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));
return gdbarch;
}
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;
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");
{
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;
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;
}
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)
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;
{
/* 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
}
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);
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. */
{
struct gdbarch_tdep *tdep;
struct gdbarch *gdbarch;
- struct tdesc_arch_data *tdesc_data;
const struct target_desc *tdesc;
int mm0_regnum;
int ymm0_regnum;
/* 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);
/* 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;
/* 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);
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;
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");
{
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;
}
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);
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;
}
{
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. */
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. */
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;
}
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;
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;
{
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;
if (MIPS_FPU_TYPE (arches->gdbarch) != fpu_type)
continue;
- if (tdesc_data != NULL)
- tdesc_data_cleanup (tdesc_data);
return arches->gdbarch;
}
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
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. */
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;
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);
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)
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. */
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))
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. */
/* 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;
}
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. */
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)
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. */
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);
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);
}
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);
{
if (riscv_debug_gdbarch)
fprintf_unfiltered (gdb_stdlog, "Target description is not valid\n");
- tdesc_data_cleanup (tdesc_data);
return NULL;
}
}
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);
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
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;
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)
};
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
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
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;
}
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
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
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
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
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
{
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
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;
}
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;
}
};
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
};
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
};
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
"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
"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
"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
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)
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
/* 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)
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. */
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. */
{
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);
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);
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);
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;
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. */
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. */
/* 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;
}
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);
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
(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
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
{
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;
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)
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;
}
}
/* 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;
}