gdb: remove BLOCK_NAMESPACE macro
[binutils-gdb.git] / gdb / frv-tdep.c
index f5edfc72ce3e700dab3b1be804b632a036d169f0..2328791a540b5577f345f5fcfda1568b5b80fa10 100644 (file)
@@ -1,6 +1,6 @@
 /* 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.
 
@@ -38,6 +38,7 @@
 #include "solib.h"
 #include "frv-tdep.h"
 #include "objfiles.h"
+#include "gdbarch.h"
 
 struct frv_unwind_cache                /* was struct frame_extra_info */
   {
@@ -67,32 +68,33 @@ 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
@@ -128,13 +130,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 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;
@@ -182,11 +183,8 @@ new_variant (void)
      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
@@ -195,11 +193,8 @@ new_variant (void)
      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.  */
 
@@ -219,7 +214,7 @@ new_variant (void)
 /* 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;
 
@@ -238,7 +233,7 @@ set_variant_num_gprs (struct gdbarch_tdep *var, int num_gprs)
 /* 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;
 
@@ -254,7 +249,7 @@ set_variant_num_fprs (struct gdbarch_tdep *var, int num_fprs)
 }
 
 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");
@@ -263,7 +258,7 @@ set_variant_abi_fdpic (struct gdbarch_tdep *var)
 }
 
 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");
@@ -276,10 +271,12 @@ frv_register_name (struct gdbarch *gdbarch, int reg)
 {
   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];
 }
 
 
@@ -599,7 +596,7 @@ frv_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
 
       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;
 
@@ -1259,7 +1256,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), 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;
@@ -1268,7 +1265,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
        }
       else
        {
-         val = value_contents (arg);
+         val = value_contents (arg).data ();
        }
 
       while (len > 0)
@@ -1387,7 +1384,7 @@ frv_frame_this_id (struct frame_info *this_frame,
 
   /* Check if the stack is empty.  */
   msym_stack = lookup_minimal_symbol ("_stack", NULL, NULL);
-  if (msym_stack.minsym && info->base == BMSYMBOL_VALUE_ADDRESS (msym_stack))
+  if (msym_stack.minsym && info->base == msym_stack.value_address ())
     return;
 
   /* Hopefully the prologue analysis either correctly determined the
@@ -1411,6 +1408,7 @@ frv_frame_prev_register (struct frame_info *this_frame,
 }
 
 static const struct frame_unwind frv_frame_unwind = {
+  "frv prologue",
   NORMAL_FRAME,
   default_frame_unwind_stop_reason,
   frv_frame_this_id,
@@ -1438,7 +1436,6 @@ static struct gdbarch *
 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
@@ -1448,7 +1445,7 @@ frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     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: