gdb/arm: Unwind Non-Secure callbacks from Secure
[binutils-gdb.git] / gdb / mn10300-tdep.c
index 8e487241e7045d0c4025f7fcb9574098998ed88c..7a41070bb30abd6ecb851c48d5af3a049e51ce1c 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for the Matsushita MN10300 for GDB, the GNU debugger.
 
-   Copyright (C) 1996-2020 Free Software Foundation, Inc.
+   Copyright (C) 1996-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -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;
        }
@@ -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;
@@ -202,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;
@@ -364,15 +364,15 @@ 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;
   int rn;
   pv_t regs[MN10300_MAX_NUM_REGS];
   CORE_ADDR after_last_frame_setup_insn = start_pc;
-  int am33_mode = AM33_MODE (gdbarch);
+  int am33_mode = get_am33_mode (gdbarch);
 
   memset (result, 0, sizeof (*result));
   result->gdbarch = gdbarch;
@@ -399,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)
@@ -472,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;
@@ -483,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;
@@ -575,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;
        }
@@ -596,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;
        }
@@ -616,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) */
@@ -919,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;
 
@@ -930,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;
@@ -945,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;
@@ -960,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;
 
@@ -971,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;
@@ -986,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;
@@ -1059,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,
@@ -1111,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);
@@ -1124,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.  */
@@ -1132,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, 
@@ -1208,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.  */
@@ -1221,7 +1222,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
       else
        {
          arg_len = TYPE_LENGTH (value_type (*args));
-         val = value_contents (*args);
+         val = value_contents (*args).data ();
        }
 
       while (regs_used < 2 && arg_len > 0)
@@ -1281,7 +1282,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
       = 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;
@@ -1336,14 +1337,13 @@ mn10300_gdbarch_init (struct gdbarch_info info,
                      struct gdbarch_list *arches)
 {
   struct gdbarch *gdbarch;
-  struct gdbarch_tdep *tdep;
   int num_regs;
 
   arches = gdbarch_list_lookup_by_info (arches, &info);
   if (arches != NULL)
     return arches->gdbarch;
 
-  tdep = XCNEW (struct gdbarch_tdep);
+  mn10300_gdbarch_tdep *tdep = new mn10300_gdbarch_tdep;
   gdbarch = gdbarch_alloc (&info, tdep);
 
   switch (info.bfd_arch_info->mach)
@@ -1412,9 +1412,9 @@ mn10300_gdbarch_init (struct gdbarch_info info,
 static void
 mn10300_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-  fprintf_unfiltered (file, "mn10300_dump_tdep: am33_mode = %d\n",
-                     tdep->am33_mode);
+  mn10300_gdbarch_tdep *tdep = (mn10300_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+  gdb_printf (file, "mn10300_dump_tdep: am33_mode = %d\n",
+             tdep->am33_mode);
 }
 
 void _initialize_mn10300_tdep ();