gdb/mi: handle no condition argument case for -break-condition
[deliverable/binutils-gdb.git] / gdb / mn10300-tdep.c
index 93c02d67b40869667f1b680deda48007ff305ff1..2961f2afde1f5f89013d94b6cfd79c05aa7ceda8 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for the Matsushita MN10300 for GDB, the GNU debugger.
 
-   Copyright (C) 1996-2018 Free Software Foundation, Inc.
+   Copyright (C) 1996-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -28,7 +28,7 @@
 #include "frame-unwind.h"
 #include "frame-base.h"
 #include "symtab.h"
-#include "dwarf2-frame.h"
+#include "dwarf2/frame.h"
 #include "osabi.h"
 #include "infcall.h"
 #include "prologue-value.h"
@@ -88,7 +88,7 @@ mn10300_type_align (struct type *type)
 {
   int i, align = 1;
 
-  switch (TYPE_CODE (type))
+  switch (type->code ())
     {
     case TYPE_CODE_INT:
     case TYPE_CODE_ENUM:
@@ -107,9 +107,9 @@ mn10300_type_align (struct type *type)
 
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:
-      for (i = 0; i < TYPE_NFIELDS (type); i++)
+      for (i = 0; i < type->num_fields (); i++)
        {
-         int falign = mn10300_type_align (TYPE_FIELD_TYPE (type, i));
+         int falign = mn10300_type_align (type->field (i).type ());
          while (align < falign)
            align <<= 1;
        }
@@ -117,7 +117,7 @@ mn10300_type_align (struct type *type)
 
     case TYPE_CODE_ARRAY:
       /* HACK!  Structures containing arrays, even small ones, are not
-        elligible for returning in registers.  */
+        eligible for returning in registers.  */
       return 256;
 
     case TYPE_CODE_TYPEDEF:
@@ -137,14 +137,14 @@ mn10300_use_struct_convention (struct type *type)
   if (TYPE_LENGTH (type) > 8)
     return 1;
 
-  switch (TYPE_CODE (type))
+  switch (type->code ())
     {
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:
       /* Structures with a single field are handled as the field
         itself.  */
-      if (TYPE_NFIELDS (type) == 1)
-       return mn10300_use_struct_convention (TYPE_FIELD_TYPE (type, 0));
+      if (type->num_fields () == 1)
+       return mn10300_use_struct_convention (type->field (0).type ());
 
       /* Structures with word or double-word size are passed in memory, as
         long as they require at least word alignment.  */
@@ -174,7 +174,7 @@ mn10300_store_return_value (struct gdbarch *gdbarch, struct type *type,
   int len = TYPE_LENGTH (type);
   int reg, regsz;
   
-  if (TYPE_CODE (type) == TYPE_CODE_PTR)
+  if (type->code () == TYPE_CODE_PTR)
     reg = 4;
   else
     reg = 0;
@@ -182,13 +182,12 @@ mn10300_store_return_value (struct gdbarch *gdbarch, struct type *type,
   regsz = register_size (gdbarch, reg);
 
   if (len <= regsz)
-    regcache_raw_write_part (regcache, reg, 0, len, valbuf);
+    regcache->raw_write_part (reg, 0, len, valbuf);
   else if (len <= 2 * regsz)
     {
-      regcache_raw_write (regcache, reg, valbuf);
+      regcache->raw_write (reg, valbuf);
       gdb_assert (regsz == register_size (gdbarch, reg + 1));
-      regcache_raw_write_part (regcache, reg+1, 0,
-                              len - regsz, valbuf + regsz);
+      regcache->raw_write_part (reg + 1, 0, len - regsz, valbuf + regsz);
     }
   else
     internal_error (__FILE__, __LINE__,
@@ -203,7 +202,7 @@ mn10300_extract_return_value (struct gdbarch *gdbarch, struct type *type,
   int len = TYPE_LENGTH (type);
   int reg, regsz;
 
-  if (TYPE_CODE (type) == TYPE_CODE_PTR)
+  if (type->code () == TYPE_CODE_PTR)
     reg = 4;
   else
     reg = 0;
@@ -212,15 +211,15 @@ mn10300_extract_return_value (struct gdbarch *gdbarch, struct type *type,
   gdb_assert (regsz <= MN10300_MAX_REGISTER_SIZE);
   if (len <= regsz)
     {
-      regcache_raw_read (regcache, reg, buf);
+      regcache->raw_read (reg, buf);
       memcpy (valbuf, buf, len);
     }
   else if (len <= 2 * regsz)
     {
-      regcache_raw_read (regcache, reg, buf);
+      regcache->raw_read (reg, buf);
       memcpy (valbuf, buf, regsz);
       gdb_assert (regsz == register_size (gdbarch, reg + 1));
-      regcache_raw_read (regcache, reg + 1, buf);
+      regcache->raw_read (reg + 1, buf);
       memcpy ((char *) valbuf + regsz, buf, len - regsz);
     }
   else
@@ -307,20 +306,6 @@ mn10300_register_type (struct gdbarch *gdbarch, int reg)
   return builtin_type (gdbarch)->builtin_int;
 }
 
-static CORE_ADDR
-mn10300_read_pc (struct regcache *regcache)
-{
-  ULONGEST val;
-  regcache_cooked_read_unsigned (regcache, E_PC_REGNUM, &val);
-  return val;
-}
-
-static void
-mn10300_write_pc (struct regcache *regcache, CORE_ADDR val)
-{
-  regcache_cooked_write_unsigned (regcache, E_PC_REGNUM, val);
-}
-
 /* The breakpoint instruction must be the same size as the smallest
    instruction in the instruction set.
 
@@ -379,8 +364,8 @@ check_for_saved (void *result_untyped, pv_t addr, CORE_ADDR size, pv_t value)
    information.  */
 static void
 mn10300_analyze_prologue (struct gdbarch *gdbarch,
-                          CORE_ADDR start_pc, CORE_ADDR limit_pc,
-                          struct mn10300_prologue *result)
+                         CORE_ADDR start_pc, CORE_ADDR limit_pc,
+                         struct mn10300_prologue *result)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR pc;
@@ -414,7 +399,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
       gdb_byte instr[2];
 
       /* Instructions can be as small as one byte; however, we usually
-         need at least two bytes to do the decoding, so fetch that many
+        need at least two bytes to do the decoding, so fetch that many
         to begin with.  */
       status = target_read_memory (pc, instr, 2);
       if (status != 0)
@@ -487,7 +472,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
        }
       /* mov aM, aN */
       else if ((instr[0] & 0xf0) == 0x90
-               && (instr[0] & 0x03) != ((instr[0] & 0x0c) >> 2))
+              && (instr[0] & 0x03) != ((instr[0] & 0x0c) >> 2))
        {
          int aN = instr[0] & 0x03;
          int aM = (instr[0] & 0x0c) >> 2;
@@ -498,7 +483,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
        }
       /* mov dM, dN */
       else if ((instr[0] & 0xf0) == 0x80
-               && (instr[0] & 0x03) != ((instr[0] & 0x0c) >> 2))
+              && (instr[0] & 0x03) != ((instr[0] & 0x0c) >> 2))
        {
          int dN = instr[0] & 0x03;
          int dM = (instr[0] & 0x0c) >> 2;
@@ -590,7 +575,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
          imm8 = extract_signed_integer (&instr[1], 1, byte_order);
 
          regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
-                                                   imm8);
+                                                   imm8);
 
          pc += 2;
        }
@@ -611,7 +596,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
          imm16 = extract_signed_integer (buf, 2, byte_order);
 
          regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
-                                                   imm16);
+                                                   imm16);
 
          pc += 4;
        }
@@ -631,7 +616,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
          imm32 = extract_signed_integer (buf, 2, byte_order);
 
          regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
-                                                   imm32);
+                                                   imm32);
          pc += 6;
        }
       /* fmov fsM, (rN) */
@@ -934,7 +919,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
        }
       /* mov imm8, aN */
       else if ((instr[0] & 0xf0) == 0x90)
-        {
+       {
          int aN = instr[0] & 0x03;
          LONGEST imm8;
 
@@ -945,7 +930,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
        }
       /* mov imm16, aN */
       else if ((instr[0] & 0xfc) == 0x24)
-        {
+       {
          int aN = instr[0] & 0x03;
          gdb_byte buf[2];
          LONGEST imm16;
@@ -960,7 +945,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
        }
       /* mov imm32, aN */
       else if (instr[0] == 0xfc && ((instr[1] & 0xfc) == 0xdc))
-        {
+       {
          int aN = instr[1] & 0x03;
          gdb_byte buf[4];
          LONGEST imm32;
@@ -975,7 +960,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
        }
       /* mov imm8, dN */
       else if ((instr[0] & 0xf0) == 0x80)
-        {
+       {
          int dN = instr[0] & 0x03;
          LONGEST imm8;
 
@@ -986,7 +971,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
        }
       /* mov imm16, dN */
       else if ((instr[0] & 0xfc) == 0x2c)
-        {
+       {
          int dN = instr[0] & 0x03;
          gdb_byte buf[2];
          LONGEST imm16;
@@ -1001,7 +986,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
        }
       /* mov imm32, dN */
       else if (instr[0] == 0xfc && ((instr[1] & 0xfc) == 0xcc))
-        {
+       {
          int dN = instr[1] & 0x03;
          gdb_byte buf[4];
          LONGEST imm32;
@@ -1074,9 +1059,9 @@ mn10300_analyze_frame_prologue (struct frame_info *this_frame,
       stop_addr = get_frame_pc (this_frame);
 
       /* If we couldn't find any function containing the PC, then
-         just initialize the prologue cache, but don't do anything.  */
+        just initialize the prologue cache, but don't do anything.  */
       if (!func_start)
-        stop_addr = func_start;
+       stop_addr = func_start;
 
       mn10300_analyze_prologue (get_frame_arch (this_frame),
                                func_start, stop_addr,
@@ -1113,15 +1098,6 @@ mn10300_frame_base (struct frame_info *this_frame, void **this_prologue_cache)
     }
 }
 
-/* Here is a dummy implementation.  */
-static struct frame_id
-mn10300_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  CORE_ADDR sp = get_frame_register_unsigned (this_frame, E_SP_REGNUM);
-  CORE_ADDR pc = get_frame_register_unsigned (this_frame, E_PC_REGNUM);
-  return frame_id_build (sp, pc);
-}
-
 static void
 mn10300_frame_this_id (struct frame_info *this_frame,
                       void **this_prologue_cache,
@@ -1135,7 +1111,7 @@ mn10300_frame_this_id (struct frame_info *this_frame,
 
 static struct value *
 mn10300_frame_prev_register (struct frame_info *this_frame,
-                            void **this_prologue_cache, int regnum)
+                            void **this_prologue_cache, int regnum)
 {
   struct mn10300_prologue *p
     = mn10300_analyze_frame_prologue (this_frame, this_prologue_cache);
@@ -1148,7 +1124,7 @@ mn10300_frame_prev_register (struct frame_info *this_frame,
      return a description of the stack slot holding it.  */
   if (p->reg_offset[regnum] != 1)
     return frame_unwind_got_memory (this_frame, regnum,
-                                    frame_base + p->reg_offset[regnum]);
+                                   frame_base + p->reg_offset[regnum]);
 
   /* Otherwise, presume we haven't changed the value of this
      register, and get it from the next frame.  */
@@ -1156,6 +1132,7 @@ mn10300_frame_prev_register (struct frame_info *this_frame,
 }
 
 static const struct frame_unwind mn10300_frame_unwind = {
+  "mn10300 prologue",
   NORMAL_FRAME,
   default_frame_unwind_stop_reason,
   mn10300_frame_this_id, 
@@ -1164,32 +1141,11 @@ static const struct frame_unwind mn10300_frame_unwind = {
   default_frame_sniffer
 };
 
-static CORE_ADDR
-mn10300_unwind_pc (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  ULONGEST pc;
-
-  pc = frame_unwind_register_unsigned (this_frame, E_PC_REGNUM);
-  return pc;
-}
-
-static CORE_ADDR
-mn10300_unwind_sp (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  ULONGEST sp;
-
-  sp = frame_unwind_register_unsigned (this_frame, E_SP_REGNUM);
-  return sp;
-}
-
 static void
 mn10300_frame_unwind_init (struct gdbarch *gdbarch)
 {
   dwarf2_append_unwinders (gdbarch);
   frame_unwind_append_unwinder (gdbarch, &mn10300_frame_unwind);
-  set_gdbarch_dummy_id (gdbarch, mn10300_dummy_id);
-  set_gdbarch_unwind_pc (gdbarch, mn10300_unwind_pc);
-  set_gdbarch_unwind_sp (gdbarch, mn10300_unwind_sp);
 }
 
 /* Function: push_dummy_call
@@ -1206,7 +1162,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
                         CORE_ADDR bp_addr, 
                         int nargs, struct value **args,
                         CORE_ADDR sp, 
-                        int struct_return,
+                        function_call_return_method return_method,
                         CORE_ADDR struct_addr)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1226,7 +1182,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
 
      XXX This doesn't appear to handle pass-by-invisible reference
      arguments.  */
-  regs_used = struct_return ? 1 : 0;
+  regs_used = (return_method == return_method_struct) ? 1 : 0;
   for (len = 0, argnum = 0; argnum < nargs; argnum++)
     {
       arg_len = (TYPE_LENGTH (value_type (args[argnum])) + 3) & ~3;
@@ -1241,7 +1197,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
   /* Allocate stack space.  */
   sp -= len;
 
-  if (struct_return)
+  if (return_method == return_method_struct)
     {
       regs_used = 1;
       regcache_cooked_write_unsigned (regcache, E_D0_REGNUM, struct_addr);
@@ -1253,7 +1209,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
   for (argnum = 0; argnum < nargs; argnum++)
     {
       /* FIXME what about structs?  Unions?  */
-      if (TYPE_CODE (value_type (*args)) == TYPE_CODE_STRUCT
+      if (value_type (*args)->code () == TYPE_CODE_STRUCT
          && TYPE_LENGTH (value_type (*args)) > 8)
        {
          /* Change to pointer-to-type.  */
@@ -1323,10 +1279,10 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
   {
     CORE_ADDR func_addr = find_function_addr (target_func, NULL);
     CORE_ADDR unwound_sp 
-      = mn10300_unwind_sp (gdbarch, create_new_frame (sp, func_addr));
+      = gdbarch_unwind_sp (gdbarch, create_new_frame (sp, func_addr));
     if (sp != unwound_sp)
       regcache_cooked_write_unsigned (regcache, E_SP_REGNUM,
-                                      sp - (unwound_sp - sp));
+                                     sp - (unwound_sp - sp));
   }
 
   return sp;
@@ -1423,8 +1379,6 @@ mn10300_gdbarch_init (struct gdbarch_info info,
   set_gdbarch_num_regs (gdbarch, num_regs);
   set_gdbarch_register_type (gdbarch, mn10300_register_type);
   set_gdbarch_skip_prologue (gdbarch, mn10300_skip_prologue);
-  set_gdbarch_read_pc (gdbarch, mn10300_read_pc);
-  set_gdbarch_write_pc (gdbarch, mn10300_write_pc);
   set_gdbarch_pc_regnum (gdbarch, E_PC_REGNUM);
   set_gdbarch_sp_regnum (gdbarch, E_SP_REGNUM);
   set_gdbarch_dwarf2_reg_to_regnum (gdbarch, mn10300_dwarf2_reg_to_regnum);
@@ -1464,8 +1418,9 @@ mn10300_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
                      tdep->am33_mode);
 }
 
+void _initialize_mn10300_tdep ();
 void
-_initialize_mn10300_tdep (void)
+_initialize_mn10300_tdep ()
 {
   gdbarch_register (bfd_arch_mn10300, mn10300_gdbarch_init, mn10300_dump_tdep);
 }
This page took 0.032223 seconds and 4 git commands to generate.