gdb/tui: fairer distribution of excess space during apply
[binutils-gdb.git] / gdb / mep-tdep.c
index 0dcfa48d67c118a068077e51dba386259ac45401..696d9c63bce978f72107111d78a7495130a023f9 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for the Toshiba MeP for GDB, the GNU debugger.
 
-   Copyright (C) 2001-2021 Free Software Foundation, Inc.
+   Copyright (C) 2001-2022 Free Software Foundation, Inc.
 
    Contributed by Red Hat, Inc.
 
@@ -45,6 +45,7 @@
 #include "prologue-value.h"
 #include "cgen/bitset.h"
 #include "infcall.h"
+#include "gdbarch.h"
 
 /* Get the user's customized MeP coprocessor register names from
    libopcodes.  */
      options are present on the current processor.  */
 
 
-struct gdbarch_tdep
+struct mep_gdbarch_tdep : gdbarch_tdep
 {
   /* A CGEN cpu descriptor for this BFD architecture and machine.
 
@@ -124,7 +125,7 @@ struct gdbarch_tdep
      MeP libopcodes machinery actually puts off module-specific
      customization until the last minute.  So this contains
      information about all supported me_modules.  */
-  CGEN_CPU_DESC cpu_desc;
+  CGEN_CPU_DESC cpu_desc = nullptr;
 
   /* The me_module index from the ELF file we used to select this
      architecture, or CONFIG_NONE if there was none.
@@ -140,7 +141,7 @@ struct gdbarch_tdep
      create a separate instance of the gdbarch structure for each
      me_module value mep_gdbarch_init sees, and store the me_module
      value from the ELF file here.  */
-  CONFIG_ATTR me_module;
+  CONFIG_ATTR me_module {};
 };
 
 
@@ -259,7 +260,9 @@ me_module_register_set (CONFIG_ATTR me_module,
        mask contains any of the me_module's coprocessor ISAs,
        specifically excluding the generic coprocessor register sets.  */
 
-  CGEN_CPU_DESC desc = gdbarch_tdep (target_gdbarch ())->cpu_desc;
+  mep_gdbarch_tdep *tdep
+    = (mep_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ());
+  CGEN_CPU_DESC desc = tdep->cpu_desc;
   const CGEN_HW_ENTRY *hw;
 
   if (me_module == CONFIG_NONE)
@@ -852,7 +855,11 @@ current_me_module (void)
       return (CONFIG_ATTR) regval;
     }
   else
-    return gdbarch_tdep (target_gdbarch ())->me_module;
+    {
+      mep_gdbarch_tdep *tdep
+       = (mep_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ());
+      return tdep->me_module;
+    }
 }
 
 
@@ -2053,6 +2060,7 @@ mep_frame_prev_register (struct frame_info *this_frame,
 
 
 static const struct frame_unwind mep_frame_unwind = {
+  "mep prologue",
   NORMAL_FRAME,
   default_frame_unwind_stop_reason,
   mep_frame_this_id,
@@ -2228,7 +2236,7 @@ push_large_arguments (CORE_ADDR sp, int argc, struct value **argv,
          /* Reserve space for the copy, and then round the SP down, to
             make sure it's all aligned properly.  */
          sp = (sp - arg_len) & -4;
-         write_memory (sp, value_contents (argv[i]), arg_len);
+         write_memory (sp, value_contents (argv[i]).data (), arg_len);
          copy[i] = sp;
        }
     }
@@ -2282,7 +2290,7 @@ mep_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
       /* Arguments that fit in a GPR get expanded to fill the GPR.  */
       if (TYPE_LENGTH (value_type (argv[i])) <= MEP_GPR_SIZE)
-       value = extract_unsigned_integer (value_contents (argv[i]),
+       value = extract_unsigned_integer (value_contents (argv[i]).data (),
                                          TYPE_LENGTH (value_type (argv[i])),
                                          byte_order);
 
@@ -2325,7 +2333,6 @@ static struct gdbarch *
 mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
   struct gdbarch *gdbarch;
-  struct gdbarch_tdep *tdep;
 
   /* Which me_module are we building a gdbarch object for?  */
   CONFIG_ATTR me_module;
@@ -2362,7 +2369,7 @@ mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
          const char *file_endianness
            = bfd_big_endian (info.abfd) ? "big" : "little";
          
-         fputc_unfiltered ('\n', gdb_stderr);
+         gdb_putc ('\n', gdb_stderr);
          if (module_name)
            warning (_("the MeP module '%s' is %s-endian, but the executable\n"
                       "%s is %s-endian."),
@@ -2383,10 +2390,15 @@ mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   for (arches = gdbarch_list_lookup_by_info (arches, &info); 
        arches != NULL;
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
-    if (gdbarch_tdep (arches->gdbarch)->me_module == me_module)
-      return arches->gdbarch;
+    {
+      mep_gdbarch_tdep *tdep
+       = (mep_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch);
+
+      if (tdep->me_module == me_module)
+       return arches->gdbarch;
+    }
 
-  tdep = XCNEW (struct gdbarch_tdep);
+  mep_gdbarch_tdep *tdep = new mep_gdbarch_tdep;
   gdbarch = gdbarch_alloc (&info, tdep);
 
   /* Get a CGEN CPU descriptor for this architecture.  */