diff options
author | Tom Tromey <tromey@adacore.com> | 2020-09-17 14:11:38 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-09-17 14:28:06 -0600 |
commit | c1e1314d00fda5625f1a87b915fd83a61c253993 (patch) | |
tree | 62affcd614124eec0c51db5223b0ea7f797a17d1 /gdb/arm-tdep.c | |
parent | 0363df3db7d3f5edd3a349ab7720eca83f460545 (diff) | |
download | binutils-c1e1314d00fda5625f1a87b915fd83a61c253993.zip binutils-c1e1314d00fda5625f1a87b915fd83a61c253993.tar.gz binutils-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/arm-tdep.c')
-rw-r--r-- | gdb/arm-tdep.c | 61 |
1 files changed, 21 insertions, 40 deletions
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. */ |