/* AArch64 code is always little-endian. */
info.byte_order_for_code = BFD_ENDIAN_LITTLE;
- aarch64_gdbarch_tdep *tdep = new aarch64_gdbarch_tdep;
- struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new aarch64_gdbarch_tdep));
+ aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
/* This should be low enough for everything. */
tdep->lowest_pc = 0x20;
static struct gdbarch *
alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
-
/* Find a candidate among extant architectures. */
arches = gdbarch_list_lookup_by_info (arches, &info);
if (arches != NULL)
return arches->gdbarch;
- alpha_gdbarch_tdep *tdep = new alpha_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new alpha_gdbarch_tdep));
+ alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
/* Lowest text address. This is used by heuristic_proc_start()
to decide when to stop looking. */
/* Allocate the ARC-private target-dependent information structure, and the
GDB target-independent information structure. */
- std::unique_ptr<arc_gdbarch_tdep> tdep_holder (new arc_gdbarch_tdep);
- arc_gdbarch_tdep *tdep = tdep_holder.get ();
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new arc_gdbarch_tdep));
+ arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (gdbarch);
tdep->jb_pc = -1; /* No longjmp support by default. */
tdep->has_hw_loops = arc_check_for_hw_loops (tdesc, tdesc_data.get ());
- struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep_holder.release ());
/* Data types. */
set_gdbarch_short_bit (gdbarch, 16);
{
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_tdep_1 called\n");
- return gdbarch->tdep;
+ return gdbarch->tdep.get ();
}
registry<gdbarch> *
static struct gdbarch *
arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
struct gdbarch_list *best_arch;
enum arm_abi_kind arm_abi = arm_abi_global;
enum arm_float_model fp_model = arm_fp_model;
if (best_arch != NULL)
return best_arch->gdbarch;
- arm_gdbarch_tdep *tdep = new arm_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new arm_gdbarch_tdep));
+ arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
/* Record additional information about the architecture we are defining.
These are gdbarch discriminators, like the OSABI. */
static struct gdbarch *
avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
struct gdbarch_list *best_arch;
int call_length;
}
/* None found, create a new architecture from the information provided. */
- avr_gdbarch_tdep *tdep = new avr_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new avr_gdbarch_tdep));
+ avr_gdbarch_tdep *tdep = gdbarch_tdep<avr_gdbarch_tdep> (gdbarch);
tdep->call_length = call_length;
static struct gdbarch *
bfin_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
enum bfin_abi abi;
abi = BFIN_ABI_FLAT;
return arches->gdbarch;
}
- bfin_gdbarch_tdep *tdep = new bfin_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new bfin_gdbarch_tdep));
+ bfin_gdbarch_tdep *tdep = gdbarch_tdep<bfin_gdbarch_tdep> (gdbarch);
tdep->bfin_abi = abi;
return arches->gdbarch;
/* Allocate space for the new architecture. */
- bpf_gdbarch_tdep *tdep = new bpf_gdbarch_tdep;
- struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new bpf_gdbarch_tdep));
/* Information about registers, etc. */
set_gdbarch_num_regs (gdbarch, BPF_NUM_REGS);
static struct gdbarch *
cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
unsigned int cris_version;
if (usr_cmd_cris_version_valid)
}
/* No matching architecture was found. Create a new one. */
- cris_gdbarch_tdep *tdep = new cris_gdbarch_tdep;
info.byte_order = BFD_ENDIAN_LITTLE;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new cris_gdbarch_tdep));
+ cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
tdep->cris_version = usr_cmd_cris_version;
tdep->cris_mode = usr_cmd_cris_mode;
static struct gdbarch *
csky_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
/* Analyze info.abfd. */
unsigned int fpu_abi = 0;
unsigned int vdsp_version = 0;
/* None found, create a new architecture from the information
provided. */
- csky_gdbarch_tdep *tdep = new csky_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new csky_gdbarch_tdep));
+ csky_gdbarch_tdep *tdep = gdbarch_tdep<csky_gdbarch_tdep> (gdbarch);
+
tdep->fpu_abi = fpu_abi;
tdep->vdsp_version = vdsp_version;
tdep->fpu_hardfp = fpu_hardfp;
const char **register_names = nullptr;
};
+using frv_gdbarch_tdep_up = std::unique_ptr<frv_gdbarch_tdep>;
+
/* Return the FR-V ABI associated with GDBARCH. */
enum frv_abi
frv_abi (struct gdbarch *gdbarch)
/* Allocate a new variant structure, and set up default values for all
the fields. */
-static frv_gdbarch_tdep *
-new_variant (void)
+static frv_gdbarch_tdep_up
+new_variant ()
{
int r;
- frv_gdbarch_tdep *var = new frv_gdbarch_tdep;
+ frv_gdbarch_tdep_up var (new frv_gdbarch_tdep);
var->frv_abi = FRV_ABI_EABI;
var->num_gprs = 64;
static struct gdbarch *
frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
int elf_flags = 0;
/* Check to see if we've already built an appropriate architecture
return arches->gdbarch;
/* Select the right tdep structure for this variant. */
- frv_gdbarch_tdep *var = new_variant ();
+ gdbarch *gdbarch = gdbarch_alloc (&info, new_variant ());
+ frv_gdbarch_tdep *var = gdbarch_tdep<frv_gdbarch_tdep> (gdbarch);
+
switch (info.bfd_arch_info->mach)
{
case bfd_mach_frv:
if (elf_flags & EF_FRV_CPU_FR450)
set_variant_scratch_registers (var);
- gdbarch = gdbarch_alloc (&info, var);
-
set_gdbarch_short_bit (gdbarch, 16);
set_gdbarch_int_bit (gdbarch, 32);
set_gdbarch_long_bit (gdbarch, 32);
static struct gdbarch *
ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
struct type *void_type;
struct type *func_void_type;
return arches->gdbarch;
/* Allocate space for the new architecture. */
- ft32_gdbarch_tdep *tdep = new ft32_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new ft32_gdbarch_tdep));
+ ft32_gdbarch_tdep *tdep = gdbarch_tdep<ft32_gdbarch_tdep> (gdbarch);
/* Create a type for PC. We can't use builtin types here, as they may not
be defined. */
const struct target_desc * target_desc;
/* target specific vector. */
- struct gdbarch_tdep_base *tdep = nullptr;
+ gdbarch_tdep_up tdep;
gdbarch_dump_tdep_ftype *dump_tdep = nullptr;
/* per-architecture data-pointers. */
struct gdbarch *
gdbarch_alloc (const struct gdbarch_info *info,
- struct gdbarch_tdep_base *tdep)
+ gdbarch_tdep_up tdep)
{
struct gdbarch *gdbarch;
gdbarch = new struct gdbarch;
- gdbarch->tdep = tdep;
+ gdbarch->tdep = std::move (tdep);
gdbarch->bfd_arch_info = info->bfd_arch_info;
gdbarch->byte_order = info->byte_order;
virtual ~gdbarch_tdep_base() = default;
};
+using gdbarch_tdep_up = std::unique_ptr<gdbarch_tdep_base>;
+
/* The architecture associated with the inferior through the
connection to the target.
parameters. set_gdbarch_*() functions are called to complete the
initialization of the object. */
-extern struct gdbarch *gdbarch_alloc (const struct gdbarch_info *info, struct gdbarch_tdep_base *tdep);
+extern struct gdbarch *gdbarch_alloc (const struct gdbarch_info *info,
+ gdbarch_tdep_up tdep);
/* Helper function. Free a partially-constructed ``struct gdbarch''.
static struct gdbarch *
hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
-
/* find a candidate among the list of pre-declared architectures. */
arches = gdbarch_list_lookup_by_info (arches, &info);
if (arches != NULL)
return (arches->gdbarch);
/* If none found, then allocate and initialize one. */
- hppa_gdbarch_tdep *tdep = new hppa_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new hppa_gdbarch_tdep));
+ hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch);
/* Determine from the bfd_arch_info structure if we are dealing with
a 32 or 64 bits architecture. If the bfd_arch_info is not available,
static struct gdbarch *
i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
const struct target_desc *tdesc;
int mm0_regnum;
int ymm0_regnum;
return arches->gdbarch;
/* Allocate space for the new architecture. Assume i386 for now. */
- i386_gdbarch_tdep *tdep = new i386_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new i386_gdbarch_tdep));
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
/* General-purpose registers. */
tdep->gregset_reg_offset = NULL;
if (!i386_validate_tdesc_p (tdep, tdesc_data.get ()))
{
- delete tdep;
gdbarch_free (gdbarch);
return NULL;
}
static struct gdbarch *
ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
-
/* If there is already a candidate, use it. */
arches = gdbarch_list_lookup_by_info (arches, &info);
if (arches != NULL)
return arches->gdbarch;
- ia64_gdbarch_tdep *tdep = new ia64_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new ia64_gdbarch_tdep));
+ ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
tdep->size_of_register_frame = ia64_size_of_register_frame;
static struct gdbarch *
lm32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
-
/* If there is already a candidate, use it. */
arches = gdbarch_list_lookup_by_info (arches, &info);
if (arches != NULL)
return arches->gdbarch;
/* None found, create a new architecture from the information provided. */
- lm32_gdbarch_tdep *tdep = new lm32_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new lm32_gdbarch_tdep));
/* Type sizes. */
set_gdbarch_short_bit (gdbarch, 16);
size_t regnum = 0;
struct loongarch_gdbarch_features features;
tdesc_arch_data_up tdesc_data = tdesc_data_alloc ();
- loongarch_gdbarch_tdep *tdep = new loongarch_gdbarch_tdep;
const struct target_desc *tdesc = info.target_desc;
/* Ensure we always have a target description. */
return arches->gdbarch;
/* None found, so create a new architecture from the information provided. */
- struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new loongarch_gdbarch_tdep));
+ loongarch_gdbarch_tdep *tdep = gdbarch_tdep<loongarch_gdbarch_tdep> (gdbarch);
+
tdep->abi_features = abi_features;
/* Target data types. */
static struct gdbarch *
m32c_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
unsigned long mach = info.bfd_arch_info->mach;
/* Find a candidate among the list of architectures we've created
arches = gdbarch_list_lookup_by_info (arches->next, &info))
return arches->gdbarch;
- m32c_gdbarch_tdep *tdep = new m32c_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new m32c_gdbarch_tdep));
/* Essential types. */
make_types (gdbarch);
static struct gdbarch *
m32r_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
-
/* If there is already a candidate, use it. */
arches = gdbarch_list_lookup_by_info (arches, &info);
if (arches != NULL)
return arches->gdbarch;
/* Allocate space for the new architecture. */
- m32r_gdbarch_tdep *tdep = new m32r_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new m32r_gdbarch_tdep));
set_gdbarch_wchar_bit (gdbarch, 16);
set_gdbarch_wchar_signed (gdbarch, 0);
m68hc11_gdbarch_init (struct gdbarch_info info,
struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
int elf_flags;
soft_reg_initialized = 0;
}
/* Need a new architecture. Fill in a target specific vector. */
- m68gc11_gdbarch_tdep *tdep = new m68gc11_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new m68gc11_gdbarch_tdep));
+ m68gc11_gdbarch_tdep *tdep = gdbarch_tdep<m68gc11_gdbarch_tdep> (gdbarch);
+
tdep->elf_flags = elf_flags;
switch (info.bfd_arch_info->arch)
static struct gdbarch *
m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
struct gdbarch_list *best_arch;
tdesc_arch_data_up tdesc_data;
int i;
if (best_arch != NULL)
return best_arch->gdbarch;
- m68k_gdbarch_tdep *tdep = new m68k_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new m68k_gdbarch_tdep));
+ m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+
tdep->fpregs_present = has_fp;
tdep->float_return = float_return;
tdep->flavour = flavour;
static struct gdbarch *
mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
-
/* Which me_module are we building a gdbarch object for? */
CONFIG_ATTR me_module;
return arches->gdbarch;
}
- mep_gdbarch_tdep *tdep = new mep_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new mep_gdbarch_tdep));
+ mep_gdbarch_tdep *tdep = gdbarch_tdep<mep_gdbarch_tdep> (gdbarch);
/* Get a CGEN CPU descriptor for this architecture. */
{
static struct gdbarch *
microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
tdesc_arch_data_up tdesc_data;
const struct target_desc *tdesc = info.target_desc;
}
/* Allocate space for the new architecture. */
- microblaze_gdbarch_tdep *tdep = new microblaze_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new microblaze_gdbarch_tdep));
set_gdbarch_long_double_bit (gdbarch, 128);
static struct gdbarch *
mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
int elf_flags;
enum mips_abi mips_abi, found_abi, wanted_abi;
int i, num_regs;
}
/* Need a new architecture. Fill in a target specific vector. */
- mips_gdbarch_tdep *tdep = new mips_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new mips_gdbarch_tdep));
+ mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+
tdep->elf_flags = elf_flags;
tdep->mips64_transfers_32bit_regs_p = mips64_transfers_32bit_regs_p;
tdep->found_abi = found_abi;
mn10300_gdbarch_init (struct gdbarch_info info,
struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
int num_regs;
arches = gdbarch_list_lookup_by_info (arches, &info);
if (arches != NULL)
return arches->gdbarch;
- mn10300_gdbarch_tdep *tdep = new mn10300_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new mn10300_gdbarch_tdep));
+ mn10300_gdbarch_tdep *tdep = gdbarch_tdep<mn10300_gdbarch_tdep> (gdbarch);
switch (info.bfd_arch_info->mach)
{
static struct gdbarch *
moxie_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
-
/* If there is already a candidate, use it. */
arches = gdbarch_list_lookup_by_info (arches, &info);
if (arches != NULL)
return arches->gdbarch;
/* Allocate space for the new architecture. */
- moxie_gdbarch_tdep *tdep = new moxie_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new moxie_gdbarch_tdep));
set_gdbarch_wchar_bit (gdbarch, 32);
set_gdbarch_wchar_signed (gdbarch, 0);
static struct gdbarch *
msp430_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
int elf_flags, isa, code_model;
/* Extract the elf_flags if available. */
/* None found, create a new architecture from the information
provided. */
- msp430_gdbarch_tdep *tdep = new msp430_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new msp430_gdbarch_tdep));
+ msp430_gdbarch_tdep *tdep = gdbarch_tdep<msp430_gdbarch_tdep> (gdbarch);
+
tdep->elf_flags = elf_flags;
tdep->isa = isa;
tdep->code_model = code_model;
static struct gdbarch *
nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
struct gdbarch_list *best_arch;
tdesc_arch_data_up tdesc_data;
const struct target_desc *tdesc = info.target_desc;
return NULL;
/* Allocate space for the new architecture. */
- nds32_gdbarch_tdep *tdep = new nds32_gdbarch_tdep;
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new nds32_gdbarch_tdep));
+ nds32_gdbarch_tdep *tdep = gdbarch_tdep<nds32_gdbarch_tdep> (gdbarch);
+
tdep->fpu_freg = fpu_freg;
tdep->use_pseudo_fsrs = use_pseudo_fsrs;
tdep->fs0_regnum = -1;
tdep->elf_abi = elf_abi;
- gdbarch = gdbarch_alloc (&info, tdep);
-
set_gdbarch_wchar_bit (gdbarch, 16);
set_gdbarch_wchar_signed (gdbarch, 0);
static struct gdbarch *
nios2_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
int i;
tdesc_arch_data_up tdesc_data;
const struct target_desc *tdesc = info.target_desc;
/* None found, create a new architecture from the information
provided. */
- nios2_gdbarch_tdep *tdep = new nios2_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new nios2_gdbarch_tdep));
+ nios2_gdbarch_tdep *tdep = gdbarch_tdep<nios2_gdbarch_tdep> (gdbarch);
/* longjmp support not enabled by default. */
tdep->jb_pc = -1;
static struct gdbarch *
or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
const struct bfd_arch_info *binfo;
tdesc_arch_data_up tdesc_data;
const struct target_desc *tdesc = info.target_desc;
actually know which target we are talking to, but put in some defaults
for now. */
binfo = info.bfd_arch_info;
- or1k_gdbarch_tdep *tdep = new or1k_gdbarch_tdep;
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new or1k_gdbarch_tdep));
+ or1k_gdbarch_tdep *tdep = gdbarch_tdep<or1k_gdbarch_tdep> (gdbarch);
+
tdep->bytes_per_word = binfo->bits_per_word / binfo->bits_per_byte;
tdep->bytes_per_address = binfo->bits_per_address / binfo->bits_per_byte;
- gdbarch = gdbarch_alloc (&info, tdep);
/* Target data types */
set_gdbarch_short_bit (gdbarch, 16);
riscv_gdbarch_init (struct gdbarch_info info,
struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
struct riscv_gdbarch_features features;
const struct target_desc *tdesc = info.target_desc;
return arches->gdbarch;
/* None found, so create a new architecture from the information provided. */
- riscv_gdbarch_tdep *tdep = new riscv_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new riscv_gdbarch_tdep));
+ riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+
tdep->isa_features = features;
tdep->abi_features = abi_features;
static struct gdbarch *
rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
int elf_flags;
/* Extract the elf_flags if available. */
/* None found, create a new architecture from the information
provided. */
- rl78_gdbarch_tdep * tdep = new rl78_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new rl78_gdbarch_tdep));
+ rl78_gdbarch_tdep *tdep = gdbarch_tdep<rl78_gdbarch_tdep> (gdbarch);
+
tdep->elf_flags = elf_flags;
/* Initialize types. */
static struct gdbarch *
rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
int wordsize, from_xcoff_exec, from_elf_exec;
enum bfd_architecture arch;
unsigned long mach;
- "set arch" trust blindly
- GDB startup useless but harmless */
- ppc_gdbarch_tdep *tdep = new ppc_gdbarch_tdep;
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new ppc_gdbarch_tdep));
+ ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+
tdep->wordsize = wordsize;
tdep->elf_abi = elf_abi;
tdep->soft_float = soft_float;
tdep->long_double_abi = long_double_abi;
tdep->vector_abi = vector_abi;
- gdbarch = gdbarch_alloc (&info, tdep);
-
tdep->ppc_gp0_regnum = PPC_R0_REGNUM;
tdep->ppc_toc_regnum = PPC_R0_REGNUM + 2;
tdep->ppc_ps_regnum = PPC_MSR_REGNUM;
static struct gdbarch *
rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
int elf_flags;
tdesc_arch_data_up tdesc_data;
const struct target_desc *tdesc = info.target_desc;
gdb_assert(tdesc_data != NULL);
- rx_gdbarch_tdep *tdep = new rx_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new rx_gdbarch_tdep));
+ rx_gdbarch_tdep *tdep = gdbarch_tdep<rx_gdbarch_tdep> (gdbarch);
+
tdep->elf_flags = elf_flags;
set_gdbarch_num_regs (gdbarch, RX_NUM_REGS);
static struct gdbarch *
s12z_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- s12z_gdbarch_tdep *tdep = new s12z_gdbarch_tdep;
- struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new s12z_gdbarch_tdep));
add_cmd ("bdccsr", class_support, show_bdccsr_command,
_("Show the current value of the microcontroller's BDCCSR."),
return true;
}
-/* Allocate and initialize new gdbarch_tdep. Caller is responsible to free
- memory after use. */
+/* Allocate and initialize new gdbarch_tdep. */
-static s390_gdbarch_tdep *
+static s390_gdbarch_tdep_up
s390_gdbarch_tdep_alloc ()
{
- s390_gdbarch_tdep *tdep = new s390_gdbarch_tdep;
+ s390_gdbarch_tdep_up tdep (new s390_gdbarch_tdep);
tdep->tdesc = NULL;
static const char *const stap_register_indirection_suffixes[] = { ")",
NULL };
- s390_gdbarch_tdep *tdep = s390_gdbarch_tdep_alloc ();
- struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch = gdbarch_alloc (&info, s390_gdbarch_tdep_alloc ());
+ s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
tdesc_arch_data_up tdesc_data = tdesc_data_alloc ();
info.tdesc_data = tdesc_data.get ();
/* Check any target description for validity. */
if (!s390_tdesc_valid (tdep, tdesc_data.get ()))
{
- delete tdep;
gdbarch_free (gdbarch);
return NULL;
}
if (tmp->vector_abi != tdep->vector_abi)
continue;
- delete tdep;
gdbarch_free (gdbarch);
return arches->gdbarch;
}
= nullptr;
};
+using s390_gdbarch_tdep_up = std::unique_ptr<s390_gdbarch_tdep>;
+
/* Decoding S/390 instructions. */
/* Named opcode values for the S/390 instructions we recognize. Some
static struct gdbarch *
sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
-
/* If there is already a candidate, use it. */
arches = gdbarch_list_lookup_by_info (arches, &info);
if (arches != NULL)
/* None found, create a new architecture from the information
provided. */
- sh_gdbarch_tdep *tdep = new sh_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new sh_gdbarch_tdep));
set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
const struct target_desc *tdesc = info.target_desc;
- struct gdbarch *gdbarch;
int valid_p = 1;
/* If there is already a candidate, use it. */
return arches->gdbarch;
/* Allocate space for the new architecture. */
- sparc_gdbarch_tdep *tdep = new sparc_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new sparc_gdbarch_tdep));
+ sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
tdep->pc_regnum = SPARC32_PC_REGNUM;
tdep->npc_regnum = SPARC32_NPC_REGNUM;
static struct gdbarch *
tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
tdesc_arch_data_up tdesc_data;
const struct target_desc *tdesc = info.target_desc;
int has_gp = 0;
return arches->gdbarch;
}
- tic6x_gdbarch_tdep *tdep = new tic6x_gdbarch_tdep;
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new tic6x_gdbarch_tdep));
+ tic6x_gdbarch_tdep *tdep = gdbarch_tdep<tic6x_gdbarch_tdep> (gdbarch);
tdep->has_gp = has_gp;
- gdbarch = gdbarch_alloc (&info, tdep);
/* Data type sizes. */
set_gdbarch_ptr_bit (gdbarch, 32);
static struct gdbarch *
v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
int e_flags, e_machine;
/* Extract the elf_flags if available. */
return arches->gdbarch;
}
- v850_gdbarch_tdep *tdep = new v850_gdbarch_tdep;
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new v850_gdbarch_tdep));
+ v850_gdbarch_tdep *tdep = gdbarch_tdep<v850_gdbarch_tdep> (gdbarch);
+
tdep->e_flags = e_flags;
tdep->e_machine = e_machine;
}
tdep->eight_byte_align = (tdep->e_flags & EF_RH850_DATA_ALIGN8) ? 1 : 0;
- gdbarch = gdbarch_alloc (&info, tdep);
switch (info.bfd_arch_info->mach)
{
/* Register map. */
-static xtensa_register_t rmap[] =
+xtensa_register_t xtensa_rmap[] =
{
/* idx ofs bi sz al targno flags cp typ group name */
XTREG( 0, 0,32, 4, 4,0x0020,0x0006,-2, 9,0x0100,pc, 0,0,0,0,0,0)
0,0,&xtensa_mask15,0,0,0)
XTREG_END
};
-
-xtensa_gdbarch_tdep xtensa_tdep (rmap);
/* Module "constructor" function. */
-extern xtensa_gdbarch_tdep xtensa_tdep;
+extern xtensa_register_t xtensa_rmap[];
static struct gdbarch *
xtensa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
-
DEBUGTRACE ("gdbarch_init()\n");
if (!xtensa_default_isa)
/* We have to set the byte order before we call gdbarch_alloc. */
info.byte_order = XCHAL_HAVE_BE ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
- xtensa_gdbarch_tdep *tdep = &xtensa_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info,
+ gdbarch_tdep_up (new xtensa_gdbarch_tdep (xtensa_rmap)));
+ xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
xtensa_derive_tdep (tdep);
/* Verify our configuration. */
static struct gdbarch *
z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
struct gdbarch_list *best_arch;
tdesc_arch_data_up tdesc_data;
unsigned long mach = info.bfd_arch_info->mach;
}
/* None found, create a new architecture from the information provided. */
- z80_gdbarch_tdep *tdep = new z80_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new z80_gdbarch_tdep));
+ z80_gdbarch_tdep *tdep = gdbarch_tdep<z80_gdbarch_tdep> (gdbarch);
if (mach == bfd_mach_ez80_adl)
{