aboutsummaryrefslogtreecommitdiff
path: root/gdb/arc-tdep.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-09-17 14:11:38 -0600
committerTom Tromey <tromey@adacore.com>2020-09-17 14:28:06 -0600
commitc1e1314d00fda5625f1a87b915fd83a61c253993 (patch)
tree62affcd614124eec0c51db5223b0ea7f797a17d1 /gdb/arc-tdep.c
parent0363df3db7d3f5edd3a349ab7720eca83f460545 (diff)
downloadgdb-c1e1314d00fda5625f1a87b915fd83a61c253993.zip
gdb-c1e1314d00fda5625f1a87b915fd83a61c253993.tar.gz
gdb-c1e1314d00fda5625f1a87b915fd83a61c253993.tar.bz2
Change management of tdesc_arch_data
While working on something else, I noticed that tdesc_data_cleanup took a void* parameter. Looking more into this, I found that tdesc_use_registers expected a transfer of ownership. I think it's better to express this sort of thing via the type system, when possible. This patch changes tdesc_data_alloc to return a unique pointer, changes tdesc_use_registers to accept an rvalue reference, and then adapts all the users. Note that a deleter structure is introduced to avoid having to move tdesc_arch_data to the header file. 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.
Diffstat (limited to 'gdb/arc-tdep.c')
-rw-r--r--gdb/arc-tdep.c17
1 files changed, 8 insertions, 9 deletions
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;
}