]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/frv-tdep.c
bfd: sframe: minor code adjustments and fix typos
[thirdparty/binutils-gdb.git] / gdb / frv-tdep.c
index 5e9f20379c2d6b06c31d688d56ac6bf717a4a4e3..1b5e15f831b7272265316e154a8e713f6330dee8 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for the Fujitsu FR-V, for GDB, the GNU Debugger.
 
-   Copyright (C) 2002-2023 Free Software Foundation, Inc.
+   Copyright (C) 2002-2024 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -17,7 +17,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
+#include "extract-store-integer.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "arch-utils.h"
@@ -29,7 +29,6 @@
 #include "dis-asm.h"
 #include "sim-regno.h"
 #include "sim/sim-frv.h"
-#include "opcodes/frv-desc.h"  /* for the H_SPR_... enums */
 #include "symtab.h"
 #include "elf-bfd.h"
 #include "elf/frv.h"
 #include "objfiles.h"
 #include "gdbarch.h"
 
+/* Make cgen names unique to prevent ODR conflicts with other targets.  */
+#define GDB_CGEN_REMAP_PREFIX frv
+#include "cgen-remap.h"
+#include "opcodes/frv-desc.h"
+
 struct frv_unwind_cache                /* was struct frame_extra_info */
   {
     /* The previous frame's inner-most stack address.  Used as this
@@ -89,6 +93,8 @@ struct frv_gdbarch_tdep : gdbarch_tdep_base
   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)
@@ -108,7 +114,7 @@ frv_fdpic_loadmap_addresses (struct gdbarch *gdbarch, CORE_ADDR *interp_addr,
     return -1;
   else
     {
-      struct regcache *regcache = get_current_regcache ();
+      regcache *regcache = get_thread_regcache (inferior_thread ());
 
       if (interp_addr != NULL)
        {
@@ -130,12 +136,12 @@ frv_fdpic_loadmap_addresses (struct gdbarch *gdbarch, CORE_ADDR *interp_addr,
 
 /* 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;
@@ -504,7 +510,7 @@ is_argument_reg (int reg)
    prologue analysis.  */
 static CORE_ADDR
 frv_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
-                     frame_info_ptr this_frame,
+                     const frame_info_ptr &this_frame,
                      struct frv_unwind_cache *info)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1078,7 +1084,7 @@ frv_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 
 
 static struct frv_unwind_cache *
-frv_frame_unwind_cache (frame_info_ptr this_frame,
+frv_frame_unwind_cache (const frame_info_ptr &this_frame,
                         void **this_prologue_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -1209,7 +1215,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   stack_space = 0;
   for (argnum = 0; argnum < nargs; ++argnum)
-    stack_space += align_up (value_type (args[argnum])->length (), 4);
+    stack_space += align_up (args[argnum]->type ()->length (), 4);
 
   stack_space -= (6 * 4);
   if (stack_space > 0)
@@ -1229,14 +1235,14 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   for (argnum = 0; argnum < nargs; ++argnum)
     {
       arg = args[argnum];
-      arg_type = check_typedef (value_type (arg));
+      arg_type = check_typedef (arg->type ());
       len = arg_type->length ();
       typecode = arg_type->code ();
 
       if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
        {
          store_unsigned_integer (valbuf, 4, byte_order,
-                                 value_address (arg));
+                                 arg->address ());
          typecode = TYPE_CODE_PTR;
          len = 4;
          val = valbuf;
@@ -1249,7 +1255,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          /* The FDPIC ABI requires function descriptors to be passed instead
             of entry points.  */
          CORE_ADDR addr = extract_unsigned_integer
-                            (value_contents (arg).data (), 4, byte_order);
+           (arg->contents ().data (), 4, byte_order);
          addr = find_func_descr (gdbarch, addr);
          store_unsigned_integer (valbuf, 4, byte_order, addr);
          typecode = TYPE_CODE_PTR;
@@ -1258,7 +1264,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
        }
       else
        {
-         val = value_contents (arg).data ();
+         val = arg->contents ().data ();
        }
 
       while (len > 0)
@@ -1361,7 +1367,7 @@ frv_return_value (struct gdbarch *gdbarch, struct value *function,
    frame.  This will be used to create a new GDB frame struct.  */
 
 static void
-frv_frame_this_id (frame_info_ptr this_frame,
+frv_frame_this_id (const frame_info_ptr &this_frame,
                    void **this_prologue_cache, struct frame_id *this_id)
 {
   struct frv_unwind_cache *info
@@ -1391,7 +1397,7 @@ frv_frame_this_id (frame_info_ptr this_frame,
 }
 
 static struct value *
-frv_frame_prev_register (frame_info_ptr this_frame,
+frv_frame_prev_register (const frame_info_ptr &this_frame,
                         void **this_prologue_cache, int regnum)
 {
   struct frv_unwind_cache *info
@@ -1410,7 +1416,7 @@ static const struct frame_unwind frv_frame_unwind = {
 };
 
 static CORE_ADDR
-frv_frame_base_address (frame_info_ptr this_frame, void **this_cache)
+frv_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct frv_unwind_cache *info
     = frv_frame_unwind_cache (this_frame, this_cache);
@@ -1427,7 +1433,6 @@ static const struct frame_base frv_frame_base = {
 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
@@ -1437,7 +1442,9 @@ frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     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:
@@ -1471,8 +1478,6 @@ frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   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);
@@ -1494,7 +1499,8 @@ frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_register_sim_regno (gdbarch, frv_register_sim_regno);
 
   set_gdbarch_pseudo_register_read (gdbarch, frv_pseudo_register_read);
-  set_gdbarch_pseudo_register_write (gdbarch, frv_pseudo_register_write);
+  set_gdbarch_deprecated_pseudo_register_write (gdbarch,
+                                               frv_pseudo_register_write);
 
   set_gdbarch_skip_prologue (gdbarch, frv_skip_prologue);
   set_gdbarch_skip_main_prologue (gdbarch, frv_skip_main_prologue);