/* Target-dependent code for the Fujitsu FR-V, for GDB, the GNU Debugger.
- Copyright (C) 2002-2021 Free Software Foundation, Inc.
+ Copyright (C) 2002-2022 Free Software Foundation, Inc.
This file is part of GDB.
#include "solib.h"
#include "frv-tdep.h"
#include "objfiles.h"
+#include "gdbarch.h"
struct frv_unwind_cache /* was struct frame_extra_info */
{
of structures, each of which gives all the necessary info for one
register. Don't stick parallel arrays in here --- that's so
Fortran. */
-struct gdbarch_tdep
+struct frv_gdbarch_tdep : gdbarch_tdep
{
/* Which ABI is in use? */
- enum frv_abi frv_abi;
+ enum frv_abi frv_abi {};
/* How many general-purpose registers does this variant have? */
- int num_gprs;
+ int num_gprs = 0;
/* How many floating-point registers does this variant have? */
- int num_fprs;
+ int num_fprs = 0;
/* How many hardware watchpoints can it support? */
- int num_hw_watchpoints;
+ int num_hw_watchpoints = 0;
/* How many hardware breakpoints can it support? */
- int num_hw_breakpoints;
+ int num_hw_breakpoints = 0;
/* Register names. */
- const char **register_names;
+ const char **register_names = nullptr;
};
/* Return the FR-V ABI associated with GDBARCH. */
enum frv_abi
frv_abi (struct gdbarch *gdbarch)
{
- return gdbarch_tdep (gdbarch)->frv_abi;
+ frv_gdbarch_tdep *tdep = (frv_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ return tdep->frv_abi;
}
/* Fetch the interpreter and executable loadmap addresses (for shared
/* Allocate a new variant structure, and set up default values for all
the fields. */
-static struct gdbarch_tdep *
+static frv_gdbarch_tdep *
new_variant (void)
{
- struct gdbarch_tdep *var;
int r;
- var = XCNEW (struct gdbarch_tdep);
+ frv_gdbarch_tdep *var = new frv_gdbarch_tdep;
var->frv_abi = FRV_ABI_EABI;
var->num_gprs = 64;
in the G packet. If we need more in the future, we'll add them
elsewhere. */
for (r = acc0_regnum; r <= acc7_regnum; r++)
- {
- char *buf;
- buf = xstrprintf ("acc%d", r - acc0_regnum);
- var->register_names[r] = buf;
- }
+ var->register_names[r]
+ = xstrprintf ("acc%d", r - acc0_regnum).release ();
/* accg0 - accg7: These are one byte registers. The remote protocol
provides the raw values packed four into a slot. accg0123 and
likely not want to see these raw values. */
for (r = accg0_regnum; r <= accg7_regnum; r++)
- {
- char *buf;
- buf = xstrprintf ("accg%d", r - accg0_regnum);
- var->register_names[r] = buf;
- }
+ var->register_names[r]
+ = xstrprintf ("accg%d", r - accg0_regnum).release ();
/* msr0 and msr1. */
/* Indicate that the variant VAR has NUM_GPRS general-purpose
registers, and fill in the names array appropriately. */
static void
-set_variant_num_gprs (struct gdbarch_tdep *var, int num_gprs)
+set_variant_num_gprs (frv_gdbarch_tdep *var, int num_gprs)
{
int r;
/* Indicate that the variant VAR has NUM_FPRS floating-point
registers, and fill in the names array appropriately. */
static void
-set_variant_num_fprs (struct gdbarch_tdep *var, int num_fprs)
+set_variant_num_fprs (frv_gdbarch_tdep *var, int num_fprs)
{
int r;
}
static void
-set_variant_abi_fdpic (struct gdbarch_tdep *var)
+set_variant_abi_fdpic (frv_gdbarch_tdep *var)
{
var->frv_abi = FRV_ABI_FDPIC;
var->register_names[fdpic_loadmap_exec_regnum] = xstrdup ("loadmap_exec");
}
static void
-set_variant_scratch_registers (struct gdbarch_tdep *var)
+set_variant_scratch_registers (frv_gdbarch_tdep *var)
{
var->register_names[scr0_regnum] = xstrdup ("scr0");
var->register_names[scr1_regnum] = xstrdup ("scr1");
{
if (reg < 0)
return "?toosmall?";
+
if (reg >= frv_num_regs + frv_num_pseudo_regs)
return "?toolarge?";
- return gdbarch_tdep (gdbarch)->register_names[reg];
+ frv_gdbarch_tdep *tdep = (frv_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ return tdep->register_names[reg];
}
if (target_read_memory (pc, buf, sizeof buf) != 0)
break;
- op = extract_signed_integer (buf, sizeof buf, byte_order);
+ op = extract_signed_integer (buf, byte_order);
next_pc = pc + 4;
/* The FDPIC ABI requires function descriptors to be passed instead
of entry points. */
CORE_ADDR addr = extract_unsigned_integer
- (value_contents (arg), 4, byte_order);
+ (value_contents (arg).data (), 4, byte_order);
addr = find_func_descr (gdbarch, addr);
store_unsigned_integer (valbuf, 4, byte_order, addr);
typecode = TYPE_CODE_PTR;
}
else
{
- val = value_contents (arg);
+ val = value_contents (arg).data ();
}
while (len > 0)
frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
struct gdbarch *gdbarch;
- struct gdbarch_tdep *var;
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. */
- var = new_variant ();
+ frv_gdbarch_tdep *var = new_variant ();
switch (info.bfd_arch_info->mach)
{
case bfd_mach_frv: